added disable warning (#32414)
fixes: #30267 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
parent
f5ce5e0480
commit
cd206b4dfe
3 changed files with 31 additions and 8 deletions
|
@ -1,11 +1,12 @@
|
||||||
import { v4 as uuid } from "uuid";
|
|
||||||
import UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
|
import UserRepresentation from "@keycloak/keycloak-admin-client/lib/defs/userRepresentation";
|
||||||
|
import { v4 as uuid } from "uuid";
|
||||||
import LoginPage from "../support/pages/LoginPage";
|
import LoginPage from "../support/pages/LoginPage";
|
||||||
import Masthead from "../support/pages/admin-ui/Masthead";
|
import Masthead from "../support/pages/admin-ui/Masthead";
|
||||||
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
|
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
|
||||||
import UsersPage from "../support/pages/admin-ui/manage/users/UsersPage";
|
import UsersPage from "../support/pages/admin-ui/manage/users/UsersPage";
|
||||||
import UserDetailsPage from "../support/pages/admin-ui/manage/users/user_details/UserDetailsPage";
|
import UserDetailsPage from "../support/pages/admin-ui/manage/users/user_details/UserDetailsPage";
|
||||||
import adminClient from "../support/util/AdminClient";
|
import adminClient from "../support/util/AdminClient";
|
||||||
|
import ModalUtils from "../support/util/ModalUtils";
|
||||||
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
||||||
|
|
||||||
const loginPage = new LoginPage();
|
const loginPage = new LoginPage();
|
||||||
|
@ -13,6 +14,7 @@ const sidebarPage = new SidebarPage();
|
||||||
const usersPage = new UsersPage();
|
const usersPage = new UsersPage();
|
||||||
const userDetailsPage = new UserDetailsPage();
|
const userDetailsPage = new UserDetailsPage();
|
||||||
const masthead = new Masthead();
|
const masthead = new Masthead();
|
||||||
|
const modal = new ModalUtils();
|
||||||
|
|
||||||
const createUser = (fields: UserRepresentation) =>
|
const createUser = (fields: UserRepresentation) =>
|
||||||
cy
|
cy
|
||||||
|
@ -35,6 +37,7 @@ describe("User enable/disable", () => {
|
||||||
userDetailsPage.assertEnabled(username!);
|
userDetailsPage.assertEnabled(username!);
|
||||||
|
|
||||||
userDetailsPage.toggleEnabled(username!);
|
userDetailsPage.toggleEnabled(username!);
|
||||||
|
modal.confirmModal();
|
||||||
masthead.checkNotificationMessage("The user has been saved");
|
masthead.checkNotificationMessage("The user has been saved");
|
||||||
cy.wait(1000);
|
cy.wait(1000);
|
||||||
userDetailsPage.assertDisabled(username!);
|
userDetailsPage.assertDisabled(username!);
|
||||||
|
@ -64,6 +67,7 @@ describe("User enable/disable", () => {
|
||||||
userDetailsPage.assertEnabled(username!);
|
userDetailsPage.assertEnabled(username!);
|
||||||
|
|
||||||
userDetailsPage.toggleEnabled(username!);
|
userDetailsPage.toggleEnabled(username!);
|
||||||
|
modal.confirmModal();
|
||||||
masthead.checkNotificationMessage("The user has been saved");
|
masthead.checkNotificationMessage("The user has been saved");
|
||||||
cy.wait(1000);
|
cy.wait(1000);
|
||||||
userDetailsPage.assertDisabled(username!);
|
userDetailsPage.assertDisabled(username!);
|
||||||
|
|
|
@ -3239,4 +3239,6 @@ loggedInAsTempAdminUser=You are logged in as a temporary admin user. To harden s
|
||||||
temporaryAdmin=Temporary admin user account. Ensure it is replaced with a permanent admin user account as soon as possible.
|
temporaryAdmin=Temporary admin user account. Ensure it is replaced with a permanent admin user account as soon as possible.
|
||||||
temporaryService=Temporary admin service account. Ensure it is replaced with a permanent admin service account as soon as possible.
|
temporaryService=Temporary admin service account. Ensure it is replaced with a permanent admin service account as soon as possible.
|
||||||
addOrganizationAttributes.label=Add organization attributes
|
addOrganizationAttributes.label=Add organization attributes
|
||||||
addOrganizationAttributes.help=If enabled, the organization attributes will be available for each organization mapped to the token.
|
addOrganizationAttributes.help=If enabled, the organization attributes will be available for each organization mapped to the token.
|
||||||
|
disableConfirmUserTitle=Disable user?
|
||||||
|
disableConfirmUser=Are you sure you want to disable this user?
|
|
@ -220,6 +220,18 @@ export default function EditUser() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [toggleDisableDialog, DisableConfirm] = useConfirmDialog({
|
||||||
|
titleKey: "disableConfirmUserTitle",
|
||||||
|
messageKey: "disableConfirmUser",
|
||||||
|
continueButtonLabel: "disable",
|
||||||
|
onConfirm: () => {
|
||||||
|
save({
|
||||||
|
...toUserFormFields(user!),
|
||||||
|
enabled: false,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
|
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
|
||||||
titleKey: "deleteConfirm",
|
titleKey: "deleteConfirm",
|
||||||
messageKey: "deleteConfirmCurrentUser",
|
messageKey: "deleteConfirmCurrentUser",
|
||||||
|
@ -269,6 +281,7 @@ export default function EditUser() {
|
||||||
<>
|
<>
|
||||||
<ImpersonateConfirm />
|
<ImpersonateConfirm />
|
||||||
<DeleteConfirm />
|
<DeleteConfirm />
|
||||||
|
<DisableConfirm />
|
||||||
<ViewHeader
|
<ViewHeader
|
||||||
titleKey={user.username!}
|
titleKey={user.username!}
|
||||||
className="kc-username-view-header"
|
className="kc-username-view-header"
|
||||||
|
@ -307,12 +320,16 @@ export default function EditUser() {
|
||||||
{t("delete")}
|
{t("delete")}
|
||||||
</DropdownItem>,
|
</DropdownItem>,
|
||||||
]}
|
]}
|
||||||
onToggle={(value) =>
|
onToggle={(value) => {
|
||||||
save({
|
if (!value) {
|
||||||
...toUserFormFields(user),
|
toggleDisableDialog();
|
||||||
enabled: value,
|
} else {
|
||||||
})
|
save({
|
||||||
}
|
...toUserFormFields(user),
|
||||||
|
enabled: value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
isEnabled={user.enabled}
|
isEnabled={user.enabled}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue