From 715fbc8fd7b59407d1efaa35aefcb90404efa03b Mon Sep 17 00:00:00 2001 From: Dion Date: Fri, 1 Mar 2024 20:19:46 +0100 Subject: [PATCH 1/6] Preferences & Tooltip UI changes --- .../Helpers/OnStartupSync.cs | 1 + .../preferences-username.spec.tsx | 22 ++++++++++++++++++- .../preferences-username.tsx | 20 +++++++---------- .../src/localization/localization.json | 11 +++++++--- .../clientapp/src/style/css/40-tooltip.css | 6 ++--- 5 files changed, 41 insertions(+), 19 deletions(-) diff --git a/starsky/starsky.feature.syncbackground/Helpers/OnStartupSync.cs b/starsky/starsky.feature.syncbackground/Helpers/OnStartupSync.cs index 181939e14f..e3a27a2290 100644 --- a/starsky/starsky.feature.syncbackground/Helpers/OnStartupSync.cs +++ b/starsky/starsky.feature.syncbackground/Helpers/OnStartupSync.cs @@ -51,6 +51,7 @@ public async Task StartUpSync() { await _backgroundTaskQueue.QueueBackgroundWorkItemAsync(async token => { + await Task.Yield(); await StartUpSyncTask(); }, nameof(StartUpSync)); } diff --git a/starsky/starsky/clientapp/src/components/organisms/preferences-username/preferences-username.spec.tsx b/starsky/starsky/clientapp/src/components/organisms/preferences-username/preferences-username.spec.tsx index ee8795039c..1a45632be6 100644 --- a/starsky/starsky/clientapp/src/components/organisms/preferences-username/preferences-username.spec.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/preferences-username/preferences-username.spec.tsx @@ -1,6 +1,7 @@ import { render, screen } from "@testing-library/react"; import * as useFetch from "../../../hooks/use-fetch"; import { newIConnectionDefault } from "../../../interfaces/IConnectionDefault"; +import localization from "../../../localization/localization.json"; import PreferencesUsername from "./preferences-username"; describe("PreferencesUsername", () => { @@ -45,13 +46,32 @@ describe("PreferencesUsername", () => { }, statusCode: 200 }; + jest.spyOn(useFetch, "default").mockImplementationOnce(() => testReply); + + const component = render(); + expect(screen.queryByTestId("preferences-username-text")?.textContent).toBe("test"); + + component.unmount(); + }); + + it("should get the identifier desktop user", () => { + const testReply = { + ...newIConnectionDefault(), + data: { + credentialsIdentifiers: ["mail@localhost"] + }, + statusCode: 200 + }; jest .spyOn(useFetch, "default") + .mockReset() .mockImplementationOnce(() => testReply) .mockImplementationOnce(() => testReply); const component = render(); - expect(screen.queryByTestId("preferences-username-text")?.textContent).toBe("test"); + expect(screen.queryByTestId("preferences-username-text")?.textContent).toBe( + localization.MessageDesktopMailLocalhostUsername.en + ); component.unmount(); }); diff --git a/starsky/starsky/clientapp/src/components/organisms/preferences-username/preferences-username.tsx b/starsky/starsky/clientapp/src/components/organisms/preferences-username/preferences-username.tsx index cb66e9bb7d..3fb3be8b29 100644 --- a/starsky/starsky/clientapp/src/components/organisms/preferences-username/preferences-username.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/preferences-username/preferences-username.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from "react"; +import React from "react"; import useFetch from "../../../hooks/use-fetch"; import useGlobalSettings from "../../../hooks/use-global-settings"; import localization from "../../../localization/localization.json"; @@ -8,22 +8,18 @@ import { UrlQuery } from "../../../shared/url/url-query"; const PreferencesUsername: React.FunctionComponent = () => { const settings = useGlobalSettings(); const language = new Language(settings.language); - const MessageUnknownUsername = language.key(localization.MessageUnknownUsername); const MessageUsername = language.key(localization.MessageUsername); const MessageRole = language.key(localization.MessageRole); const accountStatus = useFetch(new UrlQuery().UrlAccountStatus(), "get"); - const [userName, setUserName] = React.useState(MessageUnknownUsername); + let userName = language.key(localization.MessageUnknownUsername); - useEffect(() => { - if ( - accountStatus.statusCode !== 200 || - !accountStatus.data?.credentialsIdentifiers || - accountStatus.data.credentialsIdentifiers.length !== 1 - ) - return; - setUserName(accountStatus.data.credentialsIdentifiers[0]); - }, [accountStatus]); + if (accountStatus.statusCode === 200 && accountStatus?.data?.credentialsIdentifiers[0]) { + userName = accountStatus?.data?.credentialsIdentifiers[0]; + if (userName === "mail@localhost") { + userName = language.key(localization.MessageDesktopMailLocalhostUsername); + } + } return ( <> diff --git a/starsky/starsky/clientapp/src/localization/localization.json b/starsky/starsky/clientapp/src/localization/localization.json index 11d2cd9ba1..0624a30ba8 100644 --- a/starsky/starsky/clientapp/src/localization/localization.json +++ b/starsky/starsky/clientapp/src/localization/localization.json @@ -414,6 +414,11 @@ "nl": "Onbekende gebruikersnaam", "de": "Unbekannter Benutzername" }, + "MessageDesktopMailLocalhostUsername": { + "en": "Desktop user", + "nl": "Desktop gebruiker", + "de": "Desktop Benutzer" + }, "MessageUsername": { "en": "Username", "nl": "Gebruikersnaam", @@ -1020,8 +1025,8 @@ "de": "Lesen Sie hier mehr" }, "temp1": { - "en": "More", - "nl": "Meer", - "de": "Mehr" + "en": ".", + "nl": ".", + "de": "." } } diff --git a/starsky/starsky/clientapp/src/style/css/40-tooltip.css b/starsky/starsky/clientapp/src/style/css/40-tooltip.css index ffaad763c8..6271071bb9 100644 --- a/starsky/starsky/clientapp/src/style/css/40-tooltip.css +++ b/starsky/starsky/clientapp/src/style/css/40-tooltip.css @@ -19,8 +19,8 @@ } .tooltip-container.left .tooltip { - left: 70%; - transform: translateX(-30%); + left: 74%; + transform: translateX(-24%); } .tooltip-container .tooltip::after { @@ -35,7 +35,7 @@ } .tooltip-container.left .tooltip::after { - left: 28%; + left: 22%; } .tooltip-container:hover .tooltip { From d97a2dc95c8f8d5e40a93d97c8ff8962b0df879d Mon Sep 17 00:00:00 2001 From: Dion Date: Tue, 5 Mar 2024 12:55:03 +0100 Subject: [PATCH 2/6] undo --- starsky/starsky.feature.syncbackground/Helpers/OnStartupSync.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/starsky/starsky.feature.syncbackground/Helpers/OnStartupSync.cs b/starsky/starsky.feature.syncbackground/Helpers/OnStartupSync.cs index e3a27a2290..181939e14f 100644 --- a/starsky/starsky.feature.syncbackground/Helpers/OnStartupSync.cs +++ b/starsky/starsky.feature.syncbackground/Helpers/OnStartupSync.cs @@ -51,7 +51,6 @@ public async Task StartUpSync() { await _backgroundTaskQueue.QueueBackgroundWorkItemAsync(async token => { - await Task.Yield(); await StartUpSyncTask(); }, nameof(StartUpSync)); } From 877f1a16a2dabcd2e92b74ba0c3b47243b7f13ea Mon Sep 17 00:00:00 2001 From: Dion Date: Tue, 5 Mar 2024 12:58:11 +0100 Subject: [PATCH 3/6] disabel spell check due privacy issues in google chrome --- starsky/starsky/clientapp/src/containers/account-register.tsx | 3 +++ starsky/starsky/clientapp/src/containers/login.tsx | 2 ++ 2 files changed, 5 insertions(+) diff --git a/starsky/starsky/clientapp/src/containers/account-register.tsx b/starsky/starsky/clientapp/src/containers/account-register.tsx index 7f7df84b16..94af36de36 100644 --- a/starsky/starsky/clientapp/src/containers/account-register.tsx +++ b/starsky/starsky/clientapp/src/containers/account-register.tsx @@ -131,6 +131,7 @@ const AccountRegister: FunctionComponent = () => { name="email" maxLength={80} data-test="email" + spellCheck={false} value={userEmail} placeholder={MessageExampleUsername} onChange={(e) => setUserEmail(e.target.value)} @@ -145,6 +146,7 @@ const AccountRegister: FunctionComponent = () => { name="password" data-test="password" maxLength={80} + spellCheck={false} placeholder={MessageExamplePassword} value={userPassword} onChange={(e) => setUserPassword(e.target.value)} @@ -157,6 +159,7 @@ const AccountRegister: FunctionComponent = () => { autoComplete="off" type="password" maxLength={100} + spellCheck={false} name="confirm-password" data-test="confirm-password" value={userConfirmPassword} diff --git a/starsky/starsky/clientapp/src/containers/login.tsx b/starsky/starsky/clientapp/src/containers/login.tsx index 6f2486c44d..e36e5f7f93 100755 --- a/starsky/starsky/clientapp/src/containers/login.tsx +++ b/starsky/starsky/clientapp/src/containers/login.tsx @@ -153,6 +153,7 @@ export const Login: React.FC = () => { data-test="email" name="email" maxLength={80} + spellCheck={false} value={userEmail} placeholder={MessageExampleUsername} onChange={(e) => setUserEmail(e.target.value)} @@ -164,6 +165,7 @@ export const Login: React.FC = () => { data-test="password" name="password" maxLength={80} + spellCheck={false} value={userPassword} placeholder={MessageExamplePassword} onChange={(e) => setUserPassword(e.target.value)} From 88a8801732e4ae1fa287fa003bf2985eb5e2fa49 Mon Sep 17 00:00:00 2001 From: Dion Date: Tue, 5 Mar 2024 12:59:54 +0100 Subject: [PATCH 4/6] add why --- starsky/starsky/clientapp/src/containers/account-register.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/starsky/starsky/clientapp/src/containers/account-register.tsx b/starsky/starsky/clientapp/src/containers/account-register.tsx index 94af36de36..895184cf7f 100644 --- a/starsky/starsky/clientapp/src/containers/account-register.tsx +++ b/starsky/starsky/clientapp/src/containers/account-register.tsx @@ -136,6 +136,7 @@ const AccountRegister: FunctionComponent = () => { placeholder={MessageExampleUsername} onChange={(e) => setUserEmail(e.target.value)} /> + {/* why spellCheck false? https://www.bleepingcomputer.com/news/security/google-microsoft-can-get-your-passwords-via-web-browsers-spellcheck/ */} Date: Tue, 5 Mar 2024 14:07:44 +0100 Subject: [PATCH 5/6] keep a changelog --- history.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/history.md b/history.md index ac33fd0bf3..6f70276d59 100644 --- a/history.md +++ b/history.md @@ -69,6 +69,9 @@ Semantic Versioning 2.0.0 is from version 0.1.6+ #1405) - [x] (Fixed) _Docs_ Make getting started more clear (PR #1422) (Issue #1403) - [x] (Fixed) _Front-end_ Add link to docs page for storage folder (PR #1422) (Issue #1404) +- [x] (Security) _Front-end_ spellcheck false on email and password fields (PR #1430) +- [x] (Fixed) _Front-end_ Tooltip is partly not shown (PR #1430) +- [x] (Changed) _Front-end_ View user friendly name for Default Desktop user (PR #1430) ## version 0.6.0-beta.1 - 2024-02-18 {#v0.6.0-beta.1} From 96aa5560119d68c31db7df1640a8ee9d5d7ebc93 Mon Sep 17 00:00:00 2001 From: Dion Date: Tue, 5 Mar 2024 14:10:24 +0100 Subject: [PATCH 6/6] add back --- history.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/history.md b/history.md index 6f70276d59..9b5d66a1a1 100644 --- a/history.md +++ b/history.md @@ -72,6 +72,8 @@ Semantic Versioning 2.0.0 is from version 0.1.6+ - [x] (Security) _Front-end_ spellcheck false on email and password fields (PR #1430) - [x] (Fixed) _Front-end_ Tooltip is partly not shown (PR #1430) - [x] (Changed) _Front-end_ View user friendly name for Default Desktop user (PR #1430) +- [x] (Changed) _Docs_ Use Google Consent Mode, only for docs, other apps have no Google (PR #1424) + ## version 0.6.0-beta.1 - 2024-02-18 {#v0.6.0-beta.1}