Move enable / disable to header (#3397)

This commit is contained in:
Erik Jan de Wit 2022-09-29 13:07:46 +02:00 committed by GitHub
parent 283390dee9
commit 34ffd01da8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 49 deletions

View file

@ -10,8 +10,6 @@ export default class UserDetailsPage extends PageObject {
firstNameValue: string;
lastNameInput: string;
lastNameValue: string;
enabledSwitch: string;
enabledValue: boolean;
requiredUserActions: RequiredActionAlias[];
identityProviderLinksTab: string;
@ -29,8 +27,6 @@ export default class UserDetailsPage extends PageObject {
this.firstNameValue = "firstname";
this.lastNameInput = "lastName-input";
this.lastNameValue = "lastname";
this.enabledSwitch = "user-enabled-switch";
this.enabledValue = true;
this.requiredUserActions = [RequiredActionAlias.UPDATE_PASSWORD];
this.identityProviderLinksTab = "identity-provider-links-tab";
}
@ -47,7 +43,6 @@ export default class UserDetailsPage extends PageObject {
cy.findByTestId(this.emailInput).type(this.emailValue());
cy.findByTestId(this.firstNameInput).type(this.firstNameValue);
cy.findByTestId(this.lastNameInput).type(this.lastNameValue);
cy.findByTestId(this.enabledSwitch).check({ force: true });
return this;
}

View file

@ -313,30 +313,6 @@ export const UserForm = ({
/>
</FormGroup>
)}
<FormGroup
label={t("common:enabled")}
fieldId="kc-enabled"
labelIcon={
<HelpItem helpText="users-help:disabled" fieldLabelId="enabled" />
}
>
<Controller
name="enabled"
defaultValue={true}
control={control}
render={({ onChange, value }) => (
<Switch
data-testid="user-enabled-switch"
id={"kc-user-enabled"}
onChange={(value) => onChange(value)}
isChecked={value}
label={t("common:on")}
labelOff={t("common:off")}
aria-label={t("common:enabled")}
/>
)}
/>
</FormGroup>
<FormGroup
label={t("requiredUserActions")}
fieldId="kc-required-user-actions"

View file

@ -8,7 +8,7 @@ import {
TabTitleText,
} from "@patternfly/react-core";
import { useTranslation } from "react-i18next";
import { FormProvider, useForm } from "react-hook-form";
import { Controller, FormProvider, useForm } from "react-hook-form";
import type UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation";
@ -150,25 +150,37 @@ const UsersTabs = () => {
<>
<ImpersonateConfirm />
<DeleteConfirm />
<ViewHeader
titleKey={user?.id ? user.username! : t("createUser")}
divider={!id}
dropdownItems={[
<DropdownItem
key="impersonate"
isDisabled={!user?.access?.impersonate}
onClick={() => toggleImpersonateDialog()}
>
{t("impersonate")}
</DropdownItem>,
<DropdownItem
key="delete"
isDisabled={!user?.access?.manage}
onClick={() => toggleDeleteDialog()}
>
{t("common:delete")}
</DropdownItem>,
]}
<Controller
name="enabled"
control={userForm.control}
defaultValue={true}
render={({ onChange, value }) => (
<ViewHeader
titleKey={user?.id ? user.username! : t("createUser")}
divider={!id}
dropdownItems={[
<DropdownItem
key="impersonate"
isDisabled={!user?.access?.impersonate}
onClick={() => toggleImpersonateDialog()}
>
{t("impersonate")}
</DropdownItem>,
<DropdownItem
key="delete"
isDisabled={!user?.access?.manage}
onClick={() => toggleDeleteDialog()}
>
{t("common:delete")}
</DropdownItem>,
]}
isEnabled={value}
onToggle={(value) => {
onChange(value);
save(userForm.getValues());
}}
/>
)}
/>
<PageSection variant="light" className="pf-u-p-0">
<FormProvider {...userForm}>