-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sap-features-hub): add pre-installation form step2
ref: MANAGER-15976 Signed-off-by: Paul Dickerson <[email protected]>
- Loading branch information
Paul Dickerson
committed
Jan 10, 2025
1 parent
f9c5f91
commit 52e2140
Showing
13 changed files
with
302 additions
and
38 deletions.
There are no files selected for viewing
11 changes: 9 additions & 2 deletions
11
packages/manager/apps/sap-features-hub/public/translations/installation/Messages_fr_FR.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
{ | ||
"title": "Assistant de pré-installation SAP - Étape 1/8", | ||
"title": "Assistant de pré-installation SAP - Étape {{step}}/8", | ||
"description": "Cet assistant vous guide pour réaliser une pré-installation d'un système SAP.", | ||
"backlink_label": "Retour au SAP Features Hub", | ||
"previous_step_cta": "Précédent", | ||
"select_label": "Sélectionnez", | ||
"service_title": "Sélectionnez votre service VMware on OVHcloud", | ||
"service_subtitle": "Sélectionnez votre service VMware on OVHcloud, votre datacentre et le cluster sur lequel vous souhaitez déployer votre système SAP.", | ||
"service_cta": "Spécifiez l'installation", | ||
"service_input_vmware": "Service VMware on OVHcloud", | ||
"service_input_vdc": "Datacentre", | ||
"service_input_cluster": "Cluster", | ||
"service_input_error_no_cluster_available": "Vous devez sélectionner un datacentre contenant des hôtes pour continuer." | ||
"service_input_error_no_cluster_available": "Vous devez sélectionner un datacentre contenant des hôtes pour continuer.", | ||
"deployment_title": "Spécifiez l'installation souhaitée", | ||
"deployment_subtitle": "Sélectionnez le type d'installation correspondant à vos besoins.", | ||
"deployment_cta": "Précisez vos informations SAP", | ||
"deployment_input_application_version": "Version d'application", | ||
"deployment_input_application_type": "Type d'application", | ||
"deployment_input_deployment_type": "Type de déploiement" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/manager/apps/sap-features-hub/src/data/api/installationDeployment.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ApiResponse, v6 } from '@ovh-ux/manager-core-api'; | ||
|
||
const getApplicationVersionRoute = (serviceName: string) => | ||
`/dedicatedCloud/${serviceName}/sap/capabilities`; | ||
|
||
export const getApplicationVersions = async ( | ||
serviceName: string, | ||
): Promise<ApiResponse<unknown>> => | ||
v6.get(getApplicationVersionRoute(serviceName)); |
44 changes: 44 additions & 0 deletions
44
packages/manager/apps/sap-features-hub/src/hooks/formStep/useFormSteps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useLocation, useNavigate, useParams } from 'react-router-dom'; | ||
import { subRoutes, urls } from '@/routes/routes.constant'; | ||
|
||
const createStepUrl = (stepNumber: number, serviceName: string) => | ||
urls.installationStep | ||
.replace(':stepId', stepNumber.toString()) | ||
.replace(':serviceName', serviceName); | ||
|
||
export const useFormSteps = () => { | ||
const { stepId, serviceName } = useParams(); | ||
const { pathname } = useLocation(); | ||
const navigate = useNavigate(); | ||
const isInitialStep = pathname.includes(subRoutes.initialStep); | ||
|
||
const initializeAndProceed = (selectedServiceName: string) => { | ||
if (isInitialStep && selectedServiceName) | ||
navigate(createStepUrl(2, selectedServiceName)); | ||
}; | ||
|
||
const nextStep = () => { | ||
if (stepId && serviceName) | ||
navigate(createStepUrl(Number(stepId) + 1, serviceName)); | ||
}; | ||
|
||
const previousStep = () => { | ||
if (!stepId || !serviceName || isInitialStep) return; | ||
if (stepId === '2') { | ||
navigate(urls.installationInitialStep); | ||
} else { | ||
navigate(createStepUrl(Number(stepId) - 1, serviceName)); | ||
} | ||
}; | ||
|
||
const getStepLabel = (step: string) => `sap_installation_formStep_${step}`; | ||
|
||
return { | ||
initializeAndProceed, | ||
nextStep, | ||
previousStep, | ||
getStepLabel, | ||
currentStep: isInitialStep ? '1' : stepId, | ||
currentStepLabel: getStepLabel(isInitialStep ? '1' : stepId), | ||
}; | ||
}; |
11 changes: 11 additions & 0 deletions
11
.../manager/apps/sap-features-hub/src/hooks/installationDeployment/useApplicationVersions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { getApplicationVersions } from '@/data/api/installationDeployment'; | ||
|
||
// TODO: implement API calls when developed | ||
export const useApplicationVersions = (serviceName: string) => | ||
useQuery({ | ||
queryKey: ['applicationVersions', serviceName], | ||
queryFn: () => getApplicationVersions(serviceName), | ||
select: (res) => res.data, | ||
enabled: !!serviceName, | ||
}); |
28 changes: 28 additions & 0 deletions
28
packages/manager/apps/sap-features-hub/src/hooks/localStorage/useLocalStorage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export const useLocalStorage = () => { | ||
const setStorageItem = (key: string, value: Record<string, unknown>) => { | ||
try { | ||
localStorage.setItem(key, JSON.stringify(value)); | ||
} catch (err) { | ||
throw new Error('Cannot access localStorage'); | ||
} | ||
}; | ||
|
||
const getStorageItem = (key: string) => { | ||
try { | ||
const item = localStorage.getItem(key); | ||
return item ? JSON.parse(item) : undefined; | ||
} catch (err) { | ||
throw new Error('Cannot access localStorage'); | ||
} | ||
}; | ||
|
||
const removeStorageItem = (key: string) => { | ||
try { | ||
localStorage.removeItem(key); | ||
} catch (err) { | ||
throw new Error('Cannot access localStorage'); | ||
} | ||
}; | ||
|
||
return { setStorageItem, getStorageItem, removeStorageItem }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/manager/apps/sap-features-hub/src/pages/installation/formStep/FormStep.page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React, { ReactNode } from 'react'; | ||
import { useFormSteps } from '@/hooks/formStep/useFormSteps'; | ||
import InstallationInitialStep from '../initialStep/InstallationInitialStep.page'; | ||
import InstallationStepDeployment from '../stepDeployment/InstallationStepDeployment.page'; | ||
|
||
const steps: Record<string, ReactNode> = { | ||
'1': <InstallationInitialStep />, | ||
'2': <InstallationStepDeployment />, | ||
}; | ||
|
||
export default function FormStep() { | ||
const { currentStep } = useFormSteps(); | ||
|
||
return steps[currentStep] || <div>Not developed yet.</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.