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

58 lines
1.6 KiB
TypeScript
Raw Normal View History

import { Page } from "../../PageSystem/Page";
import { SecretTitleElement } from "../../elements/SecretTitleElement";
2021-05-09 11:18:18 +01:00
import { deleteSecret } from "../../api/kv/deleteSecret";
import { makeElement } from "../../htmlUtils";
import i18next from "i18next";
2021-04-15 13:01:58 +01:00
export class KeyValueDeletePage extends Page {
constructor() {
super();
}
2021-05-12 17:37:09 +01:00
async goBack(): Promise<void> {
if (this.state.currentSecretVersion != null) {
this.state.currentSecretVersion = null;
await this.router.changePage("KEY_VALUE_SECRET");
2021-04-15 13:01:58 +01:00
} else {
this.state.currentSecret = "";
await this.router.changePage("KEY_VALUE_VIEW");
2021-04-15 13:01:58 +01:00
}
}
2021-05-12 17:37:09 +01:00
async render(): Promise<void> {
await this.router.setPageContent(
makeElement({
tag: "div",
children: [
makeElement({
tag: "h5",
text: i18next.t("kv_delete_text"),
}),
makeElement({
tag: "button",
class: ["uk-button", "uk-button-danger"],
text: i18next.t("kv_delete_btn"),
onclick: () => {
void deleteSecret(
this.state.currentBaseMount,
this.state.currentMountType,
this.state.currentSecretPath,
this.state.currentSecret,
this.state.currentSecretVersion,
).then(() => {
2021-05-12 17:37:09 +01:00
void this.goBack();
});
},
}),
],
}),
);
2021-04-15 13:01:58 +01:00
}
async getPageTitle(): Promise<Element | string> {
return await SecretTitleElement(this.router, i18next.t("kv_delete_suffix"));
}
2021-05-08 03:11:09 +01:00
get name(): string {
return i18next.t("kv_delete_title");
2021-04-15 13:01:58 +01:00
}
}