Skip to content

Commit

Permalink
feat(pci-object-storage): add container step 1 & 2
Browse files Browse the repository at this point in the history
ref: DTCORE-2884
Signed-off-by: Florian Renaut <[email protected]>
  • Loading branch information
frenautvh committed Dec 4, 2024
1 parent bfc3601 commit 9929887
Show file tree
Hide file tree
Showing 17 changed files with 960 additions and 19 deletions.
139 changes: 139 additions & 0 deletions packages/manager/apps/pci-object-storage/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
export const TRACKING_PREFIX =
'PublicCloud::pci::projects::project::storages::objects::';

export const MEGA_BYTES = 1024;

export const OBJECT_CONTAINER_MODE_MULTI_ZONES = 'region-3-az';
export const OBJECT_CONTAINER_MODE_MONO_ZONE = 'region';
export const OBJECT_CONTAINER_MODE_LOCAL_ZONE = 'localzone';

export const OBJECT_CONTAINER_DEPLOYMENT_MODES = [
OBJECT_CONTAINER_MODE_MULTI_ZONES,
OBJECT_CONTAINER_MODE_MONO_ZONE,
OBJECT_CONTAINER_MODE_LOCAL_ZONE,
];

export const OBJECT_CONTAINER_DEPLOYMENT_MODES_LABELS = {
[OBJECT_CONTAINER_MODE_MULTI_ZONES]: {
beta: false,
new: false,
isMultiZone: true,
isMonoZone: false,
isLocalZone: false,
price: null,
},
[OBJECT_CONTAINER_MODE_MONO_ZONE]: {
beta: false,
new: false,
isMultiZone: false,
isMonoZone: true,
isLocalZone: false,
price: null,
},
[OBJECT_CONTAINER_MODE_LOCAL_ZONE]: {
beta: false,
new: false,
isMultiZone: false,
isMonoZone: false,
isLocalZone: true,
price: null,
},
};

export const AVAILABILITY = {
LOCALZONE: 'public-cloud:object-storage:localzone',
'3AZ': 'public-cloud:object-storage:3az',
Expand Down Expand Up @@ -72,6 +107,7 @@ export const STANDARD_S3 = [
},
},
];

export const DOWNLOAD_FILENAME = 'import.json';
export const DOWNLOAD_TYPE = 'application/json"';

Expand All @@ -80,4 +116,107 @@ export const OBJECT_STORAGE_USER_ROLE = 'objectstore_operator';
export const TRACKING_S3_POLICY_ADD = 's3-policies-users::add';
export const OPENIO_DEFAULT_REGION = 'SBG';

export const STORAGE_PRICES_LINK = {
DEFAULT: 'https://www.ovhcloud.com/en/public-cloud/prices/#439',
ASIA: 'https://www.ovhcloud.com/asia/public-cloud/prices/#439',
AU: 'https://www.ovhcloud.com/en-au/public-cloud/prices/#439',
CA: 'https://www.ovhcloud.com/en-ca/public-cloud/prices/#439',
DE: 'https://www.ovhcloud.com/de/public-cloud/prices/#439',
ES: 'https://www.ovhcloud.com/es-es/public-cloud/prices/#439',
EU: 'https://www.ovhcloud.com/en-ie/public-cloud/prices/#439',
FR: 'https://www.ovhcloud.com/fr/public-cloud/prices/#439',
GB: 'https://www.ovhcloud.com/en-gb/public-cloud/prices/#439',
IE: 'https://www.ovhcloud.com/en-ie/public-cloud/prices/#439',
IN: 'https://www.ovhcloud.com/en-in/public-cloud/prices/#439',
IT: 'https://www.ovhcloud.com/it/public-cloud/prices/#439',
MA: 'https://www.ovhcloud.com/fr/public-cloud/prices/#439',
NL: 'https://www.ovhcloud.com/nl/public-cloud/prices/#439',
PL: 'https://www.ovhcloud.com/pl/public-cloud/prices/#439',
PT: 'https://www.ovhcloud.com/pt/public-cloud/prices/#439',
QC: 'https://www.ovhcloud.com/fr-ca/public-cloud/prices/#439',
SG: 'https://www.ovhcloud.com/en-sg/public-cloud/prices/#439',
SN: 'https://www.ovhcloud.com/fr/public-cloud/prices/#439',
TN: 'https://www.ovhcloud.com/fr/public-cloud/prices/#439',
US: 'https://us.ovhcloud.com/public-cloud/prices/#439',
WE: 'https://www.ovhcloud.com/en/public-cloud/prices/#439',
WS: 'https://www.ovhcloud.com/es/public-cloud/prices/#439',
};

