Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1998047: Missing UI flags after install creation #9891

Merged
merged 1 commit into from Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,7 +21,10 @@ export const CreateStorageClass: React.FC<CreateStorageClassProps> = ({
}) => {
const { t } = useTranslation();

const { Component, displayName } = getExternalStorage(externalStorage) || {};
const { Component, displayName } = getExternalStorage(externalStorage) || {
Component: null,
displayName: '',
};

const setForm = React.useCallback(
(field: ExternalStateKeys, value: ExternalStateValues) =>
Expand Down
Expand Up @@ -77,7 +77,7 @@ export const ReviewAndCreate: React.FC<ReviewAndCreateProps> = ({ state }) => {
deployment,
})}
</ListItem>
{type === BackingStorageType.EXTERNAL && (
{!isMCG && type === BackingStorageType.EXTERNAL && (
<ListItem>
{t('ceph-storage-plugin~External storage platform: {{storagePlatform}}', {
storagePlatform,
Expand Down
@@ -1,4 +1,7 @@
import * as React from 'react';
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
import { useDispatch } from 'react-redux';
import { useTranslation } from 'react-i18next';
import { TFunction } from 'i18next';
import {
Expand All @@ -10,6 +13,8 @@ import {
AlertActionCloseButton,
} from '@patternfly/react-core';
import { history } from '@console/internal/components/utils';
import { OCS_ATTACHED_DEVICES_FLAG } from '@console/local-storage-operator-plugin/src/features';
import { setFlag } from '@console/internal/actions/features';
import { WizardCommonProps, WizardState } from './reducer';
import {
createExternalSubSystem,
Expand Down Expand Up @@ -37,6 +42,7 @@ import { MINIMUM_NODES, OCS_EXTERNAL_CR_NAME, OCS_INTERNAL_CR_NAME } from '../..
import { NetworkType, StorageSystemKind } from '../../types';
import { labelOCSNamespace } from '../ocs-install/ocs-request-data';
import { createClusterKmsResources } from '../kms-config/utils';
import { OCS_CONVERGED_FLAG, OCS_INDEPENDENT_FLAG, OCS_FLAG } from '../../features';

const validateBackingStorageStep = (backingStorage, sc) => {
const { type, externalStorage, deployment } = backingStorage;
Expand Down Expand Up @@ -97,14 +103,43 @@ const canJumpToNextStep = (name: string, state: WizardState, t: TFunction) => {
}
};

export const setActionFlags = (
type: WizardState['backingStorage']['type'],
flagDispatcher: any,
isRhcs: boolean,
) => {
switch (type) {
case BackingStorageType.EXISTING:
flagDispatcher(setFlag(OCS_CONVERGED_FLAG, true));
flagDispatcher(setFlag(OCS_INDEPENDENT_FLAG, false));
flagDispatcher(setFlag(OCS_FLAG, true));
break;
case BackingStorageType.EXTERNAL:
flagDispatcher(setFlag(OCS_INDEPENDENT_FLAG, isRhcs));
flagDispatcher(setFlag(OCS_CONVERGED_FLAG, !isRhcs));
flagDispatcher(setFlag(OCS_FLAG, true));
break;
case BackingStorageType.LOCAL_DEVICES:
flagDispatcher(setFlag(OCS_ATTACHED_DEVICES_FLAG, true));
flagDispatcher(setFlag(OCS_CONVERGED_FLAG, true));
flagDispatcher(setFlag(OCS_INDEPENDENT_FLAG, false));
flagDispatcher(setFlag(OCS_FLAG, true));
break;
default:
}
};

const handleBackingStorageNext = async (
backingStorage: WizardState['backingStorage'],
handleError: (err: string) => void,
storageSystems: StorageSystemKind[] = [],
moveToNextStep: () => void,
) => {
const { externalStorage, type, deployment } = backingStorage;
const { model, displayName } = getExternalStorage(externalStorage) || {};
const { model, displayName } = getExternalStorage(externalStorage) || {
model: { kind: '', apiVersion: '', apiGroup: '' },
displayName: '',
};
const isSSPresent = storageSystems.find((ss) => ss.spec.kind === model.kind);
const isRhcs = externalStorage === OCSServiceModel.kind;

Expand Down Expand Up @@ -134,13 +169,16 @@ const handleReviewAndCreateNext = async (
state: WizardState,
hasOCS: boolean,
handleError: (err: string) => void,
flagDispatcher: any,
) => {
const { connectionDetails, createStorageClass, storageClass, nodes } = state;
const { externalStorage, deployment, type } = state.backingStorage;
const { encryption, kms } = state.securityAndNetwork;
const isRhcs: boolean = externalStorage === OCSServiceModel.kind;
const isMCG: boolean = deployment === DeploymentType.MCG;

try {
if (deployment === DeploymentType.MCG) {
if (isMCG) {
await labelOCSNamespace();
if (encryption.advanced) await createNoobaaKmsResources(kms);
await createNoobaaResource(encryption.advanced ? kms : null);
Expand All @@ -153,7 +191,6 @@ const handleReviewAndCreateNext = async (
await createStorageCluster(state);
} else if (type === BackingStorageType.EXTERNAL) {
const { createPayload, model, displayName } = getExternalStorage(externalStorage) || {};
const isRhcs = externalStorage === OCSServiceModel.kind;

const subSystemName = isRhcs ? OCS_EXTERNAL_CR_NAME : getExternalSubSystemName(displayName);
const subSystemState = isRhcs ? connectionDetails : createStorageClass;
Expand All @@ -167,6 +204,8 @@ const handleReviewAndCreateNext = async (
await createExternalSubSystem(subSystemPayloads);
if (!hasOCS) await createStorageCluster(state);
}
// These flags control the enablement of dashboards and other ODF UI components in console
setActionFlags(isMCG ? BackingStorageType.EXISTING : type, flagDispatcher, isRhcs);
history.push('/odf/systems');
} catch (err) {
handleError(err.message);
Expand All @@ -185,6 +224,7 @@ export const CreateStorageSystemFooter: React.FC<CreateStorageSystemFooterProps>
const [requestInProgress, setRequestInProgress] = React.useState(false);
const [requestError, setRequestError] = React.useState('');
const [showErrorAlert, setShowErrorAlert] = React.useState(false);
const flagDispatcher = useDispatch();

const stepId = activeStep.id as number;
const stepName = activeStep.name as string;
Expand Down Expand Up @@ -224,7 +264,7 @@ export const CreateStorageSystemFooter: React.FC<CreateStorageSystemFooterProps>
break;
case StepsName(t)[Steps.ReviewAndCreate]:
setRequestInProgress(true);
await handleReviewAndCreateNext(state, hasOCS, handleError);
await handleReviewAndCreateNext(state, hasOCS, handleError, flagDispatcher);
setRequestInProgress(false);
break;
default:
Expand Down