From 79b8b1732897b4e4a624af7552c2ab55c54109ad Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 28 Jun 2021 17:06:21 +0200 Subject: [PATCH 1/2] Current Branch and Contributions Branch now stored as a Config Property of the Workspace not, and removed from the Browser Internal Storage. --- .../UI/Spaces/Docs-Space/DocsSpace.js | 88 ++++++++++++------- 1 file changed, 56 insertions(+), 32 deletions(-) diff --git a/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js index ff9ebe644..baf0f5679 100644 --- a/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js @@ -64,9 +64,9 @@ function newEducationDocSpace() { setupSidePanelTab() setUpMenuItemsMap() setupUserLanguage() - setupActiveBranch() + setupCurrentBranch() setupContributionsBranch() - + thisObject.searchEngine = newFoundationsDocsSearchEngine() thisObject.mainSearchPage = newFoundationsDocsMainSearchPage() thisObject.searchResultsPage = newFoundationsDocsSearchResultsPage() @@ -74,7 +74,7 @@ function newEducationDocSpace() { thisObject.footer = newFoundationsDocsFooter() thisObject.commandInterface = newFoundationsDocsCommmandInterface() thisObject.contextMenu = newFoundationsDocsContextMenu() - + thisObject.searchEngine.initialize() thisObject.mainSearchPage.initialize() thisObject.searchResultsPage.initialize() @@ -82,50 +82,72 @@ function newEducationDocSpace() { thisObject.footer.initialize() thisObject.commandInterface.initialize() thisObject.contextMenu.initialize() - + isInitialized = true - + UI.projects.foundations.utilities.statusBar.changeStatus("Setting up Docs Search Engine...") setTimeout(setUpSearchEngine, 100) function setUpSearchEngine() { thisObject.searchEngine.setUpSearchEngine(whenFinished) - function whenFinished(){ + function whenFinished() { resolve() } } - - function setupActiveBranch() { + + function setupCurrentBranch() { /* - Getting the used preferred languague + Getting the currentBranch */ - if (window.localStorage.getItem('Current Branch') !== null && window.localStorage.getItem('Current Branch') !== undefined && window.localStorage.getItem('Current Branch') !== 'undefined') { - UI.projects.education.spaces.docsSpace.currentBranch = window.localStorage.getItem('Current Branch') - } else { - window.localStorage.setItem('Current Branch', UI.projects.education.globals.docs.DEFAULT_CURRENT_BRANCH) + let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode + let currentBranch = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(workspace.payload, 'currentBranch') + + if (currentBranch === undefined) { + UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'currentBranch', UI.projects.education.globals.docs.DEFAULT_CURRENT_BRANCH) UI.projects.education.spaces.docsSpace.currentBranch = UI.projects.education.globals.docs.DEFAULT_CURRENT_BRANCH + } else { + UI.projects.education.spaces.docsSpace.currentBranch = currentBranch } + /* + Every time this setup occurs, we will automatically change to the currentBranch of the workspace. + */ + changeCurrentBranch(UI.projects.education.spaces.docsSpace.currentBranch) + /* + Deleting what was is here because is not longer used... + */ + window.localStorage.removeItem('Current Branch') } - + function setupContributionsBranch() { /* - Getting the used preferred languague + Getting the contributionsBranch */ - if (window.localStorage.getItem('Contributions Branch') !== null && window.localStorage.getItem('Contributions Branch') !== undefined && window.localStorage.getItem('Contributions Branch') !== 'undefined') { - UI.projects.education.spaces.docsSpace.contributionsBranch = window.localStorage.getItem('Contributions Branch') - } else { - window.localStorage.setItem('Contributions Branch', UI.projects.education.globals.docs.DEFAULT_CONTRIBUTIONS_BRANCH) + let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode + let contributionsBranch = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(workspace.payload, 'contributionsBranch') + + if (contributionsBranch === undefined) { + UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'contributionsBranch', UI.projects.education.globals.docs.DEFAULT_CONTRIBUTIONS_BRANCH) UI.projects.education.spaces.docsSpace.contributionsBranch = UI.projects.education.globals.docs.DEFAULT_CONTRIBUTIONS_BRANCH + } else { + UI.projects.education.spaces.docsSpace.contributionsBranch = contributionsBranch } + /* + Every time this setup occurs, we will automatically change to the contributionsBranch of the workspace. + */ + changeContributionsBranch(UI.projects.education.spaces.docsSpace.contributionsBranch) + /* + Deleting what was is here because is not longer used... + */ + window.localStorage.removeItem('Contributions Branch') } - + function setupUserLanguage() { /* Getting the used preferred languague */ let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode let docsLanguage = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(workspace.payload, 'docsLanguage') - + if (docsLanguage === undefined) { UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'docsLanguage', UI.projects.education.globals.docs.DEFAULT_LANGUAGE) UI.projects.education.spaces.docsSpace.language = UI.projects.education.globals.docs.DEFAULT_LANGUAGE @@ -133,21 +155,21 @@ function newEducationDocSpace() { UI.projects.education.spaces.docsSpace.language = docsLanguage } /* - Deleting was is here because is not longer used + Deleting what was is here because is not longer used... */ - window.localStorage.setItem('Docs Language', undefined) + window.localStorage.removeItem('Docs Language') } - + function setupSidePanelTab() { thisObject.sidePanelTab = newSidePanelTab() thisObject.sidePanelTab.container.connectToParent(thisObject.container, false, false) thisObject.sidePanelTab.initialize('right') openingEventSubscriptionId = thisObject.sidePanelTab.container.eventHandler.listenToEvent('opening', onOpening) closingEventSubscriptionId = thisObject.sidePanelTab.container.eventHandler.listenToEvent('closing', onClosing) - + browserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize) } - + function setUpMenuItemsMap() { /* Here we will put put all the menu item labels of all nodes at all @@ -157,10 +179,10 @@ function newEducationDocSpace() { for (let i = 0; i < PROJECTS_SCHEMA.length; i++) { let project = PROJECTS_SCHEMA[i].name let appSchemaArray = SCHEMAS_BY_PROJECT.get(project).array.appSchema - + for (let j = 0; j < appSchemaArray.length; j++) { let docsSchemaDocument = appSchemaArray[j] - + if (docsSchemaDocument.menuItems === undefined) { continue } for (let k = 0; k < docsSchemaDocument.menuItems.length; k++) { let menuItem = docsSchemaDocument.menuItems[k] @@ -169,7 +191,7 @@ function newEducationDocSpace() { } } } - }) + }) return promise } @@ -216,7 +238,8 @@ function newEducationDocSpace() { data = JSON.parse(data) if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { UI.projects.education.spaces.docsSpace.currentBranch = branch - window.localStorage.setItem('Current Branch', branch) + let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode + UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'currentBranch', branch) UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Switching Branches - Current Branch Changed') } else { UI.projects.education.spaces.docsSpace.navigateTo( @@ -233,7 +256,9 @@ function newEducationDocSpace() { function changeContributionsBranch(branch) { UI.projects.education.spaces.docsSpace.contributionsBranch = branch - window.localStorage.setItem('Contributions Branch', UI.projects.education.spaces.docsSpace.contributionsBranch) + let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode + UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'contributionsBranch', branch) + UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Switching Branches - Contributions Branch Changed') } @@ -243,7 +268,6 @@ function newEducationDocSpace() { UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs In ' + languageLabel) let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode - UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'docsLanguage', UI.projects.education.spaces.docsSpace.language) } From 3a1f99ff869609d609b8a052a543a1cdf88283df Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 28 Jun 2021 17:17:16 +0200 Subject: [PATCH 2/2] Branch Changes after new workspace is loaded, if needed, depending on Workspace Config Property --- .../UI/Spaces/Docs-Space/DocsSpace.js | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js index baf0f5679..42f9e9b4d 100644 --- a/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js @@ -64,8 +64,6 @@ function newEducationDocSpace() { setupSidePanelTab() setUpMenuItemsMap() setupUserLanguage() - setupCurrentBranch() - setupContributionsBranch() thisObject.searchEngine = newFoundationsDocsSearchEngine() thisObject.mainSearchPage = newFoundationsDocsMainSearchPage() @@ -83,6 +81,9 @@ function newEducationDocSpace() { thisObject.commandInterface.initialize() thisObject.contextMenu.initialize() + setupCurrentBranch() + setupContributionsBranch() + isInitialized = true UI.projects.foundations.utilities.statusBar.changeStatus("Setting up Docs Search Engine...") @@ -111,7 +112,7 @@ function newEducationDocSpace() { /* Every time this setup occurs, we will automatically change to the currentBranch of the workspace. */ - changeCurrentBranch(UI.projects.education.spaces.docsSpace.currentBranch) + changeCurrentBranch(UI.projects.education.spaces.docsSpace.currentBranch, true) /* Deleting what was is here because is not longer used... */ @@ -134,7 +135,7 @@ function newEducationDocSpace() { /* Every time this setup occurs, we will automatically change to the contributionsBranch of the workspace. */ - changeContributionsBranch(UI.projects.education.spaces.docsSpace.contributionsBranch) + changeContributionsBranch(UI.projects.education.spaces.docsSpace.contributionsBranch, true) /* Deleting what was is here because is not longer used... */ @@ -229,9 +230,11 @@ function newEducationDocSpace() { await initialize() } - function changeCurrentBranch(branch) { + function changeCurrentBranch(branch, doNotNavigate) { httpRequest(undefined, 'App/Checkout/' + branch, onResponse) - UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Switching Branches - Changing Current Branch') + if (doNotNavigate !== true) { + UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Switching Branches - Changing Current Branch') + } function onResponse(err, data) { /* Lets check the result of the call through the http interface */ @@ -240,6 +243,8 @@ function newEducationDocSpace() { UI.projects.education.spaces.docsSpace.currentBranch = branch let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'currentBranch', branch) + + if (doNotNavigate === true) { return } UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Switching Branches - Current Branch Changed') } else { UI.projects.education.spaces.docsSpace.navigateTo( @@ -254,12 +259,14 @@ function newEducationDocSpace() { } } - function changeContributionsBranch(branch) { + function changeContributionsBranch(branch, doNotNavigate) { UI.projects.education.spaces.docsSpace.contributionsBranch = branch let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'contributionsBranch', branch) - UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Switching Branches - Contributions Branch Changed') + if (doNotNavigate !== true) { + UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Switching Branches - Contributions Branch Changed') + } } function changeLanguage(pLanguage) {