export const DEPLOYMENT_MODE_LINK = {
DEFAULT:
'https://help.ovhcloud.com/csm/en-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065336',
ASIA:
'https://help.ovhcloud.com/csm/asia-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065346',
AU:
'https://help.ovhcloud.com/csm/en-au-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065339',
CA:
'https://help.ovhcloud.com/csm/en-ca-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065340',
DE:
'https://help.ovhcloud.com/csm/de-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065337',
ES:
'https://help.ovhcloud.com/csm/es-es-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065348',
EU:
'https://help.ovhcloud.com/csm/en-ie-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065349',
FR:
'https://help.ovhcloud.com/csm/fr-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065345',
GB:
'https://help.ovhcloud.com/csm/en-gb-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065338',
IE:
'https://help.ovhcloud.com/csm/en-ie-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065349',
IN:
'https://help.ovhcloud.com/csm/asia-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065346',
IT:
'https://help.ovhcloud.com/csm/it-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065347',
MA:
'https://help.ovhcloud.com/csm/fr-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065345',
NL:
'https://help.ovhcloud.com/csm/en-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065336',
PL:
'https://help.ovhcloud.com/csm/pl-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065335',
PT:
'https://help.ovhcloud.com/csm/pt-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065342',
QC:
'https://help.ovhcloud.com/csm/fr-ca-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065344',
SG:
'https://help.ovhcloud.com/csm/en-sg-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065343',
SN:
'https://help.ovhcloud.com/csm/fr-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065345',
TN:
'https://help.ovhcloud.com/csm/fr-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065345',
US:
'https://help.ovhcloud.com/csm/en-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065336',
WE:
'https://help.ovhcloud.com/csm/en-ie-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065349',
WS:
'https://help.ovhcloud.com/csm/es-public-cloud-storage-s3-deployments-modes?id=kb_article_view&sysparm_article=KB0065341',
};

export const OBJECT_CONTAINER_OFFER_STORAGE_STANDARD = 'storage-s3-standard';
export const OBJECT_CONTAINER_OFFER_SWIFT = 'storage';

export const PLAN_CODES = {
[OBJECT_CONTAINER_OFFER_STORAGE_STANDARD]: 'storage-standard.consumption',
[OBJECT_CONTAINER_OFFER_SWIFT]: 'storage.consumption',
};

export const STORAGE_STANDARD_PLANCODE = 'storage-standard.consumption';

export const OBJECT_CONTAINER_OFFERS = [
OBJECT_CONTAINER_OFFER_STORAGE_STANDARD,
OBJECT_CONTAINER_OFFER_SWIFT,
];

export const OBJECT_CONTAINER_OFFERS_LABELS = {
[OBJECT_CONTAINER_OFFER_SWIFT]: {
beta: false,
new: false,
recommanded: false,
price: null,
},
[OBJECT_CONTAINER_OFFER_STORAGE_STANDARD]: {
beta: false,
new: false,
recommanded: true,
price: null,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useMemo } from 'react';
import { useWindowSize } from 'react-use';

export const useColumnsCount = (): 1 | 2 | 3 => {
const { width: windowWidth } = useWindowSize();
return useMemo(() => {
if (windowWidth >= 1200) return 3;
if (windowWidth >= 768) return 2;

return 1;
}, [windowWidth]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { useProject } from '@ovh-ux/manager-pci-common';
import { Headers, useProjectUrl } from '@ovh-ux/manager-react-components';
import {
ODS_ICON_NAME,
ODS_ICON_SIZE,
ODS_TEXT_LEVEL,
ODS_TEXT_SIZE,
} from '@ovhcloud/ods-components';
import { OdsHTMLAnchorElementTarget } from '@ovhcloud/ods-common-core';
import {
OsdsBreadcrumb,
OsdsIcon,
OsdsLink,
OsdsText,
} from '@ovhcloud/ods-components/react';
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming';
import { useTranslation } from 'react-i18next';
import { useContext } from 'react';
import { ShellContext } from '@ovh-ux/manager-react-shell-client';
import {
OBJECT_CONTAINER_OFFER_STORAGE_STANDARD,
STORAGE_PRICES_LINK,
} from '@/constants';
import { SolutionStepComponent } from './step/SolutionStep.component';
import { DeploymentModeStep } from './step/DeploymentModeStep.component';
import { useContainerCreationStore } from './useContainerCreationStore';

export default function ContainerNewPage() {
const { t } = useTranslation('containers/add');
const projectHref = useProjectUrl('public-cloud');
const { data: project } = useProject();
const context = useContext(ShellContext);
const { ovhSubsidiary } = context.environment.getUser();
const pricesLink =
STORAGE_PRICES_LINK[ovhSubsidiary] || STORAGE_PRICES_LINK.DEFAULT;
const { form } = useContainerCreationStore();
return (
<>
<OsdsBreadcrumb
items={[
{
href: projectHref,
label: project?.description,
},
{
label: t('pci_projects_project_storages_containers_add_title'),
},
]}
/>

<div className="header mt-8">
<Headers
title={t('pci_projects_project_storages_containers_add_title')}
/>
</div>

<OsdsText
size={ODS_TEXT_SIZE._400}
level={ODS_TEXT_LEVEL.body}
color={ODS_THEME_COLOR_INTENT.text}
>
{t('pci_projects_project_storages_containers_add_description')}
</OsdsText>
<br />
<OsdsLink
className="mt-4"
color={ODS_THEME_COLOR_INTENT.primary}
href={pricesLink}
target={OdsHTMLAnchorElementTarget._blank}
>
{t('pci_projects_project_storages_containers_add_description_link')}
<span slot="end">
<OsdsIcon
aria-hidden="true"
className="ml-4"
name={ODS_ICON_NAME.EXTERNAL_LINK}
hoverable
size={ODS_ICON_SIZE.xxs}
color={ODS_THEME_COLOR_INTENT.primary}
/>
</span>
</OsdsLink>
{
// @TODO remove debugging data
<pre>FORM DATA: {JSON.stringify(form)}</pre>
}
<div className="mt-6">
<SolutionStepComponent />
{form.offer === OBJECT_CONTAINER_OFFER_STORAGE_STANDARD && (
<DeploymentModeStep />
)}
</div>
</>
);
}
Loading

0 comments on commit 9929887

Please sign in to comment.