Skip to content

Commit eae7fcf

Browse files
committed
Block creation of external mode when Provider mode is already present
Reset radio button when Provider mode is selected from dropdown Signed-off-by: Bipul Adhikari <[email protected]>
1 parent db63819 commit eae7fcf

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

packages/odf/components/create-storage-system/create-storage-system-steps/backing-storage-step/backing-storage-step.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
STORAGE_CLUSTER_SYSTEM_KIND,
44
NO_PROVISIONER,
55
} from '@odf/core/constants';
6+
import { PROVIDER_MODE } from '@odf/core/features';
67
import { useSafeK8sGet } from '@odf/core/hooks';
78
import { useODFNamespaceSelector } from '@odf/core/redux';
89
import { scResource } from '@odf/core/resources';
@@ -25,6 +26,7 @@ import {
2526
} from '@odf/shared/types';
2627
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
2728
import { isDefaultClass, getODFCsv, getGVKLabel } from '@odf/shared/utils';
29+
import { useFlag } from '@openshift-console/dynamic-plugin-sdk';
2830
import * as _ from 'lodash-es';
2931
import {
3032
Form,
@@ -213,6 +215,7 @@ export const BackingStorage: React.FC<BackingStorageProps> = ({
213215

214216
const isFullDeployment = deployment === DeploymentType.FULL;
215217
const isProviderMode = deployment === DeploymentType.PROVIDER_MODE;
218+
const isProviderModePresent = useFlag(PROVIDER_MODE) && hasInternal;
216219
const isNonRHCSExternalType =
217220
type === BackingStorageType.EXTERNAL &&
218221
externalStorage !== OCSStorageClusterModel.kind;
@@ -269,7 +272,7 @@ export const BackingStorage: React.FC<BackingStorageProps> = ({
269272
* Allow pre selecting the "external connection" option instead of the "existing" option
270273
* if an OCS Storage System is already created.
271274
*/
272-
if (hasOCS && allowedExternalStorage.length) {
275+
if (hasOCS && allowedExternalStorage.length && !isProviderModePresent) {
273276
dispatch({
274277
type: 'backingStorage/setType',
275278
payload: BackingStorageType.EXTERNAL,
@@ -282,7 +285,7 @@ export const BackingStorage: React.FC<BackingStorageProps> = ({
282285
},
283286
});
284287
}
285-
}, [dispatch, allowedExternalStorage.length, hasOCS]);
288+
}, [dispatch, allowedExternalStorage.length, hasOCS, isProviderModePresent]);
286289

287290
React.useEffect(() => {
288291
/*
@@ -384,7 +387,11 @@ export const BackingStorage: React.FC<BackingStorageProps> = ({
384387
value={BackingStorageType.EXTERNAL}
385388
isChecked={type === BackingStorageType.EXTERNAL}
386389
onChange={(event, _unused) => onRadioSelect(_unused, event)}
387-
isDisabled={allowedExternalStorage.length === 0 || isProviderMode}
390+
isDisabled={
391+
allowedExternalStorage.length === 0 ||
392+
isProviderMode ||
393+
isProviderModePresent
394+
}
388395
body={
389396
showExternalStorageSelection && (
390397
<ExternalSystemSelection

packages/odf/components/create-storage-system/create-storage-system-steps/backing-storage-step/select-deployment.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { FDF_FLAG } from '@odf/core/redux';
3-
import { DeploymentType } from '@odf/core/types';
3+
import { BackingStorageType, DeploymentType } from '@odf/core/types';
44
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
55
import { useFlag } from '@openshift-console/dynamic-plugin-sdk';
66
import {
@@ -49,6 +49,12 @@ export const SelectDeployment: React.FC<SelectDeploymentProps> = ({
4949
// 'value' on SelectProps['onSelect'] is string hence does not match with payload of type "DeploymentType"
5050
payload: value as DeploymentType,
5151
});
52+
if (value === DeploymentType.PROVIDER_MODE) {
53+
dispatch({
54+
type: 'backingStorage/setType',
55+
payload: BackingStorageType.EXISTING,
56+
});
57+
}
5258
setIsSelectOpen(false);
5359
};
5460

0 commit comments

Comments
 (0)