2020-09-25 17:11:25 +00:00
|
|
|
import React, { useContext, useState } from "react";
|
|
|
|
import { Button, PageSection } from "@patternfly/react-core";
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { useHistory } from "react-router-dom";
|
|
|
|
|
|
|
|
import { RealmContext } from "../components/realm-context/RealmContext";
|
|
|
|
import { HttpClientContext } from "../http-service/HttpClientContext";
|
|
|
|
import { ClientRepresentation } from "../realm/models/Realm";
|
|
|
|
import { DataLoader } from "../components/data-loader/DataLoader";
|
|
|
|
import { TableToolbar } from "../components/table-toolbar/TableToolbar";
|
|
|
|
import { ClientScopeList } from "./ClientScopesList";
|
2020-10-02 13:56:46 +00:00
|
|
|
import { ViewHeader } from "../components/view-header/ViewHeader";
|
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();
|
|
|
|
|
|
|
|
const [max, setMax] = useState(10);
|
|
|
|
const [first, setFirst] = useState(0);
|
|
|
|
const httpClient = useContext(HttpClientContext)!;
|
|
|
|
const { realm } = useContext(RealmContext);
|
|
|
|
|
|
|
|
const loader = async () => {
|
|
|
|
return await httpClient
|
|
|
|
.doGet(`/admin/realms/${realm}/client-scopes`, { params: { first, max } })
|
|
|
|
.then((r) => r.data as ClientRepresentation[]);
|
|
|
|
};
|
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">
|
|
|
|
<DataLoader loader={loader}>
|
|
|
|
{(scopes) => (
|
|
|
|
<TableToolbar
|
|
|
|
count={scopes!.length}
|
|
|
|
first={first}
|
|
|
|
max={max}
|
|
|
|
onNextClick={setFirst}
|
|
|
|
onPreviousClick={setFirst}
|
|
|
|
onPerPageSelect={(first, max) => {
|
|
|
|
setFirst(first);
|
|
|
|
setMax(max);
|
|
|
|
}}
|
|
|
|
toolbarItem={
|
|
|
|
<Button onClick={() => history.push("/add-client-scopes")}>
|
|
|
|
{t("createClientScope")}
|
|
|
|
</Button>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<ClientScopeList clientScopes={scopes} />
|
|
|
|
</TableToolbar>
|
|
|
|
)}
|
|
|
|
</DataLoader>
|
|
|
|
</PageSection>
|
|
|
|
</>
|
2020-09-18 08:04:55 +00:00
|
|
|
);
|
2020-09-09 09:07:17 +00:00
|
|
|
};
|