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