1
0
Fork 0

make non-action links use href instead of onClick

This commit is contained in:
ChaotiCryptidz 2022-08-28 16:08:24 +01:00
parent ba6cc0d46c
commit eddc01fc35
No known key found for this signature in database
26 changed files with 131 additions and 208 deletions

View file

@ -2,54 +2,54 @@
"name": "vaultui", "name": "vaultui",
"version": "latest", "version": "latest",
"devDependencies": { "devDependencies": {
"@babel/core": "^7.17.5", "@babel/core": "^7.18.13",
"@babel/eslint-parser": "^7.17.0", "@babel/eslint-parser": "^7.18.9",
"@babel/plugin-proposal-class-properties": "^7.16.7", "@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.17.2", "@babel/plugin-proposal-decorators": "^7.18.10",
"@babel/plugin-proposal-object-rest-spread": "^7.17.3", "@babel/plugin-proposal-object-rest-spread": "^7.18.9",
"@babel/plugin-syntax-import-assertions": "^7.16.7", "@babel/plugin-syntax-import-assertions": "^7.18.6",
"@babel/plugin-transform-runtime": "^7.17.0", "@babel/plugin-transform-runtime": "^7.18.10",
"@babel/preset-env": "^7.16.11", "@babel/preset-env": "^7.18.10",
"@types/file-saver": "^2.0.5", "@types/file-saver": "^2.0.5",
"@types/js-yaml": "^4.0.5", "@types/js-yaml": "^4.0.5",
"@types/prismjs": "^1.26.0", "@types/prismjs": "^1.26.0",
"@types/uikit": "^3.3.2", "@types/uikit": "^3.14.0",
"@typescript-eslint/eslint-plugin": "^5.13.0", "@typescript-eslint/eslint-plugin": "^5.35.1",
"@typescript-eslint/parser": "^5.13.0", "@typescript-eslint/parser": "^5.35.1",
"babel-loader": "^8.2.3", "babel-loader": "^8.2.5",
"css-loader": "^6.6.0", "css-loader": "^6.7.1",
"css-minimizer-webpack-plugin": "^3.4.1", "css-minimizer-webpack-plugin": "^4.0.0",
"eslint": "^8.10.0", "eslint": "^8.23.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4", "eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0", "eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
"git-revision-webpack-plugin": "^5.0.0", "git-revision-webpack-plugin": "^5.0.0",
"html-webpack-plugin": "^5.5.0", "html-webpack-plugin": "^5.5.0",
"node-sass": "^7.0.1", "node-sass": "^7.0.1",
"prettier": "^2.5.1", "prettier": "^2.7.1",
"raw-loader": "^4.0.2", "raw-loader": "^4.0.2",
"sass-loader": "^12.6.0", "sass-loader": "^13.0.2",
"ts-loader": "^9.2.7", "ts-loader": "^9.3.1",
"typescript": "^4.6.2", "typescript": "^4.8.2",
"webpack": "^5.69.1", "webpack": "^5.74.0",
"webpack-cli": "^4.9.2", "webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.7.4" "webpack-dev-server": "^4.10.0"
}, },
"dependencies": { "dependencies": {
"clipboard": "^2.0.10", "clipboard": "^2.0.11",
"codejar": "^3.5.0", "codejar": "^3.6.0",
"core-js": "^3.21.1", "core-js": "^3.25.0",
"date-fns": "^2.28.0", "date-fns": "^2.29.2",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"i18next": "^21.6.13", "i18next": "^21.9.1",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"json5": "^2.2.0", "json5": "^2.2.1",
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"preact": "^10.6.6", "preact": "^10.10.6",
"preact-router": "^4.0.1", "preact-router": "^4.1.0",
"prismjs": "^1.27.0", "prismjs": "^1.29.0",
"qr-scanner": "^1.4.1", "qr-scanner": "^1.4.1",
"uikit": "^3.11.1" "uikit": "^3.15.5"
} }
} }

View file

