import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { FormGroup, PageSection, ActionGroup, Button, TextArea, AlertVariant, } from "@patternfly/react-core"; import { FormAccess } from "../../components/form-access/FormAccess"; import { HelpItem } from "../../components/help-enabler/HelpItem"; import { useAdminClient, useFetch } from "../../context/auth/AdminClient"; import { useParams } from "react-router-dom"; import FileSaver from "file-saver"; import { prettyPrintJSON } from "../../util"; import "./authorization-details.css"; import { useAlerts } from "../../components/alert/Alerts"; import type { ClientParams } from "../routes/Client"; import type ResourceServerRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceServerRepresentation"; export const AuthorizationExport = () => { const { t } = useTranslation("clients"); const adminClient = useAdminClient(); const { clientId } = useParams(); const { addAlert, addError } = useAlerts(); const [code, setCode] = useState(); const [authorizationDetails, setAuthorizationDetails] = useState(); useFetch( () => adminClient.clients.exportResource({ id: clientId, }), (authDetails) => { setCode(JSON.stringify(authDetails, null, 2)); setAuthorizationDetails(authDetails); }, [] ); const exportAuthDetails = () => { try { FileSaver.saveAs( new Blob([prettyPrintJSON(authorizationDetails)], { type: "application/json", }), "test-authz-config.json" ); addAlert(t("exportAuthDetailsSuccess"), AlertVariant.success); } catch (error) { addError("exportAuthDetailsError", error); } }; return ( } fieldId="client" >