From 5afa97a7b9cd248631250da7625278066ace5c2b Mon Sep 17 00:00:00 2001 From: Edward Brunton <42774600+EdwardBrunton@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:09:23 +0100 Subject: [PATCH 01/21] Update readme to document deployment --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d1565cf3..f4cbaf65 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,17 @@ $ docker build --force-rm -t pcs:latest -f .docker/Dockerfile . $ docker run -it -p 80:80 pcs:latest ``` +# How to deploy + +## Deploy to dev +When you are ready to deploy your changes to dev/test create a PR and merge it into the development branch. This will trigger a build and deploy to the dev environment. + +## Deploy to test +When you want your changes to test merge the develop branch into the test branch and your changes will be deployed to test. + +## Deploy to prod +When you are ready to deploy to production merge the develop branch into the master branch and your changes will be deployed to production. You can **NOT** merge test to master because test has different styling than production. + # Libraries ### Microsoft Authentication Library (MSAL) @@ -92,4 +103,4 @@ https://webpack.js.org/ ### Browserslist Used to define which browsers we support, as well as integrate with polyfill loading in CSS and Babel. -https://www.npmjs.com/package/browserslist \ No newline at end of file +https://www.npmjs.com/package/browserslist From 8140734b09aceb53ddc248f9e64ac515482bc71f Mon Sep 17 00:00:00 2001 From: Karolina Slazyk <76835138+kslazykv@users.noreply.github.com> Date: Wed, 18 Dec 2024 10:01:56 +0100 Subject: [PATCH 02/21] fixed Route (#886) --- src/modules/InvitationForPunchOut/InvitationForPunchOut.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/InvitationForPunchOut/InvitationForPunchOut.tsx b/src/modules/InvitationForPunchOut/InvitationForPunchOut.tsx index ca271378..1bd3fe0c 100644 --- a/src/modules/InvitationForPunchOut/InvitationForPunchOut.tsx +++ b/src/modules/InvitationForPunchOut/InvitationForPunchOut.tsx @@ -45,10 +45,13 @@ const InvitationForPunchOut = (): JSX.Element => { /> } /> + } + /> Date: Thu, 9 Jan 2025 12:16:11 +0100 Subject: [PATCH 03/21] wip --- src/modules/PlantConfig/types.d.ts | 5 - .../LibraryTreeview/LibraryTreeview.tsx | 41 +++-- .../PreservationJourney.tsx | 160 ++++++++++-------- .../types/AutoTransferMethod.ts | 5 + .../PreservationJourney/types/Journey.ts | 11 ++ .../Library/PreservationJourney/types/Mode.ts | 7 + .../types/PreservationJourneyProps.ts | 5 + .../Library/PreservationJourney/types/Step.ts | 17 ++ .../PreservationJourney/types/index.ts | 5 + .../http/PreservationApiClient.ts | 11 +- 10 files changed, 174 insertions(+), 93 deletions(-) delete mode 100644 src/modules/PlantConfig/types.d.ts create mode 100644 src/modules/PlantConfig/views/Library/PreservationJourney/types/AutoTransferMethod.ts create mode 100644 src/modules/PlantConfig/views/Library/PreservationJourney/types/Journey.ts create mode 100644 src/modules/PlantConfig/views/Library/PreservationJourney/types/Mode.ts create mode 100644 src/modules/PlantConfig/views/Library/PreservationJourney/types/PreservationJourneyProps.ts create mode 100644 src/modules/PlantConfig/views/Library/PreservationJourney/types/Step.ts create mode 100644 src/modules/PlantConfig/views/Library/PreservationJourney/types/index.ts diff --git a/src/modules/PlantConfig/types.d.ts b/src/modules/PlantConfig/types.d.ts deleted file mode 100644 index e8c226a6..00000000 --- a/src/modules/PlantConfig/types.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type ProjectDetails = { - id: number; - name: string; - description: string; -}; diff --git a/src/modules/PlantConfig/views/Library/LibraryTreeview/LibraryTreeview.tsx b/src/modules/PlantConfig/views/Library/LibraryTreeview/LibraryTreeview.tsx index 4decc783..886ad25c 100644 --- a/src/modules/PlantConfig/views/Library/LibraryTreeview/LibraryTreeview.tsx +++ b/src/modules/PlantConfig/views/Library/LibraryTreeview/LibraryTreeview.tsx @@ -11,6 +11,7 @@ import { unsavedChangesConfirmationMessage, useDirtyContext, } from '@procosys/core/DirtyContext'; +import { Journey } from '../PreservationJourney/types'; type LibraryTreeviewProps = { forceUpdate: React.DispatchWithoutAction; @@ -23,7 +24,8 @@ type LibraryTreeviewProps = { const LibraryTreeview = (props: LibraryTreeviewProps): JSX.Element => { const { isDirty } = useDirtyContext(); - const { libraryApiClient, preservationApiClient } = usePlantConfigContext(); + const { libraryApiClient, preservationApiClient, projects } = + usePlantConfigContext(); const handleTreeviewClick = ( libraryType: LibraryType, @@ -68,13 +70,28 @@ const LibraryTreeview = (props: LibraryTreeviewProps): JSX.Element => { const getPresJourneyTreeNodes = async (): Promise => { const children: TreeViewNode[] = []; try { - return await preservationApiClient - .getJourneys(true) - .then((response) => { - if (response) { - response.forEach((journey) => - children.push({ - id: 'journey_' + journey.id, + const journeys = await preservationApiClient.getJourneys(true); + const groupedJourneys = journeys.reduce( + (acc: { [key: string]: Journey[] }, journey) => { + const projectDescription = journey.project + ? journey.project.description + : 'Global'; + if (!acc[projectDescription]) { + acc[projectDescription] = []; + } + acc[projectDescription].push(journey); + return acc; + }, + {} as { [key: string]: Journey[] } + ); + Object.keys(groupedJourneys).forEach((projectDescription) => { + const projectNode: TreeViewNode = { + id: `project_${projectDescription}`, + name: projectDescription, + getChildren: async (): Promise => { + return groupedJourneys[projectDescription].map( + (journey) => ({ + id: `journey_${journey.id}`, name: journey.title, isVoided: journey.isVoided, onClick: (): void => @@ -84,9 +101,11 @@ const LibraryTreeview = (props: LibraryTreeviewProps): JSX.Element => { ), }) ); - } - return children; - }); + }, + }; + children.push(projectNode); + }); + return children; } catch (error) { console.error( 'Get preservation journeys failed: ', diff --git a/src/modules/PlantConfig/views/Library/PreservationJourney/PreservationJourney.tsx b/src/modules/PlantConfig/views/Library/PreservationJourney/PreservationJourney.tsx index 6e45eb5d..62888987 100644 --- a/src/modules/PlantConfig/views/Library/PreservationJourney/PreservationJourney.tsx +++ b/src/modules/PlantConfig/views/Library/PreservationJourney/PreservationJourney.tsx @@ -30,6 +30,16 @@ import { ButtonContainerLeft, ButtonContainerRight, } from '../Library.style'; +import { + AutoTransferMethod, + Journey, + Mode, + PreservationJourneyProps, + Step, +} from './types'; +import { ProjectDetails } from '@procosys/modules/Preservation/types'; +import { useProcosysContext } from '@procosys/core/ProcosysContext'; +import e from 'express'; const addIcon = ; const upIcon = ; @@ -48,51 +58,6 @@ const WAIT_INTERVAL = 300; const checkboxHeightInGridUnits = 4; -enum AutoTransferMethod { - NONE = 'None', - RFCC = 'OnRfccSign', - RFOC = 'OnRfocSign', -} - -interface Journey { - id: number; - title: string; - isVoided: boolean; - isInUse: boolean; - steps: Step[]; - rowVersion: string; -} - -interface Step { - id: number; - title: string; - autoTransferMethod: string; - isVoided: boolean; - isInUse: boolean; - mode: Mode; - responsible: { - code: string; - title: string; - rowVersion: string; - description?: string; - }; - rowVersion: string; -} - -interface Mode { - id: number; - title: string; - forSupplier: boolean; - isVoided: boolean; - rowVersion: string; -} - -type PreservationJourneyProps = { - forceUpdate: number; - journeyId: number; - setDirtyLibraryType: () => void; -}; - const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { const getInitialJourney = (): Journey => { return { @@ -108,6 +73,8 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { const [isEditMode, setIsEditMode] = useState(false); const [isLoading, setIsLoading] = useState(false); const [journey, setJourney] = useState(null); + const [selectedProject, setSelectedProject] = + useState(null); const [newJourney, setNewJourney] = useState(getInitialJourney); const [mappedModes, setMappedModes] = useState([]); const [modes, setModes] = useState([]); @@ -130,7 +97,9 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { return JSON.stringify(journey) != JSON.stringify(newJourney); }, [journey, newJourney]); - const { preservationApiClient, libraryApiClient } = usePlantConfigContext(); + const { preservationApiClient, libraryApiClient, projects } = + usePlantConfigContext(); + const { procosysApiClient } = useProcosysContext(); const cloneJourney = (journey: Journey): Journey => { return JSON.parse(JSON.stringify(journey)); @@ -140,12 +109,12 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { * Get Modes */ useEffect(() => { - let requestCancellor: Canceler | null = null; + let requestCanceler: Canceler | null = null; (async (): Promise => { try { const modes = await preservationApiClient.getModes( false, - (cancel: Canceler) => (requestCancellor = cancel) + (cancel: Canceler) => (requestCanceler = cancel) ); const mappedModes: SelectItem[] = []; modes.forEach((mode) => @@ -183,7 +152,7 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { })(); return (): void => { - requestCancellor && requestCancellor(); + requestCanceler && requestCanceler(); }; }, [journey]); @@ -261,6 +230,18 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { } }, [props.journeyId]); + useEffect(() => { + if (journey) { + setSelectedProject( + projects?.find( + (project) => project.id === newJourney.projectId + ) ?? null + ); + } else { + setSelectedProject(null); + } + }, [projects, newJourney?.projectId]); + const saveNewStep = async ( journeyId: number, step: Step @@ -312,7 +293,8 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { await preservationApiClient.updateJourney( newJourney.id, newJourney.title, - newJourney.rowVersion + newJourney.rowVersion, + newJourney.projectId ); props.setDirtyLibraryType(); return true; @@ -356,7 +338,10 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { setIsLoading(true); let saveOk = true; let noChangesToSave = true; - if (journey && journey.title != newJourney.title) { + if ( + journey?.title != newJourney.title || + journey?.projectId != newJourney.projectId + ) { saveOk = await updateJourney(); noChangesToSave = false; } @@ -415,8 +400,8 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { newJourney.steps.some((step: Step) => { if ( - step.mode.id === -1 || - step.responsible.code === '' || + step.mode.id === -1 ?? + step.responsible.code === '' ?? step.title === '' ) { errorMessage += 'Some step information is missing.'; @@ -445,7 +430,7 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { }; const confirmDiscardingChangesIfExist = (): boolean => { - return !isDirty || confirm(unsavedChangesConfirmationMessage); + return !isDirty ?? confirm(unsavedChangesConfirmationMessage); }; const cancel = (): void => { @@ -564,6 +549,11 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { setNewJourney(cloneJourney(newJourney)); }; + const setProjectIdValue = (value: number): void => { + newJourney.projectId = value; + setNewJourney(cloneJourney(newJourney)); + }; + const setResponsibleValue = ( event: React.MouseEvent, stepIndex: number, @@ -757,7 +747,7 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { /** Update canSave and isDirty when newJourney or journey changes */ useEffect(() => { - if (journey == null || !isDirty) { + if (journey == null ?? !isDirty) { setCanSave(false); unsetDirtyStateFor(moduleName); return; @@ -770,7 +760,7 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { } let breakFunction = false; newJourney.steps.forEach((step, i) => { - if (!step.title || step.mode.id == -1 || !step.responsible.code) { + if (!step.title ?? step.mode.id == -1 ?? !step.responsible.code) { setCanSave(false); breakFunction = true; return; @@ -886,7 +876,7 @@ const PreservationJourney = (props: PreservationJourneyProps): JSX.Element => { } - {(step.id == -1 || + {(step.id == -1 ?? (step.isVoided && !step.isInUse)) && ( } - {(step.id == -1 ?? + {(step.id == -1 || (step.isVoided && !step.isInUse)) && (