From eddc01fc35bead09a9148bfcaf1932fa63e47ffc Mon Sep 17 00:00:00 2001 From: ChaotiCryptidz Date: Sun, 28 Aug 2022 16:08:24 +0100 Subject: [PATCH] make non-action links use href instead of onClick --- package.json | 68 +++++++++---------- src/settings/Settings.ts | 2 +- src/ui/elements/Button.tsx | 13 +--- src/ui/elements/CopyableBox.tsx | 2 +- src/ui/elements/InlineButtonBox.tsx | 4 +- src/ui/elements/NavBar.tsx | 8 +-- src/ui/elements/Tile.tsx | 12 +++- src/ui/pages/Access/AccessHome.tsx | 10 ++- src/ui/pages/Access/Auth/AuthHome.tsx | 20 ++---- .../Access/Auth/userpass/UserPassUserView.tsx | 2 +- .../Auth/userpass/UserPassUsersList.tsx | 9 +-- src/ui/pages/Home.tsx | 12 +--- src/ui/pages/Policies/PoliciesHome.tsx | 11 +-- src/ui/pages/Policies/PolicyView.tsx | 2 +- .../pages/Secrets/KeyValue/KeyValueEdit.tsx | 4 +- .../pages/Secrets/KeyValue/KeyValueList.tsx | 34 +++++----- .../Secrets/KeyValue/KeyValueVersions.tsx | 9 +-- .../pages/Secrets/KeyValue/KeyValueView.tsx | 2 +- src/ui/pages/Secrets/NewSecretsEngine.tsx | 13 +--- src/ui/pages/Secrets/SecretTitleElement.tsx | 41 ++++------- src/ui/pages/Secrets/SecretsHome.tsx | 4 +- src/ui/pages/Secrets/TOTP/TOTPList.tsx | 30 ++++---- src/ui/pages/Secrets/Transit/TransitList.tsx | 11 +-- src/ui/pages/Secrets/Transit/TransitView.tsx | 7 +- .../pages/Settings/KVLoadExportSettings.tsx | 8 +-- src/ui/pages/Settings/Settings.tsx | 1 - 26 files changed, 131 insertions(+), 208 deletions(-) diff --git a/package.json b/package.json index fd9c2d2..e9041b9 100644 --- a/package.json +++ b/package.json @@ -2,54 +2,54 @@ "name": "vaultui", "version": "latest", "devDependencies": { - "@babel/core": "^7.17.5", - "@babel/eslint-parser": "^7.17.0", - "@babel/plugin-proposal-class-properties": "^7.16.7", - "@babel/plugin-proposal-decorators": "^7.17.2", - "@babel/plugin-proposal-object-rest-spread": "^7.17.3", - "@babel/plugin-syntax-import-assertions": "^7.16.7", - "@babel/plugin-transform-runtime": "^7.17.0", - "@babel/preset-env": "^7.16.11", + "@babel/core": "^7.18.13", + "@babel/eslint-parser": "^7.18.9", + "@babel/plugin-proposal-class-properties": "^7.18.6", + "@babel/plugin-proposal-decorators": "^7.18.10", + "@babel/plugin-proposal-object-rest-spread": "^7.18.9", + "@babel/plugin-syntax-import-assertions": "^7.18.6", + "@babel/plugin-transform-runtime": "^7.18.10", + "@babel/preset-env": "^7.18.10", "@types/file-saver": "^2.0.5", "@types/js-yaml": "^4.0.5", "@types/prismjs": "^1.26.0", - "@types/uikit": "^3.3.2", - "@typescript-eslint/eslint-plugin": "^5.13.0", - "@typescript-eslint/parser": "^5.13.0", - "babel-loader": "^8.2.3", - "css-loader": "^6.6.0", - "css-minimizer-webpack-plugin": "^3.4.1", - "eslint": "^8.10.0", + "@types/uikit": "^3.14.0", + "@typescript-eslint/eslint-plugin": "^5.35.1", + "@typescript-eslint/parser": "^5.35.1", + "babel-loader": "^8.2.5", + "css-loader": "^6.7.1", + "css-minimizer-webpack-plugin": "^4.0.0", + "eslint": "^8.23.0", "eslint-config-prettier": "^8.5.0", - "eslint-plugin-import": "^2.25.4", - "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-sort-imports-es6-autofix": "^0.6.0", "git-revision-webpack-plugin": "^5.0.0", "html-webpack-plugin": "^5.5.0", "node-sass": "^7.0.1", - "prettier": "^2.5.1", + "prettier": "^2.7.1", "raw-loader": "^4.0.2", - "sass-loader": "^12.6.0", - "ts-loader": "^9.2.7", - "typescript": "^4.6.2", - "webpack": "^5.69.1", - "webpack-cli": "^4.9.2", - "webpack-dev-server": "^4.7.4" + "sass-loader": "^13.0.2", + "ts-loader": "^9.3.1", + "typescript": "^4.8.2", + "webpack": "^5.74.0", + "webpack-cli": "^4.10.0", + "webpack-dev-server": "^4.10.0" }, "dependencies": { - "clipboard": "^2.0.10", - "codejar": "^3.5.0", - "core-js": "^3.21.1", - "date-fns": "^2.28.0", + "clipboard": "^2.0.11", + "codejar": "^3.6.0", + "core-js": "^3.25.0", + "date-fns": "^2.29.2", "file-saver": "^2.0.5", - "i18next": "^21.6.13", + "i18next": "^21.9.1", "js-yaml": "^4.1.0", - "json5": "^2.2.0", + "json5": "^2.2.1", "normalize.css": "^8.0.1", - "preact": "^10.6.6", - "preact-router": "^4.0.1", - "prismjs": "^1.27.0", + "preact": "^10.10.6", + "preact-router": "^4.1.0", + "prismjs": "^1.29.0", "qr-scanner": "^1.4.1", - "uikit": "^3.11.1" + "uikit": "^3.15.5" } } diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index 32af5a1..9f37b16 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -60,7 +60,7 @@ export class Settings { kvViewDefaultLanguage: this.kvViewDefaultLanguage, kvViewIndent: this.kvViewIndent, kvHideKeyValues: this.kvHideKeyValues, - } + }; } loadSettings(settings: Partial) { diff --git a/src/ui/elements/Button.tsx b/src/ui/elements/Button.tsx index d066cda..52780e7 100644 --- a/src/ui/elements/Button.tsx +++ b/src/ui/elements/Button.tsx @@ -1,5 +1,4 @@ import { JSX, RefObject } from "preact"; -import { route } from "preact-router"; export type ButtonProps = { color: "primary" | "danger" | "secondary"; @@ -15,17 +14,9 @@ export function Button(props: ButtonProps): JSX.Element { const classes = "uk-button " + ("uk-button-" + props.color); if (props.route) { return ( - + ); } else { return ( diff --git a/src/ui/elements/CopyableBox.tsx b/src/ui/elements/CopyableBox.tsx index 0eebd8f..4aae63b 100644 --- a/src/ui/elements/CopyableBox.tsx +++ b/src/ui/elements/CopyableBox.tsx @@ -1,11 +1,11 @@ import { Button } from "./Button"; import { CodeBlock } from "./CodeBlock"; import { Component, JSX, createRef } from "preact"; +import { InlineButtonBox } from "./InlineButtonBox"; import { addClipboardNotifications } from "../../utils/clipboardNotifs"; import ClipboardJS from "clipboard"; import FileSaver from "file-saver"; import i18next from "i18next"; -import { InlineButtonBox } from "./InlineButtonBox"; export type CopyableBoxProps = { title: string; diff --git a/src/ui/elements/InlineButtonBox.tsx b/src/ui/elements/InlineButtonBox.tsx index b9fd6b7..da3d135 100644 --- a/src/ui/elements/InlineButtonBox.tsx +++ b/src/ui/elements/InlineButtonBox.tsx @@ -1,9 +1,9 @@ import { JSX } from "preact"; export type InlineButtonBoxProps = { - children?: JSX.Element | JSX.Element[]; + children?: JSX.Element | JSX.Element[]; }; export function InlineButtonBox(props: InlineButtonBoxProps): JSX.Element { - return
{props.children}
; + return
{props.children}
; } diff --git a/src/ui/elements/NavBar.tsx b/src/ui/elements/NavBar.tsx index 6983454..0c0a661 100644 --- a/src/ui/elements/NavBar.tsx +++ b/src/ui/elements/NavBar.tsx @@ -34,13 +34,7 @@ export function NavBar(): JSX.Element { diff --git a/src/ui/elements/Tile.tsx b/src/ui/elements/Tile.tsx index e03ef20..6d223fc 100644 --- a/src/ui/elements/Tile.tsx +++ b/src/ui/elements/Tile.tsx @@ -1,4 +1,5 @@ import { Component, JSX } from "preact"; +import { notImplementedNotification } from "./ErrorMessage"; export type TileParams = { disabled?: boolean; @@ -7,7 +8,8 @@ export type TileParams = { description: string; icon?: string; iconText?: string; - onclick: () => void; + href?: string; + notImplemented?: boolean; }; export class Tile extends Component { @@ -33,9 +35,15 @@ export class Tile extends Component { if (this.props.disabled == true) { return

{tileInner}

; + } else if (this.props.notImplemented == true) { + return ( + notImplementedNotification()}> + {tileInner} + + ); } else { return ( - + {tileInner} ); diff --git a/src/ui/pages/Access/AccessHome.tsx b/src/ui/pages/Access/AccessHome.tsx index c055e27..71a8abd 100644 --- a/src/ui/pages/Access/AccessHome.tsx +++ b/src/ui/pages/Access/AccessHome.tsx @@ -3,8 +3,6 @@ import { DefaultPageProps } from "../../../types/DefaultPageProps"; import { Grid, GridSizes } from "../../elements/Grid"; import { PageTitle } from "../../elements/PageTitle"; import { Tile } from "../../elements/Tile"; -import { notImplementedNotification } from "../../elements/ErrorMessage"; -import { route } from "preact-router"; import i18next from "i18next"; export class AccessHomePage extends Component { @@ -17,25 +15,25 @@ export class AccessHomePage extends Component { title={i18next.t("access_auth_methods_title")} description={i18next.t("access_auth_methods_description")} icon="sign-in" - onclick={async () => route("/access/auth")} + href="/access/auth" /> notImplementedNotification()} + notImplemented={true} /> notImplementedNotification()} + notImplemented={true} /> notImplementedNotification()} + notImplemented={true} /> diff --git a/src/ui/pages/Access/Auth/AuthHome.tsx b/src/ui/pages/Access/Auth/AuthHome.tsx index e3b2453..08a53a6 100644 --- a/src/ui/pages/Access/Auth/AuthHome.tsx +++ b/src/ui/pages/Access/Auth/AuthHome.tsx @@ -6,7 +6,6 @@ import { PageTitle } from "../../../elements/PageTitle"; import { authViewConfigURL, userPassUserListURL } from "../../pageLinks"; import { notImplementedNotification, sendErrorNotification } from "../../../elements/ErrorMessage"; import { objectToMap } from "../../../../utils"; -import { route } from "preact-router"; import i18next from "i18next"; export type AuthListElementProps = { @@ -17,26 +16,17 @@ export type AuthListElementProps = { export function AuthListElement(props: AuthListElementProps): JSX.Element { const isViewable = ["userpass"].includes(props.method.type); - const onViewClick = (props: AuthListElementProps) => { - if (props.method.type == "userpass") { - route(userPassUserListURL(props.path)); - } - }; + let link = ""; + if (props.method.type == "userpass") { + link = userPassUserListURL(props.path); + } return (
{props.path} {` (${props.method.accessor})`}
- {isViewable && ( -