added missing delete account feature (#21006)

fixes: #20901
This commit is contained in:
Erik Jan de Wit 2023-06-19 08:35:29 +02:00 committed by GitHub
parent 29f9523646
commit 73daf8b540
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 1 deletions

View file

@ -20,11 +20,14 @@
"close": "Close",
"credentialCreatedAt": "<0>Created</0> {{date}}.",
"currentSession": "Current session",
"deleteAccount": "Delete account",
"deleteAccountWarning": "This is irreversible. All your data will be permanently destroyed, and irretrievable.",
"description": "Description",
"device-activity": "Device activity",
"deviceActivity": "Device activity",
"directMembership": "Direct membership",
"doCancel": "Cancel",
"doDelete": "Delete",
"doDeny": "Deny",
"done": "Done",
"doSave": "Save",

View file

@ -1,4 +1,10 @@
import { ActionGroup, Button, Form } from "@patternfly/react-core";
import {
ActionGroup,
Alert,
Button,
ExpandableSection,
Form,
} from "@patternfly/react-core";
import { useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
@ -10,6 +16,8 @@ import {
UserRepresentation,
} from "../api/representations";
import { Page } from "../components/page/Page";
import { environment } from "../environment";
import { keycloak } from "../keycloak";
import { usePromise } from "../utils/usePromise";
import { FormField } from "./FormField";
@ -79,6 +87,31 @@ const PersonalInfo = () => {
{t("doCancel")}
</Button>
</ActionGroup>
{environment.features.deleteAccountAllowed && (
<ExpandableSection toggleText={t("deleteAccount")}>
<Alert
isInline
title={t("deleteAccount")}
variant="danger"
actionLinks={
<Button
id="delete-account-btn"
variant="danger"
onClick={() =>
keycloak.login({
action: "delete_account",
})
}
className="delete-button"
>
{t("doDelete")}
</Button>
}
>
{t("deleteAccountWarning")}
</Alert>
</ExpandableSection>
)}
</Form>
</Page>
);