From 0a5eedbaea6a0ba877f9b03d1ab72c5b1f2d558c Mon Sep 17 00:00:00 2001 From: Christoph Stenglein Date: Sat, 11 Jun 2022 13:15:51 +0200 Subject: [PATCH 1/2] add tooltip with login information for installed apps --- src/assets/info.svg | 5 -- ...info-circle.svg => information-circle.svg} | 6 +- src/components/Apps/AppCard/AppCard.test.tsx | 32 ++++++++--- src/components/Apps/AppCard/AppCard.tsx | 55 +++++++++++++++---- .../Home/TransactionCard/TransactionCard.tsx | 2 +- src/i18n/langs/en.json | 7 ++- src/models/app-status.ts | 13 ++++- src/models/app.model.ts | 3 + src/pages/Apps.tsx | 48 ++++++---------- 9 files changed, 111 insertions(+), 60 deletions(-) delete mode 100644 src/assets/info.svg rename src/assets/{info-circle.svg => information-circle.svg} (51%) diff --git a/src/assets/info.svg b/src/assets/info.svg deleted file mode 100644 index 3829ab4e..00000000 --- a/src/assets/info.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - \ No newline at end of file diff --git a/src/assets/info-circle.svg b/src/assets/information-circle.svg similarity index 51% rename from src/assets/info-circle.svg rename to src/assets/information-circle.svg index 7b24efb6..6e0bebc0 100644 --- a/src/assets/info-circle.svg +++ b/src/assets/information-circle.svg @@ -1,3 +1,5 @@ - - + + \ No newline at end of file diff --git a/src/components/Apps/AppCard/AppCard.test.tsx b/src/components/Apps/AppCard/AppCard.test.tsx index 2269b049..532fc1b7 100644 --- a/src/components/Apps/AppCard/AppCard.test.tsx +++ b/src/components/Apps/AppCard/AppCard.test.tsx @@ -1,17 +1,35 @@ -import { render, screen, act } from "@testing-library/react"; +import { render, screen } from "@testing-library/react"; import { I18nextProvider } from "react-i18next"; import i18n from "../../../i18n/test_config"; -import { AppCard } from "./AppCard"; +import { AppStatus, AuthMethod } from "../../../models/app-status"; +import { App } from "../../../models/app.model"; +import { AppCard, Props } from "./AppCard"; -const app = { +const app: App = { id: "123", - description: "Hi", - name: "d", + author: "Me", + name: "someApp", + repository: "http://example.com", + version: "1.0.0", }; -const basicProps = { +const appStatus: AppStatus = { + id: "123", + installed: false, + address: "", + authMethod: AuthMethod.NONE, + details: "", + hiddenService: "", + httpsForced: "0", + httpsSelfsigned: "0", + error: "", +}; + +const basicProps: Props = { installingApp: null, - app: app, + appInfo: app, + appStatusInfo: appStatus, + installed: false, onInstall: () => {}, onOpenDetails: () => {}, }; diff --git a/src/components/Apps/AppCard/AppCard.tsx b/src/components/Apps/AppCard/AppCard.tsx index be9cfb66..7ae97cb9 100644 --- a/src/components/Apps/AppCard/AppCard.tsx +++ b/src/components/Apps/AppCard/AppCard.tsx @@ -1,14 +1,19 @@ -import { FC, useState, useEffect } from "react"; +import Tooltip from "rc-tooltip"; +import { FC, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; -import { ReactComponent as InfoIcon } from "../../../assets/info.svg"; +import { ReactComponent as InfoIcon } from "../../../assets/information-circle.svg"; import { ReactComponent as LinkIcon } from "../../../assets/link.svg"; +import { ReactComponent as LockIcon } from "../../../assets/lock-open.svg"; import { ReactComponent as PlusIcon } from "../../../assets/plus.svg"; import AppIcon from "../../../container/AppIcon/AppIcon"; +import { AppStatus, AuthMethod } from "../../../models/app-status"; import { App } from "../../../models/app.model"; + import ButtonWithSpinner from "../../Shared/ButtonWithSpinner/ButtonWithSpinner"; -type Props = { - app: App; +export type Props = { + appInfo: App; + appStatusInfo: AppStatus; installed: boolean; installingApp: any | null; address?: string; @@ -18,15 +23,15 @@ type Props = { }; export const AppCard: FC = ({ - app, + appInfo, + appStatusInfo, installed, installingApp, onInstall, onOpenDetails, address, - hiddenService, }) => { - const { id, name } = app; + const { id, name } = appInfo; const { t } = useTranslation(); const [isInstallWaiting, setInstallWaiting] = useState(false); @@ -39,6 +44,27 @@ export const AppCard: FC = ({ onInstall(id); }; + const tooltipContent = ( +
+ {appStatusInfo.httpsForced === "1" && + appStatusInfo.httpsSelfsigned === "1" && ( +

{t("apps.selfsigned_cert")}

+ )} + {appStatusInfo.authMethod === AuthMethod.NONE && ( +

{t("apps.login_no_pass")}

+ )} + {appStatusInfo.authMethod === AuthMethod.PASSWORD_B && ( +

{t("apps.login_pass_b")}

+ )} + {appStatusInfo.authMethod === AuthMethod.USER_ADMIN_PASSWORD_B && ( +

{t("apps.login_admin_pass_b")}

+ )} + {appStatusInfo.authMethod === AuthMethod.USER_DEFINED && ( +

{t("apps.login_userdef")}

+ )} +
+ ); + return (
@@ -47,11 +73,16 @@ export const AppCard: FC = ({
{/* Content */} -
-
{name}
-
+
+

{name}

+ {installed && ( + + + + )} +

{t(`appInfo.${id}.shortDescription`)} -

+

@@ -103,7 +134,7 @@ export const AppCard: FC = ({ )}