Wizard: Add Users step to the wizard (HMS-4902)

This commit adds a new step 'Users' that is enabled only in stage-preview,
and will enable it in stage-stable once IQE tests are ready.
The step is not functional yet, this is just the first step.
This commit is contained in:
Michal Gold 2024-10-29 14:39:36 +02:00 committed by Klara Simickova
parent d734d4ca91
commit 176c64dd47
17 changed files with 79 additions and 1 deletions

View file

@ -27,6 +27,7 @@ import SnapshotStep from './steps/Snapshot';
import Aws from './steps/TargetEnvironment/Aws';
import Azure from './steps/TargetEnvironment/Azure';
import Gcp from './steps/TargetEnvironment/Gcp';
import UsersStep from './steps/Users';
import {
useFilesystemValidation,
useSnapshotValidation,
@ -132,6 +133,8 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
const [searchParams] = useSearchParams();
const { isBeta } = useGetEnvironment();
const isUsersEnabled = useFlag('image-builder.users.enabled');
// Remove this and all fallthrough logic when snapshotting is enabled in Prod-stable
// =========================TO REMOVE=======================
const { data, isSuccess, isFetching, isError } =
@ -211,7 +214,7 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
let startIndex = 1; // default index
if (isEdit) {
startIndex = 15;
startIndex = 16;
}
// Duplicating some of the logic from the Wizard component to allow for custom nav items status
@ -432,6 +435,17 @@ const CreateImageWizard = ({ isEdit }: CreateImageWizardProps) => {
>
<PackagesStep />
</WizardStep>,
<WizardStep
name="Users"
id="wizard-users"
key="wizard-users"
isHidden={!isUsersEnabled}
footer={
<CustomWizardFooter disableNext={false} optional={true} />
}
>
<UsersStep />
</WizardStep>,
<WizardStep
name="First boot script configuration"
id="wizard-first-boot"

View file

@ -0,0 +1,28 @@
import React from 'react';
import {
Button,
EmptyState,
EmptyStateFooter,
EmptyStateHeader,
EmptyStateIcon,
EmptyStateVariant,
} from '@patternfly/react-core';
import UserIcon from '@patternfly/react-icons/dist/esm/icons/user-icon';
const EmptyUserState = () => {
return (
<EmptyState variant={EmptyStateVariant.lg}>
<EmptyStateHeader
icon={<EmptyStateIcon icon={UserIcon} />}
headingLevel="h4"
/>
<EmptyStateFooter>
<Button variant="secondary" onClick={() => {}}>
Add a user
</Button>
</EmptyStateFooter>
</EmptyState>
);
};
export default EmptyUserState;

View file

@ -0,0 +1,19 @@
import React from 'react';
import { Form, Text, Title } from '@patternfly/react-core';
import EmptyUserState from './component/Empty';
const UsersStep = () => {
return (
<Form>
<Title headingLevel="h1" size="xl">
Users
</Title>
<Text>Add a user to your image.</Text>
<EmptyUserState />
</Form>
);
};
export default UsersStep;

View file

@ -25,6 +25,7 @@ const goToDetailsStep = async () => {
await clickNext();
await clickNext();
await clickNext();
await clickNext();
};
const enterBlueprintDescription = async (

View file

@ -113,6 +113,7 @@ const goToReviewStep = async () => {
await clickNext();
await clickNext();
await clickNext();
await clickNext();
await enterBlueprintName();
await clickNext();
};

View file

@ -43,6 +43,7 @@ const goToFirstBootStep = async (): Promise<void> => {
await clickNext(); // File System
await clickNext(); // Custom repositories
await clickNext(); // Additional packages
await clickNext(); // Users
await clickNext(); // Snapshot
await clickNext(); // First Boot
};
@ -64,6 +65,7 @@ const goFromOscapToFirstBoot = async () => {
await clickNext();
await clickNext();
await clickNext();
await clickNext();
};
const openCodeEditor = async (): Promise<void> => {

View file

@ -135,6 +135,7 @@ const goToReviewStep = async () => {
await clickNext(); // Snapshots
await clickNext(); // Custom repositories
await clickNext(); // Additional packages
await clickNext(); // Users
await clickNext(); // First boot
await clickNext(); // Details
await enterBlueprintName();

View file

@ -98,6 +98,7 @@ const goToReviewStep = async () => {
await clickNext(); // Snapshot repositories
await clickNext(); // Custom repositories
await clickNext(); // Additional packages
await clickNext(); // Users
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName('Oscap test');

View file

@ -52,6 +52,7 @@ const goToPackagesStep = async () => {
};
const goToReviewStep = async () => {
await clickNext(); // Users
await clickNext(); // First Boot
await clickNext(); // Details
await enterBlueprintName();
@ -177,6 +178,7 @@ describe('Step Packages', () => {
await renderCreateMode();
await goToPackagesStep();
await clickNext();
await clickNext();
await screen.findByRole('heading', {
name: 'First boot configuration',
});

View file

@ -96,6 +96,7 @@ const goToReviewStep = async () => {
await clickNext();
await clickNext();
await clickNext();
await clickNext();
await enterBlueprintName();
await clickNext();
};

View file

@ -46,6 +46,7 @@ const goToRepositoriesStep = async () => {
const goToReviewStep = async () => {
await clickNext(); // Additional packages
await clickNext();
await clickNext(); // Users
await clickNext(); // First Boot
await enterBlueprintName();
await clickNext(); // Review

View file

@ -56,6 +56,7 @@ const goToReviewStep = async () => {
await clickNext();
await clickNext();
await clickNext();
await clickNext();
};
describe('Step Review', () => {

View file

@ -38,6 +38,7 @@ const goToReviewStep = async () => {
await clickNext(); // Repositories step
await clickNext(); // Additional packages
await clickNext();
await clickNext(); // Users
await enterBlueprintName();
await clickNext();
};

View file

@ -44,6 +44,7 @@ const goToReview = async () => {
await clickNext(); // Snapshot repositories
await clickNext(); // Custom repositories
await clickNext(); // Additional packages
await clickNext(); // Users
await clickNext(); // Details
await clickNext(); // FirstBoot
await enterBlueprintName();

View file

@ -44,6 +44,7 @@ const goToReview = async () => {
await clickNext(); // Snapshot repositories
await clickNext(); // Custom repositories
await clickNext(); // Additional packages
await clickNext(); // Users
await clickNext(); // FirstBoot
await clickNext(); // Details
await enterBlueprintName();

View file

@ -39,6 +39,7 @@ const goToReview = async () => {
await clickNext(); // Snapshot repositories
await clickNext(); // Custom repositories
await clickNext(); // Additional packages
await clickNext(); // Users
await clickNext(); // Details
await clickNext(); // FirstBoot
await enterBlueprintName();

View file

@ -53,6 +53,8 @@ vi.mock('@unleash/proxy-client-react', () => ({
useUnleashContext: () => vi.fn(),
useFlag: vi.fn((flag) => {
switch (flag) {
case 'image-builder.users.enabled':
return true;
case 'image-builder.import.enabled':
return true;
case 'image-builder.firstboot.enabled':