mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	works! verify shareRoot is set and note is shared
This commit is contained in:
		
							parent
							
								
									2734e230ab
								
							
						
					
					
						commit
						bdd6395a76
					
				| @ -6,11 +6,11 @@ import searchService from "../../../../services/search.js"; | ||||
| 
 | ||||
| const TPL = ` | ||||
| <div class="options-section"> | ||||
|     <p>${t("share.redirect_bare_domain_description")}</p> | ||||
|     <label class="tn-checkbox"> | ||||
|         <input type="checkbox" name="redirectBareDomain"> | ||||
|         <span>${t("share.redirect_bare_domain")}</span> | ||||
|     </label> | ||||
|     <p class="form-text">${t("share.redirect_bare_domain_description")}</p> | ||||
| 
 | ||||
|     <div class="share-root-check mt-2 mb-2" style="display: none;"> | ||||
|         <button class="btn btn-sm btn-secondary check-share-root">${t("share.check_share_root")}</button> | ||||
| @ -18,8 +18,8 @@ const TPL = ` | ||||
|     </div> | ||||
| 
 | ||||
|     <label class="tn-checkbox"> | ||||
|         <input type="checkbox" name="shareSubtree"> | ||||
|         <span>${t("share.share_subtree")}</span> | ||||
|         <input type="checkbox" name="showLoginInShareTheme"> | ||||
|         <span>${t("share.show_login_link")}</span> | ||||
|     </label> | ||||
| </div>`;
 | ||||
| 
 | ||||
| @ -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); | ||||
|          | ||||
|         if (shareRootNotes.length > 0) { | ||||
|         try { | ||||
|             const shareRootNotes = await searchService.searchForNotes("#shareRoot"); | ||||
|             const sharedShareRootNote = shareRootNotes.find(note => note.isShared()); | ||||
| 
 | ||||
|             if (sharedShareRootNote) { | ||||
|                 this.$shareRootStatus | ||||
|                     .removeClass('text-danger') | ||||
|                     .addClass('text-success') | ||||
|                 .text(t("share.share_root_found", {noteTitle: shareRootNotes[0].title})); | ||||
|                     .text(t("share.share_root_found", {noteTitle: sharedShareRootNote.title})); | ||||
|             } else { | ||||
|                 this.$shareRootStatus | ||||
|                     .removeClass('text-success') | ||||
|                     .addClass('text-danger') | ||||
|                 .text(t("share.share_root_not_found")); | ||||
|                     .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()); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -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." | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 matt wilkie
						matt wilkie