lint code
This commit is contained in:
parent
121b487fea
commit
b2e1ab3057
|
@ -356,11 +356,11 @@ export class API {
|
|||
baseMount: string,
|
||||
secretPath: string[],
|
||||
name: string,
|
||||
version: string = "null",
|
||||
version = "null",
|
||||
): Promise<void> {
|
||||
let secretURL = "";
|
||||
|
||||
let request;
|
||||
let request: Request;
|
||||
|
||||
const mountInfo = await this.getMount(baseMount);
|
||||
const mountVersion = mountInfo.options.version;
|
||||
|
@ -396,7 +396,7 @@ export class API {
|
|||
baseMount: string,
|
||||
secretPath: string[],
|
||||
name: string,
|
||||
version: string = "null",
|
||||
version = "null",
|
||||
): Promise<void> {
|
||||
let secretURL = `/v1/${baseMount}/undelete/${secretPath.join("/")}/${name}`;
|
||||
secretURL = removeDoubleSlash(secretURL).replace(/\/$/, "");
|
||||
|
@ -442,7 +442,7 @@ export class API {
|
|||
baseMount: string,
|
||||
secretPath: string[],
|
||||
name: string,
|
||||
version: string = "null",
|
||||
version = "null",
|
||||
): Promise<Record<string, unknown>> {
|
||||
let secretURL = "";
|
||||
|
||||
|
@ -464,7 +464,7 @@ export class API {
|
|||
baseMount: string,
|
||||
secretPath: string[],
|
||||
name: string,
|
||||
version: string = "null",
|
||||
version = "null",
|
||||
): Promise<Record<string, unknown>> {
|
||||
const mountInfo = await this.getMount(baseMount);
|
||||
if (mountInfo.options.version == "2") {
|
||||
|
|
|
@ -11,6 +11,7 @@ import { KeyValueDelete } from "./ui/pages/Secrets/KeyValue/KeyValueDelete";
|
|||
import { KeyValueEdit } from "./ui/pages/Secrets/KeyValue/KeyValueEdit";
|
||||
import { KeyValueList } from "./ui/pages/Secrets/KeyValue/KeyValueList";
|
||||
import { KeyValueNew } from "./ui/pages/Secrets/KeyValue/KeyValueNew";
|
||||
import { KeyValueVersions } from "./ui/pages/Secrets/KeyValue/KeyValueVersions";
|
||||
import { KeyValueView } from "./ui/pages/Secrets/KeyValue/KeyValueView";
|
||||
import { Login } from "./ui/pages/Login";
|
||||
import { Me } from "./ui/pages/Me";
|
||||
|
@ -43,7 +44,6 @@ import { UserPassUserEdit } from "./ui/pages/Access/Auth/userpass/UserPassUserEd
|
|||
import { UserPassUserNew } from "./ui/pages/Access/Auth/userpass/UserPassUserNew";
|
||||
import { UserPassUserView } from "./ui/pages/Access/Auth/userpass/UserPassUserView";
|
||||
import { UserPassUsersList } from "./ui/pages/Access/Auth/userpass/UserPassUsersList";
|
||||
import { KeyValueVersions } from "./ui/pages/Secrets/KeyValue/KeyValueVersions";
|
||||
|
||||
export const Main = () => (
|
||||
<Router>
|
||||
|
@ -89,7 +89,11 @@ export const Main = () => (
|
|||
<TOTPList path="/secrets/totp/list/:baseMount" settings={settings} api={api} />
|
||||
<TOTPNew path="/secrets/totp/new/:baseMount" settings={settings} api={api} />
|
||||
<TOTPNewGenerated path="/secrets/totp/new_generated/:baseMount" settings={settings} api={api} />
|
||||
<TOTPDelete path="/secrets/totp/delete/:version/:baseMount/:item" settings={settings} api={api} />
|
||||
<TOTPDelete
|
||||
path="/secrets/totp/delete/:version/:baseMount/:item"
|
||||
settings={settings}
|
||||
api={api}
|
||||
/>
|
||||
|
||||
<TransitNew path="/secrets/transit/new/:baseMount" settings={settings} api={api} />
|
||||
<TransitList path="/secrets/transit/list/:baseMount" settings={settings} api={api} />
|
||||
|
|
|
@ -50,7 +50,11 @@ export class CodeEditor extends Component<CodeEditorProps, unknown> {
|
|||
|
||||
render(): JSX.Element {
|
||||
return (
|
||||
<div dir="ltr" class={"editor line-numbers language-" + this.props.language} ref={this.editorRef} />
|
||||
<div
|
||||
dir="ltr"
|
||||
class={"editor line-numbers language-" + this.props.language}
|
||||
ref={this.editorRef}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { Component } from "preact";
|
||||
import { DefaultPageProps } from "../../../../types/DefaultPageProps";
|
||||
import { SecretTitleElement } from "../SecretTitleElement";
|
||||
import i18next from "i18next";
|
||||
import { route } from "preact-router";
|
||||
import { kvListURL, kvViewURL } from "../../pageLinks";
|
||||
import { route } from "preact-router";
|
||||
import i18next from "i18next";
|
||||
|
||||
export class KeyValueDelete extends Component<DefaultPageProps> {
|
||||
render() {
|
||||
|
@ -28,9 +28,9 @@ export class KeyValueDelete extends Component<DefaultPageProps> {
|
|||
onClick={async () => {
|
||||
await this.props.api.deleteSecret(baseMount, secretPath, item, version);
|
||||
if (version == "null") {
|
||||
route(kvListURL(baseMount, secretPath))
|
||||
route(kvListURL(baseMount, secretPath));
|
||||
} else {
|
||||
route(kvViewURL(baseMount, secretPath, item, "null"))
|
||||
route(kvViewURL(baseMount, secretPath, item, "null"));
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -2,8 +2,8 @@ import { Component } from "preact";
|
|||
import { DefaultPageProps } from "../../../../types/DefaultPageProps";
|
||||
import { SecretTitleElement } from "../SecretTitleElement";
|
||||
import { kvViewURL } from "../../pageLinks";
|
||||
import { route } from "preact-router";
|
||||
import { objectToMap } from "../../../../utils";
|
||||
import { route } from "preact-router";
|
||||
|
||||
export class KeyValueVersions extends Component<DefaultPageProps, { versions: string[] }> {
|
||||
async componentDidMount() {
|
||||
|
@ -11,11 +11,7 @@ export class KeyValueVersions extends Component<DefaultPageProps, { versions: st
|
|||
const secretPath = this.props.matches["secretPath"].split("/");
|
||||
const secretItem = this.props.matches["item"];
|
||||
|
||||
const metadata = await this.props.api.getSecretMetadata(
|
||||
baseMount,
|
||||
secretPath,
|
||||
secretItem,
|
||||
);
|
||||
const metadata = await this.props.api.getSecretMetadata(baseMount, secretPath, secretItem);
|
||||
|
||||
const versions = Array.from(objectToMap(metadata.versions).keys());
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ import { CodeBlock } from "../../../elements/CodeBlock";
|
|||
import { Component, JSX } from "preact";
|
||||
import { CopyableInputBox } from "../../../elements/CopyableInputBox";
|
||||
import { DefaultPageProps } from "../../../../types/DefaultPageProps";
|
||||
import { DoesNotExistError } from "../../../../types/internalErrors";
|
||||
import { Grid, GridSizes } from "../../../elements/Grid";
|
||||
import { SecretTitleElement } from "../SecretTitleElement";
|
||||
import { kvDeleteURL, kvEditURL, kvVersionsURL } from "../../pageLinks";
|
||||
import { route } from "preact-router";
|
||||
import { sortedObjectMap } from "../../../../utils";
|
||||
import i18next from "i18next";
|
||||
import { DoesNotExistError } from "../../../../types/internalErrors";
|
||||
|
||||
export type KVSecretViewProps = {
|
||||
kvData: Record<string, unknown>;
|
||||
|
@ -63,13 +63,18 @@ export class KeyValueView extends Component<DefaultPageProps, KeyValueViewState>
|
|||
.capabilities;
|
||||
|
||||
const mountInfo = await this.props.api.getMount(baseMount);
|
||||
let kvVersion = mountInfo.options.version;
|
||||
const kvVersion = mountInfo.options.version;
|
||||
|
||||
let secretInfo: Record<string, unknown>;
|
||||
|
||||
if (kvVersion == "2") {
|
||||
try {
|
||||
secretInfo = await this.props.api.getSecretKV2(baseMount, secretPath, secretItem, secretVersion);
|
||||
secretInfo = await this.props.api.getSecretKV2(
|
||||
baseMount,
|
||||
secretPath,
|
||||
secretItem,
|
||||
secretVersion,
|
||||
);
|
||||
} catch (e) {
|
||||
if (e == DoesNotExistError) {
|
||||
secretInfo = null;
|
||||
|
@ -79,7 +84,7 @@ export class KeyValueView extends Component<DefaultPageProps, KeyValueViewState>
|
|||
secretInfo = await this.props.api.getSecretKV1(baseMount, secretPath, secretItem);
|
||||
}
|
||||
|
||||
let isDeleted = (secretInfo == null) && (kvVersion == "2");
|
||||
const isDeleted = secretInfo == null && kvVersion == "2";
|
||||
|
||||
this.setState({
|
||||
baseMount,
|
||||
|
@ -127,10 +132,7 @@ export class KeyValueView extends Component<DefaultPageProps, KeyValueViewState>
|
|||
if (this.state.kvVersion == "2" && this.state.secretVersion == "null") {
|
||||
// Delete All
|
||||
deleteButtonText = i18next.t("kv_secret_delete_all_btn");
|
||||
} else if (
|
||||
this.state.kvVersion == "2" &&
|
||||
this.state.secretVersion != "null"
|
||||
) {
|
||||
} else if (this.state.kvVersion == "2" && this.state.secretVersion != "null") {
|
||||
// Delete Version X
|
||||
deleteButtonText = i18next.t("kv_secret_delete_version_btn", {
|
||||
version: this.state.secretVersion,
|
||||
|
@ -158,14 +160,17 @@ export class KeyValueView extends Component<DefaultPageProps, KeyValueViewState>
|
|||
class="uk-button uk-button-secondary"
|
||||
onClick={async () => {
|
||||
route(
|
||||
kvVersionsURL(this.state.baseMount, this.state.secretPath, this.state.secretItem),
|
||||
kvVersionsURL(
|
||||
this.state.baseMount,
|
||||
this.state.secretPath,
|
||||
this.state.secretItem,
|
||||
),
|
||||
);
|
||||
}}
|
||||
>
|
||||
{i18next.t("kv_secret_versions_btn")}
|
||||
</button>
|
||||
)}
|
||||
|
||||
</p>
|
||||
|
||||
{!this.state.isDeleted && <KVSecretVew kvData={this.state.secretInfo} />}
|
||||
|
|
|
@ -54,17 +54,24 @@ export function SecretTitleElement(props: SecretTitleElementProps): JSX.Element
|
|||
);
|
||||
})}
|
||||
|
||||
{item.length != 0 && (() => {
|
||||
{item.length != 0 &&
|
||||
(() => {
|
||||
if (["kv", "transit"].includes(type)) {
|
||||
return <a onClick={() => {
|
||||
return (
|
||||
<a
|
||||
onClick={() => {
|
||||
if (type == "kv") {
|
||||
route(kvViewURL(baseMount, secretPath, item))
|
||||
route(kvViewURL(baseMount, secretPath, item));
|
||||
} else if (type == "transit") {
|
||||
route(transitViewSecretURL(baseMount, item))
|
||||
route(transitViewSecretURL(baseMount, item));
|
||||
}
|
||||
}}>{item}</a>
|
||||
}}
|
||||
>
|
||||
{item}
|
||||
</a>
|
||||
);
|
||||
} else {
|
||||
return <span>{item}</span>
|
||||
return <span>{item}</span>;
|
||||
}
|
||||
})()}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import { Form } from "../elements/Form";
|
|||
import { Margin } from "../elements/Margin";
|
||||
import { MarginInline } from "../elements/MarginInline";
|
||||
import { PageTitle } from "../elements/PageTitle";
|
||||
import { route } from "preact-router";
|
||||
import i18next from "i18next";
|
||||
|
||||
const languageIDs = Object.getOwnPropertyNames(translations);
|
||||
|
|
|
@ -10,7 +10,12 @@ export function kvNewURL(baseMount: string, secretPath?: string[]): string {
|
|||
return `/secrets/kv/new/${baseMount}` + (secretPath ? `/${secretPath.join("/")}` : "");
|
||||
}
|
||||
|
||||
export function kvDeleteURL(baseMount: string, secretPath: string[], secret: string, version: string = "null"): string {
|
||||
export function kvDeleteURL(
|
||||
baseMount: string,
|
||||
secretPath: string[],
|
||||
secret: string,
|
||||
version = "null",
|
||||
): string {
|
||||
return `/secrets/kv/delete/${secret}/${version}/${baseMount}/${secretPath.join("/")}`;
|
||||
}
|
||||
|
||||
|
@ -22,7 +27,12 @@ export function kvVersionsURL(baseMount: string, secretPath: string[], secret: s
|
|||
return `/secrets/kv/versions/${secret}/${baseMount}/${secretPath.join("/")}`;
|
||||
}
|
||||
|
||||
export function kvViewURL(baseMount: string, secretPath: string[], secret: string, version: string = "null"): string {
|
||||
export function kvViewURL(
|
||||
baseMount: string,
|
||||
secretPath: string[],
|
||||
secret: string,
|
||||
version = "null",
|
||||
): string {
|
||||
return `/secrets/kv/view/${secret}/${version}/${baseMount}/${secretPath.join("/")}`;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue