Added missing delete action (#3645)

This commit is contained in:
Erik Jan de Wit 2022-10-25 16:59:37 +02:00 committed by GitHub
parent a66caf954e
commit c401fa6eee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View file

@ -316,6 +316,8 @@
"searchForMessageBundle": "Search for message bundle",
"addMessageBundle": "Add message bundle",
"addMessageBundleSuccess": "Success! The message bundle has been added.",
"deleteMessageBundleSuccess": "Successfully removed the message from the bundle",
"deleteMessageBundleError": "Error removing the message from the bundle, {{error}}",
"rowEditBtnAriaLabel": "Edit {{messageBundle}}",
"rowSaveBtnAriaLabel": "Save edits for {{messageBundle}}",
"rowCancelBtnAriaLabel": "Cancel edits for {{messageBundle}}",

View file

@ -61,6 +61,7 @@ export enum RowEditAction {
Save = "save",
Cancel = "cancel",
Edit = "edit",
Delete = "delete",
}
export type BundleForm = {
@ -332,6 +333,20 @@ export const LocalizationTab = ({ save, realm }: LocalizationTabProps) => {
}
};
const deleteKey = async (key: string) => {
try {
await adminClient.realms.deleteRealmLocalizationTexts({
realm: currentRealm!,
selectedLocale: selectMenuLocale,
key,
});
refreshTable();
addAlert(t("deleteMessageBundleSuccess"));
} catch (error) {
addError("realm-settings:deleteMessageBundleError", error);
}
};
return (
<>
{addMessageBundleModalOpen && (
@ -578,6 +593,15 @@ export const LocalizationTab = ({ save, realm }: LocalizationTabProps) => {
onRowEdit={(_, type, _b, rowIndex, validation) =>
updateEditableRows(type, rowIndex, validation)
}
actions={[
{
title: t("common:delete"),
onClick: (_, row) =>
deleteKey(
(tableRows[row].cells?.[0] as IRowCell).props.value
),
},
]}
>
<TableHeader />
<TableBody />