Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(react/app): environment variables #2180

Merged
merged 3 commits into from
May 23, 2024
Merged

Conversation

odinr
Copy link
Collaborator

@odinr odinr commented May 23, 2024

Why

This PR introduces the following changes:

  • Adds a new useAppEnvironmentVariables hook to the @equinor/fusion-framework-react-app package, allowing React components to access the application's environment variables.
  • Creates a new cookbook example @equinor/fusion-framework-cookbook-app-react-environment-variables that demonstrates how to use the useAppEnvironmentVariables hook.
  • Updates the "Getting started" guide with a new section explaining how to use environment variables in a Fusion Framework React application.

The current behavior is that there is no built-in way to access the application's environment variables from React components. This PR introduces a new hook that fills this gap, making it easier for developers to retrieve and use the environment configuration in their applications.

This PR does not introduce any breaking changes.

fixes: https://github.com/equinor/fusion/issues/355

Check off the following:

  • Confirm that I checked changes to branch which I am merging into.

    • I have validated included files
    • My code does not generate new linting warnings
    • My PR is not a duplicate, check existing pr's
  • Confirm that the I have completed the self-review checklist.

  • Confirm that my changes meet our code of conduct.

Copy link

changeset-bot bot commented May 23, 2024

🦋 Changeset detected

Latest commit: e67edff

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@equinor/fusion-framework-docs Patch
@equinor/fusion-framework-cookbook-app-react-environment-variables Major
@equinor/fusion-framework-react-app Minor
@equinor/fusion-framework-legacy-interopt Major
@equinor/fusion-framework-cookbook-app-react-context-custom-error Patch
@equinor/fusion-framework-cookbook-app-react-context Patch
@equinor/fusion-framework-cookbook-app-react-feature-flag Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@odinr odinr changed the title Feat/app/environment variables Feat(react/app): environment variables May 23, 2024
@odinr odinr self-assigned this May 23, 2024
@odinr odinr force-pushed the feat/app/environment-variables branch from 0eccd05 to f31189a Compare May 23, 2024 07:18
@odinr odinr force-pushed the feat/app/environment-variables branch from f31189a to bd3b27c Compare May 23, 2024 07:19
@odinr odinr force-pushed the feat/app/environment-variables branch from bd3b27c to 59d1962 Compare May 23, 2024 07:37
@odinr odinr force-pushed the feat/app/environment-variables branch from bdc0d96 to 2905ac4 Compare May 23, 2024 07:48
@odinr odinr marked this pull request as ready for review May 23, 2024 07:52
@odinr odinr requested a review from a team as a code owner May 23, 2024 07:52
Copy link
Contributor

github-actions bot commented May 23, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 12.86% 3678 / 28592
🔵 Statements 12.86% 3678 / 28592
🔵 Functions 12.68% 92 / 725
🔵 Branches 27.3% 225 / 824
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
cookbooks/app-react-environment-variables/app.config.ts 0% 0% 0% 0% 1-12
cookbooks/app-react-environment-variables/app.manifest.config.ts 0% 0% 0% 0% 1-7
cookbooks/app-react-environment-variables/src/App.tsx 0% 0% 0% 0% 1-13
cookbooks/app-react-environment-variables/src/config.ts 0% 0% 0% 0% 1-18
cookbooks/app-react-environment-variables/src/index.ts 0% 0% 0% 0% 1-30
packages/react/app/src/index.ts 0% 0% 0% 0% 1-27
packages/react/app/src/useAppEnvironmentVariables.ts 0% 0% 0% 0% 1-54
Generated in workflow #6238

@odinr odinr enabled auto-merge (squash) May 23, 2024 11:03
odinr added 3 commits May 23, 2024 13:03
Add a new React hook 'useAppEnvironmentVariables' to access the application's environment variables from the app module. The hook returns an observable state containing the environment configuration.

The changes include:
- Add 'useAppEnvironmentVariables.ts' file with the hook implementation
- Export the new hook from 'index.ts'
- Update 'tsconfig.json' to include a reference to the 'observable' package
…t app

Add a new cookbook demonstrating how to use the `useAppEnvironmentVariables` hook to access environment variables in a Fusion Framework React application.

The cookbook includes:
- App configuration file (`app.config.ts`) defining environment variables and endpoints
- App manifest configuration file (`app.manifest.config.ts`)
- `package.json` with scripts and dependencies
- `src/App.tsx` component using the `useAppEnvironmentVariables` hook
- `src/config.ts` for configuring the application
- `src/index.ts` for rendering the application
Add a new section to the "Getting started" guide, explaining how to access environment variables in the application using the `useAppEnvironmentVariables` hook from `@equinor/fusion-framework-react-app`.

Add  a code example demonstrating the usage of the hook.
@odinr odinr force-pushed the feat/app/environment-variables branch from 2905ac4 to e67edff Compare May 23, 2024 11:03
@odinr odinr merged commit 060a1aa into main May 23, 2024
7 of 8 checks passed
@odinr odinr deleted the feat/app/environment-variables branch May 23, 2024 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👨🏻‍🍳 cookbooks 📚 documentation Improvements or additions to documentation 🚀 feature New feature or request 👾 React
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants