From 77527c96cf6da03048e5014e54c6c7c18273ea70 Mon Sep 17 00:00:00 2001 From: Bipul Adhikari Date: Fri, 3 May 2024 14:22:32 +0545 Subject: [PATCH] Removes namespace bar from Client creation flow Removes Performance configuration from the UI Signed-off-by: Bipul Adhikari --- locales/en/plugin__odf-console.json | 2 +- .../create-client/create-client.tsx | 24 +----------- packages/ocs/storage-class/sc-form.tsx | 4 +- .../odf/components/actions/csv-actions.ts | 39 +++++++++++-------- .../create-storage-system/create-steps.tsx | 1 + .../capacity-and-nodes-step.tsx | 31 ++++++++++----- .../review-and-create-step.tsx | 12 +++--- .../create-storage-system/footer.tsx | 14 ++++--- packages/odf/components/utils/common.ts | 10 ++++- packages/shared/src/utils/storage.ts | 7 +++- 10 files changed, 75 insertions(+), 69 deletions(-) diff --git a/locales/en/plugin__odf-console.json b/locales/en/plugin__odf-console.json index 595197470..e606600b9 100644 --- a/locales/en/plugin__odf-console.json +++ b/locales/en/plugin__odf-console.json @@ -2,7 +2,6 @@ "Create StorageClient": "Create StorageClient", "Create a StorageClient to connect to a Data Foundation system.": "Create a StorageClient to connect to a Data Foundation system.", "Name": "Name", - "Namespace": "Namespace", "Data Foundation endpoint": "Data Foundation endpoint", "Please provide a proper URL with a valid port.": "Please provide a proper URL with a valid port.", "Onboarding token": "Onboarding token", @@ -104,6 +103,7 @@ "Enable disaster recovery protection by selecting the namespaces of your ACM discovered application.": "Enable disaster recovery protection by selecting the namespaces of your ACM discovered application.", "DR cluster": "DR cluster", "Select cluster": "Select cluster", + "Namespace": "Namespace", "Select namespaces that belongs to your ACM discovered applications.": "Select namespaces that belongs to your ACM discovered applications.", "Once you select namespaces, applications regardless of their type, within those namespaces cannot be subsequently enrolled separately under disaster recovery protection.": "Once you select namespaces, applications regardless of their type, within those namespaces cannot be subsequently enrolled separately under disaster recovery protection.", "Replication type: {{type}}, Interval: {{interval}}, Clusters: {{clusters}}": "Replication type: {{type}}, Interval: {{interval}}, Clusters: {{clusters}}", diff --git a/packages/client/src/components/create-client/create-client.tsx b/packages/client/src/components/create-client/create-client.tsx index 522664d98..e37b23f65 100644 --- a/packages/client/src/components/create-client/create-client.tsx +++ b/packages/client/src/components/create-client/create-client.tsx @@ -1,12 +1,5 @@ import * as React from 'react'; -import { - ButtonBar, - K8sResourceKind, - NamespaceModel, - ResourceDropdown, - getName, - useCustomTranslation, -} from '@odf/shared'; +import { ButtonBar, useCustomTranslation } from '@odf/shared'; import { k8sCreate } from '@openshift-console/dynamic-plugin-sdk'; import * as _ from 'lodash-es'; import { useNavigate } from 'react-router-dom-v5-compat'; @@ -62,7 +55,6 @@ const validateURL = (userInput: string): ValidatedOptions => { const CreateStorageClient: React.FC = () => { const [name, setName] = React.useState(''); - const [namespace, setNamespace] = React.useState(''); const [address, setAddress] = React.useState(''); const [ticket, setTicket] = React.useState(''); const [inProgress, setProgress] = React.useState(false); @@ -78,7 +70,6 @@ const CreateStorageClient: React.FC = () => { data: { metadata: { name, - namespace, }, spec: { storageProviderEndpoint: address, @@ -107,19 +98,6 @@ const CreateStorageClient: React.FC = () => { onChange={(_e, value) => setName(value)} /> - - - className="pf-v5-u-w-100" - id="namespace" - resource={{ - kind: NamespaceModel.kind, - isList: true, - namespaced: false, - }} - resourceModel={NamespaceModel} - onSelect={(ns) => setNamespace(getName(ns))} - /> - - isOCSStorageSystem(resource as StorageSystemKind); +const filterOCSStorageSystems = (resource) => isOCSStorageSystem(resource); const setSessionValueAgain = (systemNamespace: string) => { // session value will get removed after clicking "Create" (check "mutators.ts"), diff --git a/packages/odf/components/actions/csv-actions.ts b/packages/odf/components/actions/csv-actions.ts index 16162dfde..d54d4267e 100644 --- a/packages/odf/components/actions/csv-actions.ts +++ b/packages/odf/components/actions/csv-actions.ts @@ -12,10 +12,12 @@ import { import { Action, K8sResourceCommon, + useFlag, useK8sModel, useModal, } from '@openshift-console/dynamic-plugin-sdk'; import { LaunchModal } from '@openshift-console/dynamic-plugin-sdk/lib/app/modal-support/ModalProvider'; +import { PROVIDER_MODE } from '../../features'; export const useCsvActions = ({ resource, @@ -27,25 +29,28 @@ export const useCsvActions = ({ referenceFor(group)(version)(resource.kind) ); const launchModal = useModal(); + const isProviderMode = useFlag(PROVIDER_MODE); - const actions = useMemo( - () => + const actions = useMemo(() => { + const items = []; + if ( referenceForModel(k8sModel) === referenceForModel(ODFStorageSystem) && - isOCSStorageSystem(resource as StorageSystemKind) - ? [ - AddCapacityStorageSystem( - resource as StorageSystemKind, - launchModal - ), - ConfigurePerformanceStorageSystem( - resource as StorageSystemKind, - launchModal - ), - ] - : [], - - [k8sModel, resource, launchModal] - ); + isOCSStorageSystem(resource) + ) { + items.push( + AddCapacityStorageSystem(resource as StorageSystemKind, launchModal) + ); + if (!isProviderMode) { + items.push( + ConfigurePerformanceStorageSystem( + resource as StorageSystemKind, + launchModal + ) + ); + } + } + return items; + }, [k8sModel, resource, launchModal, isProviderMode]); return useMemo(() => [actions, !inFlight, undefined], [actions, inFlight]); }; diff --git a/packages/odf/components/create-storage-system/create-steps.tsx b/packages/odf/components/create-storage-system/create-steps.tsx index a34f51b27..e31c28daa 100644 --- a/packages/odf/components/create-storage-system/create-steps.tsx +++ b/packages/odf/components/create-storage-system/create-steps.tsx @@ -54,6 +54,7 @@ export const createSteps = ( volumeSetName={createLocalVolumeSet.volumeSetName} nodes={nodes} systemNamespace={systemNamespace} + deploymentMode={backingStorage.deployment} /> ), }, diff --git a/packages/odf/components/create-storage-system/create-storage-system-steps/capacity-and-nodes-step/capacity-and-nodes-step.tsx b/packages/odf/components/create-storage-system/create-storage-system-steps/capacity-and-nodes-step/capacity-and-nodes-step.tsx index c11f9ee92..2a2a69785 100644 --- a/packages/odf/components/create-storage-system/create-storage-system-steps/capacity-and-nodes-step/capacity-and-nodes-step.tsx +++ b/packages/odf/components/create-storage-system/create-storage-system-steps/capacity-and-nodes-step/capacity-and-nodes-step.tsx @@ -22,7 +22,12 @@ import { } from '@odf/core/constants'; import { useNodesData } from '@odf/core/hooks'; import { pvResource } from '@odf/core/resources'; -import { NodeData, NodesPerZoneMap, ResourceProfile } from '@odf/core/types'; +import { + DeploymentType, + NodeData, + NodesPerZoneMap, + ResourceProfile, +} from '@odf/core/types'; import { calcPVsCapacity, getSCAvailablePVs, @@ -400,6 +405,7 @@ export const CapacityAndNodes: React.FC = ({ volumeSetName, nodes, systemNamespace, + deploymentMode, }) => { const { capacity, @@ -411,6 +417,7 @@ export const CapacityAndNodes: React.FC = ({ } = state; const isNoProvisioner = storageClass.provisioner === NO_PROVISIONER; + const isProviderMode = deploymentMode === DeploymentType.PROVIDER_MODE; const flexibleScaling = isFlexibleScaling( nodes, isNoProvisioner, @@ -429,7 +436,8 @@ export const CapacityAndNodes: React.FC = ({ enableArbiter, isNoProvisioner, resourceProfile, - osdAmount + osdAmount, + deploymentMode ); const onProfileChange = React.useCallback( (profile) => onResourceProfileChange(dispatch)(profile), @@ -464,14 +472,16 @@ export const CapacityAndNodes: React.FC = ({ )} {(!isNoProvisioner || nodes.length > 0) && ( <> - + {!isProviderMode && ( + + )} )} @@ -496,4 +506,5 @@ type CapacityAndNodesProps = { volumeSetName: WizardState['createLocalVolumeSet']['volumeSetName']; dispatch: WizardDispatch; systemNamespace: WizardState['backingStorage']['systemNamespace']; + deploymentMode: DeploymentType; }; diff --git a/packages/odf/components/create-storage-system/create-storage-system-steps/review-and-create-step/review-and-create-step.tsx b/packages/odf/components/create-storage-system/create-storage-system-steps/review-and-create-step/review-and-create-step.tsx index 216962b11..1578e5f4f 100644 --- a/packages/odf/components/create-storage-system/create-storage-system-steps/review-and-create-step/review-and-create-step.tsx +++ b/packages/odf/components/create-storage-system/create-storage-system-steps/review-and-create-step/review-and-create-step.tsx @@ -168,11 +168,13 @@ export const ReviewAndCreate: React.FC = ({ memory: humanizeBinaryBytes(totalMemory).string, })} - - {t('Performance profile: {{resourceProfile}}', { - resourceProfile: _.capitalize(capacityAndNodes.resourceProfile), - })} - + {!isProviderMode && ( + + {t('Performance profile: {{resourceProfile}}', { + resourceProfile: _.capitalize(capacityAndNodes.resourceProfile), + })} + + )} {t('Zone: {{zoneCount, number}} zone', { zoneCount: zones.size, diff --git a/packages/odf/components/create-storage-system/footer.tsx b/packages/odf/components/create-storage-system/footer.tsx index 5698c3e12..38f9add40 100644 --- a/packages/odf/components/create-storage-system/footer.tsx +++ b/packages/odf/components/create-storage-system/footer.tsx @@ -172,12 +172,14 @@ const canJumpToNextStep = ( return ( nodes.length >= MINIMUM_NODES && capacity && - isResourceProfileAllowed( - capacityAndNodes.resourceProfile, - getTotalCpu(nodes), - getTotalMemoryInGiB(nodes), - osdAmount - ) + (backingStorage.deployment !== DeploymentType.PROVIDER_MODE + ? isResourceProfileAllowed( + capacityAndNodes.resourceProfile, + getTotalCpu(nodes), + getTotalMemoryInGiB(nodes), + osdAmount + ) + : true) ); case StepsName(t)[Steps.SecurityAndNetwork]: if (isExternal && isRHCS) { diff --git a/packages/odf/components/utils/common.ts b/packages/odf/components/utils/common.ts index f827af180..7c47e2734 100644 --- a/packages/odf/components/utils/common.ts +++ b/packages/odf/components/utils/common.ts @@ -4,6 +4,7 @@ import { EncryptionType, ResourceProfile, NodeData, + DeploymentType, } from '@odf/core/types'; import { getNodeCPUCapacity, @@ -151,7 +152,8 @@ export const capacityAndNodesValidate = ( enableStretchCluster: boolean, isNoProvSC: boolean, resourceProfile: ResourceProfile, - osdAmount: number + osdAmount: number, + deploymentType: DeploymentType ): ValidationType[] => { const validations = []; @@ -163,7 +165,11 @@ export const capacityAndNodesValidate = ( } if (!enableStretchCluster && nodes.length && nodes.length < MINIMUM_NODES) { validations.push(ValidationType.MINIMUMNODES); - } else if (nodes.length && nodes.length >= MINIMUM_NODES) { + } else if ( + nodes.length && + nodes.length >= MINIMUM_NODES && + deploymentType !== DeploymentType.PROVIDER_MODE + ) { if ( !isResourceProfileAllowed( resourceProfile, diff --git a/packages/shared/src/utils/storage.ts b/packages/shared/src/utils/storage.ts index ad0f972a0..90918b581 100644 --- a/packages/shared/src/utils/storage.ts +++ b/packages/shared/src/utils/storage.ts @@ -4,6 +4,7 @@ import { ClusterServiceVersionKind, StorageSystemKind, } from '@odf/shared/types'; +import { K8sResourceKind } from '@openshift-console/dynamic-plugin-sdk'; import { ODF_OPERATOR } from '../constants'; import { getGVKLabel } from '../utils/common'; @@ -13,8 +14,10 @@ export const getODFCsv = (csvList: ClusterServiceVersionKind[] = []) => csv?.metadata.name?.substring(0, ODF_OPERATOR.length) === ODF_OPERATOR ); -export const isOCSStorageSystem = (storageSystem: StorageSystemKind) => - storageSystem?.spec?.kind === +export const isOCSStorageSystem = ( + resource: K8sResourceKind +): resource is StorageSystemKind => + resource?.spec?.kind === getGVKLabel({ kind: OCSStorageClusterModel.kind, apiVersion: OCSStorageClusterModel.apiVersion,