update the admin client to the latest version (#1522)
* update admin client to latetst * removed type workarounds
This commit is contained in:
parent
4e05f0c57e
commit
c09f57d7b0
4 changed files with 26 additions and 31 deletions
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -7,7 +7,7 @@
|
|||
"name": "keycloak-admin-ui",
|
||||
"license": "Apache",
|
||||
"dependencies": {
|
||||
"@keycloak/keycloak-admin-client": "^16.0.0-dev.41",
|
||||
"@keycloak/keycloak-admin-client": "^16.0.0-dev.46",
|
||||
"@patternfly/patternfly": "^4.151.4",
|
||||
"@patternfly/react-code-editor": "^4.9.8",
|
||||
"@patternfly/react-core": "^4.168.8",
|
||||
|
@ -3403,9 +3403,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@keycloak/keycloak-admin-client": {
|
||||
"version": "16.0.0-dev.41",
|
||||
"resolved": "https://registry.npmjs.org/@keycloak/keycloak-admin-client/-/keycloak-admin-client-16.0.0-dev.41.tgz",
|
||||
"integrity": "sha512-idSpN/zweF5Xa3iOfROrQ2bynQ/LceMoUibPxV16jhd/1W0s2adFVzhTrxSaUX2UuWlfgZl4uEs/U9GHI28mGQ==",
|
||||
"version": "16.0.0-dev.46",
|
||||
"resolved": "https://registry.npmjs.org/@keycloak/keycloak-admin-client/-/keycloak-admin-client-16.0.0-dev.46.tgz",
|
||||
"integrity": "sha512-ilYV/6U2oVDvMCXEIwk3/Ay7I1phA17x+kiqFHVqWmMgUHu8jYv+tSyeX7Cq3cJr6NfhIlVGal9ESwLoDaVMbA==",
|
||||
"dependencies": {
|
||||
"axios": "^0.24.0",
|
||||
"camelize-ts": "^1.0.8",
|
||||
|
@ -23734,9 +23734,9 @@
|
|||
}
|
||||
},
|
||||
"@keycloak/keycloak-admin-client": {
|
||||
"version": "16.0.0-dev.41",
|
||||
"resolved": "https://registry.npmjs.org/@keycloak/keycloak-admin-client/-/keycloak-admin-client-16.0.0-dev.41.tgz",
|
||||
"integrity": "sha512-idSpN/zweF5Xa3iOfROrQ2bynQ/LceMoUibPxV16jhd/1W0s2adFVzhTrxSaUX2UuWlfgZl4uEs/U9GHI28mGQ==",
|
||||
"version": "16.0.0-dev.46",
|
||||
"resolved": "https://registry.npmjs.org/@keycloak/keycloak-admin-client/-/keycloak-admin-client-16.0.0-dev.46.tgz",
|
||||
"integrity": "sha512-ilYV/6U2oVDvMCXEIwk3/Ay7I1phA17x+kiqFHVqWmMgUHu8jYv+tSyeX7Cq3cJr6NfhIlVGal9ESwLoDaVMbA==",
|
||||
"requires": {
|
||||
"axios": "^0.24.0",
|
||||
"camelize-ts": "^1.0.8",
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
"prepare": "husky install"
|
||||
},
|
||||
"dependencies": {
|
||||
"@keycloak/keycloak-admin-client": "^16.0.0-dev.41",
|
||||
"@keycloak/keycloak-admin-client": "^16.0.0-dev.46",
|
||||
"@patternfly/patternfly": "^4.151.4",
|
||||
"@patternfly/react-code-editor": "^4.9.8",
|
||||
"@patternfly/react-core": "^4.168.8",
|
||||
|
|
|
@ -5,6 +5,7 @@ import {
|
|||
ButtonVariant,
|
||||
DropdownItem,
|
||||
PageSection,
|
||||
Spinner,
|
||||
Tab,
|
||||
TabTitleText,
|
||||
} from "@patternfly/react-core";
|
||||
|
@ -31,13 +32,6 @@ import { AssociatedRolesTab } from "./AssociatedRolesTab";
|
|||
import { UsersInRoleTab } from "./UsersInRoleTab";
|
||||
import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
|
||||
|
||||
type myRealmRepresentation = RealmRepresentation & {
|
||||
defaultRole?: {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
};
|
||||
|
||||
export default function RealmRoleTabs() {
|
||||
const { t } = useTranslation("roles");
|
||||
const form = useForm<AttributeForm>({
|
||||
|
@ -72,7 +66,7 @@ export default function RealmRoleTabs() {
|
|||
};
|
||||
};
|
||||
|
||||
const [realm, setRealm] = useState<myRealmRepresentation>();
|
||||
const [realm, setRealm] = useState<RealmRepresentation>();
|
||||
|
||||
useFetch(
|
||||
async () => {
|
||||
|
@ -287,17 +281,24 @@ export default function RealmRoleTabs() {
|
|||
refresh();
|
||||
};
|
||||
|
||||
const isDefaultRole = (name: string) =>
|
||||
(realm?.defaultRole! as unknown as RoleRepresentation).name === name;
|
||||
|
||||
if (!realm || !role) {
|
||||
return <Spinner />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<DeleteConfirm />
|
||||
<DeleteAllAssociatedRolesConfirm />
|
||||
{open && <AssociatedRolesModal toggleDialog={toggleModal} />}
|
||||
<ViewHeader
|
||||
titleKey={role?.name || t("createRole")}
|
||||
titleKey={role.name || t("createRole")}
|
||||
badges={[
|
||||
{
|
||||
id: "composite-role-badge",
|
||||
text: role?.composite ? t("composite") : "",
|
||||
text: role.composite ? t("composite") : "",
|
||||
readonly: true,
|
||||
},
|
||||
]}
|
||||
|
@ -320,7 +321,7 @@ export default function RealmRoleTabs() {
|
|||
editMode={true}
|
||||
/>
|
||||
</Tab>
|
||||
{role?.composite && (
|
||||
{role.composite && (
|
||||
<Tab
|
||||
eventKey="AssociatedRoles"
|
||||
title={<TabTitleText>{t("associatedRolesText")}</TabTitleText>}
|
||||
|
@ -328,7 +329,7 @@ export default function RealmRoleTabs() {
|
|||
<AssociatedRolesTab parentRole={role} refresh={refresh} />
|
||||
</Tab>
|
||||
)}
|
||||
{role?.name !== realm?.defaultRole?.name && (
|
||||
{!isDefaultRole(role.name!) && (
|
||||
<Tab
|
||||
eventKey="attributes"
|
||||
className="kc-attributes-tab"
|
||||
|
@ -342,7 +343,7 @@ export default function RealmRoleTabs() {
|
|||
/>
|
||||
</Tab>
|
||||
)}
|
||||
{role?.name !== realm?.defaultRole?.name && (
|
||||
{!isDefaultRole(role.name!) && (
|
||||
<Tab
|
||||
eventKey="users-in-role"
|
||||
title={<TabTitleText>{t("usersInRole")}</TabTitleText>}
|
||||
|
|
|
@ -19,13 +19,6 @@ import { toRealmRole } from "./routes/RealmRole";
|
|||
|
||||
import "./RealmRolesSection.css";
|
||||
|
||||
type myRealmRepresentation = RealmRepresentation & {
|
||||
defaultRole?: {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
};
|
||||
|
||||
type RolesListProps = {
|
||||
paginated?: boolean;
|
||||
parentRoleId?: string;
|
||||
|
@ -67,7 +60,7 @@ export const RolesList = ({
|
|||
const { addAlert, addError } = useAlerts();
|
||||
const { url } = useRouteMatch();
|
||||
const { realm: realmName } = useRealm();
|
||||
const [realm, setRealm] = useState<myRealmRepresentation>();
|
||||
const [realm, setRealm] = useState<RealmRepresentation>();
|
||||
|
||||
const [selectedRole, setSelectedRole] = useState<RoleRepresentation>();
|
||||
|
||||
|
@ -137,9 +130,10 @@ export const RolesList = ({
|
|||
{
|
||||
title: t("common:delete"),
|
||||
onRowClick: (role) => {
|
||||
setSelectedRole(role as RoleRepresentation);
|
||||
setSelectedRole(role);
|
||||
if (
|
||||
(role as RoleRepresentation).name === realm!.defaultRole!.name
|
||||
role.name ===
|
||||
(realm!.defaultRole! as unknown as RoleRepresentation).name
|
||||
) {
|
||||
addAlert(t("defaultRoleDeleteError"), AlertVariant.danger);
|
||||
} else toggleDeleteDialog();
|
||||
|
|
Loading…
Reference in a new issue