Skip to content

Commit

Permalink
Fix creation for BackingStore, BucketClass and NamespaceStore
Browse files Browse the repository at this point in the history
  • Loading branch information
bipuladh committed Sep 23, 2021
1 parent c6923b9 commit 036639c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
Expand Up @@ -27,7 +27,7 @@ import { BucketClassType, NamespacePolicyType } from '../../constants/bucket-cla
import { validateBucketClassName, validateDuration } from '../../utils/bucket-class';
import { NooBaaBucketClassModel } from '../../models';
import { PlacementPolicy } from '../../types';
import { ODF_MODEL_FLAG } from '../../constants';
import { ODF_MODEL_FLAG, CEPH_STORAGE_NAMESPACE } from '../../constants';

enum CreateStepsBC {
GENERAL = 'GENERAL',
Expand All @@ -39,7 +39,7 @@ enum CreateStepsBC {
const CreateBucketClass: React.FC<CreateBCProps> = ({ match }) => {
const { t } = useTranslation();
const [state, dispatch] = React.useReducer(reducer, initialState);
const { ns, appName } = match.params;
const { ns = CEPH_STORAGE_NAMESPACE, appName } = match.params;
const [clusterServiceVersion, setClusterServiceVersion] = React.useState(null);
const isODF = useFlag(ODF_MODEL_FLAG);

Expand Down Expand Up @@ -159,11 +159,15 @@ const CreateBucketClass: React.FC<CreateBCProps> = ({ match }) => {
promiseObj
.then((obj) => {
dispatch({ type: 'setIsLoading', value: false });
history.push(
`/k8s/ns/${ns}/clusterserviceversions/${getName(
clusterServiceVersion,
)}/${referenceForModel(NooBaaBucketClassModel)}/${getName(obj)}`,
);
!isODF
? history.push(
`/k8s/ns/${ns}/clusterserviceversions/${getName(
clusterServiceVersion,
)}/${referenceForModel(NooBaaBucketClassModel)}/${getName(obj)}`,
)
: history.push(
`/odf/resource/${referenceForModel(NooBaaBucketClassModel)}/${getName(obj)}`,
);
})
.catch((err) => {
dispatch({ type: 'setIsLoading', value: false });
Expand Down
Expand Up @@ -10,7 +10,7 @@ import {
} from '@console/internal/components/utils';
import { apiVersionForModel, k8sCreate, referenceForModel } from '@console/internal/module/k8s';
import { ModalComponentProps } from '@console/internal/components/factory';
import { getName } from '@console/shared';
import { getName, useFlag } from '@console/shared';
import { SecretModel } from '@console/internal/models';
import { history } from '@console/internal/components/utils/router';
import { CEPH_STORAGE_NAMESPACE } from '@console/ceph-storage-plugin/src/constants';
Expand All @@ -22,6 +22,7 @@ import {
NOOBAA_TYPE_MAP,
PROVIDERS_NOOBAA_MAP,
BUCKET_LABEL_NOOBAA_MAP,
ODF_MODEL_FLAG,
} from '../../constants';
import { getExternalProviders, getProviders, secretPayloadCreator } from '../../utils/noobaa-utils';
import { Payload } from '../../types';
Expand All @@ -43,6 +44,7 @@ const CreateBackingStoreForm: React.FC<CreateBackingStoreFormProps> = withHandle
providerDataReducer,
initialState,
);
const isODF = useFlag(ODF_MODEL_FLAG);

const handleBsNameTextInputChange = (strVal: string) => {
if (strVal.length <= 43) {
Expand All @@ -59,7 +61,7 @@ const CreateBackingStoreForm: React.FC<CreateBackingStoreFormProps> = withHandle
handlePromise,
isPage,
appName,
namespace,
namespace = CEPH_STORAGE_NAMESPACE,
} = props;

const onSubmit = (event) => {
Expand Down Expand Up @@ -135,11 +137,17 @@ const CreateBackingStoreForm: React.FC<CreateBackingStoreFormProps> = withHandle
return handlePromise(Promise.all(promises), (resource) => {
const lastIndex = resource.length - 1;
if (isPage)
history.push(
`/k8s/ns/${namespace}/clusterserviceversions/${appName}/${referenceForModel(
NooBaaBackingStoreModel,
)}/${getName(resource[lastIndex])}`,
);
!isODF
? history.push(
`/k8s/ns/${namespace}/clusterserviceversions/${appName}/${referenceForModel(
NooBaaBackingStoreModel,
)}/${getName(resource[lastIndex])}`,
)
: history.push(
`/odf/resource/${referenceForModel(NooBaaBackingStoreModel)}/${getName(
resource[lastIndex],
)}`,
);
else close();
});
};
Expand Down
Expand Up @@ -11,11 +11,11 @@ import { useFlag } from '@console/shared/src/hooks/flag';
import NamespaceStoreForm from './namespace-store-form';
import '../noobaa-provider-endpoints/noobaa-provider-endpoints.scss';
import { NooBaaNamespaceStoreModel } from '../../models';
import { ODF_MODEL_FLAG } from '../../constants';
import { ODF_MODEL_FLAG, CEPH_STORAGE_NAMESPACE } from '../../constants';

const CreateNamespaceStore: React.FC<CreateNamespaceStoreProps> = ({ match }) => {
const { t } = useTranslation();
const { ns, appName } = match.params;
const { ns = CEPH_STORAGE_NAMESPACE, appName } = match.params;
const onCancel = () => history.goBack();
const isODF = useFlag(ODF_MODEL_FLAG);

Expand Down Expand Up @@ -48,11 +48,17 @@ const CreateNamespaceStore: React.FC<CreateNamespaceStoreProps> = ({ match }) =>
onCancel={onCancel}
redirectHandler={(resources) => {
const lastIndex = resources.length - 1;
history.push(
`/k8s/ns/${ns}/clusterserviceversions/${appName}/${referenceForModel(
NooBaaNamespaceStoreModel,
)}/${getName(resources[lastIndex])}`,
);
!isODF
? history.push(
`/k8s/ns/${ns}/clusterserviceversions/${appName}/${referenceForModel(
NooBaaNamespaceStoreModel,
)}/${getName(resources[lastIndex])}`,
)
: history.push(
`/odf/resource/${referenceForModel(NooBaaNamespaceStoreModel)}/${getName(
resources[lastIndex],
)}`,
);
}}
namespace={ns}
className="nb-endpoints-page-form__short"
Expand Down

0 comments on commit 036639c

Please sign in to comment.