2020-12-07 19:23:18 +00:00
|
|
|
import React from "react";
|
2020-09-25 17:11:25 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2021-01-05 19:49:33 +00:00
|
|
|
import { Link, useHistory, useRouteMatch } from "react-router-dom";
|
2020-12-07 19:23:18 +00:00
|
|
|
import { Button, PageSection } from "@patternfly/react-core";
|
|
|
|
import ClientScopeRepresentation from "keycloak-admin/lib/defs/clientScopeRepresentation";
|
2020-09-25 17:11:25 +00:00
|
|
|
|
2020-11-12 12:55:52 +00:00
|
|
|
import { useAdminClient } from "../context/auth/AdminClient";
|
2020-12-07 19:23:18 +00:00
|
|
|
import { ViewHeader } from "../components/view-header/ViewHeader";
|
2020-12-11 10:28:38 +00:00
|
|
|
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
|
2020-09-09 09:07:17 +00:00
|
|
|
|
2020-09-10 18:04:03 +00:00
|
|
|
export const ClientScopesSection = () => {
|
2020-09-25 17:11:25 +00:00
|
|
|
const { t } = useTranslation("client-scopes");
|
|
|
|
const history = useHistory();
|
2021-01-05 19:49:33 +00:00
|
|
|
const { url } = useRouteMatch();
|
2020-09-25 17:11:25 +00:00
|
|
|
|
2020-11-12 12:55:52 +00:00
|
|
|
const adminClient = useAdminClient();
|
2020-09-25 17:11:25 +00:00
|
|
|
|
2020-12-07 19:23:18 +00:00
|
|
|
const loader = async () => await adminClient.clientScopes.find();
|
2020-10-07 15:47:03 +00:00
|
|
|
|
2020-12-07 19:23:18 +00:00
|
|
|
const ClientScopeDetailLink = (clientScope: ClientScopeRepresentation) => (
|
|
|
|
<>
|
2021-01-05 19:49:33 +00:00
|
|
|
<Link key={clientScope.id} to={`${url}/${clientScope.id}`}>
|
2020-12-07 19:23:18 +00:00
|
|
|
{clientScope.name}
|
|
|
|
</Link>
|
|
|
|
</>
|
|
|
|
);
|
2020-09-18 08:04:55 +00:00
|
|
|
return (
|
2020-10-02 13:56:46 +00:00
|
|
|
<>
|
|
|
|
<ViewHeader
|
|
|
|
titleKey="clientScopes"
|
|
|
|
subKey="client-scopes:clientScopeExplain"
|
|
|
|
/>
|
|
|
|
<PageSection variant="light">
|
2020-12-11 10:18:29 +00:00
|
|
|
<KeycloakDataTable
|
2020-12-07 19:23:18 +00:00
|
|
|
loader={loader}
|
|
|
|
ariaLabelKey="client-scopes:clientScopeList"
|
|
|
|
searchPlaceholderKey="client-scopes:searchFor"
|
|
|
|
toolbarItem={
|
2021-01-05 19:49:33 +00:00
|
|
|
<Button onClick={() => history.push(`${url}/new`)}>
|
2020-12-07 19:23:18 +00:00
|
|
|
{t("createClientScope")}
|
|
|
|
</Button>
|
|
|
|
}
|
|
|
|
actions={[
|
|
|
|
{
|
|
|
|
title: t("common:export"),
|
|
|
|
onRowClick: () => {},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: t("common:delete"),
|
|
|
|
onRowClick: () => {},
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
columns={[
|
|
|
|
{
|
|
|
|
name: "name",
|
|
|
|
cellRenderer: ClientScopeDetailLink,
|
|
|
|
},
|
|
|
|
{ name: "description" },
|
|
|
|
{
|
|
|
|
name: "protocol",
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
2020-10-02 13:56:46 +00:00
|
|
|
</PageSection>
|
|
|
|
</>
|
2020-09-18 08:04:55 +00:00
|
|
|
);
|
2020-09-09 09:07:17 +00:00
|
|
|
};
|