Skip to content

Commit

Permalink
Wizard: Add Users step to the wizard (HMS-4902)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mgold1234 authored and regexowl committed Nov 7, 2024
1 parent d734d4c commit 176c64d
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Components/CreateImageWizard/CreateImageWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 } =
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
28 changes: 28 additions & 0 deletions src/Components/CreateImageWizard/steps/Users/component/Empty.tsx
Original file line number Diff line number Diff line change
@@ -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;
19 changes: 19 additions & 0 deletions src/Components/CreateImageWizard/steps/Users/index.tsx
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const goToDetailsStep = async () => {
await clickNext();
await clickNext();
await clickNext();
await clickNext();
};

const enterBlueprintDescription = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const goToReviewStep = async () => {
await clickNext();
await clickNext();
await clickNext();
await clickNext();
await enterBlueprintName();
await clickNext();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -64,6 +65,7 @@ const goFromOscapToFirstBoot = async () => {
await clickNext();
await clickNext();
await clickNext();
await clickNext();
};

const openCodeEditor = async (): Promise<void> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const goToPackagesStep = async () => {
};

const goToReviewStep = async () => {
await clickNext(); // Users
await clickNext(); // First Boot
await clickNext(); // Details
await enterBlueprintName();
Expand Down Expand Up @@ -177,6 +178,7 @@ describe('Step Packages', () => {
await renderCreateMode();
await goToPackagesStep();
await clickNext();
await clickNext();
await screen.findByRole('heading', {
name: 'First boot configuration',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const goToReviewStep = async () => {
await clickNext();
await clickNext();
await clickNext();
await clickNext();
await enterBlueprintName();
await clickNext();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const goToReviewStep = async () => {
await clickNext();
await clickNext();
await clickNext();
await clickNext();
};

describe('Step Review', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const goToReviewStep = async () => {
await clickNext(); // Repositories step
await clickNext(); // Additional packages
await clickNext();
await clickNext(); // Users
await enterBlueprintName();
await clickNext();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit 176c64d

Please sign in to comment.