From a64dd3ccd832c41f461b38328bb9f182718bf176 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 4 Jul 2021 10:42:13 +0200 Subject: [PATCH] Current Branch being asked to Git, removed from Workspace Config and Browser Local Storage --- Client/httpInterface.js | 62 ++++++++++++-- .../UI/Spaces/Docs-Space/DocsSpace.js | 32 ++++--- ...pp-error-could-not-get-current-branch.json | 85 +++++++++++++++++++ 3 files changed, 162 insertions(+), 17 deletions(-) create mode 100644 Projects/Foundations/Schemas/Docs-Topics/A/App/App-Commands-Errors/app-commands-errors-004-app-error-could-not-get-current-branch.json diff --git a/Client/httpInterface.js b/Client/httpInterface.js index d972eedcf..44900a6e5 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -833,9 +833,6 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } catch (err) { console.log('[ERROR] httpInterface -> App -> Update -> Method call produced an error.') console.log('[ERROR] httpInterface -> App -> Update -> err.stack = ' + err.stack) - console.log('[ERROR] httpInterface -> App -> Update -> commitMessage = ' + commitMessage) - console.log('[ERROR] httpInterface -> App -> Update -> username = ' + username) - console.log('[ERROR] httpInterface -> App -> Update -> token = ' + token) let error = { result: 'Fail Because', @@ -892,9 +889,62 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } catch (err) { console.log('[ERROR] httpInterface -> App -> Update -> Method call produced an error.') console.log('[ERROR] httpInterface -> App -> Update -> err.stack = ' + err.stack) - console.log('[ERROR] httpInterface -> App -> Update -> commitMessage = ' + commitMessage) - console.log('[ERROR] httpInterface -> App -> Update -> username = ' + username) - console.log('[ERROR] httpInterface -> App -> Update -> token = ' + token) + + let error = { + result: 'Fail Because', + message: err.message, + stack: err.stack + } + respondWithContent(JSON.stringify(error), httpResponse) + } + break + } + + case 'Branch': { + try { + branch() + + async function branch() { + let result = await doGit() + + if (result.error === undefined) { + let customResponse = { + result: global.CUSTOM_OK_RESPONSE.result, + message: result + } + respondWithContent(JSON.stringify(customResponse), httpResponse) + } else { + let docs = { + project: 'Foundations', + category: 'Topic', + type: 'App Error - Could Not Get Current Branch', + anchor: undefined, + placeholder: {} + } + + respondWithDocsObject(docs, error) + } + } + + async function doGit() { + const simpleGit = require('simple-git'); + const options = { + baseDir: process.cwd(), + binary: 'git', + maxConcurrentProcesses: 6, + } + const git = simpleGit(options) + try { + return await git.branch() + } catch (err) { + console.log('[ERROR] Error reading current branch.') + console.log(err.stack) + } + } + + } catch (err) { + console.log('[ERROR] httpInterface -> App -> Update -> Method call produced an error.') + console.log('[ERROR] httpInterface -> App -> Update -> err.stack = ' + err.stack) let error = { result: 'Fail Because', diff --git a/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js index d2262444b..367c50209 100644 --- a/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Education/UI/Spaces/Docs-Space/DocsSpace.js @@ -101,22 +101,32 @@ function newEducationDocSpace() { Getting the currentBranch */ let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode - let currentBranch = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(workspace.payload, 'currentBranch') + let 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, true) + httpRequest(undefined, 'App/Branch', onResponse) /* Deleting what was is here because is not longer used... */ window.localStorage.removeItem('Current Branch') + UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'currentBranch', undefined) + + function onResponse(err, data) { + /* Lets check the result of the call through the http interface */ + data = JSON.parse(data) + if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.CUSTOM_OK_RESPONSE.result) { + let currentBranch = data.message.current + UI.projects.education.spaces.docsSpace.currentBranch = currentBranch + } else { + UI.projects.education.spaces.docsSpace.navigateTo( + data.docs.project, + data.docs.category, + data.docs.type, + data.docs.anchor, + undefined, + data.docs.placeholder + ) + } + } } function setupContributionsBranch() { diff --git a/Projects/Foundations/Schemas/Docs-Topics/A/App/App-Commands-Errors/app-commands-errors-004-app-error-could-not-get-current-branch.json b/Projects/Foundations/Schemas/Docs-Topics/A/App/App-Commands-Errors/app-commands-errors-004-app-error-could-not-get-current-branch.json new file mode 100644 index 000000000..653327d63 --- /dev/null +++ b/Projects/Foundations/Schemas/Docs-Topics/A/App/App-Commands-Errors/app-commands-errors-004-app-error-could-not-get-current-branch.json @@ -0,0 +1,85 @@ +{ + "topic": "App Commands Errors", + "pageNumber": "3", + "type": "App Error - Could Not Get Current Branch", + "definition": { + "text": "There was a problem trying to get the Current Branch. Check the console for errors.", + "updated": 1611129344277 + }, + "paragraphs": [ + { + "style": "Success", + "text": "Check for the following section for details on what may have happened. After you fix the issue, you may try again.", + "updated": 1611152967185 + }, + { + "style": "Title", + "text": "Error Info", + "updated": 1611154641024 + }, + { + "style": "Text", + "text": "In the following section, you will find the information recorded when the error occurred." + }, + { + "style": "Note", + "text": "You will only see the information if you opened this page as a result of the error actually occurring.", + "updated": 1611151375974 + }, + { + "style": "Subtitle", + "text": "Error Message" + }, + { + "style": "Text", + "text": "The following is the Error Message of the Exception that occured at the Client:", + "updated": 1611151299633 + }, + { + "style": "Placeholder", + "text": "errorMessage" + }, + { + "style": "Subtitle", + "text": "Error Stack" + }, + { + "style": "Text", + "text": "The following is the Error Stack of the Exception that occured at the Client:", + "updated": 1611151427220 + }, + { + "style": "Placeholder", + "text": "errorStack" + }, + { + "style": "Subtitle", + "text": "Error Code" + }, + { + "style": "Text", + "text": "The following is the Error Code of the Exception that occured at the Client:", + "updated": 1611151443562 + }, + { + "style": "Placeholder", + "text": "errorCode" + }, + { + "style": "Subtitle", + "text": "Error Details" + }, + { + "style": "Text", + "text": "The following are all the Error details of the Exception that occured at the Client:" + }, + { + "style": "Placeholder", + "text": "errorDetails" + }, + { + "style": "Text", + "text": "" + } + ] +} \ No newline at end of file