From c380d4bc315fddec2263035fcf894a103823be61 Mon Sep 17 00:00:00 2001 From: Uriel-Sautron Date: Tue, 7 Jan 2025 17:39:50 +0100 Subject: [PATCH] front: change name in interne deployment - change logo stdcm when using application internally Signed-off-by: Uriel-Sautron - add lmr logo in stdcm simulation report sheet when using the application internally - create hook useLogo - use useLogo in app - remove logo.ts - add customized name - change hook useLoge to useDeploymentSetting test: change name stdcm pdf - with the modifications on the names in internal deployment the name of the pdf changed from STDCM to Stdcm --- front/src/applications/editor/Home.tsx | 2 - .../applications/operationalStudies/Home.tsx | 6 +- front/src/applications/referenceMap/Home.tsx | 2 - .../applications/rollingStockEditor/Home.tsx | 3 +- .../stdcm/components/StdcmHeader.tsx | 11 ++- .../StdcmResults/SimulationReportSheet.tsx | 17 +++- .../SimulationReportStyleSheet.ts | 4 + .../components/StdcmResults/StdcmResults.tsx | 4 +- front/src/common/BootstrapSNCF/NavBarSNCF.tsx | 19 +++- .../ReleaseInformations.tsx | 5 +- front/src/main/home.tsx | 5 +- front/src/styles/scss/_body.scss | 6 ++ .../scss/applications/stdcm/_header.scss | 4 + .../src/utils/hooks/useDeploymentSettings.ts | 88 +++++++++++++++++++ front/src/utils/logo.ts | 31 ------- front/tests/pages/stdcm-page-model.ts | 2 +- 16 files changed, 154 insertions(+), 55 deletions(-) create mode 100644 front/src/utils/hooks/useDeploymentSettings.ts delete mode 100644 front/src/utils/logo.ts diff --git a/front/src/applications/editor/Home.tsx b/front/src/applications/editor/Home.tsx index 8f3ec3fa655..a1375435121 100644 --- a/front/src/applications/editor/Home.tsx +++ b/front/src/applications/editor/Home.tsx @@ -5,7 +5,6 @@ import { Route, Routes } from 'react-router-dom'; import { ModalProvider } from 'common/BootstrapSNCF/ModalSNCF/ModalProvider'; import NavBarSNCF from 'common/BootstrapSNCF/NavBarSNCF'; import { useCurrentInfra } from 'modules/infra/useInfra'; -import { getLogo } from 'utils/logo'; import Editor from './Editor'; @@ -16,7 +15,6 @@ export default function HomeEditorUnplugged() { return ( {t('editor')} diff --git a/front/src/applications/operationalStudies/Home.tsx b/front/src/applications/operationalStudies/Home.tsx index 45c154c7750..30f5fab5138 100644 --- a/front/src/applications/operationalStudies/Home.tsx +++ b/front/src/applications/operationalStudies/Home.tsx @@ -19,7 +19,6 @@ import ProjectCard from 'modules/project/components/ProjectCard'; import cleanLocalStorageByProject from 'modules/project/helpers/cleanLocalStorageByProject'; import { getUserSafeWord } from 'reducers/user/userSelectors'; import { useAppDispatch } from 'store'; -import { getLogo } from 'utils/logo'; import AddNewCard from './components/AddNewCard'; import useMultiSelection from './hooks/useMultiSelection'; @@ -165,10 +164,7 @@ const HomeOperationalStudies = () => { return ( <> - {t('projects')}} - /> + {t('projects')}} />
diff --git a/front/src/applications/referenceMap/Home.tsx b/front/src/applications/referenceMap/Home.tsx index 005dda9426e..fe1352905e1 100644 --- a/front/src/applications/referenceMap/Home.tsx +++ b/front/src/applications/referenceMap/Home.tsx @@ -9,7 +9,6 @@ import { ModalProvider } from 'common/BootstrapSNCF/ModalSNCF/ModalProvider'; import NavBarSNCF from 'common/BootstrapSNCF/NavBarSNCF'; import { useInfraActions, useInfraID } from 'common/osrdContext'; import { useAppDispatch } from 'store'; -import { getLogo } from 'utils/logo'; import Map from './Map'; @@ -40,7 +39,6 @@ const HomeReferenceMap = () => { return ( {t('map')} diff --git a/front/src/applications/rollingStockEditor/Home.tsx b/front/src/applications/rollingStockEditor/Home.tsx index 082fa6447be..1ef6344f02c 100644 --- a/front/src/applications/rollingStockEditor/Home.tsx +++ b/front/src/applications/rollingStockEditor/Home.tsx @@ -2,7 +2,6 @@ import { useTranslation } from 'react-i18next'; import { ModalProvider } from 'common/BootstrapSNCF/ModalSNCF/ModalProvider'; import NavBarSNCF from 'common/BootstrapSNCF/NavBarSNCF'; -import { getLogo } from 'utils/logo'; import RollingStockEditor from './views/RollingStockEditor'; @@ -11,7 +10,7 @@ const HomeRollingStockEditor = () => { return ( - {t('rollingStockEditor')}} /> + {t('rollingStockEditor')}} /> ); diff --git a/front/src/applications/stdcm/components/StdcmHeader.tsx b/front/src/applications/stdcm/components/StdcmHeader.tsx index b43bd2b92ea..0fe4ef667b2 100644 --- a/front/src/applications/stdcm/components/StdcmHeader.tsx +++ b/front/src/applications/stdcm/components/StdcmHeader.tsx @@ -4,6 +4,14 @@ import { useTranslation } from 'react-i18next'; import { useSelector } from 'react-redux'; import { getIsSuperUser } from 'reducers/user/userSelectors'; +import useDeploymentSettings from 'utils/hooks/useDeploymentSettings'; + +const LogoSTDCM = ({ logo }: { logo: string | undefined }) => { + if (logo) { + return LMR Logo; + } + return ST DCM; +}; type StdcmHeaderProps = { isDebugMode: boolean; @@ -20,10 +28,11 @@ const StdcmHeader = ({ }: StdcmHeaderProps) => { const { t } = useTranslation(['stdcm', 'translation']); const isSuperUser = useSelector(getIsSuperUser); + const { stdcmLogo } = useDeploymentSettings(); return (
- ST DCM +
{t('stdcm:notificationTitle')} diff --git a/front/src/applications/stdcm/components/StdcmResults/SimulationReportSheet.tsx b/front/src/applications/stdcm/components/StdcmResults/SimulationReportSheet.tsx index 6da532c26c7..0f36bd41683 100644 --- a/front/src/applications/stdcm/components/StdcmResults/SimulationReportSheet.tsx +++ b/front/src/applications/stdcm/components/StdcmResults/SimulationReportSheet.tsx @@ -8,6 +8,7 @@ import logoSNCF from 'assets/simulationReportSheet/logo_sncf_reseau.png'; import i18n from 'i18n'; import type { StdcmPathStep } from 'reducers/osrdconf/types'; import { dateToHHMMSS, formatDateToString, formatDay } from 'utils/date'; +import useDeploymentSettings from 'utils/hooks/useDeploymentSettings'; import { msToKmh } from 'utils/physics'; import { capitalizeFirstLetter } from 'utils/strings'; import { secToMin } from 'utils/timeManipulation'; @@ -35,6 +36,18 @@ const getArrivalTimes = (step: StdcmPathStep, t: TFunction, shouldDisplay: boole return ''; }; +const LogoSTDCM = ({ logo, t }: { logo: string | undefined; t: TFunction }) => { + if (logo) { + return ; + } + return ( + <> + {t('stdcm')} + {t('stdcmCreation')} + + ); +}; + const SimulationReportSheet = ({ stdcmLinkedTrains, stdcmData, @@ -42,6 +55,7 @@ const SimulationReportSheet = ({ simulationReportSheetNumber, operationalPointsList, }: SimulationReportSheetProps) => { + const { stdcmSimulationSheetLogo } = useDeploymentSettings(); const { t } = useTranslation(['stdcm-simulation-report-sheet', 'stdcm']); let renderedIndex = 0; @@ -63,8 +77,7 @@ const SimulationReportSheet = ({ - {t('stdcm')} - {t('stdcmCreation')} + diff --git a/front/src/applications/stdcm/components/StdcmResults/SimulationReportStyleSheet.ts b/front/src/applications/stdcm/components/StdcmResults/SimulationReportStyleSheet.ts index fcf033b9303..ae6eb28a621 100644 --- a/front/src/applications/stdcm/components/StdcmResults/SimulationReportStyleSheet.ts +++ b/front/src/applications/stdcm/components/StdcmResults/SimulationReportStyleSheet.ts @@ -42,6 +42,10 @@ const styles = { height: '24', marginLeft: '20', }, + lmrLogo: { + width: 'auto', + marginRight: 'auto', + }, simulationTitle: { fontSize: '28', fontWeight: 'semibold', diff --git a/front/src/applications/stdcm/components/StdcmResults/StdcmResults.tsx b/front/src/applications/stdcm/components/StdcmResults/StdcmResults.tsx index af6ac452b5a..a297470a435 100644 --- a/front/src/applications/stdcm/components/StdcmResults/StdcmResults.tsx +++ b/front/src/applications/stdcm/components/StdcmResults/StdcmResults.tsx @@ -14,6 +14,7 @@ import { import { hasConflicts, hasResults } from 'applications/stdcm/utils/simulationOutputUtils'; import { type TrackRange } from 'common/api/osrdEditoastApi'; import NewMap from 'modules/trainschedule/components/ManageTrainSchedule/NewMap'; +import useDeploymentSettings from 'utils/hooks/useDeploymentSettings'; import SimulationReportSheet from './SimulationReportSheet'; import StdcmDebugResults from './StdcmDebugResults'; @@ -50,6 +51,7 @@ const StcdmResults = ({ pathTrackRanges, }: StcdmResultsProps) => { const { t } = useTranslation('stdcm', { keyPrefix: 'simulation.results' }); + const { stdcmName } = useDeploymentSettings(); const selectedSimulation = simulationsList[selectedSimulationIndex]; const { outputs } = selectedSimulation || {}; @@ -112,7 +114,7 @@ const StcdmResults = ({ operationalPointsList={operationalPointsList} /> } - fileName={`STDCM-${simulationReportSheetNumber}.pdf`} + fileName={`${stdcmName}-${simulationReportSheetNumber}.pdf`} >