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

Change name for interne deployment #10302

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions front/src/applications/editor/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -16,7 +15,6 @@ export default function HomeEditorUnplugged() {
return (
<ModalProvider>
<NavBarSNCF
logo={getLogo()}
appName={
<>
{t('editor')}
Expand Down
6 changes: 1 addition & 5 deletions front/src/applications/operationalStudies/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -165,10 +164,7 @@ const HomeOperationalStudies = () => {

return (
<>
<NavBarSNCF
logo={getLogo()}
appName={<div className="navbar-breadcrumbs">{t('projects')}</div>}
/>
<NavBarSNCF appName={<div className="navbar-breadcrumbs">{t('projects')}</div>} />
<main className="mastcontainer mastcontainer-no-mastnav">
<div className="p-3">
<div className="projects-toolbar">
Expand Down
2 changes: 0 additions & 2 deletions front/src/applications/referenceMap/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -40,7 +39,6 @@ const HomeReferenceMap = () => {
return (
<ModalProvider>
<NavBarSNCF
logo={getLogo()}
appName={
<>
{t('map')}
Expand Down
3 changes: 1 addition & 2 deletions front/src/applications/rollingStockEditor/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -11,7 +10,7 @@ const HomeRollingStockEditor = () => {

return (
<ModalProvider>
<NavBarSNCF logo={getLogo()} appName={<>{t('rollingStockEditor')}</>} />
<NavBarSNCF appName={<>{t('rollingStockEditor')}</>} />
<RollingStockEditor />
</ModalProvider>
);
Expand Down
11 changes: 10 additions & 1 deletion front/src/applications/stdcm/components/StdcmHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';

import { getIsSuperUser } from 'reducers/user/userSelectors';
import useLogo from 'utils/hooks/useLogo';

const LogoSTDCM = ({ logo }: { logo: string | undefined }) => {
if (logo) {
return <img src={logo} data-testid="lmr-logo" alt="LMR Logo" className="stdcm-header__logo" />;
}
return <span className="stdcm-header__title pl-5">ST DCM</span>;
};

type StdcmHeaderProps = {
isDebugMode: boolean;
Expand All @@ -20,10 +28,11 @@ const StdcmHeader = ({
}: StdcmHeaderProps) => {
const { t } = useTranslation(['stdcm', 'translation']);
const isSuperUser = useSelector(getIsSuperUser);
const { stdcm } = useLogo();

return (
<div className="stdcm-header d-flex">
<span className="stdcm-header__title pl-5">ST DCM</span>
<LogoSTDCM logo={stdcm.stdcmLogo} />
Yohh marked this conversation as resolved.
Show resolved Hide resolved
<div className="flex-grow-1 d-flex justify-content-center">
<span className="stdcm-header__notification " id="notification">
{t('stdcm:notificationTitle')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import iconAlert from 'assets/simulationReportSheet/icon_alert_fill.png';
import logoSNCF from 'assets/simulationReportSheet/logo_sncf_reseau.png';
import type { StdcmPathStep } from 'reducers/osrdconf/types';
import { dateToHHMMSS, formatDateToString, formatDay } from 'utils/date';
import useLogo from 'utils/hooks/useLogo';
import { msToKmh } from 'utils/physics';
import { capitalizeFirstLetter } from 'utils/strings';

Expand All @@ -15,6 +16,7 @@ import type { SimulationReportSheetProps } from '../../types';
import { getStopDurationTime } from '../../utils/formatSimulationReportSheet';

const getSecondaryCode = ({ location }: StdcmPathStep) => location!.secondary_code;
const lmrLogoPath = '../../overrides/[email protected]';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not reference any override directly in terms of path, they are dynamically defined by the JSON.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


const getStopType = (step: StdcmPathStep, t: TFunction) => {
if (!step.isVia) {
Expand All @@ -33,13 +35,26 @@ const getArrivalTime = (step: StdcmPathStep, t: TFunction) => {
return '';
};

const LogoSTDCM = ({ logo, t }: { logo: string | undefined; t: TFunction }) => {
if (logo) {
return <Image src={lmrLogoPath} style={styles.header.lmrLogo} />;
}
return (
<>
<Text style={styles.header.title}>{t('stdcm')}</Text>
<Text style={styles.header.creation}>{t('stdcmCreation')}</Text>
</>
);
};

const SimulationReportSheet = ({
stdcmLinkedTrains,
stdcmData,
consist,
simulationReportSheetNumber,
operationalPointsList,
}: SimulationReportSheetProps) => {
const { stdcm } = useLogo();
const { t } = useTranslation(['stdcm-simulation-report-sheet', 'stdcm']);
let renderedIndex = 0;

Expand Down Expand Up @@ -71,8 +86,7 @@ const SimulationReportSheet = ({
<View style={styles.header.numberDateBanner}>
<View style={styles.header.stdcmTitleBox}>
<View style={styles.header.stdcm}>
<Text style={styles.header.title}>{t('stdcm')}</Text>
<Text style={styles.header.creation}>{t('stdcmCreation')}</Text>
<LogoSTDCM logo={stdcm.stdcmPngLogo} t={t} />
</View>
</View>
<View style={styles.header.numericInfo}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ const styles = {
height: '24',
marginLeft: '20',
},
lmrLogo: {
width: 'auto',
height: 'auto',
marginTop: 'auto',
marginRight: 'auto',
},
simulationTitle: {
fontSize: '28',
fontWeight: 'semibold',
Expand Down
17 changes: 13 additions & 4 deletions front/src/common/BootstrapSNCF/NavBarSNCF.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type ReactElement } from 'react';

import { Gear, Info, Report, ShieldCheck, SignOut } from '@osrd-project/ui-icons';
import cx from 'classnames';
import getUnicodeFlagIcon from 'country-flag-icons/unicode';
import i18n from 'i18next';
import { useTranslation } from 'react-i18next';
Expand All @@ -13,7 +14,7 @@ import ReleaseInformations from 'common/ReleaseInformations/ReleaseInformations'
import UserSettings from 'common/UserSettings';
import { getUserSafeWord } from 'reducers/user/userSelectors';
import useAuth from 'utils/hooks/OsrdAuth';
import { getLogo } from 'utils/logo';
import useLogo from 'utils/hooks/useLogo';
import { language2flag } from 'utils/strings';

import DropdownSNCF, { DROPDOWN_STYLE_TYPES } from './DropdownSNCF';
Expand All @@ -24,17 +25,25 @@ type Props = {
logo?: string;
};

const LegacyNavBarSNCF = ({ appName, logo = getLogo() }: Props) => {
const LegacyNavBarSNCF = ({ appName, logo }: Props) => {
const { openModal } = useModal();
const { digitalTwin, isIntenalProd } = useLogo();
const safeWord = useSelector(getUserSafeWord);
const { t } = useTranslation('home/navbar');
const { logout, username } = useAuth();

const headerLogo = logo ?? digitalTwin.logo;

return (
<div className="mastheader">
<div className="mastheader-logo flex-grow-0">
<div
className={cx(
isIntenalProd && logo ? `mastheader-logo__horizon` : `mastheader-logo`,
`flex-grow-0`
)}
>
<Link to="/">
<img src={logo} data-testid="osrd-logo" alt="OSRD Logo" />
<img src={headerLogo} data-testid="osrd-logo" alt="OSRD Logo" />
</Link>
</div>
<header role="banner" className="mastheader-title d-flex flex-grow-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { osrdEditoastApi } from 'common/api/osrdEditoastApi';
import ModalBodySNCF from 'common/BootstrapSNCF/ModalSNCF/ModalBodySNCF';
import ModalHeaderSNCF from 'common/BootstrapSNCF/ModalSNCF/ModalHeaderSNCF';
import motriceParty from 'common/MotriceRelated/motriceParty';
import { getLogo } from 'utils/logo';
import useLogo from 'utils/hooks/useLogo';

import LicenseAttributions from './LicenseAttributions';

function ReleaseInformations() {
const { t } = useTranslation('home/navbar');
const { digitalTwin } = useLogo();
const { data: editoastVersion } = osrdEditoastApi.endpoints.getVersion.useQuery();
const { data: coreVersion } = osrdEditoastApi.endpoints.getVersionCore.useQuery();

Expand Down Expand Up @@ -45,7 +46,7 @@ function ReleaseInformations() {
rel="noopener noreferrer"
onMouseEnter={motriceParty}
>
<img src={getLogo()} alt="OSRD logo" width={192} />
<img src={digitalTwin.logo} alt="OSRD logo" width={192} />
</a>
<h2>OSRD</h2>
<h3>Open Source Railway Designer</h3>
Expand Down
5 changes: 3 additions & 2 deletions front/src/main/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useAllowedUserRoles from 'common/authorization/hooks/useAllowedUserRoles'
import Card from 'common/BootstrapSNCF/CardSNCF/CardSNCF';
import { ModalProvider } from 'common/BootstrapSNCF/ModalSNCF/ModalProvider';
import NavBarSNCF from 'common/BootstrapSNCF/NavBarSNCF';
import { getOsrdLogo } from 'utils/logo';
import useLogo from 'utils/hooks/useLogo';

export default function Home() {
const { t } = useTranslation('home/home');
Expand All @@ -20,10 +20,11 @@ export default function Home() {
rollingStockEditorAllowed,
mapAllowed,
} = useAllowedUserRoles();
const { digitalTwin } = useLogo();

return (
<ModalProvider>
<NavBarSNCF logo={getOsrdLogo()} />
<NavBarSNCF logo={digitalTwin.digitalTwinLogo} />
<main className="mastcontainer mastcontainer-no-mastnav">
<div className="cardscontainer">
<div className="row justify-content-center mb-2">
Expand Down
5 changes: 5 additions & 0 deletions front/src/styles/scss/_body.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ body {
img {
height: 24px !important;
}
&__horizon{
img {
height: 40px;
}
}
}

.actionbar.fullscreen {
Expand Down
4 changes: 4 additions & 0 deletions front/src/styles/scss/applications/stdcm/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
justify-content: space-between;
padding-right: 50px;

&__logo {
padding: 10px 0 10px 10px;
}

&__title {
max-height: 48px;
color: rgba(0, 0, 0, 1);
Expand Down
58 changes: 58 additions & 0 deletions front/src/utils/hooks/useLogo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { useEffect, useState } from 'react';

import defaultLogo from 'assets/logo-color.svg';
import defaultOsrdLogo from 'assets/logo-osrd-color-white.svg';
import proudLogo from 'assets/proud-logo-color.svg';
import proudOsrdLogo from 'assets/proud-logo-osrd-color-white.svg';
import xmasLogo from 'assets/xmas-logo-color.svg';
import xmasOsrdLogo from 'assets/xmas-logo-osrd-color-white.svg';

const MONTH_VALUES = {
JUNE: 5,
DECEMBER: 11,
};

const lmrLogoPath = '../../overrides/Logotype_LastMinuteRequest_light.svg';
const horizonFullLogoPath = '../../overrides/Logotype_Horizon_dark.svg';
const horizonLogoPath = '../../overrides/Logo_Horizon.svg';
const lmrPngLogoPath = '../../overrides/[email protected]';

const useLogo = () => {
const [digitalTwin, setDigitalTwin] = useState<{ logo: string; digitalTwinLogo: string }>({
logo: defaultLogo,
digitalTwinLogo: defaultOsrdLogo,
});
const [stdcm, setStdcm] = useState<{ stdcmLogo?: string; stdcmPngLogo: string }>({
stdcmLogo: undefined,
stdcmPngLogo: defaultLogo,
});
const [isIntenalProd, setIsIntenalProd] = useState(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should not name this internalProd, but "customizedDeployment", it seems more accurate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


useEffect(() => {
const fetchInternalProd = async () => {
try {
const response = await fetch('/overrides/overrides.json');
if (!response.ok || response.headers.get('Content-Type') !== 'application/json') {
setIsIntenalProd(false);
if (new Date().getMonth() === MONTH_VALUES.JUNE) {
setDigitalTwin({ logo: proudLogo, digitalTwinLogo: proudOsrdLogo });
}
if (new Date().getMonth() === MONTH_VALUES.DECEMBER) {
setDigitalTwin({ logo: xmasLogo, digitalTwinLogo: xmasOsrdLogo });
}
} else {
setIsIntenalProd(true);
setStdcm({ stdcmLogo: lmrLogoPath, stdcmPngLogo: lmrPngLogoPath });
setDigitalTwin({ logo: horizonLogoPath, digitalTwinLogo: horizonFullLogoPath });
}
} catch {
setIsIntenalProd(false);
}
};
fetchInternalProd();
}, []);

return { digitalTwin, stdcm, isIntenalProd };
};

export default useLogo;
31 changes: 0 additions & 31 deletions front/src/utils/logo.ts

This file was deleted.

Loading