Skip to content

Commit

Permalink
[Mission] Ajout d'un feature flag sur le rafraîchissement automatique (
Browse files Browse the repository at this point in the history
  • Loading branch information
claire2212 authored Dec 11, 2023
2 parents a76c5ec + db01193 commit 1d09f65
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion frontend/public/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ self.env = {
REACT_APP_SENTRY_DSN: '__REACT_APP_SENTRY_DSN__',
REACT_APP_SENTRY_ENV: '__REACT_APP_SENTRY_ENV__',
REACT_APP_SENTRY_TRACING_ORIGINS: '__REACT_APP_SENTRY_TRACING_ORIGINS__',
REACT_APP_SHOM_KEY: '__REACT_APP_SHOM_KEY__'
REACT_APP_SHOM_KEY: '__REACT_APP_SHOM_KEY__',
REACT_APP_MISSION_FORM_AUTO_UPDATE: '__REACT_APP_MISSION_FORM_AUTO_UPDATE__',
}
5 changes: 5 additions & 0 deletions frontend/src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ export const MONITORENV_VERSION =
self?.env?.REACT_APP_MONITORENV_VERSION !== '__REACT_APP_MONITORENV_VERSION__'
? self.env.REACT_APP_MONITORENV_VERSION
: process.env.REACT_APP_MONITORENV_VERSION

export const MISSION_FORM_AUTO_UPDATE =
self?.env?.REACT_APP_MISSION_FORM_AUTO_UPDATE !== '__REACT_APP_MISSION_FORM_AUTO_UPDATE__'
? self.env.REACT_APP_MISSION_FORM_AUTO_UPDATE
: process.env.REACT_APP_MISSION_FORM_AUTO_UPDATE
11 changes: 11 additions & 0 deletions frontend/src/features/missions/MissionForm/sse.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MISSION_FORM_AUTO_UPDATE } from '../../../env'
import { ReconnectingEventSource } from '../../../libs/ReconnectingEventSource'

import type { Mission } from '../../../domain/entities/missions'
Expand Down Expand Up @@ -68,6 +69,16 @@ export const missionEventListener =
// eslint-disable-next-line no-console
console.log(`SSE: received an update for mission id ${id}.`)

if (!MISSION_FORM_AUTO_UPDATE) {
// eslint-disable-next-line no-console
console.log(
'Skipping automatic update of mission form. ' +
"Set 'REACT_APP_MISSION_FORM_AUTO_UPDATE=true' feature flag to activate this feature."
)

return
}

updateCachedData(draft => {
const { envActions } = draft

Expand Down
4 changes: 4 additions & 0 deletions infra/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ REACT_APP_SHOM_KEY=rg8ele7cft4ujkwjspsmtwas
# Attention: utiliser des double quotes (") et non des single quotes (')
REACT_APP_SENTRY_TRACING_ORIGINS=["monitorenv-test.csam.e2.rie.gouv.fr", "monitorenv.din.developpement-durable.gouv.fr"]

# Feature flags
REACT_APP_MISSION_FORM_AUTO_UPDATE=false

################################################################################
# Monitoring & Backup

Expand All @@ -54,3 +57,4 @@ SENTRY_DSN=""
MONITORENV_LOGS_AND_BACKUPS_GID=changeme
MONITORENV_LOGS_FOLDER=./logs
MONITORENV_BACKUPS_FOLDER=./backups

1 change: 1 addition & 0 deletions infra/docker/app/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ sed -i 's#__REACT_APP_SENTRY_ENV__#'"$REACT_APP_SENTRY_ENV"'#g' /home/monitorenv
sed -i 's#__REACT_APP_SENTRY_TRACING_ORIGINS__#'"$REACT_APP_SENTRY_TRACING_ORIGINS"'#g' /home/monitorenv/public/env.js
sed -i 's#__REACT_APP_SHOM_KEY__#'"$REACT_APP_SHOM_KEY"'#g' /home/monitorenv/public/env.js
sed -i 's#__REACT_APP_CYPRESS_TEST__#'"$REACT_APP_CYPRESS_TEST"'#g' /home/monitorenv/public/env.js
sed -i 's#__REACT_APP_MISSION_FORM_AUTO_UPDATE__#'"$REACT_APP_MISSION_FORM_AUTO_UPDATE"'#g' /home/monitorenv/public/env.js

exec "$@"
1 change: 1 addition & 0 deletions infra/docker/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ services:
- REACT_APP_GEOSERVER_REMOTE_URL=http://0.0.0.0:8081
- REACT_APP_GEOSERVER_NAMESPACE=monitorenv
- REACT_APP_CYPRESS_TEST=true
- REACT_APP_MISSION_FORM_AUTO_UPDATE=true
ports:
- 8880:8880
- 8000:8000
Expand Down

0 comments on commit 1d09f65

Please sign in to comment.