Skip to content

Commit

Permalink
[Tech] Correction de la messagerie (UPDATE ENV VAR) (#3029)
Browse files Browse the repository at this point in the history
## Linked issues

- Resolve #3015 

----

- [ ] Tests E2E (Cypress)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Updated environment variable names and configurations for chat
integration.
- **New Features**
- Simplified the configuration setup for injecting chat functionality in
the frontend application.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
louptheron authored Mar 21, 2024
2 parents 67643fc + 0c556ae commit 7c8ba0d
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 14 deletions.
4 changes: 1 addition & 3 deletions frontend/.env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
################################################################################
# Chat

# We need to use a VITE_ env var to replace the HTML index file
# see: https://vitejs.dev/guide/env-and-mode.html#html-env-replacement
VITE_SMALL_CHAT_SNIPPET=
FRONTEND_SMALL_CHAT_SNIPPET=

################################################################################
# Feature flags
Expand Down
2 changes: 1 addition & 1 deletion frontend/.env.local.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# We need to use a VITE_ env var to replace the HTML index file
# see: https://vitejs.dev/guide/env-and-mode.html#html-env-replacement
VITE_SMALL_CHAT_SNIPPET=
FRONTEND_SMALL_CHAT_SNIPPET=

################################################################################
# Feature flags
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ beforeEach(() => {
}
)

// PROD :: VITE_SMALL_CHAT_SNIPPET
// PROD :: FRONTEND_SMALL_CHAT_SNIPPET
cy.intercept(
{ url: /^https:\/\/embed\.small\.chat\/.*/ },
{
Expand Down
4 changes: 0 additions & 4 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>

<!-- We need to use a VITE_ env var to replace the HTML index file -->
<!-- see: https://vitejs.dev/guide/env-and-mode.html#html-env-replacement -->
%VITE_SMALL_CHAT_SNIPPET%

<!-- This script will be used by the `import-meta-env` library to inject -->
<!-- runtime environment variables when running in production -->
<!-- see: https://import-meta-env.org/guide/getting-started/introduction.html -->
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export function App({ auth }: AppProps) {
</AuthorizationContext.Provider>
</FrontendErrorBoundary>
</RsuiteCustomProvider>
{/* This script is used to inject the chat */}
{import.meta.env.FRONTEND_SMALL_CHAT_SNIPPET && (
<script async src={import.meta.env.FRONTEND_SMALL_CHAT_SNIPPET} />
)}
</ThemeProvider>
)
}
1 change: 1 addition & 0 deletions frontend/src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface ImportMetaEnv {
readonly FRONTEND_OIDC_REDIRECT_URI: string
readonly FRONTEND_SENTRY_DSN?: string
readonly FRONTEND_SHOM_KEY: string
readonly FRONTEND_SMALL_CHAT_SNIPPET: string
}

interface ImportMeta {
Expand Down
3 changes: 0 additions & 3 deletions infra/configurations/frontend/.env.prod

This file was deleted.

2 changes: 1 addition & 1 deletion infra/docker/docker-compose.cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ services:
- FRONTEND_OIDC_REDIRECT_URI=https://monitorfish.din.developpement-durable.gouv.fr
- FRONTEND_SENTRY_DSN=https://[email protected]/8
- FRONTEND_SHOM_KEY=rg8ele7cft4ujkwjspsmtwas
- VITE_SMALL_CHAT_SNIPPET=
- FRONTEND_MISSION_FORM_AUTO_SAVE_ENABLED=true # Even if we inject this env var, the value is not used (see cypress.config.ts)
- FRONTEND_MISSION_FORM_AUTO_UPDATE_ENABLED=true
- FRONTEND_SMALL_CHAT_SNIPPET=
ports:
- 8880:8880
- 8000:8000
Expand Down
2 changes: 1 addition & 1 deletion infra/docker/docker-compose.puppeteer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ services:
- FRONTEND_OIDC_REDIRECT_URI=https://monitorfish.din.developpement-durable.gouv.fr
- FRONTEND_SENTRY_DSN=https://[email protected]/8
- FRONTEND_SHOM_KEY=rg8ele7cft4ujkwjspsmtwas
- VITE_SMALL_CHAT_SNIPPET=
- FRONTEND_MISSION_FORM_AUTO_SAVE_ENABLED=true
- FRONTEND_MISSION_FORM_AUTO_UPDATE_ENABLED=true
- FRONTEND_SMALL_CHAT_SNIPPET=
ports:
- 8880:8880
- 8000:8000
Expand Down
1 change: 1 addition & 0 deletions infra/remote/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ services:
- FRONTEND_OIDC_ENABLED=$MONITORFISH_OIDC_ENABLED
- MONITORFISH_OIDC_ENABLED=$MONITORFISH_OIDC_ENABLED
- MONITORFISH_API_PROTECTED_API_KEY=$MONITORFISH_API_PROTECTED_API_KEY
- FRONTEND_SMALL_CHAT_SNIPPET=
ports:
- 8880:8880
- 8000:8000
Expand Down

0 comments on commit 7c8ba0d

Please sign in to comment.