mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +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 = ` | const TPL = ` | ||||||
| <div class="options-section"> | <div class="options-section"> | ||||||
|  |     <p>${t("share.redirect_bare_domain_description")}</p> | ||||||
|     <label class="tn-checkbox"> |     <label class="tn-checkbox"> | ||||||
|         <input type="checkbox" name="redirectBareDomain"> |         <input type="checkbox" name="redirectBareDomain"> | ||||||
|         <span>${t("share.redirect_bare_domain")}</span> |         <span>${t("share.redirect_bare_domain")}</span> | ||||||
|     </label> |     </label> | ||||||
|     <p class="form-text">${t("share.redirect_bare_domain_description")}</p> |  | ||||||
| 
 | 
 | ||||||
|     <div class="share-root-check mt-2 mb-2" style="display: none;"> |     <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> |         <button class="btn btn-sm btn-secondary check-share-root">${t("share.check_share_root")}</button> | ||||||
| @ -18,8 +18,8 @@ const TPL = ` | |||||||
|     </div> |     </div> | ||||||
| 
 | 
 | ||||||
|     <label class="tn-checkbox"> |     <label class="tn-checkbox"> | ||||||
|         <input type="checkbox" name="shareSubtree"> |         <input type="checkbox" name="showLoginInShareTheme"> | ||||||
|         <span>${t("share.share_subtree")}</span> |         <span>${t("share.show_login_link")}</span> | ||||||
|     </label> |     </label> | ||||||
| </div>`;
 | </div>`;
 | ||||||
| 
 | 
 | ||||||
| @ -60,25 +60,32 @@ export default class ShareSettingsOptions extends OptionsWidget { | |||||||
|             await this.checkShareRoot(); |             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() { |     async checkShareRoot() { | ||||||
|         const shareRootNotes = await searchService.searchNotes("#shareRoot", { |         const $button = this.$widget.find('.check-share-root'); | ||||||
|             includeArchivedNotes: true, |         $button.prop('disabled', true); | ||||||
|             ignoreHoistedNote: true |  | ||||||
|         }); |  | ||||||
|          |          | ||||||
|         if (shareRootNotes.length > 0) { |         try { | ||||||
|  |             const shareRootNotes = await searchService.searchForNotes("#shareRoot"); | ||||||
|  |             const sharedShareRootNote = shareRootNotes.find(note => note.isShared()); | ||||||
|  | 
 | ||||||
|  |             if (sharedShareRootNote) { | ||||||
|                 this.$shareRootStatus |                 this.$shareRootStatus | ||||||
|                     .removeClass('text-danger') |                     .removeClass('text-danger') | ||||||
|                     .addClass('text-success') |                     .addClass('text-success') | ||||||
|                 .text(t("share.share_root_found", {noteTitle: shareRootNotes[0].title})); |                     .text(t("share.share_root_found", {noteTitle: sharedShareRootNote.title})); | ||||||
|             } else { |             } else { | ||||||
|                 this.$shareRootStatus |                 this.$shareRootStatus | ||||||
|                     .removeClass('text-success') |                     .removeClass('text-success') | ||||||
|                     .addClass('text-danger') |                     .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"); |         const redirectBareDomain = this.$widget.find('input[name="redirectBareDomain"]').prop("checked"); | ||||||
|         await this.updateOption<"redirectBareDomain">("redirectBareDomain", redirectBareDomain.toString()); |         await this.updateOption<"redirectBareDomain">("redirectBareDomain", redirectBareDomain.toString()); | ||||||
| 
 | 
 | ||||||
|         const showLoginInShareTheme = this.$widget.find('input[name="shareSubtree"]').prop("checked"); |         const showLoginInShareTheme = this.$widget.find('input[name="showLoginInShareTheme"]').prop("checked"); | ||||||
|         await this.updateOption<"shareSubtree">("shareSubtree", showLoginInShareTheme.toString()); |         await this.updateOption<"showLoginInShareTheme">("showLoginInShareTheme", showLoginInShareTheme.toString()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1658,12 +1658,13 @@ | |||||||
|   "share": { |   "share": { | ||||||
|     "title": "Share Settings", |     "title": "Share Settings", | ||||||
|     "redirect_bare_domain": "Redirect bare domain to Share page", |     "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": "Show Login link in Share theme", | ||||||
|     "show_login_link_description": "Add a login link to the Share page footer", |     "show_login_link_description": "Add a login link to the Share page footer", | ||||||
|     "check_share_root": "Check Share Root Status", |     "check_share_root": "Check Share Root Status", | ||||||
|     "share_root_found": "Share root found: {{noteTitle}}", |     "share_root_found": "Share root note '{{noteTitle}}' is ready", | ||||||
|     "share_root_not_found": "No note with #shareRoot label found. Set up a note with #shareRoot label first." |     "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": { |   "time_selector": { | ||||||
|     "invalid_input": "The entered time value is not a valid number." |     "invalid_input": "The entered time value is not a valid number." | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 matt wilkie
						matt wilkie