diff --git a/bin/tpl/anonymize-database.sql b/bin/tpl/anonymize-database.sql index c99e56e7a..afdff5168 100644 --- a/bin/tpl/anonymize-database.sql +++ b/bin/tpl/anonymize-database.sql @@ -5,8 +5,8 @@ UPDATE note_contents SET content = 'text' WHERE content IS NOT NULL; UPDATE note_revisions SET title = 'title'; UPDATE note_revision_contents SET content = 'text' WHERE content IS NOT NULL; -UPDATE attributes SET name = 'name', value = 'value' WHERE type = 'label' AND name NOT IN('inbox', 'disableVersioning', 'calendarRoot', 'archived', 'excludeFromExport', 'disableInclusion', 'appCss', 'appTheme', 'hidePromotedAttributes', 'readOnly', 'autoReadOnlyDisabled', 'hoistedCssClass', 'cssClass', 'iconClass', 'keyboardShortcut', 'run', 'runOnInstance', 'runAtHour', 'customRequestHandler', 'customResourceProvider', 'widget', 'noteInfoWidgetDisabled', 'linkMapWidgetDisabled', 'noteRevisionsWidgetDisabled', 'whatLinksHereWidgetDisabled', 'similarNotesWidgetDisabled', 'workspace', 'workspaceIconClass', 'workspaceTabBackgroundColor', 'searchHome', 'hoistedInbox', 'hoistedSearchHome', 'sqlConsoleHome', 'datePattern', 'pageSize', 'viewType', 'mapRootNoteId', 'bookmarkFolder', 'sorted', 'top', 'fullContentWidth', 'shareHiddenFromTree', 'shareAlias', 'shareOmitDefaultCss', 'shareRoot', 'shareDescription', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation', 'runOnNoteTitleChange', 'runOnNoteContentChange', 'runOnNoteChange', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareFavicon'); -UPDATE attributes SET name = 'name' WHERE type = 'relation' AND name NOT IN ('inbox', 'disableVersioning', 'calendarRoot', 'archived', 'excludeFromExport', 'disableInclusion', 'appCss', 'appTheme', 'hidePromotedAttributes', 'readOnly', 'autoReadOnlyDisabled', 'hoistedCssClass', 'cssClass', 'iconClass', 'keyboardShortcut', 'run', 'runOnInstance', 'runAtHour', 'customRequestHandler', 'customResourceProvider', 'widget', 'noteInfoWidgetDisabled', 'linkMapWidgetDisabled', 'noteRevisionsWidgetDisabled', 'whatLinksHereWidgetDisabled', 'similarNotesWidgetDisabled', 'workspace', 'workspaceIconClass', 'workspaceTabBackgroundColor', 'searchHome', 'hoistedInbox', 'hoistedSearchHome', 'sqlConsoleHome', 'datePattern', 'pageSize', 'viewType', 'mapRootNoteId', 'bookmarkFolder', 'sorted', 'top', 'fullContentWidth', 'shareHiddenFromTree', 'shareAlias', 'shareOmitDefaultCss', 'shareRoot', 'shareDescription', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation', 'runOnNoteTitleChange', 'runOnNoteContentChange', 'runOnNoteChange', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareFavicon'); +UPDATE attributes SET name = 'name', value = 'value' WHERE type = 'label' AND name NOT IN('inbox', 'disableVersioning', 'calendarRoot', 'archived', 'excludeFromExport', 'disableInclusion', 'appCss', 'appTheme', 'hidePromotedAttributes', 'readOnly', 'autoReadOnlyDisabled', 'cssClass', 'iconClass', 'keyboardShortcut', 'run', 'runOnInstance', 'runAtHour', 'customRequestHandler', 'customResourceProvider', 'widget', 'noteInfoWidgetDisabled', 'linkMapWidgetDisabled', 'noteRevisionsWidgetDisabled', 'whatLinksHereWidgetDisabled', 'similarNotesWidgetDisabled', 'workspace', 'workspaceIconClass', 'workspaceTabBackgroundColor', 'searchHome', 'workspaceInbox', 'workspaceSearchHome', 'sqlConsoleHome', 'datePattern', 'pageSize', 'viewType', 'mapRootNoteId', 'bookmarkFolder', 'sorted', 'top', 'fullContentWidth', 'shareHiddenFromTree', 'shareAlias', 'shareOmitDefaultCss', 'shareRoot', 'shareDescription', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation', 'runOnNoteTitleChange', 'runOnNoteContentChange', 'runOnNoteChange', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareFavicon'); +UPDATE attributes SET name = 'name' WHERE type = 'relation' AND name NOT IN ('inbox', 'disableVersioning', 'calendarRoot', 'archived', 'excludeFromExport', 'disableInclusion', 'appCss', 'appTheme', 'hidePromotedAttributes', 'readOnly', 'autoReadOnlyDisabled', 'cssClass', 'iconClass', 'keyboardShortcut', 'run', 'runOnInstance', 'runAtHour', 'customRequestHandler', 'customResourceProvider', 'widget', 'noteInfoWidgetDisabled', 'linkMapWidgetDisabled', 'noteRevisionsWidgetDisabled', 'whatLinksHereWidgetDisabled', 'similarNotesWidgetDisabled', 'workspace', 'workspaceIconClass', 'workspaceTabBackgroundColor', 'searchHome', 'workspaceInbox', 'workspaceSearchHome', 'sqlConsoleHome', 'datePattern', 'pageSize', 'viewType', 'mapRootNoteId', 'bookmarkFolder', 'sorted', 'top', 'fullContentWidth', 'shareHiddenFromTree', 'shareAlias', 'shareOmitDefaultCss', 'shareRoot', 'shareDescription', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation', 'runOnNoteTitleChange', 'runOnNoteContentChange', 'runOnNoteChange', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareFavicon'); UPDATE branches SET prefix = 'prefix' WHERE prefix IS NOT NULL AND prefix != 'recovered'; UPDATE options SET value = 'anonymized' WHERE name IN ('documentId', 'documentSecret', 'encryptedDataKey', diff --git a/db/migrations/0199__rename_ids.sql b/db/migrations/0199__rename_ids.sql index 07859064b..d0de0233d 100644 --- a/db/migrations/0199__rename_ids.sql +++ b/db/migrations/0199__rename_ids.sql @@ -1,4 +1,4 @@ -UPDATE notes SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; +UPDATE notes SET noteId = '_globalNoteMap', title = 'Note Map' WHERE noteId = 'globalnotemap'; UPDATE note_contents SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; UPDATE note_revisions SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; UPDATE branches SET branchId = '_globalNoteMap' WHERE branchId = 'globalnotemap'; @@ -8,7 +8,7 @@ UPDATE attributes SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; UPDATE attributes SET value = '_globalNoteMap' WHERE type = 'relation' AND value = 'globalnotemap'; UPDATE entity_changes SET entityId = '_globalNoteMap' WHERE entityId = 'globalnotemap'; -UPDATE notes SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; +UPDATE notes SET noteId = '_bulkAction', title = 'Bulk Action' WHERE noteId = 'bulkaction'; UPDATE note_contents SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; UPDATE note_revisions SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; UPDATE branches SET branchId = '_bulkAction' WHERE branchId = 'bulkaction'; @@ -18,7 +18,7 @@ UPDATE attributes SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; UPDATE attributes SET value = '_bulkAction' WHERE type = 'relation' AND value = 'bulkaction'; UPDATE entity_changes SET entityId = '_bulkAction' WHERE entityId = 'bulkaction'; -UPDATE notes SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; +UPDATE notes SET noteId = '_sqlConsole', title = 'SQL Console History' WHERE noteId = 'sqlconsole'; UPDATE note_contents SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; UPDATE note_revisions SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; UPDATE branches SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; @@ -28,7 +28,7 @@ UPDATE attributes SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; UPDATE attributes SET value = '_sqlConsole' WHERE type = 'relation' AND value = 'sqlconsole'; UPDATE entity_changes SET entityId = '_sqlConsole' WHERE entityId = 'sqlconsole'; -UPDATE notes SET noteId = '_hidden' WHERE noteId = 'hidden'; +UPDATE notes SET noteId = '_hidden', title = 'Hidden Notes' WHERE noteId = 'hidden'; UPDATE note_contents SET noteId = '_hidden' WHERE noteId = 'hidden'; UPDATE note_revisions SET noteId = '_hidden' WHERE noteId = 'hidden'; UPDATE branches SET noteId = '_hidden' WHERE noteId = 'hidden'; @@ -38,7 +38,7 @@ UPDATE attributes SET noteId = '_hidden' WHERE noteId = 'hidden'; UPDATE attributes SET value = '_hidden' WHERE type = 'relation' AND value = 'hidden'; UPDATE entity_changes SET entityId = '_hidden' WHERE entityId = 'hidden'; -UPDATE notes SET noteId = '_search' WHERE noteId = 'search'; +UPDATE notes SET noteId = '_search', title = 'Search History' WHERE noteId = 'search'; UPDATE note_contents SET noteId = '_search' WHERE noteId = 'search'; UPDATE note_revisions SET noteId = '_search' WHERE noteId = 'search'; UPDATE branches SET noteId = '_search' WHERE noteId = 'search'; diff --git a/db/migrations/0209__rename_hoisted_labels.sql b/db/migrations/0209__rename_hoisted_labels.sql new file mode 100644 index 000000000..0ece2c52b --- /dev/null +++ b/db/migrations/0209__rename_hoisted_labels.sql @@ -0,0 +1,5 @@ +UPDATE attributes SET name = 'workspaceInbox' WHERE type = 'label' AND name = 'hoistedInbox'; +UPDATE entity_changes SET entityId = 'workspaceInbox' WHERE entityName = 'attributes' AND entityId = 'hoistedInbox'; + +UPDATE attributes SET name = 'workspaceSearchHome' WHERE type = 'label' AND name = 'hoistedSearchHome'; +UPDATE entity_changes SET entityId = 'workspaceSearchHome' WHERE entityName = 'attributes' AND entityId = 'hoistedSearchHome'; diff --git a/src/becca/becca.js b/src/becca/becca.js index 86c5e169c..9456c5623 100644 --- a/src/becca/becca.js +++ b/src/becca/becca.js @@ -32,6 +32,10 @@ class Becca { this.loaded = false; } + getRoot() { + return this.getNote('root'); + } + /** @returns {Attribute[]} */ findAttributes(type, name) { name = name.trim().toLowerCase(); diff --git a/src/public/app/components/entrypoints.js b/src/public/app/components/entrypoints.js index b1706f357..68117280e 100644 --- a/src/public/app/components/entrypoints.js +++ b/src/public/app/components/entrypoints.js @@ -38,11 +38,7 @@ export default class Entrypoints extends Component { await ws.waitForMaxKnownEntityChangeId(); - const hoistedNoteId = appContext.tabManager.getActiveContext() - ? appContext.tabManager.getActiveContext().hoistedNoteId - : 'root'; - - await appContext.tabManager.openContextWithNote(note.noteId, true, null, hoistedNoteId); + await appContext.tabManager.openTabWithNoteWithHoisting(note.noteId, true); appContext.triggerEvent('focusAndSelectTitle', {isNewNote: true}); } diff --git a/src/public/app/components/tab_manager.js b/src/public/app/components/tab_manager.js index be910ffa7..2e3bd6ec3 100644 --- a/src/public/app/components/tab_manager.js +++ b/src/public/app/components/tab_manager.js @@ -95,6 +95,7 @@ export default class TabManager extends Component { await this.tabsUpdate.allowUpdateWithoutChange(async () => { for (const tab of filteredTabs) { + await this.openContextWithNote(tab.notePath, tab.active, tab.ntxId, tab.hoistedNoteId, tab.mainNtxId); } }); diff --git a/src/public/app/widgets/attribute_widgets/attribute_detail.js b/src/public/app/widgets/attribute_widgets/attribute_detail.js index 8cc024912..bf44a8a4e 100644 --- a/src/public/app/widgets/attribute_widgets/attribute_detail.js +++ b/src/public/app/widgets/attribute_widgets/attribute_detail.js @@ -210,9 +210,9 @@ const ATTR_HELP = { "workspaceCalendarRoot": "Defines per-workspace calendar root", "workspaceTemplate": "This note will appear in the selection of available template when creating new note, but only when hoisted into a workspace containing this template", "searchHome": "new search notes will be created as children of this note", - "hoistedSearchHome": "new search notes will be created as children of this note when hoisted to some ancestor of this note", + "workspaceSearchHome": "new search notes will be created as children of this note when hoisted to some ancestor of this workspace note", "inbox": "default inbox location for new notes - when you create a note using \"new note\" button in the sidebar, notes will be created as child notes in the note marked as with #inbox label.", - "hoistedInbox": "default inbox location for new notes when hoisted to some ancestor of this note", + "workspaceInbox": "default inbox location for new notes when hoisted to some ancestor of this workspace note", "sqlConsoleHome": "default location of SQL console notes", "bookmarkFolder": "note with this label will appear in bookmarks as folder (allowing access to its children)", "shareHiddenFromTree": "this note is hidden from left navigation tree, but still accessible with its URL", diff --git a/src/services/app_info.js b/src/services/app_info.js index c7c3e5949..eba845c1e 100644 --- a/src/services/app_info.js +++ b/src/services/app_info.js @@ -4,7 +4,7 @@ const build = require('./build'); const packageJson = require('../../package'); const {TRILIUM_DATA_DIR} = require('./data_dir'); -const APP_DB_VERSION = 208; +const APP_DB_VERSION = 209; const SYNC_VERSION = 28; const CLIPPER_PROTOCOL_VERSION = "1.0"; diff --git a/src/services/builtin_attributes.js b/src/services/builtin_attributes.js index d39fff8f0..80331a02a 100644 --- a/src/services/builtin_attributes.js +++ b/src/services/builtin_attributes.js @@ -11,7 +11,6 @@ module.exports = [ { type: 'label', name: 'hidePromotedAttributes' }, { type: 'label', name: 'readOnly' }, { type: 'label', name: 'autoReadOnlyDisabled' }, - { type: 'label', name: 'hoistedCssClass' }, { type: 'label', name: 'cssClass' }, { type: 'label', name: 'iconClass' }, { type: 'label', name: 'keyboardShortcut' }, @@ -32,8 +31,8 @@ module.exports = [ { type: 'label', name: 'workspaceCalendarRoot' }, { type: 'label', name: 'workspaceTemplate' }, { type: 'label', name: 'searchHome' }, - { type: 'label', name: 'hoistedInbox' }, - { type: 'label', name: 'hoistedSearchHome' }, + { type: 'label', name: 'workspaceInbox' }, + { type: 'label', name: 'workspaceSearchHome' }, { type: 'label', name: 'sqlConsoleHome' }, { type: 'label', name: 'datePattern' }, { type: 'label', name: 'pageSize' }, diff --git a/src/services/date_notes.js b/src/services/date_notes.js index 1f6484096..c296e6762 100644 --- a/src/services/date_notes.js +++ b/src/services/date_notes.js @@ -9,6 +9,7 @@ const protectedSessionService = require('./protected_session'); const cls = require("./cls"); const searchService = require('../services/search/services/search'); const SearchContext = require('../services/search/search_context'); +const hoistedNoteService = require("./hoisted_note"); const CALENDAR_ROOT_LABEL = 'calendarRoot'; const YEAR_LABEL = 'yearNote'; @@ -32,7 +33,9 @@ function createNote(parentNote, noteTitle) { function getRootCalendarNote() { let rootNote; - if (cls.getHoistedNoteId() !== 'root') { + const workspaceNote = hoistedNoteService.getWorkspaceNote(); + + if (!workspaceNote.isRoot()) { rootNote = searchService.findFirstNoteWithQuery('#workspaceCalendarRoot', new SearchContext({ignoreHoistedNote: false})); } diff --git a/src/services/hidden_subtree.js b/src/services/hidden_subtree.js index b93fbc2b3..071f68549 100644 --- a/src/services/hidden_subtree.js +++ b/src/services/hidden_subtree.js @@ -13,7 +13,7 @@ const LBTPL_CUSTOM_WIDGET = "_lbTplCustomWidget"; const HIDDEN_SUBTREE_DEFINITION = { id: '_hidden', - title: '_hidden', + title: 'Hidden Notes', type: 'doc', icon: 'bx bx-chip', // we want to keep the hidden subtree always last, otherwise there will be problems with e.g. keyboard navigation @@ -52,7 +52,7 @@ const HIDDEN_SUBTREE_DEFINITION = { }, { id: '_bulkAction', - title: 'Bulk action', + title: 'Bulk Action', type: 'doc', }, { @@ -153,7 +153,7 @@ const HIDDEN_SUBTREE_DEFINITION = { }, { id: '_lbRoot', - title: 'Launch bar', + title: 'Launch Bar', type: 'doc', icon: 'bx-sidebar', isExpanded: true, diff --git a/src/services/hoisted_note.js b/src/services/hoisted_note.js index b461ce7ed..a61dc4919 100644 --- a/src/services/hoisted_note.js +++ b/src/services/hoisted_note.js @@ -23,7 +23,23 @@ function isHoistedInHiddenSubtree() { return hoistedNote.hasAncestor('_hidden'); } +function getHoistedNote() { + return becca.getNote(cls.getHoistedNoteId()); +} + +function getWorkspaceNote() { + const hoistedNote = getHoistedNote(); + + if (hoistedNote.isRoot() || hoistedNote.hasLabel('workspace')) { + return hoistedNote; + } else { + return becca.getRoot(); + } +} + module.exports = { getHoistedNoteId, + getHoistedNote, + getWorkspaceNote, isHoistedInHiddenSubtree }; diff --git a/src/services/special_notes.js b/src/services/special_notes.js index 523c7b7fc..ef6f63987 100644 --- a/src/services/special_notes.js +++ b/src/services/special_notes.js @@ -2,28 +2,28 @@ const attributeService = require("./attributes"); const dateNoteService = require("./date_notes"); const becca = require("../becca/becca"); const noteService = require("./notes"); -const cls = require("./cls"); const dateUtils = require("./date_utils"); const log = require("./log"); const hiddenSubtreeService = require("./hidden_subtree"); +const hoistedNoteService = require("./hoisted_note"); const searchService = require("./search/services/search"); const SearchContext = require("./search/search_context"); const {LBTPL_NOTE_LAUNCHER, LBTPL_CUSTOM_WIDGET, LBTPL_SPACER, LBTPL_SCRIPT} = require("./hidden_subtree"); function getInboxNote(date) { - const hoistedNote = getHoistedNote(); + const workspaceNote = hoistedNoteService.getWorkspaceNote(); let inbox; - if (!hoistedNote.isRoot()) { - inbox = hoistedNote.searchNoteInSubtree('#hoistedInbox'); + if (!workspaceNote.isRoot()) { + inbox = workspaceNote.searchNoteInSubtree('#workspaceInbox'); if (!inbox) { - inbox = hoistedNote.searchNoteInSubtree('#inbox'); + inbox = workspaceNote.searchNoteInSubtree('#inbox'); } if (!inbox) { - inbox = hoistedNote; + inbox = workspaceNote; } } else { @@ -88,16 +88,16 @@ function createSearchNote(searchString, ancestorNoteId) { } function getSearchHome() { - const hoistedNote = getHoistedNote(); + const workspaceNote = hoistedNoteService.getWorkspaceNote(); - if (!hoistedNote.isRoot()) { - return hoistedNote.searchNoteInSubtree('#hoistedSearchHome') - || hoistedNote.searchNoteInSubtree('#searchHome') - || hoistedNote; + if (!workspaceNote.isRoot()) { + return workspaceNote.searchNoteInSubtree('#workspaceSearchHome') + || workspaceNote.searchNoteInSubtree('#searchHome') + || workspaceNote; } else { const today = dateUtils.localNowDate(); - return hoistedNote.searchNoteInSubtree('#searchHome') + return workspaceNote.searchNoteInSubtree('#searchHome') || dateNoteService.getDayNote(today); } } @@ -139,10 +139,6 @@ function getMonthlyParentNoteId(rootNoteId, prefix) { return monthNote.noteId; } -function getHoistedNote() { - return becca.getNote(cls.getHoistedNoteId()); -} - function createScriptLauncher(parentNoteId, forceId = null) { const note = noteService.createNewNote({ noteId: forceId,