1
0
Fork 0

Make KeyValueVersions use tsx syntax.

This commit is contained in:
Kitteh 2021-05-22 10:00:36 +01:00
parent a95c6d250f
commit bc78661c49
2 changed files with 19 additions and 24 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,8 +1,8 @@
import { Page } from "../../../types/Page";
import { SecretTitleElement } from "../SecretTitleElement";
import { getSecretMetadata } from "../../../api/kv/getSecretMetadata";
import { makeElement } from "z-makeelement";
import { objectToMap } from "../../../utils";
import { render } from "preact";
import i18next from "i18next";
export class KeyValueVersionsPage extends Page {
@ -16,34 +16,30 @@ export class KeyValueVersionsPage extends Page {
await this.router.changePage("KEY_VALUE_SECRET");
}
async render(): Promise<void> {
const versionsList = makeElement({
tag: "ul",
id: "versionsList",
class: ["uk-nav", "uk-nav-default"],
});
await this.router.setPageContent(versionsList);
const metadata = await getSecretMetadata(
this.state.baseMount,
this.state.secretPath,
this.state.secretItem,
);
const versions = Array.from(objectToMap(metadata.versions).keys());
objectToMap(metadata.versions).forEach((_, ver) => {
versionsList.appendChild(
makeElement({
tag: "li",
children: makeElement({
tag: "a",
text: `v${ver}`,
onclick: async () => {
render(
<ul class="uk-nav uk-nav-default">
{versions.map((ver) => (
<li>
<a
onClick={async () => {
this.state.secretVersion = ver;
await this.router.changePage("KEY_VALUE_SECRET");
},
}),
}),
}}
>
{`v${ver}`}
</a>
</li>
))}
</ul>,
this.router.pageContentElement,
);
});
}
async getPageTitle(): Promise<Element | string> {