Remove ability to delete a realm client from the overview (#1278)
This commit is contained in:
parent
b5dfcda451
commit
e832e2e454
3 changed files with 35 additions and 18 deletions
|
@ -52,8 +52,7 @@ import { toClients } from "./routes/Clients";
|
||||||
import { ClientScopes } from "./scopes/ClientScopes";
|
import { ClientScopes } from "./scopes/ClientScopes";
|
||||||
import { EvaluateScopes } from "./scopes/EvaluateScopes";
|
import { EvaluateScopes } from "./scopes/EvaluateScopes";
|
||||||
import { ServiceAccount } from "./service-account/ServiceAccount";
|
import { ServiceAccount } from "./service-account/ServiceAccount";
|
||||||
|
import { isRealmClient } from "./utils";
|
||||||
const isRealmClient = (client: ClientRepresentation) => !client.protocol;
|
|
||||||
|
|
||||||
type ClientDetailHeaderProps = {
|
type ClientDetailHeaderProps = {
|
||||||
onChange: (value: boolean) => void;
|
onChange: (value: boolean) => void;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
TabTitleText,
|
TabTitleText,
|
||||||
ToolbarItem,
|
ToolbarItem,
|
||||||
} from "@patternfly/react-core";
|
} from "@patternfly/react-core";
|
||||||
import { cellWidth, TableText } from "@patternfly/react-table";
|
import { cellWidth, IRowData, TableText } from "@patternfly/react-table";
|
||||||
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
|
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
@ -17,7 +17,10 @@ import { useAlerts } from "../components/alert/Alerts";
|
||||||
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
||||||
import { formattedLinkTableCell } from "../components/external-link/FormattedLink";
|
import { formattedLinkTableCell } from "../components/external-link/FormattedLink";
|
||||||
import { KeycloakTabs } from "../components/keycloak-tabs/KeycloakTabs";
|
import { KeycloakTabs } from "../components/keycloak-tabs/KeycloakTabs";
|
||||||
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
|
import {
|
||||||
|
Action,
|
||||||
|
KeycloakDataTable,
|
||||||
|
} from "../components/table-toolbar/KeycloakDataTable";
|
||||||
import { ViewHeader } from "../components/view-header/ViewHeader";
|
import { ViewHeader } from "../components/view-header/ViewHeader";
|
||||||
import { useAdminClient } from "../context/auth/AdminClient";
|
import { useAdminClient } from "../context/auth/AdminClient";
|
||||||
import { useRealm } from "../context/realm-context/RealmContext";
|
import { useRealm } from "../context/realm-context/RealmContext";
|
||||||
|
@ -26,6 +29,7 @@ import { InitialAccessTokenList } from "./initial-access/InitialAccessTokenList"
|
||||||
import { toAddClient } from "./routes/AddClient";
|
import { toAddClient } from "./routes/AddClient";
|
||||||
import { toClient } from "./routes/Client";
|
import { toClient } from "./routes/Client";
|
||||||
import { toImportClient } from "./routes/ImportClient";
|
import { toImportClient } from "./routes/ImportClient";
|
||||||
|
import { isRealmClient } from "./utils";
|
||||||
|
|
||||||
export const ClientsSection = () => {
|
export const ClientsSection = () => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
|
@ -130,21 +134,29 @@ export const ClientsSection = () => {
|
||||||
</ToolbarItem>
|
</ToolbarItem>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
actions={[
|
actionResolver={(rowData: IRowData) => {
|
||||||
|
const client: ClientRepresentation = rowData.data;
|
||||||
|
const actions: Action<ClientRepresentation>[] = [
|
||||||
{
|
{
|
||||||
title: t("common:export"),
|
title: t("common:export"),
|
||||||
onRowClick: (client) => {
|
onClick() {
|
||||||
exportClient(client);
|
exportClient(client);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (!isRealmClient(client)) {
|
||||||
|
actions.push({
|
||||||
title: t("common:delete"),
|
title: t("common:delete"),
|
||||||
onRowClick: (client) => {
|
onClick() {
|
||||||
setSelectedClient(client);
|
setSelectedClient(client);
|
||||||
toggleDeleteDialog();
|
toggleDeleteDialog();
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
]}
|
}
|
||||||
|
|
||||||
|
return actions;
|
||||||
|
}}
|
||||||
columns={[
|
columns={[
|
||||||
{
|
{
|
||||||
name: "clientId",
|
name: "clientId",
|
||||||
|
|
6
src/clients/utils.ts
Normal file
6
src/clients/utils.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a client is intended to be used for authenticating a to a realm.
|
||||||
|
*/
|
||||||
|
export const isRealmClient = (client: ClientRepresentation) => !client.protocol;
|
Loading…
Reference in a new issue