8000 WizardModal: use current pf wizard by himdel · Pull Request #4947 · ansible/ansible-hub-ui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

WizardModal: use current pf wizard #4947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 13 additions & 27 deletions src/components/access-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ export class AccessTab extends Component<IProps> {
{
id: 0,
name: t`Select a user`,
component: (
children: (
<SelectUser
assignedUsers={users}
selectedUser={user}
Expand All @@ -552,13 +552,11 @@ export class AccessTab extends Component<IProps> {
}
/>
),
backButtonText: t`Cancel`,
enableNext: hasUser,
},
{
id: 1,
name: t`Select role(s)`,
component: (
children: (
<SelectRoles
assignedRoles={assignedRoles}
selectedRoles={roles}
Expand All @@ -571,16 +569,13 @@ export class AccessTab extends Component<IProps> {
pulpObjectType={pulpObjectType}
/>
),
canJumpTo: hasUser,
enableNext: hasUser && hasRoles,
isDisabled: !hasUser,
},
{
id: 2,
name: t`Preview`,
component: <PreviewRoles user={user} selectedRoles={roles} />,
nextButtonText: t`Add`,
canJumpTo: hasUser && hasRoles,
isFinished: true,
children: <PreviewRoles user={user} selectedRoles={roles} />,
isDisabled: !(hasUser && hasRoles),
},
];

Expand Down Expand Up @@ -617,7 +612,7 @@ export class AccessTab extends Component<IProps> {
{
id: 0,
name: t`Select a group`,
component: (
children: (
<SelectGroup
assignedGroups={groups}
selectedGroup={group}
Expand All @@ -628,13 +623,11 @@ export class AccessTab extends Component<IProps> {
}
/>
),
backButtonText: t`Cancel`,
enableNext: hasGroup,
},
{
id: 1,
name: t`Select role(s)`,
component: (
children: (
<SelectRoles
assignedRoles={assignedRoles}
selectedRoles={roles}
Expand All @@ -647,16 +640,13 @@ export class AccessTab extends Component<IProps> {
pulpObjectType={pulpObjectType}
/>
),
canJumpTo: hasGroup,
enableNext: hasGroup && hasRoles,
isDisabled: !hasGroup,
},
{
id: 2,
name: t`Preview`,
component: <PreviewRoles group={group} selectedRoles={roles} />,
nextButtonText: t`Add`,
canJumpTo: hasGroup && hasRoles,
isFinished: true,
children: <PreviewRoles group={group} selectedRoles={roles} />,
isDisabled: !(hasGroup && hasRoles),
},
];

Expand Down Expand Up @@ -692,7 +682,7 @@ export class AccessTab extends Component<IProps> {
{
id: 0,
name: t`Select role(s)`,
component: (
children: (
<SelectRoles
assignedRoles={assignedRoles}
selectedRoles={roles}
Expand All @@ -702,18 +692,14 @@ export class AccessTab extends Component<IProps> {
pulpObjectType={pulpObjectType}
/>
),
backButtonText: t`Cancel`,
enableNext: hasRoles,
},
{
id: 1,
name: t`Preview`,
component: (
children: (
<PreviewRoles user={user} group={group} selectedRoles={roles} />
),
nextButtonText: t`Add`,
canJumpTo: hasRoles,
isFinished: true,
isDisabled: !hasRoles,
},
];

Expand Down
100 changes: 61 additions & 39 deletions src/components/wizard-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,69 @@
import { t } from '@lingui/macro';
import { Modal, ModalVariant } from '@patternfly/react-core';
import {
Wizard as PFWizard,
type WizardStep,
} from '@patternfly/react-core/deprecated';
import React from 'react';
Modal,
ModalVariant,
Wizard,
WizardHeader,
WizardStep,
} from '@patternfly/react-core';
import React, { type ReactNode } from 'react';

interface Props {
steps: WizardStep[];
title: string;
variant?: ModalVariant;
onClose: () => void;
onSave: () => void;
steps: {
children: ReactNode;
id: string | number;
isDisabled?: boolean;
name: string;
}[];
title: string;
}

export const WizardModal = ({
steps,
title,
onClose,
onSave,
variant,
}: Props) => (
<Modal
isOpen
variant={variant ?? ModalVariant.large}
showClose={false}
aria-label={title}
hasNoBodyWrapper
>
<PFWizard
hasNoBodyPadding
navAriaLabel={t`${title} steps`}
mainAriaLabel={t`${title} content`}
backButtonText={t`Back`}
cancelButtonText={t`Cancel`}
closeButtonAriaLabel={t`Close`}
nextButtonText={t`Next`}
titleId='wizard-modal-title'
descriptionId='wizard-modal-description'
title={title}
steps={steps}
>
>
/>
</Modal>
);
export const WizardModal = ({ onClose, onSave, steps, title }: Props) => {
const footer = {
backButtonText: t`Back`,
cancelButtonText: t`Cancel`,
nextButtonText: t`Next`,
};

return (
<Modal
aria-label={title}
hasNoBodyWrapper
isOpen
>
showClose={false}
variant={ModalVariant.large}
>
<Wizard
header={
<WizardHeader
closeButtonAriaLabel={t`Close`}
>
title={title}
/>
}
navAriaLabel={t`${title} steps`}
>
>
>
{steps.map((step, i, { [i + 1]: next, length }) =>
i === length - 1 ? (
<WizardStep
key={step.id}
{...step}
footer={{ ...footer, nextButtonText: t`Add` }}
/>
) : (
<WizardStep
key={step.id}
{...step}
footer={{ ...footer, isNextDisabled: next.isDisabled }}
/>
),
)}
</Wizard>
</Modal>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@
}

.hub-custom-wizard-layout {
padding: 1rem 1.5rem 0;

.hub-select-roles-content {
overflow: auto;
}

.pf-v5-c-pagination.pf-m-bottom {
padding-top: 0;
}

.hub-permission {
margin: 3px;
}
Expand All @@ -41,15 +35,15 @@
justify-content: center;
height: 400px;
}
}

.hub-loading-wizard {
display: flex;
align-items: center;
}
&.hub-no-data {
display: flex;
justify-content: center;
min-height: 590px;
}

.hub-no-data {
display: flex;
justify-content: center;
min-height: 590px;
&.hub-loading-wizard {
display: flex;
align-items: center;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,19 @@ const GroupDetailRoleManagement: FunctionComponent<Props> = ({
{
id: 0,
name: t`Select role(s)`,
component: (
children: (
<SelectRoles
assignedRoles={roles}
selectedRoles={selectedRoles}
=> setSelectedRoles(roles)}
/>
),
backButtonText: t`Cancel`,
enableNext: isPreviewEnabled,
},
{
id: 1,
name: t`Preview`,
component: <PreviewRoles group={group} selectedRoles={selectedRoles} />,
nextButtonText: t`Add`,
canJumpTo: isPreviewEnabled,
isFinished: true,
children: <PreviewRoles group={group} selectedRoles={selectedRoles} />,
isDisabled: !isPreviewEnabled,
},
];

Expand Down
2 changes: 1 addition & 1 deletion test/cypress/e2e/groups_and_users/group_roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('Group Roles Tests', () => {
.should('not.be.disabled')
.click();

cy.get('[aria-label="Add roles content"]').contains('Selected roles');
cy.get('.pf-v5-c-wizard').contains('Selected roles');
cy.get(`[data-cy="HubPermission-${testContainerRole.name}"]`);

cy.contains('Next').click();
Expand Down
1 change: 1 addition & 0 deletions test/cypress/e2e/misc/rbac.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ describe('RBAC test for user with permissions', () => {
cy.galaxykit('task wait all');

cy.visit(`${uiPrefix}repo/published/testspace2/testcollection2`);
cy.contains('Go to documentation');

// can Delete collection
cy.openHeaderKebab();
Expand Down
0