src: Remove snapshots fallthrough logic
Snapshotting is available in prod-stable now. We can probably remove the fallthrough logic now.
This commit is contained in:
parent
87d6c57174
commit
34720c799e
6 changed files with 60 additions and 100 deletions
|
|
@ -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={
|
||||
<CustomWizardFooter
|
||||
disableNext={snapshotValidation.disabledNext}
|
||||
|
|
@ -633,8 +612,7 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
|
|||
id="step-review"
|
||||
footer={<ReviewWizardFooter />}
|
||||
>
|
||||
{/* Intentional prop drilling for simplicity - To be removed */}
|
||||
<ReviewStep snapshottingEnabled={snapshottingEnabled} />
|
||||
<ReviewStep />
|
||||
</WizardStep>
|
||||
</Wizard>
|
||||
</PageSection>
|
||||
|
|
|
|||
|
|
@ -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 */}
|
||||
<ContentList snapshottingEnabled={snapshottingEnabled} />
|
||||
<ContentList />
|
||||
</ExpandableSection>
|
||||
{isUsersEnabled && users.length > 0 && (
|
||||
<ExpandableSection
|
||||
|
|
|
|||
|
|
@ -433,11 +433,7 @@ export const TargetEnvOtherList = () => {
|
|||
);
|
||||
};
|
||||
|
||||
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 = ({
|
|||
<>
|
||||
<TextContent>
|
||||
<TextList component={TextListVariants.dl}>
|
||||
{snapshottingEnabled ? (
|
||||
<>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-v5-u-min-width"
|
||||
<>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dt}
|
||||
className="pf-v5-u-min-width"
|
||||
>
|
||||
Repository snapshot
|
||||
</TextListItem>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dd}
|
||||
data-testid="snapshot-method"
|
||||
>
|
||||
<Popover
|
||||
position="bottom"
|
||||
headerContent={
|
||||
useLatest
|
||||
? 'Repositories as of today'
|
||||
: `Repositories as of ${yyyyMMddFormat(
|
||||
new Date(snapshotDate)
|
||||
)}`
|
||||
}
|
||||
hasAutoWidth
|
||||
minWidth="60rem"
|
||||
bodyContent={
|
||||
<SnapshotTable snapshotForDate={data?.data || []} />
|
||||
}
|
||||
>
|
||||
Repository snapshot
|
||||
</TextListItem>
|
||||
<TextListItem
|
||||
component={TextListItemVariants.dd}
|
||||
data-testid="snapshot-method"
|
||||
>
|
||||
<Popover
|
||||
position="bottom"
|
||||
headerContent={
|
||||
useLatest
|
||||
? 'Repositories as of today'
|
||||
: `Repositories as of ${yyyyMMddFormat(
|
||||
new Date(snapshotDate)
|
||||
)}`
|
||||
}
|
||||
hasAutoWidth
|
||||
minWidth="60rem"
|
||||
bodyContent={
|
||||
<SnapshotTable snapshotForDate={data?.data || []} />
|
||||
}
|
||||
<Button
|
||||
variant="link"
|
||||
aria-label="Snapshot method"
|
||||
className="pf-v5-u-p-0"
|
||||
isDisabled={noRepositoriesSelected || isLoading || isError}
|
||||
isLoading={isLoading}
|
||||
>
|
||||
<Button
|
||||
variant="link"
|
||||
aria-label="Snapshot method"
|
||||
className="pf-v5-u-p-0"
|
||||
isDisabled={noRepositoriesSelected || isLoading || isError}
|
||||
isLoading={isLoading}
|
||||
>
|
||||
{snapshottingText}
|
||||
</Button>
|
||||
</Popover>
|
||||
{!useLatest &&
|
||||
!isLoading &&
|
||||
isSuccess &&
|
||||
hasSnapshotDateAfter ? (
|
||||
<Alert
|
||||
variant="warning"
|
||||
isInline
|
||||
isPlain
|
||||
title="A snapshot for this date is not available for some repositories."
|
||||
/>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</TextListItem>
|
||||
</>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{snapshottingText}
|
||||
</Button>
|
||||
</Popover>
|
||||
{!useLatest && !isLoading && isSuccess && hasSnapshotDateAfter ? (
|
||||
<Alert
|
||||
variant="warning"
|
||||
isInline
|
||||
isPlain
|
||||
title="A snapshot for this date is not available for some repositories."
|
||||
/>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</TextListItem>
|
||||
</>
|
||||
<TextListItem component={TextListItemVariants.dt}>
|
||||
Custom repositories
|
||||
</TextListItem>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
</Title>
|
||||
{blueprintDescription && <Text>{blueprintDescription}</Text>}
|
||||
{/* Intentional prop drilling for simplicity - To be removed */}
|
||||
<Review snapshottingEnabled={snapshottingEnabled} />
|
||||
<Review />
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue