From 1ad982dda9c522dba0ca825a2368c5e21bb9887d Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Fri, 2 May 2025 18:00:43 +0200 Subject: [PATCH 1/2] feat: add guest auth prompt component Signed-off-by: skjnldsv [skip ci] --- l10n/messages.pot | 24 +++ lib/components/PublicAuthPrompt.vue | 223 ++++++++++++++++++++++++++++ lib/public-auth.ts | 28 ++++ package-lock.json | 8 + package.json | 1 + 5 files changed, 284 insertions(+) create mode 100644 lib/components/PublicAuthPrompt.vue create mode 100644 lib/public-auth.ts diff --git a/l10n/messages.pot b/l10n/messages.pot index 685520ecd..d4f84560c 100644 --- a/l10n/messages.pot +++ b/l10n/messages.pot @@ -14,6 +14,9 @@ msgstr "" msgid "All files" msgstr "" +msgid "Cancel" +msgstr "" + msgid "Choose" msgstr "" @@ -46,6 +49,12 @@ msgstr "" msgid "Current view selector" msgstr "" +msgid "Enter your name" +msgstr "" + +msgid "Failed to set nickname." +msgstr "" + msgid "Favorites" msgstr "" @@ -61,6 +70,9 @@ msgstr "" msgid "Folder name cannot be empty." msgstr "" +msgid "Guest identification" +msgstr "" + msgid "Home" msgstr "" @@ -94,6 +106,9 @@ msgstr "" msgid "No matching files" msgstr "" +msgid "Please enter a name with at least 2 characters." +msgstr "" + msgid "Recent" msgstr "" @@ -109,8 +124,17 @@ msgstr "" msgid "Size" msgstr "" +msgid "Submit name" +msgstr "" + msgid "Undo" msgstr "" msgid "Upload some content or sync with your devices!" msgstr "" + +msgid "You are currently not identified." +msgstr "" + +msgid "You cannot leave the name empty." +msgstr "" diff --git a/lib/components/PublicAuthPrompt.vue b/lib/components/PublicAuthPrompt.vue new file mode 100644 index 000000000..1d3ee5748 --- /dev/null +++ b/lib/components/PublicAuthPrompt.vue @@ -0,0 +1,223 @@ + + + + + + diff --git a/lib/public-auth.ts b/lib/public-auth.ts new file mode 100644 index 000000000..31c128d9a --- /dev/null +++ b/lib/public-auth.ts @@ -0,0 +1,28 @@ +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import type { ComponentProps } from 'vue-component-type-helpers' +import { defineAsyncComponent } from 'vue' +import { spawnDialog } from '@nextcloud/vue/functions/dialog' + +import type PublicAuthPrompt from './components/PublicAuthPrompt.vue' + +type PublicAuthPromptProps = ComponentProps + +/** + * Show the public auth prompt dialog + * This is used to ask the current user their nickname + * as well as show some additional contextual information + * @param props The props to pass to the dialog, see PublicAuthPrompt.vue for details + */ +export function showGuestUserPrompt(props: PublicAuthPromptProps) { + return new Promise((resolve) => { + spawnDialog( + defineAsyncComponent(() => import('./components/PublicAuthPrompt.vue')), + props, + resolve, + ) + }) +} diff --git a/package-lock.json b/package-lock.json index 6ae5346c9..ddabb13f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@mdi/js": "^7.4.47", "@nextcloud/auth": "^2.4.0", "@nextcloud/axios": "^2.5.1", + "@nextcloud/browser-storage": "^0.4.0", "@nextcloud/event-bus": "^3.3.2", "@nextcloud/files": "^3.10.2", "@nextcloud/initial-state": "^2.2.0", @@ -12059,6 +12060,13 @@ "dev": true, "license": "MIT" }, + "node_modules/vue-component-type-helpers": { + "version": "2.2.10", + "resolved": "https://registry.npmjs.org/vue-component-type-helpers/-/vue-component-type-helpers-2.2.10.tgz", + "integrity": "sha512-iDUO7uQK+Sab2tYuiP9D1oLujCWlhHELHMgV/cB13cuGbG4qwkLHvtfWb6FzvxrIOPDnU0oHsz2MlQjhYDeaHA==", + "dev": true, + "license": "MIT" + }, "node_modules/vue-eslint-parser": { "version": "10.1.3", "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-10.1.3.tgz", diff --git a/package.json b/package.json index 20d524d68..b94981dda 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "@mdi/js": "^7.4.47", "@nextcloud/auth": "^2.4.0", "@nextcloud/axios": "^2.5.1", + "@nextcloud/browser-storage": "^0.4.0", "@nextcloud/event-bus": "^3.3.2", "@nextcloud/files": "^3.10.2", "@nextcloud/initial-state": "^2.2.0", From 4453fd229acc2e556e261087eeb6db4bf1af8dec Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sun, 11 May 2025 16:52:05 +0200 Subject: [PATCH 2/2] refactor(PublicAuthPrompt): adjust code style to match the library (script-setup) Signed-off-by: Ferdinand Thiessen --- lib/components/PublicAuthPrompt.vue | 295 ++++++++++++---------------- lib/public-auth.ts | 7 +- package-lock.json | 7 - tsconfig.json | 3 +- 4 files changed, 131 insertions(+), 181 deletions(-) diff --git a/lib/components/PublicAuthPrompt.vue b/lib/components/PublicAuthPrompt.vue index 1d3ee5748..48bc7306d 100644 --- a/lib/components/PublicAuthPrompt.vue +++ b/lib/components/PublicAuthPrompt.vue @@ -3,8 +3,134 @@ - SPDX-License-Identifier: AGPL-3.0-or-later --> + + -