1
0
Fork 0
VaultUI/src/pages/KeyValue/KeyValueDelete.js

55 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-05-07 23:33:58 +01:00
import { Page } from "../../types/Page";
2021-05-07 23:21:38 +01:00
import { changePage, setPageContent, setTitleElement } from "../../pageUtils";
2021-05-07 11:53:26 +01:00
import { deleteSecret } from "../../api/deleteSecret";
import { makeElement } from "../../htmlUtils";
2021-05-07 23:08:02 +01:00
import { pageState } from "../../globalPageState.ts";
import i18next from 'i18next';
2021-04-15 13:01:58 +01:00
export class KeyValueDeletePage extends Page {
constructor() {
super();
}
goBack() {
if (pageState.currentSecretVersion != null) {
pageState.currentSecretVersion = null;
changePage("KEY_VALUE_SECRET");
2021-04-15 13:01:58 +01:00
} else {
pageState.currentSecret = "";
2021-04-17 11:24:43 +01:00
changePage("KEY_VALUE_VIEW");
2021-04-15 13:01:58 +01:00
}
}
render() {
setTitleElement(pageState);
setPageContent(makeElement({
tag: "div",
children: [
makeElement({
tag: "h5",
text: i18next.t("kv_delete_text")
2021-04-15 13:01:58 +01:00
}),
makeElement({
tag: "button",
class: ["uk-button", "uk-button-danger"],
text: i18next.t("kv_delete_btn"),
2021-04-15 13:01:58 +01:00
onclick: _ => {
deleteSecret(
pageState.currentBaseMount,
pageState.currentMountType,
pageState.currentSecretPath,
pageState.currentSecret,
pageState.currentSecretVersion,
).then(() => {
2021-04-15 13:01:58 +01:00
this.goBack();
});
}
}),
]
}));
}
get titleSuffix() {
return i18next.t("kv_delete_suffix");
}
2021-04-15 13:01:58 +01:00
get name() {
return i18next.t("kv_delete_title");
2021-04-15 13:01:58 +01:00
}
}