preliminary UI for enable and actions

This commit is contained in:
mfrances 2021-01-20 10:43:52 -05:00
parent e90f4d3702
commit 35ca42f267
3 changed files with 95 additions and 16 deletions

View file

@ -142,15 +142,6 @@ export const routes: RoutesFn = (t: TFunction) => [
breadcrumb: t("users:title"), breadcrumb: t("users:title"),
access: "query-users", access: "query-users",
}, },
{
path: "/:realm/groups",
component: GroupsSection,
breadcrumb: null,
matchOptions: {
exact: false,
},
access: "query-groups",
},
{ {
path: "/:realm/sessions", path: "/:realm/sessions",
component: SessionsSection, component: SessionsSection,
@ -235,4 +226,13 @@ export const routes: RoutesFn = (t: TFunction) => [
breadcrumb: null, breadcrumb: null,
access: "anyone", access: "anyone",
}, },
{
path: "/:realm/groups",
component: GroupsSection,
breadcrumb: null,
matchOptions: {
exact: false,
},
access: "query-groups",
},
]; ];

View file

@ -1,23 +1,71 @@
import React, { useEffect } from "react";
import { import {
ActionGroup, ActionGroup,
AlertVariant, AlertVariant,
Button, Button,
ButtonVariant,
DropdownItem,
Form, Form,
PageSection, PageSection,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import { useTranslation } from "react-i18next";
import React, { useEffect } from "react";
import { KerberosSettingsRequired } from "./kerberos/KerberosSettingsRequired"; import { KerberosSettingsRequired } from "./kerberos/KerberosSettingsRequired";
import { KerberosSettingsCache } from "./kerberos/KerberosSettingsCache"; import { KerberosSettingsCache } from "./kerberos/KerberosSettingsCache";
import { useHistory } from "react-router-dom";
import { useRealm } from "../context/realm-context/RealmContext"; import { useRealm } from "../context/realm-context/RealmContext";
import { useParams } from "react-router-dom";
import { convertToFormValues } from "../util"; import { convertToFormValues } from "../util";
import { useAlerts } from "../components/alert/Alerts";
import { useAdminClient } from "../context/auth/AdminClient";
import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation"; import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
import { useForm } from "react-hook-form";
import { Controller, useForm } from "react-hook-form";
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
import { useAdminClient } from "../context/auth/AdminClient";
import { useAlerts } from "../components/alert/Alerts";
import { useTranslation } from "react-i18next";
import { ViewHeader } from "../components/view-header/ViewHeader";
import { useHistory, useParams } from "react-router-dom";
type KerberosSettingsHeaderProps = {
onChange: (...event: any[]) => void;
value: any;
toggleDeleteDialog: () => void;
};
const KerberosSettingsHeader = ({
onChange,
value,
toggleDeleteDialog,
}: KerberosSettingsHeaderProps) => {
const { t } = useTranslation("user-federation");
const [toggleDisableDialog, DisableConfirm] = useConfirmDialog({
titleKey: "user-federation:userFedDisableConfirmTitle",
messageKey: "user-federation:userFedDisableConfirm",
continueButtonLabel: "common:disable",
onConfirm: () => {
onChange(!value);
},
});
return (
<>
<DisableConfirm />
<ViewHeader
titleKey="Kerberos"
subKey=""
dropdownItems={[
<DropdownItem key="delete" onClick={() => toggleDeleteDialog()}>
{t("deleteProvider")}
</DropdownItem>,
]}
isEnabled={value}
onToggle={(value) => {
if (!value) {
toggleDisableDialog();
} else {
onChange(value);
}
}}
/>
</>
);
};
export const UserFederationKerberosSettings = () => { export const UserFederationKerberosSettings = () => {
const { t } = useTranslation("user-federation"); const { t } = useTranslation("user-federation");
@ -61,9 +109,38 @@ export const UserFederationKerberosSettings = () => {
addAlert(`${t("saveError")} '${error}'`, AlertVariant.danger); addAlert(`${t("saveError")} '${error}'`, AlertVariant.danger);
} }
}; };
// const form = useForm();
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({
titleKey: "user-federation:userFedDeleteConfirmTitle",
messageKey: "user-federation:userFedDeleteConfirm",
continueButtonLabel: "common:delete",
continueButtonVariant: ButtonVariant.danger,
onConfirm: async () => {
try {
await adminClient.clients.del({ id });
addAlert(t("userFedDeletedSuccess"), AlertVariant.success);
} catch (error) {
addAlert(`${t("userFedDeleteError")} ${error}`, AlertVariant.danger);
}
},
});
return ( return (
<> <>
<DeleteConfirm />
<Controller
name="enabled"
control={form.control}
defaultValue={true}
render={({ onChange, value }) => (
<KerberosSettingsHeader
value={value}
onChange={onChange}
toggleDeleteDialog={toggleDeleteDialog}
/>
)}
/>
<PageSection variant="light"> <PageSection variant="light">
<KerberosSettingsRequired form={form} showSectionHeading /> <KerberosSettingsRequired form={form} showSectionHeading />
</PageSection> </PageSection>

View file

@ -89,6 +89,8 @@
"userFedDeleteError": "Could not delete user federation provider: '{{error}}'", "userFedDeleteError": "Could not delete user federation provider: '{{error}}'",
"userFedDeleteConfirmTitle": "Delete user federation provider?", "userFedDeleteConfirmTitle": "Delete user federation provider?",
"userFedDeleteConfirm": "If you delete this user federation provider, all associated data will be removed.", "userFedDeleteConfirm": "If you delete this user federation provider, all associated data will be removed.",
"userFedDisableConfirmTitle": "Disable user federation provider?",
"userFedDisableConfirm": "If you disable this user federation provider, you cannot make changes to the provider.",
"validateName": "You must enter a name", "validateName": "You must enter a name",
"validateRealm":"You must enter a realm", "validateRealm":"You must enter a realm",