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
|
|
|
|
2022-01-06 18:53:38 +00:00
|
|
|
export class KeyValueDelete extends Component<DefaultPageProps> {
|
|
|
|
render() {
|
2022-01-06 22:57:12 +00:00
|
|
|
const baseMount = this.props.matches["baseMount"];
|
|
|
|
const secretPath = this.props.matches["secretPath"].split("/");
|
2022-01-06 18:53:38 +00:00
|
|
|
const item = this.props.matches["item"];
|
2022-01-11 14:41:33 +00:00
|
|
|
const version = this.props.matches["version"];
|
2021-05-15 10:54:39 +01:00
|
|
|
|
2022-01-06 18:53:38 +00:00
|
|
|
return (
|
|
|
|
<>
|
2022-01-06 22:57:12 +00:00
|
|
|
<SecretTitleElement
|
|
|
|
type="kv"
|
|
|
|
baseMount={baseMount}
|
|
|
|
secretPath={secretPath}
|
|
|
|
item={item}
|
2022-01-11 14:55:41 +00:00
|
|
|
suffix={i18next.t("kv_delete_suffix")}
|
2022-01-06 22:57:12 +00:00
|
|
|
/>
|
2022-01-06 18:53:38 +00:00
|
|
|
<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
|
|
|
}
|
2022-01-06 18:53:38 +00:00
|
|
|
}}
|
|
|
|
>
|
2022-01-10 14:57:53 +00:00
|
|
|
{i18next.t("common_delete")}
|
2022-01-06 18:53:38 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
2021-04-15 13:01:58 +01:00
|
|
|
}
|
2021-05-12 16:01:04 +01:00
|
|
|
}
|