Skip to content

Commit 82cd094

Browse files
author
Élyse Viard
committed
front: support no infra edit override
Signed-off-by: Élyse Viard <[email protected]>
1 parent b3c1228 commit 82cd094

File tree

3 files changed

+45
-19
lines changed

3 files changed

+45
-19
lines changed

front/src/common/BootstrapSNCF/NavBarSNCF.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const LegacyNavBarSNCF = ({ appName, showLogoWithName }: Props) => {
5151
<div
5252
className={cx(
5353
'flex-grow-0',
54-
deploymentSettings?.isCustomizedDeployment && showLogoWithName
54+
deploymentSettings?.hasCustomizedLogo && showLogoWithName
5555
? 'mastheader-logo-with-name'
5656
: 'mastheader-logo',
5757
{ 'without-image': logoUrl }

front/src/modules/infra/components/InfraSelector/InfraSelectorModal.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { setFailure } from 'reducers/main';
1313
import { useAppDispatch } from 'store';
1414
import { castErrorToFailure } from 'utils/error';
1515
import { useDebounce } from 'utils/helpers';
16+
import useDeploymentSettings from 'utils/hooks/useDeploymentSettings';
1617

1718
import InfraSelectorModalBodyEdition from './InfraSelectorModalBodyEdition';
1819
import InfraSelectorModalBodyStandard from './InfraSelectorModalBodyStandard';
@@ -24,10 +25,12 @@ type InfraSelectorModalProps = {
2425

2526
const InfraSelectorModal = ({ onlySelectionMode = false, isInEditor }: InfraSelectorModalProps) => {
2627
const { t } = useTranslation(['translation', 'infraManagement']);
28+
const deploymentSettings = useDeploymentSettings();
2729
const dispatch = useAppDispatch();
2830
const [filter, setFilter] = useState('');
2931
const [filteredInfrasList, setFilteredInfrasList] = useState<Infra[]>([]);
3032
const [editionMode, setEditionMode] = useState(false);
33+
const canEditInfra = !deploymentSettings?.noInfraEdit;
3134
const {
3235
data: infrasList,
3336
isSuccess,
@@ -85,7 +88,7 @@ const InfraSelectorModal = ({ onlySelectionMode = false, isInEditor }: InfraSele
8588
? t('infraManagement:infraManagement')
8689
: t('infraManagement:infraChoice')}
8790
</span>
88-
{!onlySelectionMode && (
91+
{!onlySelectionMode && canEditInfra && (
8992
<button
9093
className="infra-switch-mode"
9194
type="button"

front/src/utils/hooks/useDeploymentSettings.tsx

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ const defaultSettings = {
1919
stdcmName: 'Stdcm',
2020
stdcmLogo: undefined,
2121
stdcmSimulationSheetLogo: undefined,
22-
isCustomizedDeployment: false,
22+
hasCustomizedLogo: false,
2323
stdcmFeedbackMail: '[email protected]',
24+
noInfraEdit: false,
2425
};
2526

2627
export type DeploymentSettings = {
@@ -30,8 +31,9 @@ export type DeploymentSettings = {
3031
stdcmName: string;
3132
stdcmLogo?: string;
3233
stdcmSimulationSheetLogo?: string;
33-
isCustomizedDeployment: boolean;
34+
hasCustomizedLogo: boolean;
3435
stdcmFeedbackMail?: string;
36+
noInfraEdit?: boolean;
3537
};
3638

3739
export type DeploymentSettingsContext = {
@@ -76,25 +78,46 @@ export const DeploymentContextProvider = ({ children }: DeploymentContextProvide
7678
});
7779
} else {
7880
const overridesData = await response.json();
79-
const { icons, names, stdcm_feedback_mail } = overridesData;
81+
const { icons, names, stdcm_feedback_mail, no_infra_edit } = overridesData;
82+
83+
const deploySettings: DeploymentSettings = {
84+
...defaultSettings,
85+
};
86+
87+
if (names) {
88+
if (names.digital_twin) {
89+
deploySettings.digitalTwinName = names.digital_twin;
90+
}
91+
if (names.stdcm) {
92+
deploySettings.stdcmName = names.stdcm;
93+
}
94+
}
95+
96+
if (icons) {
97+
deploySettings.hasCustomizedLogo = true;
98+
99+
if (icons.digital_twin) {
100+
deploySettings.digitalTwinLogo = `/overrides/${icons.digital_twin.dark}_Logo_Grey40.svg`;
101+
deploySettings.digitalTwinLogoWithName = `/overrides/${icons.digital_twin.dark}_Grey10.svg`;
102+
}
103+
104+
if (icons.stdcm) {
105+
deploySettings.stdcmLogo = `/overrides/${icons.stdcm.light}.svg`;
106+
deploySettings.stdcmSimulationSheetLogo = `/overrides/${icons.stdcm.light}@2x.png`;
107+
}
108+
}
80109

81-
const lmrLogoPath = `/overrides/${icons.stdcm.light}.svg`;
82-
const lmrPngLogoPath = `/overrides/${icons.stdcm.light}@2x.png`;
83-
const horizonLogoWithNamePath = `/overrides/${icons.digital_twin.dark}_Grey10.svg`;
84-
const horizonLogoPath = `/overrides/${icons.digital_twin.dark}_Logo_Grey40.svg`;
110+
if (stdcm_feedback_mail) {
111+
deploySettings.stdcmFeedbackMail = stdcm_feedback_mail;
112+
}
113+
114+
if (no_infra_edit) {
115+
deploySettings.noInfraEdit = no_infra_edit;
116+
}
85117

86118
setCustomizedDeploymentSetting({
87119
isLoading: false,
88-
deploymentSettings: {
89-
digitalTwinName: names.digital_twin,
90-
digitalTwinLogo: horizonLogoPath,
91-
digitalTwinLogoWithName: horizonLogoWithNamePath,
92-
stdcmName: names.stdcm,
93-
stdcmLogo: lmrLogoPath,
94-
stdcmSimulationSheetLogo: lmrPngLogoPath,
95-
isCustomizedDeployment: true,
96-
stdcmFeedbackMail: stdcm_feedback_mail,
97-
},
120+
deploymentSettings: deploySettings,
98121
});
99122
}
100123
} catch (error) {

0 commit comments

Comments
 (0)