diff --git a/frontend/__tests__/components/cluster-settings.spec.tsx b/frontend/__tests__/components/cluster-settings.spec.tsx index 518b54eebf5..7e2b2d10e8f 100644 --- a/frontend/__tests__/components/cluster-settings.spec.tsx +++ b/frontend/__tests__/components/cluster-settings.spec.tsx @@ -30,7 +30,6 @@ import { } from '../../public/components/cluster-settings/cluster-settings'; import { GlobalConfigPage } from '../../public/components/cluster-settings/global-config'; import { Firehose, HorizontalNav, ResourceLink, Timestamp } from '../../public/components/utils'; -import { AddCircleOIcon } from '@patternfly/react-icons'; jest.mock('react-i18next', () => { const reactI18next = require.requireActual('react-i18next'); @@ -44,6 +43,15 @@ jest.mock('@console/internal/components/utils/k8s-watch-hook', () => ({ useK8sWatchResource: jest.fn(), })); +jest.mock('react-redux', () => { + const ActualReactRedux = require.requireActual('react-redux'); + return { + ...ActualReactRedux, + useSelector: jest.fn(), + useDispatch: jest.fn(), + }; +}); + const i18nNS = 'cluster-settings'; describe('Cluster Settings page', () => { @@ -68,19 +76,13 @@ describe('Cluster Settings page', () => { .find(Firehose) .at(0) .props().resources.length, - ).toBe(2); + ).toBe(1); expect( wrapper .find(Firehose) .at(0) .props().resources[0].kind, ).toBe('config.openshift.io~v1~ClusterVersion'); - expect( - wrapper - .find(Firehose) - .at(0) - .props().resources[1].kind, - ).toBe('autoscaling.openshift.io~v1~ClusterAutoscaler'); expect( wrapper .find(Firehose) @@ -93,12 +95,6 @@ describe('Cluster Settings page', () => { .at(0) .props().resources[0].isList, ).toBe(false); - expect( - wrapper - .find(Firehose) - .at(0) - .props().resources[1].isList, - ).toBe(true); }); it('should render the HorizontalNav Component with the props', () => { expect(wrapper.find(HorizontalNav).exists()).toBe(true); @@ -168,7 +164,6 @@ describe('Cluster Version Details Table page', () => { expect(wrapper.find(UpdatesGraph).exists()).toBe(true); expect(wrapper.find(UpdateInProgress).exists()).toBe(false); expect(wrapper.find(ResourceLink).exists()).toBe(true); - expect(wrapper.find(AddCircleOIcon).exists()).toBe(true); expect(wrapper.find(Timestamp).exists()).toBe(true); }); it('should render correct values of ClusterVersionDetailsTable component', () => { @@ -198,24 +193,6 @@ describe('Cluster Version Details Table page', () => { .at(0) .props().name, ).toEqual('version'); - expect( - wrapper - .find(Link) - .childAt(1) - .text(), - ).toEqual(`${i18nNS}~Create autoscaler`); - expect( - wrapper - .find(ResourceLink) - .at(0) - .props().name, - ).toEqual('version'); - expect( - wrapper - .find(Link) - .childAt(1) - .text(), - ).toEqual(`${i18nNS}~Create autoscaler`); expect( wrapper .find(Timestamp) diff --git a/frontend/__tests__/reducers/features.spec.tsx b/frontend/__tests__/reducers/features.spec.tsx index 3c0f01a618f..bf1e57d31b8 100644 --- a/frontend/__tests__/reducers/features.spec.tsx +++ b/frontend/__tests__/reducers/features.spec.tsx @@ -66,6 +66,7 @@ describe('featureReducer', () => { [FLAGS.CONSOLE_NOTIFICATION]: false, [FLAGS.CONSOLE_EXTERNAL_LOG_LINK]: false, [FLAGS.CONSOLE_YAML_SAMPLE]: false, + [FLAGS.CLUSTER_AUTOSCALER]: false, }), ); }); diff --git a/frontend/packages/console-shared/src/constants/common.ts b/frontend/packages/console-shared/src/constants/common.ts index 6dbe05f29f1..6a499ead87d 100644 --- a/frontend/packages/console-shared/src/constants/common.ts +++ b/frontend/packages/console-shared/src/constants/common.ts @@ -70,6 +70,7 @@ export enum FLAGS { CAN_LIST_PACKAGE_MANIFEST = 'CAN_LIST_PACKAGE_MANIFEST', CAN_CREATE_PROJECT = 'CAN_CREATE_PROJECT', CAN_LIST_VSC = 'CAN_LIST_VSC', + CLUSTER_AUTOSCALER = 'CLUSTER_AUTOSCALER', SHOW_OPENSHIFT_START_GUIDE = 'SHOW_OPENSHIFT_START_GUIDE', SERVICE_CATALOG = 'SERVICE_CATALOG', CLUSTER_API = 'CLUSTER_API', diff --git a/frontend/public/components/cluster-settings/cluster-settings.tsx b/frontend/public/components/cluster-settings/cluster-settings.tsx index 11c6c8557a9..3f6f39e4bd5 100644 --- a/frontend/public/components/cluster-settings/cluster-settings.tsx +++ b/frontend/public/components/cluster-settings/cluster-settings.tsx @@ -70,6 +70,7 @@ import { EmptyBox, ExternalLink, Firehose, + FirehoseResource, HorizontalNav, openshiftHelpBase, ResourceLink, @@ -89,6 +90,8 @@ import { RedExclamationCircleIcon, YellowExclamationTriangleIcon, } from '@console/shared'; +import { useFlag } from '@console/shared/src/hooks/flag'; +import { FLAGS } from '@console/shared/src/constants'; const cancelUpdate = (cv: ClusterVersionKind) => { k8sPatch(ClusterVersionModel, cv, [{ path: '/spec/desiredUpdate', op: 'remove' }]).catch( @@ -875,24 +878,28 @@ export const ClusterVersionDetailsTable: React.FC -
{t('cluster-settings~Cluster autoscaler')}
-
- {_.isEmpty(autoscalers) ? ( - - - {t('cluster-settings~Create autoscaler')} - - ) : ( - autoscalers.map((autoscaler) => ( -
- -
- )) - )} -
+ {autoscalers && ( + <> +
{t('cluster-settings~Cluster autoscaler')}
+
+ {_.isEmpty(autoscalers) ? ( + + + {t('cluster-settings~Create autoscaler')} + + ) : ( + autoscalers.map((autoscaler) => ( +
+ +
+ )) + )} +
+ + )} @@ -960,11 +967,19 @@ export const ClusterOperatorTabPage: React.FC = ({ export const ClusterSettingsPage: React.FC = ({ match }) => { const { t } = useTranslation(); + const hasClusterAutoscaler = useFlag(FLAGS.CLUSTER_AUTOSCALER); const title = t('cluster-settings~Cluster Settings'); - const resources = [ + const resources: FirehoseResource[] = [ { kind: clusterVersionReference, name: 'version', isList: false, prop: 'obj' }, - { kind: clusterAutoscalerReference, isList: true, prop: 'autoscalers', optional: true }, ]; + if (hasClusterAutoscaler) { + resources.push({ + kind: clusterAutoscalerReference, + isList: true, + prop: 'autoscalers', + optional: true, + }); + } const resourceKeys = _.map(resources, 'prop'); const pages = [ { @@ -1098,7 +1113,7 @@ type UpdateInProgressProps = { type ClusterVersionDetailsTableProps = { obj: ClusterVersionKind; - autoscalers: K8sResourceKind[]; + autoscalers?: K8sResourceKind[]; }; type ClusterVersionConditionsLinkProps = { diff --git a/frontend/public/reducers/features.ts b/frontend/public/reducers/features.ts index 98aa7914134..6e4bc4bc6d2 100644 --- a/frontend/public/reducers/features.ts +++ b/frontend/public/reducers/features.ts @@ -10,6 +10,7 @@ import { } from '@console/plugin-sdk/src/api/subscribeToExtensions'; import { ChargebackReportModel, + ClusterAutoscalerModel, ClusterServiceClassModel, ConsoleCLIDownloadModel, ConsoleExternalLogLinkModel, @@ -38,6 +39,7 @@ export const defaults = _.mapValues(FLAGS, (flag) => export const baseCRDs = { [referenceForModel(ChargebackReportModel)]: FLAGS.CHARGEBACK, + [referenceForModel(ClusterAutoscalerModel)]: FLAGS.CLUSTER_AUTOSCALER, [referenceForModel(ClusterServiceClassModel)]: FLAGS.SERVICE_CATALOG, [referenceForModel(ConsoleLinkModel)]: FLAGS.CONSOLE_LINK, [referenceForModel(ConsoleCLIDownloadModel)]: FLAGS.CONSOLE_CLI_DOWNLOAD,