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