1
0
Fork 0
VaultUI/src/ui/pages/Secrets/KeyValue/KeyValueDelete.tsx

44 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-01-07 15:55:15 +00:00
import { Component } from "preact";
2022-01-06 23:02:34 +00:00
import { DefaultPageProps } from "../../../../types/DefaultPageProps";
2021-05-19 10:27:00 +01:00
import { SecretTitleElement } from "../SecretTitleElement";
2022-01-11 14:41:33 +00:00
import { kvListURL, kvViewURL } from "../../pageLinks";
2022-01-11 14:56:39 +00:00
import { route } from "preact-router";
import i18next from "i18next";
2021-04-15 13:01:58 +01:00
export class KeyValueDelete extends Component<DefaultPageProps> {
render() {
const baseMount = this.props.matches["baseMount"];
const secretPath = this.props.matches["secretPath"].split("/");
const item = this.props.matches["item"];
2022-01-11 14:41:33 +00:00
const version = this.props.matches["version"];
return (
<>
<SecretTitleElement
type="kv"
baseMount={baseMount}
secretPath={secretPath}
item={item}
2022-01-11 14:55:41 +00:00
suffix={i18next.t("kv_delete_suffix")}
/>
<div>
<h5>{i18next.t("kv_delete_text")}</h5>
<button
class="uk-button uk-button-danger"
onClick={async () => {
2022-01-11 14:41:33 +00:00
await this.props.api.deleteSecret(baseMount, secretPath, item, version);
if (version == "null") {
2022-01-11 14:56:39 +00:00
route(kvListURL(baseMount, secretPath));
2022-01-11 14:41:33 +00:00
} else {
2022-01-11 14:56:39 +00:00
route(kvViewURL(baseMount, secretPath, item, "null"));
2022-01-11 14:41:33 +00:00
}
}}
>
{i18next.t("common_delete")}
</button>
</div>
</>
);
2021-04-15 13:01:58 +01:00
}
}