From e79db43d2cf269beec700353e776e92b15ac9af9 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Fri, 19 Jan 2018 09:38:34 +0000 Subject: WebIDE: Fix Commit bugs --- app/assets/javascripts/api.js | 1 + app/assets/javascripts/flash.js | 4 ++ .../ide/components/repo_commit_section.vue | 9 +-- .../javascripts/ide/components/repo_editor.vue | 5 +- .../javascripts/ide/components/repo_file.vue | 11 ++-- app/assets/javascripts/ide/ide_router.js | 4 +- app/assets/javascripts/ide/lib/editor.js | 4 +- app/assets/javascripts/ide/stores/actions.js | 35 ++++++---- .../javascripts/ide/stores/actions/branch.js | 2 +- app/assets/javascripts/ide/stores/actions/file.js | 18 ++++-- .../javascripts/ide/stores/actions/project.js | 2 +- app/assets/javascripts/ide/stores/actions/tree.js | 4 +- .../javascripts/ide/stores/mutations/file.js | 2 +- app/assets/javascripts/lib/utils/text_utility.js | 2 +- .../vue_shared/components/loading_icon.vue | 2 +- app/assets/stylesheets/framework/variables.scss | 2 + app/assets/stylesheets/pages/repo.scss | 74 ++++++++++++++++++++-- app/helpers/webpack_helper.rb | 14 ++-- app/views/ide/index.html.haml | 5 +- app/views/layouts/nav_only.html.haml | 5 +- config/webpack.config.js | 7 +- spec/javascripts/flash_spec.js | 12 +++- spec/javascripts/lib/utils/text_utility_spec.js | 6 +- spec/javascripts/repo/stores/actions_spec.js | 13 ---- .../vue_shared/components/loading_icon_spec.js | 3 +- 25 files changed, 169 insertions(+), 77 deletions(-) diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index 21d8c790e90..38c67b5f04e 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -218,6 +218,7 @@ const Api = { (jqXHR, textStatus, errorThrown) => { const error = new Error(`${options.url}: ${errorThrown}`); error.textStatus = textStatus; + if (jqXHR && jqXHR.responseJSON) error.responseJSON = jqXHR.responseJSON; reject(error); }, ); diff --git a/app/assets/javascripts/flash.js b/app/assets/javascripts/flash.js index 44deab9288e..a0af2875ab5 100644 --- a/app/assets/javascripts/flash.js +++ b/app/assets/javascripts/flash.js @@ -10,6 +10,7 @@ const hideFlash = (flashEl, fadeTransition = true) => { flashEl.addEventListener('transitionend', () => { flashEl.remove(); + if (document.body.classList.contains('flash-shown')) document.body.classList.remove('flash-shown'); }, { once: true, passive: true, @@ -64,6 +65,7 @@ const createFlash = function createFlash( parent = document, actionConfig = null, fadeTransition = true, + addBodyClass = false, ) { const flashContainer = parent.querySelector('.flash-container'); @@ -86,6 +88,8 @@ const createFlash = function createFlash( flashContainer.style.display = 'block'; + if (addBodyClass) document.body.classList.add('flash-shown'); + return flashContainer; }; diff --git a/app/assets/javascripts/ide/components/repo_commit_section.vue b/app/assets/javascripts/ide/components/repo_commit_section.vue index 5279417a72a..96b1bb78c1d 100644 --- a/app/assets/javascripts/ide/components/repo_commit_section.vue +++ b/app/assets/javascripts/ide/components/repo_commit_section.vue @@ -68,12 +68,8 @@ export default { this.commitChanges({ payload, newMr: this.startNewMR }) .then(() => { this.submitCommitsLoading = false; - this.$store.dispatch('getTreeData', { - projectId: this.currentProjectId, - branch: this.currentBranchId, - endpoint: `/tree/${this.currentBranchId}`, - force: true, - }); + this.commitMessage = ''; + this.startNewMR = false; }) .catch(() => { this.submitCommitsLoading = false; @@ -153,6 +149,7 @@ you started editing. Would you like to create a new branch?`)" type="submit" :disabled="commitButtonDisabled" class="btn btn-default btn-sm append-right-10 prepend-left-10" + :class="{ disabled: submitCommitsLoading }" > this.setupEditor()) - .catch(() => flash('Error setting up monaco. Please try again.')); + .catch((err) => { + flash('Error setting up monaco. Please try again.', 'alert', document, null, false, true); + throw err; + }); }, setupEditor() { if (!this.activeFile) return; diff --git a/app/assets/javascripts/ide/components/repo_file.vue b/app/assets/javascripts/ide/components/repo_file.vue index f7f4db89bdf..110918872fb 100644 --- a/app/assets/javascripts/ide/components/repo_file.vue +++ b/app/assets/javascripts/ide/components/repo_file.vue @@ -35,9 +35,12 @@ return this.file.type === 'tree'; }, levelIndentation() { - return { - marginLeft: `${this.file.level * 16}px`, - }; + if (this.file.level > 0) { + return { + marginLeft: `${this.file.level * 16}px`, + }; + } + return {}; }, shortId() { return this.file.id.substr(0, 8); @@ -111,7 +114,7 @@ />