@ -60,7 +60,7 @@ export class Settings {
kvViewDefaultLanguage: this.kvViewDefaultLanguage, kvViewDefaultLanguage: this.kvViewDefaultLanguage,
kvViewIndent: this.kvViewIndent, kvViewIndent: this.kvViewIndent,
kvHideKeyValues: this.kvHideKeyValues, kvHideKeyValues: this.kvHideKeyValues,
} };
} }
loadSettings(settings: Partial<SettingsData>) { loadSettings(settings: Partial<SettingsData>) {

View file

@ -1,5 +1,4 @@
import { JSX, RefObject } from "preact"; import { JSX, RefObject } from "preact";
import { route } from "preact-router";
export type ButtonProps = { export type ButtonProps = {
color: "primary" | "danger" | "secondary"; color: "primary" | "danger" | "secondary";
@ -15,17 +14,9 @@ export function Button(props: ButtonProps): JSX.Element {
const classes = "uk-button " + ("uk-button-" + props.color); const classes = "uk-button " + ("uk-button-" + props.color);
if (props.route) { if (props.route) {
return ( return (
<button <a class={classes} href={props.route} type={props.type}>
{...props}
ref={props.buttonRef}
class={classes}
onClick={() => {
route(props.route);
}}
type={props.type}
>
{props.text} {props.text}
</button> </a>
); );
} else { } else {
return ( return (

View file

@ -1,11 +1,11 @@
import { Button } from "./Button"; import { Button } from "./Button";
import { CodeBlock } from "./CodeBlock"; import { CodeBlock } from "./CodeBlock";
import { Component, JSX, createRef } from "preact"; import { Component, JSX, createRef } from "preact";
import { InlineButtonBox } from "./InlineButtonBox";
import { addClipboardNotifications } from "../../utils/clipboardNotifs"; import { addClipboardNotifications } from "../../utils/clipboardNotifs";
import ClipboardJS from "clipboard"; import ClipboardJS from "clipboard";
import FileSaver from "file-saver"; import FileSaver from "file-saver";
import i18next from "i18next"; import i18next from "i18next";
import { InlineButtonBox } from "./InlineButtonBox";
export type CopyableBoxProps = { export type CopyableBoxProps = {
title: string; title: string;

View file

@ -1,9 +1,9 @@
import { JSX } from "preact"; import { JSX } from "preact";
export type InlineButtonBoxProps = { export type InlineButtonBoxProps = {
children?: JSX.Element | JSX.Element[]; children?: JSX.Element | JSX.Element[];
}; };
export function InlineButtonBox(props: InlineButtonBoxProps): JSX.Element { export function InlineButtonBox(props: InlineButtonBoxProps): JSX.Element {
return <div>{props.children}</div>; return <div>{props.children}</div>;
} }

View file

@ -34,13 +34,7 @@ export function NavBar(): JSX.Element {
<div class="uk-navbar-right"> <div class="uk-navbar-right">
<ul class="uk-navbar-nav"> <ul class="uk-navbar-nav">
<li> <li>
<a <a href="/me">{i18next.t("me_btn")}</a>
onClick={async () => {
route("/me", true);
}}
>
{i18next.t("me_btn")}
</a>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -1,4 +1,5 @@
import { Component, JSX } from "preact"; import { Component, JSX } from "preact";
import { notImplementedNotification } from "./ErrorMessage";
export type TileParams = { export type TileParams = {
disabled?: boolean; disabled?: boolean;
@ -7,7 +8,8 @@ export type TileParams = {
description: string; description: string;
icon?: string; icon?: string;
iconText?: string; iconText?: string;
onclick: () => void; href?: string;
notImplemented?: boolean;
}; };
export class Tile extends Component<TileParams, unknown> { export class Tile extends Component<TileParams, unknown> {
@ -33,9 +35,15 @@ export class Tile extends Component<TileParams, unknown> {
if (this.props.disabled == true) { if (this.props.disabled == true) {
return <p>{tileInner}</p>; return <p>{tileInner}</p>;
} else if (this.props.notImplemented == true) {
return (
<a class="uk-link-heading" onClick={async () => notImplementedNotification()}>
{tileInner}
</a>
);
} else { } else {
return ( return (
<a class="uk-link-heading" onClick={this.props.onclick}> <a class="uk-link-heading" href={this.props.href}>
{tileInner} {tileInner}
</a> </a>
); );

View file

@ -3,8 +3,6 @@ import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { Grid, GridSizes } from "../../elements/Grid"; import { Grid, GridSizes } from "../../elements/Grid";
import { PageTitle } from "../../elements/PageTitle"; import { PageTitle } from "../../elements/PageTitle";
import { Tile } from "../../elements/Tile"; import { Tile } from "../../elements/Tile";
import { notImplementedNotification } from "../../elements/ErrorMessage";
import { route } from "preact-router";
import i18next from "i18next"; import i18next from "i18next";
export class AccessHomePage extends Component<DefaultPageProps> { export class AccessHomePage extends Component<DefaultPageProps> {
@ -17,25 +15,25 @@ export class AccessHomePage extends Component<DefaultPageProps> {
title={i18next.t("access_auth_methods_title")} title={i18next.t("access_auth_methods_title")}
description={i18next.t("access_auth_methods_description")} description={i18next.t("access_auth_methods_description")}
icon="sign-in" icon="sign-in"
onclick={async () => route("/access/auth")} href="/access/auth"
/> />
<Tile <Tile
title={i18next.t("access_entities_title")} title={i18next.t("access_entities_title")}
description={i18next.t("access_entities_description")} description={i18next.t("access_entities_description")}
icon="user" icon="user"
onclick={async () => notImplementedNotification()} notImplemented={true}
/> />
<Tile <Tile
title={i18next.t("access_groups_title")} title={i18next.t("access_groups_title")}
description={i18next.t("access_groups_description")} description={i18next.t("access_groups_description")}
icon="users" icon="users"
onclick={async () => notImplementedNotification()} notImplemented={true}
/> />
<Tile <Tile
title={i18next.t("access_leases_title")} title={i18next.t("access_leases_title")}
description={i18next.t("access_leases_description")} description={i18next.t("access_leases_description")}
icon="unlock" icon="unlock"
onclick={async () => notImplementedNotification()} notImplemented={true}
/> />
</Grid> </Grid>
</> </>

View file

@ -6,7 +6,6 @@ import { PageTitle } from "../../../elements/PageTitle";
import { authViewConfigURL, userPassUserListURL } from "../../pageLinks"; import { authViewConfigURL, userPassUserListURL } from "../../pageLinks";
import { notImplementedNotification, sendErrorNotification } from "../../../elements/ErrorMessage"; import { notImplementedNotification, sendErrorNotification } from "../../../elements/ErrorMessage";
import { objectToMap } from "../../../../utils"; import { objectToMap } from "../../../../utils";
import { route } from "preact-router";
import i18next from "i18next"; import i18next from "i18next";
export type AuthListElementProps = { export type AuthListElementProps = {
@ -17,26 +16,17 @@ export type AuthListElementProps = {
export function AuthListElement(props: AuthListElementProps): JSX.Element { export function AuthListElement(props: AuthListElementProps): JSX.Element {
const isViewable = ["userpass"].includes(props.method.type); const isViewable = ["userpass"].includes(props.method.type);
const onViewClick = (props: AuthListElementProps) => { let link = "";
if (props.method.type == "userpass") { if (props.method.type == "userpass") {
route(userPassUserListURL(props.path)); link = userPassUserListURL(props.path);
} }
};
return ( return (
<div class="uk-padding-small uk-background-secondary"> <div class="uk-padding-small uk-background-secondary">
<span class="uk-h4 uk-margin-bottom">{props.path}</span> <span class="uk-h4 uk-margin-bottom">{props.path}</span>
<span class="uk-text-muted">{` (${props.method.accessor})`}</span> <span class="uk-text-muted">{` (${props.method.accessor})`}</span>
<div class="uk-margin-top"> <div class="uk-margin-top">
{isViewable && ( {isViewable && <Button text={i18next.t("common_view")} color="primary" route={link} />}
<Button
text={i18next.t("common_view")}
color="primary"
onClick={() => {
onViewClick(props);
}}
/>
)}
<Button <Button
text={i18next.t("auth_home_view_config")} text={i18next.t("auth_home_view_config")}
color="primary" color="primary"

View file

@ -2,6 +2,7 @@ import { Button } from "../../../../elements/Button";
import { Component } from "preact"; import { Component } from "preact";
import { DefaultPageProps } from "../../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../../types/DefaultPageProps";
import { HeaderAndContent } from "../../../../elements/HeaderAndContent"; import { HeaderAndContent } from "../../../../elements/HeaderAndContent";
import { InlineButtonBox } from "../../../../elements/InlineButtonBox";
import { Margin } from "../../../../elements/Margin"; import { Margin } from "../../../../elements/Margin";
import { PageTitle } from "../../../../elements/PageTitle"; import { PageTitle } from "../../../../elements/PageTitle";
import { UserType } from "../../../../../api/types/user"; import { UserType } from "../../../../../api/types/user";
@ -9,7 +10,6 @@ import { sendErrorNotification } from "../../../../elements/ErrorMessage";
import { toStr } from "../../../../../utils"; import { toStr } from "../../../../../utils";
import { userPassUserDeleteURL, userPassUserEditURL } from "../../../pageLinks"; import { userPassUserDeleteURL, userPassUserEditURL } from "../../../pageLinks";
import i18next from "i18next"; import i18next from "i18next";
import { InlineButtonBox } from "../../../../elements/InlineButtonBox";
export class UserPassUserView extends Component<DefaultPageProps, { user_data: UserType }> { export class UserPassUserView extends Component<DefaultPageProps, { user_data: UserType }> {
async componentDidMount() { async componentDidMount() {

View file

@ -3,7 +3,6 @@ import { Component } from "preact";
import { DefaultPageProps } from "../../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../../types/DefaultPageProps";
import { Margin } from "../../../../elements/Margin"; import { Margin } from "../../../../elements/Margin";
import { PageTitle } from "../../../../elements/PageTitle"; import { PageTitle } from "../../../../elements/PageTitle";
import { route } from "preact-router";
import { sendErrorNotification } from "../../../../elements/ErrorMessage"; import { sendErrorNotification } from "../../../../elements/ErrorMessage";
import { userPassUserNewURL, userPassUserViewURL } from "../../../pageLinks"; import { userPassUserNewURL, userPassUserViewURL } from "../../../pageLinks";
import i18next from "i18next"; import i18next from "i18next";
@ -40,13 +39,7 @@ export class UserPassUsersList extends Component<DefaultPageProps, { users: stri
<ul> <ul>
{...this.state.users.map((user) => ( {...this.state.users.map((user) => (
<li> <li>
<a <a href={userPassUserViewURL(baseMount, user)}>{user}</a>
onClick={async () => {
route(userPassUserViewURL(baseMount, user));
}}
>
{user}
</a>
</li> </li>
))} ))}
</ul> </ul>

View file

@ -84,27 +84,21 @@ export class Home extends Component<DefaultPageProps, HomeState> {
title={i18next.t("home_secrets_title")} title={i18next.t("home_secrets_title")}
description={i18next.t("home_secrets_description")} description={i18next.t("home_secrets_description")}
icon="file-edit" icon="file-edit"
onclick={async () => { href="/secrets"
route("/secrets");
}}
/> />
<Tile <Tile
title={i18next.t("home_access_title")} title={i18next.t("home_access_title")}
description={i18next.t("home_access_description")} description={i18next.t("home_access_description")}
icon="users" icon="users"
disabled={!this.state.authCaps.includes("read")} disabled={!this.state.authCaps.includes("read")}
onclick={async () => { href="/access"
route("/access");
}}
/> />
<Tile <Tile
title={i18next.t("home_policies_title")} title={i18next.t("home_policies_title")}
description={i18next.t("home_policies_description")} description={i18next.t("home_policies_description")}
icon="pencil" icon="pencil"
disabled={!this.state.policiesCaps.includes("read")} disabled={!this.state.policiesCaps.includes("read")}
onclick={async () => { href="/policies"
route("/policies");
}}
/> />
</Grid> </Grid>
</Margin> </Margin>

View file

@ -1,13 +1,12 @@
import { Button } from "../../elements/Button"; import { Button } from "../../elements/Button";
import { Component } from "preact"; import { Component } from "preact";
import { DefaultPageProps } from "../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { InlineButtonBox } from "../../elements/InlineButtonBox";
import { Margin } from "../../elements/Margin"; import { Margin } from "../../elements/Margin";
import { PageTitle } from "../../elements/PageTitle"; import { PageTitle } from "../../elements/PageTitle";
import { policyNewURL, policyViewURL } from "../pageLinks"; import { policyNewURL, policyViewURL } from "../pageLinks";
import { route } from "preact-router";
import { sendErrorNotification } from "../../elements/ErrorMessage"; import { sendErrorNotification } from "../../elements/ErrorMessage";
import i18next from "i18next"; import i18next from "i18next";
import { InlineButtonBox } from "../../elements/InlineButtonBox";
export class PoliciesHome extends Component<DefaultPageProps, { policies: string[] }> { export class PoliciesHome extends Component<DefaultPageProps, { policies: string[] }> {
async componentDidMount() { async componentDidMount() {
@ -41,13 +40,7 @@ export class PoliciesHome extends Component<DefaultPageProps, { policies: string
<ul class="uk-nav uk-nav-default"> <ul class="uk-nav uk-nav-default">
{this.state.policies.map((policyName: string) => ( {this.state.policies.map((policyName: string) => (
<li> <li>
<a <a href={policyViewURL(policyName)}>{policyName}</a>
onClick={async () => {
route(policyViewURL(policyName));
}}
>
{policyName}
</a>
</li> </li>
))} ))}
</ul> </ul>

View file

@ -2,12 +2,12 @@ import { Button } from "../../elements/Button";
import { CodeBlock } from "../../elements/CodeBlock"; import { CodeBlock } from "../../elements/CodeBlock";
import { Component } from "preact"; import { Component } from "preact";
import { DefaultPageProps } from "../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { InlineButtonBox } from "../../elements/InlineButtonBox";
import { Margin } from "../../elements/Margin"; import { Margin } from "../../elements/Margin";
import { PageTitle } from "../../elements/PageTitle"; import { PageTitle } from "../../elements/PageTitle";
import { policyDeleteURL, policyEditURL } from "../pageLinks"; import { policyDeleteURL, policyEditURL } from "../pageLinks";
import { sendErrorNotification } from "../../elements/ErrorMessage"; import { sendErrorNotification } from "../../elements/ErrorMessage";
import i18next from "i18next"; import i18next from "i18next";
import { InlineButtonBox } from "../../elements/InlineButtonBox";
export class PolicyView extends Component< export class PolicyView extends Component<
DefaultPageProps, DefaultPageProps,

View file

@ -14,10 +14,10 @@ import {
toPrismCode, toPrismCode,
} from "../../../../utils/dataInterchange"; } from "../../../../utils/dataInterchange";
import { combineKVPath, splitKVPath } from "./kvPathUtils"; import { combineKVPath, splitKVPath } from "./kvPathUtils";
import { kvViewURL } from "../../pageLinks";
import { route } from "preact-router";
import { sortedObjectMap } from "../../../../utils"; import { sortedObjectMap } from "../../../../utils";
import i18next from "i18next"; import i18next from "i18next";
import { route } from "preact-router";
import { kvViewURL } from "../../pageLinks";
export type KVEditProps = DefaultPageProps & { export type KVEditProps = DefaultPageProps & {
baseMount: string; baseMount: string;

View file

@ -2,15 +2,14 @@ import { Button } from "../../../elements/Button";
import { Component, JSX, createRef } from "preact"; import { Component, JSX, createRef } from "preact";
import { DefaultPageProps } from "../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../types/DefaultPageProps";
import { DoesNotExistError } from "../../../../types/internalErrors"; import { DoesNotExistError } from "../../../../types/internalErrors";
import { InlineButtonBox } from "../../../elements/InlineButtonBox";
import { Margin } from "../../../elements/Margin"; import { Margin } from "../../../elements/Margin";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { TextInput } from "../../../elements/forms/TextInput"; import { TextInput } from "../../../elements/forms/TextInput";
import { combineKVPath, splitKVPath } from "./kvPathUtils"; import { combineKVPath, splitKVPath } from "./kvPathUtils";
import { delSecretsEngineURL, kvListURL, kvNewURL, kvViewURL } from "../../pageLinks"; import { delSecretsEngineURL, kvListURL, kvNewURL, kvViewURL } from "../../pageLinks";
import { route } from "preact-router";
import { sendErrorNotification } from "../../../elements/ErrorMessage"; import { sendErrorNotification } from "../../../elements/ErrorMessage";
import i18next from "i18next"; import i18next from "i18next";
import { InlineButtonBox } from "../../../elements/InlineButtonBox";
export type KVKeysListProps = DefaultPageProps & { export type KVKeysListProps = DefaultPageProps & {
baseMount: string; baseMount: string;
@ -24,22 +23,21 @@ type KVKeysListState = {
}; };
function SecretsList(baseMount: string, secretPath: string[], secrets: string[]): JSX.Element[] { function SecretsList(baseMount: string, secretPath: string[], secrets: string[]): JSX.Element[] {
return secrets.map((secret) => ( return secrets.map((secret) => {
<li> let link = "";
<a const combined = combineKVPath(secretPath, secret);
onClick={async () => { if (secret.endsWith("/")) {
const combined = combineKVPath(secretPath, secret); link = kvListURL(baseMount, [...combined.secretPath, combined.secretItem]);
if (secret.endsWith("/")) { } else {
route(kvListURL(baseMount, [...combined.secretPath, combined.secretItem])); link = kvViewURL(baseMount, combined.secretPath, combined.secretItem);
} else { }
route(kvViewURL(baseMount, combined.secretPath, combined.secretItem));
} return (
}} <li>
> <a href={link}>{secret}</a>
{secret} </li>
</a> );
</li> });
));
} }
export class KVKeysList extends Component<KVKeysListProps, KVKeysListState> { export class KVKeysList extends Component<KVKeysListProps, KVKeysListState> {

View file

@ -3,7 +3,6 @@ import { DefaultPageProps } from "../../../../types/DefaultPageProps";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { kvViewURL } from "../../pageLinks"; import { kvViewURL } from "../../pageLinks";
import { objectToMap } from "../../../../utils"; import { objectToMap } from "../../../../utils";
import { route } from "preact-router";
import { sendErrorNotification } from "../../../elements/ErrorMessage"; import { sendErrorNotification } from "../../../elements/ErrorMessage";
import { splitKVPath } from "./kvPathUtils"; import { splitKVPath } from "./kvPathUtils";
@ -42,13 +41,7 @@ export class KeyValueVersions extends Component<DefaultPageProps, { versions: st
<ul class="uk-nav uk-nav-default"> <ul class="uk-nav uk-nav-default">
{this.state.versions.map((ver) => ( {this.state.versions.map((ver) => (
<li> <li>
<a <a href={kvViewURL(baseMount, secretPath, secretItem, ver)}>{`v${ver}`}</a>
onClick={async () => {
route(kvViewURL(baseMount, secretPath, secretItem, ver));
}}
>
{`v${ver}`}
</a>
</li> </li>
))} ))}
</ul> </ul>

View file

@ -240,7 +240,7 @@ export class KeyValueView extends Component<DefaultPageProps, KeyValueViewState>
this.state.secretItem, this.state.secretItem,
this.state.secretVersion, this.state.secretVersion,
); );
// Is there a better way to force refresh of a Component? // TODO: Is there a better way to force refresh of a Component?
this.setState({}); this.setState({});
await this.componentDidMount(); await this.componentDidMount();
}} }}

View file

@ -3,7 +3,6 @@ import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { Grid, GridSizes } from "../../elements/Grid"; import { Grid, GridSizes } from "../../elements/Grid";
import { PageTitle } from "../../elements/PageTitle"; import { PageTitle } from "../../elements/PageTitle";
import { Tile } from "../../elements/Tile"; import { Tile } from "../../elements/Tile";
import { route } from "preact-router";
import i18next from "i18next"; import i18next from "i18next";
export class NewSecretsEngine extends Component<DefaultPageProps> { export class NewSecretsEngine extends Component<DefaultPageProps> {
@ -15,23 +14,17 @@ export class NewSecretsEngine extends Component<DefaultPageProps> {
<Tile <Tile
title={i18next.t("new_secrets_engine_kv_title")} title={i18next.t("new_secrets_engine_kv_title")}
description={i18next.t("new_secrets_engine_kv_description")} description={i18next.t("new_secrets_engine_kv_description")}
onclick={async () => { href="/secrets/new_secrets_engine/kv"
route("/secrets/new_secrets_engine/kv");
}}
/> />
<Tile <Tile
title={i18next.t("new_secrets_engine_totp_title")} title={i18next.t("new_secrets_engine_totp_title")}
description={i18next.t("new_secrets_engine_totp_description")} description={i18next.t("new_secrets_engine_totp_description")}
onclick={async () => { href="/secrets/new_secrets_engine/totp"
route("/secrets/new_secrets_engine/totp");
}}
/> />
<Tile <Tile
title={i18next.t("new_secrets_engine_transit_title")} title={i18next.t("new_secrets_engine_transit_title")}
description={i18next.t("new_secrets_engine_transit_description")} description={i18next.t("new_secrets_engine_transit_description")}
onclick={async () => { href="/secrets/new_secrets_engine/transit"
route("/secrets/new_secrets_engine/transit");
}}
/> />
</Grid> </Grid>
</> </>

View file

@ -1,6 +1,5 @@
import { JSX } from "preact/jsx-runtime"; import { JSX } from "preact/jsx-runtime";
import { kvListURL, kvViewURL, transitViewSecretURL } from "../pageLinks"; import { kvListURL, kvViewURL, transitViewSecretURL } from "../pageLinks";
import { route } from "preact-router";
type SecretTitleElementProps = { type SecretTitleElementProps = {
type: string; type: string;
@ -20,12 +19,7 @@ export function SecretTitleElement(props: SecretTitleElementProps): JSX.Element
return ( return (
<h3 class="uk-card-title" id="pageTitle"> <h3 class="uk-card-title" id="pageTitle">
<div> <div>
<a <a test-data="secrets-title-first-slash" href="/secrets">
test-data="secrets-title-first-slash"
onClick={async () => {
route("/secrets");
}}
>
{"/ "} {"/ "}
</a> </a>
@ -37,16 +31,12 @@ export function SecretTitleElement(props: SecretTitleElementProps): JSX.Element
// Sometimes we pass a extra / in urls // Sometimes we pass a extra / in urls
// just ignore this. // just ignore this.
if (secretPath.length < 1) return; if (secretPath.length < 1) return;
if (type != "kv") return;
return ( return (
<a <a
test-data="secrets-title-secretPath" test-data="secrets-title-secretPath"
onClick={async () => { href={kvListURL(baseMount, secretPaths.slice(0, index + 1))}
if (type == "kv") {
const secretPath = secretPaths.slice(0, index + 1);
route(kvListURL(baseMount, secretPath));
}
}}
> >
{secretPath + "/" + " "} {secretPath + "/" + " "}
</a> </a>
@ -55,23 +45,18 @@ export function SecretTitleElement(props: SecretTitleElementProps): JSX.Element
{item.length != 0 && {item.length != 0 &&
(() => { (() => {
if (["kv", "transit"].includes(type)) { if (!["kv", "transit"].includes(type)) {
return (
<a
onClick={() => {
if (type == "kv") {
route(kvViewURL(baseMount, secretPath, item));
} else if (type == "transit") {
route(transitViewSecretURL(baseMount, item));
}
}}
>
{item}
</a>
);
} else {
return <span>{item}</span>; return <span>{item}</span>;
} }
let link = "";
if (type == "kv") {
link = kvViewURL(baseMount, secretPath, item);
} else if (type == "transit") {
link = transitViewSecretURL(baseMount, item);
}
return <a href={link}>{item}</a>;
})()} })()}
{suffix.length != 0 && <span>{suffix}</span>} {suffix.length != 0 && <span>{suffix}</span>}

View file

@ -1,12 +1,12 @@
import { Button } from "../../elements/Button"; import { Button } from "../../elements/Button";
import { Component, JSX } from "preact"; import { Component, JSX } from "preact";
import { DefaultPageProps } from "../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { InlineButtonBox } from "../../elements/InlineButtonBox";
import { MountType } from "../../../api/types/mount"; import { MountType } from "../../../api/types/mount";
import { PageTitle } from "../../elements/PageTitle"; import { PageTitle } from "../../elements/PageTitle";
import { sendErrorNotification } from "../../elements/ErrorMessage"; import { sendErrorNotification } from "../../elements/ErrorMessage";
import { sortedObjectMap } from "../../../utils"; import { sortedObjectMap } from "../../../utils";
import i18next from "i18next"; import i18next from "i18next";
import { InlineButtonBox } from "../../elements/InlineButtonBox";
const supportedMountTypes = ["kv", "totp", "transit", "cubbyhole"]; const supportedMountTypes = ["kv", "totp", "transit", "cubbyhole"];
@ -91,7 +91,7 @@ export class Secrets extends Component<DefaultPageProps, SecretsState> {
)} )}
</InlineButtonBox> </InlineButtonBox>
<div class="uk-margin-top"> <div class="uk-margin-top">
<ul class="uk-nav uk-nav-default"> <ul class="uk-nav">
{Array.from(this.state.mountsMap).map((args: [string, MountType]) => { {Array.from(this.state.mountsMap).map((args: [string, MountType]) => {
const baseMount = args[0]; const baseMount = args[0];
const mount = args[1]; const mount = args[1];

View file

@ -4,7 +4,7 @@ import { Component, JSX, createRef } from "preact";
import { CopyableInputBox } from "../../../elements/CopyableInputBox"; import { CopyableInputBox } from "../../../elements/CopyableInputBox";
import { DefaultPageProps } from "../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../types/DefaultPageProps";
import { Grid, GridSizes } from "../../../elements/Grid"; import { Grid, GridSizes } from "../../../elements/Grid";
import { Margin } from "../../../elements/Margin"; import { InlineButtonBox } from "../../../elements/InlineButtonBox";
import { MarginInline } from "../../../elements/MarginInline"; import { MarginInline } from "../../../elements/MarginInline";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { TextInput } from "../../../elements/forms/TextInput"; import { TextInput } from "../../../elements/forms/TextInput";
@ -17,7 +17,6 @@ import {
import { removeDoubleSlash } from "../../../../utils"; import { removeDoubleSlash } from "../../../../utils";
import { sendErrorNotification } from "../../../elements/ErrorMessage"; import { sendErrorNotification } from "../../../elements/ErrorMessage";
import i18next from "i18next"; import i18next from "i18next";
import { InlineButtonBox } from "../../../elements/InlineButtonBox";
type TOTPGridItemProps = DefaultPageProps & { type TOTPGridItemProps = DefaultPageProps & {
baseMount: string; baseMount: string;
@ -106,18 +105,21 @@ export class TOTPListView extends Component<TOTPListViewProps, TOTPListViewState
return ( return (
<> <>
<Margin> <br />
<TextInput
inputRef={this.searchBarRef} <TextInput
name="path" inputRef={this.searchBarRef}
placeholder={i18next.t("totp_list_search_input_text")} name="path"
onInput={async () => { placeholder={i18next.t("totp_list_search_input_text")}
this.setState({ onInput={async () => {
searchQuery: this.searchBarRef.current.value, this.setState({
}); searchQuery: this.searchBarRef.current.value,
}} });
/> }}
</Margin> />
<br />
<br />
{this.props.totpItems.map((totpItem) => { {this.props.totpItems.map((totpItem) => {
if (this.state.searchQuery.length > 0) { if (this.state.searchQuery.length > 0) {

View file

@ -2,12 +2,11 @@ import { Button } from "../../../elements/Button";
import { CapabilitiesType } from "../../../../api/types/capabilities"; import { CapabilitiesType } from "../../../../api/types/capabilities";
import { Component, JSX } from "preact"; import { Component, JSX } from "preact";
import { DefaultPageProps } from "../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../types/DefaultPageProps";
import { InlineButtonBox } from "../../../elements/InlineButtonBox";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { delSecretsEngineURL, transitNewSecretURL, transitViewSecretURL } from "../../pageLinks"; import { delSecretsEngineURL, transitNewSecretURL, transitViewSecretURL } from "../../pageLinks";
import { route } from "preact-router";
import { sendErrorNotification } from "../../../elements/ErrorMessage"; import { sendErrorNotification } from "../../../elements/ErrorMessage";
import i18next from "i18next"; import i18next from "i18next";
import { InlineButtonBox } from "../../../elements/InlineButtonBox";
type TransitViewListState = { type TransitViewListState = {
contentLoaded: boolean; contentLoaded: boolean;
@ -58,13 +57,7 @@ export class TransitViewListItem extends Component<
<ul class="uk-nav uk-nav-default"> <ul class="uk-nav uk-nav-default">
{...this.state.transitKeysList.map((key) => ( {...this.state.transitKeysList.map((key) => (
<li> <li>
<a <a href={transitViewSecretURL(this.props.baseMount, key)}>{key}</a>
onClick={async () => {
route(transitViewSecretURL(this.props.baseMount, key));
}}
>
{key}
</a>
</li> </li>
))} ))}
</ul> </ul>

View file

@ -4,7 +4,6 @@ import { Grid, GridSizes } from "../../../elements/Grid";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { Tile } from "../../../elements/Tile"; import { Tile } from "../../../elements/Tile";
import { TransitKeyType } from "../../../../api/types/transit"; import { TransitKeyType } from "../../../../api/types/transit";
import { route } from "preact-router";
import { sendErrorNotification } from "../../../elements/ErrorMessage"; import { sendErrorNotification } from "../../../elements/ErrorMessage";
import { import {
transitDecryptSecretURL, transitDecryptSecretURL,
@ -43,7 +42,7 @@ export class TransitView extends Component<DefaultPageProps, { transitKey: Trans
description={i18next.t("transit_view_encrypt_description")} description={i18next.t("transit_view_encrypt_description")}
icon="lock" icon="lock"
iconText={i18next.t("transit_view_encrypt_icon_text")} iconText={i18next.t("transit_view_encrypt_icon_text")}
onclick={async () => route(transitEncryptSecretURL(baseMount, secretItem))} href={transitEncryptSecretURL(baseMount, secretItem)}
/> />
)} )}
{transitKey.supports_decryption && ( {transitKey.supports_decryption && (
@ -52,7 +51,7 @@ export class TransitView extends Component<DefaultPageProps, { transitKey: Trans
description={i18next.t("transit_view_decrypt_description")} description={i18next.t("transit_view_decrypt_description")}
icon="mail" icon="mail"
iconText={i18next.t("transit_view_decrypt_icon_text")} iconText={i18next.t("transit_view_decrypt_icon_text")}
onclick={() => route(transitDecryptSecretURL(baseMount, secretItem))} href={transitDecryptSecretURL(baseMount, secretItem)}
/> />
)} )}
{transitKey.supports_decryption && ( {transitKey.supports_decryption && (
@ -61,7 +60,7 @@ export class TransitView extends Component<DefaultPageProps, { transitKey: Trans
description={i18next.t("transit_view_rewrap_description")} description={i18next.t("transit_view_rewrap_description")}
icon="code" icon="code"
iconText={i18next.t("transit_view_rewrap_icon_text")} iconText={i18next.t("transit_view_rewrap_icon_text")}
onclick={async () => route(transitRewrapSecretURL(baseMount, secretItem))} href={transitRewrapSecretURL(baseMount, secretItem)}
/> />
)} )}
</Grid> </Grid>

View file

@ -2,8 +2,8 @@ import { Component } from "preact";
import { DefaultPageProps } from "../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../types/DefaultPageProps";
export class KVLoadExportSettings extends Component<DefaultPageProps> { export class KVLoadExportSettings extends Component<DefaultPageProps> {
render() { render() {
// TODO: Do This // TODO: Do This
return <></>; return <></>;
} }
} }

View file

@ -6,7 +6,6 @@ import { KeyValueSettings } from "./KeyValue/KeyValueSettings";
import { PageTitle } from "../../elements/PageTitle"; import { PageTitle } from "../../elements/PageTitle";
import UIkit from "uikit"; import UIkit from "uikit";
import i18next from "i18next"; import i18next from "i18next";
import { KVLoadExportSettings } from "./KVLoadExportSettings";
export function settingsSavedNotification() { export function settingsSavedNotification() {
UIkit.notification(i18next.t("settings_saved_notification"), { UIkit.notification(i18next.t("settings_saved_notification"), {