Skip to content

Commit

Permalink
Merge pull request #1360 from bipuladh/bug-413
Browse files Browse the repository at this point in the history
Removes namespace bar from Client creation flow
  • Loading branch information
openshift-merge-bot[bot] authored May 13, 2024
2 parents ab61bee + 77527c9 commit 7a08959
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 69 deletions.
2 changes: 1 addition & 1 deletion locales/en/plugin__odf-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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}}",
Expand Down
24 changes: 1 addition & 23 deletions packages/client/src/components/create-client/create-client.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand All @@ -78,7 +70,6 @@ const CreateStorageClient: React.FC = () => {
data: {
metadata: {
name,
namespace,
},
spec: {
storageProviderEndpoint: address,
Expand Down Expand Up @@ -107,19 +98,6 @@ const CreateStorageClient: React.FC = () => {
onChange={(_e, value) => setName(value)}
/>
</FormGroup>
<FormGroup label={t('Namespace')} fieldId="namespace" isRequired>
<ResourceDropdown<K8sResourceKind>
className="pf-v5-u-w-100"
id="namespace"
resource={{
kind: NamespaceModel.kind,
isList: true,
namespaced: false,
}}
resourceModel={NamespaceModel}
onSelect={(ns) => setNamespace(getName(ns))}
/>
</FormGroup>
<FormGroup
label={t('Data Foundation endpoint')}
fieldId="address"
Expand Down
4 changes: 1 addition & 3 deletions packages/ocs/storage-class/sc-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import {
K8sResourceKind,
StorageClassResourceKind,
SecretKind,
StorageSystemKind,
} from '@odf/shared/types';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { isOCSStorageSystem, referenceForModel } from '@odf/shared/utils';
Expand Down Expand Up @@ -99,8 +98,7 @@ const cephBlockPoolResource: WatchK8sResource = {
isList: true,
};

const filterOCSStorageSystems = (resource) =>
isOCSStorageSystem(resource as StorageSystemKind);
const filterOCSStorageSystems = (resource) => isOCSStorageSystem(resource);

const setSessionValueAgain = (systemNamespace: string) => {
// session value will get removed after clicking "Create" (check "mutators.ts"),
Expand Down
39 changes: 22 additions & 17 deletions packages/odf/components/actions/csv-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const createSteps = (
volumeSetName={createLocalVolumeSet.volumeSetName}
nodes={nodes}
systemNamespace={systemNamespace}
deploymentMode={backingStorage.deployment}
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -400,6 +405,7 @@ export const CapacityAndNodes: React.FC<CapacityAndNodesProps> = ({
volumeSetName,
nodes,
systemNamespace,
deploymentMode,
}) => {
const {
capacity,
Expand All @@ -411,6 +417,7 @@ export const CapacityAndNodes: React.FC<CapacityAndNodesProps> = ({
} = state;

const isNoProvisioner = storageClass.provisioner === NO_PROVISIONER;
const isProviderMode = deploymentMode === DeploymentType.PROVIDER_MODE;
const flexibleScaling = isFlexibleScaling(
nodes,
isNoProvisioner,
Expand All @@ -429,7 +436,8 @@ export const CapacityAndNodes: React.FC<CapacityAndNodesProps> = ({
enableArbiter,
isNoProvisioner,
resourceProfile,
osdAmount
osdAmount,
deploymentMode
);
const onProfileChange = React.useCallback(
(profile) => onResourceProfileChange(dispatch)(profile),
Expand Down Expand Up @@ -464,14 +472,16 @@ export const CapacityAndNodes: React.FC<CapacityAndNodesProps> = ({
)}
{(!isNoProvisioner || nodes.length > 0) && (
<>
<ConfigurePerformance
onResourceProfileChange={onProfileChange}
resourceProfile={resourceProfile}
headerText={PerformanceHeaderText}
profileRequirementsText={ProfileRequirementsText}
selectedNodes={nodes}
osdAmount={osdAmount}
/>
{!isProviderMode && (
<ConfigurePerformance
onResourceProfileChange={onProfileChange}
resourceProfile={resourceProfile}
headerText={PerformanceHeaderText}
profileRequirementsText={ProfileRequirementsText}
selectedNodes={nodes}
osdAmount={osdAmount}
/>
)}
<EnableTaintNodes dispatch={dispatch} enableTaint={enableTaint} />
</>
)}
Expand All @@ -496,4 +506,5 @@ type CapacityAndNodesProps = {
volumeSetName: WizardState['createLocalVolumeSet']['volumeSetName'];
dispatch: WizardDispatch;
systemNamespace: WizardState['backingStorage']['systemNamespace'];
deploymentMode: DeploymentType;
};
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,13 @@ export const ReviewAndCreate: React.FC<ReviewAndCreateProps> = ({
memory: humanizeBinaryBytes(totalMemory).string,
})}
</ListItem>
<ListItem>
{t('Performance profile: {{resourceProfile}}', {
resourceProfile: _.capitalize(capacityAndNodes.resourceProfile),
})}
</ListItem>
{!isProviderMode && (
<ListItem>
{t('Performance profile: {{resourceProfile}}', {
resourceProfile: _.capitalize(capacityAndNodes.resourceProfile),
})}
</ListItem>
)}
<ListItem>
{t('Zone: {{zoneCount, number}} zone', {
zoneCount: zones.size,
Expand Down
14 changes: 8 additions & 6 deletions packages/odf/components/create-storage-system/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions packages/odf/components/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
EncryptionType,
ResourceProfile,
NodeData,
DeploymentType,
} from '@odf/core/types';
import {
getNodeCPUCapacity,
Expand Down Expand Up @@ -151,7 +152,8 @@ export const capacityAndNodesValidate = (
enableStretchCluster: boolean,
isNoProvSC: boolean,
resourceProfile: ResourceProfile,
osdAmount: number
osdAmount: number,
deploymentType: DeploymentType
): ValidationType[] => {
const validations = [];

Expand All @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions packages/shared/src/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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,
Expand Down

0 comments on commit 7a08959

Please sign in to comment.