From 34720c799e2f284e2f7079b9a29cd5f09a573029 Mon Sep 17 00:00:00 2001 From: regexowl Date: Wed, 5 Feb 2025 11:59:04 +0100 Subject: [PATCH] src: Remove snapshots fallthrough logic Snapshotting is available in prod-stable now. We can probably remove the fallthrough logic now. --- .../CreateImageWizard/CreateImageWizard.tsx | 38 ++----- .../steps/Review/ReviewStep.tsx | 5 +- .../steps/Review/ReviewStepTextLists.tsx | 105 ++++++++---------- .../CreateImageWizard/steps/Review/index.tsx | 9 +- .../steps/Oscap/Compliance.test.tsx | 1 + src/test/setup.ts | 2 - 6 files changed, 60 insertions(+), 100 deletions(-) diff --git a/src/Components/CreateImageWizard/CreateImageWizard.tsx b/src/Components/CreateImageWizard/CreateImageWizard.tsx index 1930fb43..5373d264 100644 --- a/src/Components/CreateImageWizard/CreateImageWizard.tsx +++ b/src/Components/CreateImageWizard/CreateImageWizard.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Button, @@ -57,7 +57,6 @@ import { } from './validators'; import { RHEL_8, RHEL_10_BETA, AARCH64 } from '../../constants'; -import { useListFeaturesQuery } from '../../store/contentSourcesApi'; import { useAppDispatch, useAppSelector } from '../../store/hooks'; import './CreateImageWizard.scss'; import { @@ -145,6 +144,9 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => { const dispatch = useAppDispatch(); const [searchParams] = useSearchParams(); + // Feature flags + const isFirstBootEnabled = useFlag('image-builder.firstboot.enabled'); + const complianceEnabled = useFlag('image-builder.compliance.enabled'); const isUsersEnabled = useFlag('image-builder.users.enabled'); const isTimezoneEnabled = useFlag('image-builder.timezone.enabled'); const isLocaleEnabled = useFlag('image-builder.locale.enabled'); @@ -153,31 +155,6 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => { const isFirewallEnabled = useFlag('image-builder.firewall.enabled'); const isServicesStepEnabled = useFlag('image-builder.services.enabled'); - // Remove this and all fallthrough logic when snapshotting is enabled in Prod-stable - // =========================TO REMOVE======================= - const { data, isSuccess, isFetching, isError } = - useListFeaturesQuery(undefined); - - const snapshotsFlag = useFlag('image-builder.snapshots.enabled'); - - const snapshottingEnabled = useMemo(() => { - if (!snapshotsFlag) return false; - // The below checks if other environments permit the snapshot step - return !( - !isError && - !isFetching && - isSuccess && - data?.snapshots?.accessible === false && - data?.snapshots?.enabled === false - ); - }, [data, isSuccess, isFetching, isError, snapshotsFlag]); - - // =========================TO REMOVE======================= - - // Feature flags - const isFirstBootEnabled = useFlag('image-builder.firstboot.enabled'); - const complianceEnabled = useFlag('image-builder.compliance.enabled'); - // IMPORTANT: Ensure the wizard starts with a fresh initial state useEffect(() => { dispatch(initializeWizard()); @@ -456,7 +433,9 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => { key="wizard-repository-snapshot" navItem={customStatusNavItem} status={snapshotValidation.disabledNext ? 'error' : 'default'} - isHidden={!snapshottingEnabled || distribution === RHEL_10_BETA} + isHidden={ + distribution === RHEL_10_BETA || !!process.env.IS_ON_PREMISE + } footer={ { id="step-review" footer={} > - {/* Intentional prop drilling for simplicity - To be removed */} - + diff --git a/src/Components/CreateImageWizard/steps/Review/ReviewStep.tsx b/src/Components/CreateImageWizard/steps/Review/ReviewStep.tsx index f21943f8..4354fb5b 100644 --- a/src/Components/CreateImageWizard/steps/Review/ReviewStep.tsx +++ b/src/Components/CreateImageWizard/steps/Review/ReviewStep.tsx @@ -61,7 +61,7 @@ import { } from '../../../../store/wizardSlice'; import { useFlag } from '../../../../Utilities/useGetEnvironment'; -const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => { +const Review = () => { const { goToStepById } = useWizardContext(); const blueprintName = useAppSelector(selectBlueprintName); @@ -349,8 +349,7 @@ const Review = ({ snapshottingEnabled }: { snapshottingEnabled: boolean }) => { isIndented data-testid="content-expandable" > - {/* Intentional prop drilling for simplicity - To be removed */} - + {isUsersEnabled && users.length > 0 && ( { ); }; -export const ContentList = ({ - snapshottingEnabled, -}: { - snapshottingEnabled: boolean; -}) => { +export const ContentList = () => { const customRepositories = useAppSelector(selectCustomRepositories); const packages = useAppSelector(selectPackages); const groups = useAppSelector(selectGroups); @@ -497,61 +493,54 @@ export const ContentList = ({ <> - {snapshottingEnabled ? ( - <> - + + Repository snapshot + + + + } > - Repository snapshot - - - - } + - - {!useLatest && - !isLoading && - isSuccess && - hasSnapshotDateAfter ? ( - - ) : ( - '' - )} - - - ) : ( - '' - )} + {snapshottingText} + + + {!useLatest && !isLoading && isSuccess && hasSnapshotDateAfter ? ( + + ) : ( + '' + )} + + Custom repositories diff --git a/src/Components/CreateImageWizard/steps/Review/index.tsx b/src/Components/CreateImageWizard/steps/Review/index.tsx index 886f3b44..7a61a38c 100644 --- a/src/Components/CreateImageWizard/steps/Review/index.tsx +++ b/src/Components/CreateImageWizard/steps/Review/index.tsx @@ -11,11 +11,7 @@ import { } from '../../../../store/wizardSlice'; import { useGenerateDefaultName } from '../../utilities/useGenerateDefaultName'; -const ReviewStep = ({ - snapshottingEnabled, -}: { - snapshottingEnabled: boolean; -}) => { +const ReviewStep = () => { const blueprintName = useAppSelector(selectBlueprintName); const blueprintDescription = useAppSelector(selectBlueprintDescription); @@ -27,8 +23,7 @@ const ReviewStep = ({ Review {blueprintName} blueprint {blueprintDescription && {blueprintDescription}} - {/* Intentional prop drilling for simplicity - To be removed */} - + ); }; diff --git a/src/test/Components/CreateImageWizard/steps/Oscap/Compliance.test.tsx b/src/test/Components/CreateImageWizard/steps/Oscap/Compliance.test.tsx index c688fab6..632c43e9 100644 --- a/src/test/Components/CreateImageWizard/steps/Oscap/Compliance.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Oscap/Compliance.test.tsx @@ -47,6 +47,7 @@ const goToComplianceStep = async () => { const goToReviewStep = async () => { await clickNext(); // File system configuration + await clickNext(); // Snapshots await clickNext(); // Custom repositories await clickNext(); // Additional packages await clickNext(); // Details diff --git a/src/test/setup.ts b/src/test/setup.ts index a0671bb8..03847929 100644 --- a/src/test/setup.ts +++ b/src/test/setup.ts @@ -59,8 +59,6 @@ vi.mock('@unleash/proxy-client-react', () => ({ return true; case 'image-builder.firstboot.enabled': return true; - case 'image-builder.snapshots.enabled': - return true; case 'image-builder.wsl.enabled': return true; case 'image-builder.pkgrecs.enabled':