From bdd6395a762f29b46e3fecadb5c7783af57e132a Mon Sep 17 00:00:00 2001 From: matt wilkie Date: Thu, 20 Feb 2025 09:08:24 -0700 Subject: [PATCH] works! verify shareRoot is set and note is shared --- .../options/other/share_settings.ts | 47 +++++++++++-------- src/public/translations/en/translation.json | 7 +-- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/public/app/widgets/type_widgets/options/other/share_settings.ts b/src/public/app/widgets/type_widgets/options/other/share_settings.ts index abc540b49..d2d77bc6d 100644 --- a/src/public/app/widgets/type_widgets/options/other/share_settings.ts +++ b/src/public/app/widgets/type_widgets/options/other/share_settings.ts @@ -6,11 +6,11 @@ import searchService from "../../../../services/search.js"; const TPL = `
+

${t("share.redirect_bare_domain_description")}

-

${t("share.redirect_bare_domain_description")}

`; @@ -60,25 +60,32 @@ export default class ShareSettingsOptions extends OptionsWidget { await this.checkShareRoot(); } - this.$widget.find('input[name="shareSubtree"]').prop("checked", options.shareSubtree === "true"); + this.$widget.find('input[name="showLoginInShareTheme"]').prop("checked", options.showLoginInShareTheme === "true"); } async checkShareRoot() { - const shareRootNotes = await searchService.searchNotes("#shareRoot", { - includeArchivedNotes: true, - ignoreHoistedNote: true - }); + const $button = this.$widget.find('.check-share-root'); + $button.prop('disabled', true); + + try { + const shareRootNotes = await searchService.searchForNotes("#shareRoot"); + const sharedShareRootNote = shareRootNotes.find(note => note.isShared()); - if (shareRootNotes.length > 0) { - this.$shareRootStatus - .removeClass('text-danger') - .addClass('text-success') - .text(t("share.share_root_found", {noteTitle: shareRootNotes[0].title})); - } else { - this.$shareRootStatus - .removeClass('text-success') - .addClass('text-danger') - .text(t("share.share_root_not_found")); + if (sharedShareRootNote) { + this.$shareRootStatus + .removeClass('text-danger') + .addClass('text-success') + .text(t("share.share_root_found", {noteTitle: sharedShareRootNote.title})); + } else { + this.$shareRootStatus + .removeClass('text-success') + .addClass('text-danger') + .text(shareRootNotes.length > 0 + ? t("share.share_root_not_shared", {noteTitle: shareRootNotes[0].title}) + : t("share.share_root_not_found")); + } + } finally { + $button.prop('disabled', false); } } @@ -86,7 +93,7 @@ export default class ShareSettingsOptions extends OptionsWidget { const redirectBareDomain = this.$widget.find('input[name="redirectBareDomain"]').prop("checked"); await this.updateOption<"redirectBareDomain">("redirectBareDomain", redirectBareDomain.toString()); - const showLoginInShareTheme = this.$widget.find('input[name="shareSubtree"]').prop("checked"); - await this.updateOption<"shareSubtree">("shareSubtree", showLoginInShareTheme.toString()); + const showLoginInShareTheme = this.$widget.find('input[name="showLoginInShareTheme"]').prop("checked"); + await this.updateOption<"showLoginInShareTheme">("showLoginInShareTheme", showLoginInShareTheme.toString()); } } diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json index c0ee99e4b..506952623 100644 --- a/src/public/translations/en/translation.json +++ b/src/public/translations/en/translation.json @@ -1658,12 +1658,13 @@ "share": { "title": "Share Settings", "redirect_bare_domain": "Redirect bare domain to Share page", - "redirect_bare_domain_description": "When enabled, accessing the root URL will redirect to the Share page instead of Login", + "redirect_bare_domain_description": "Redirect anonymous users to the Share page instead of showing Login", "show_login_link": "Show Login link in Share theme", "show_login_link_description": "Add a login link to the Share page footer", "check_share_root": "Check Share Root Status", - "share_root_found": "Share root found: {{noteTitle}}", - "share_root_not_found": "No note with #shareRoot label found. Set up a note with #shareRoot label first." + "share_root_found": "Share root note '{{noteTitle}}' is ready", + "share_root_not_found": "No note with #shareRoot label found", + "share_root_not_shared": "Note '{{noteTitle}}' has #shareRoot label but is not Shared" }, "time_selector": { "invalid_input": "The entered time value is not a valid number."