diff options
author | Phil Hughes <me@iamphill.com> | 2018-05-01 14:42:55 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-05-01 14:42:55 +0100 |
commit | 2dc3d43c6409a7e68c7a952a541955e20dc8c395 (patch) | |
tree | cda59e604baecf36e1c0c7e0b2478631bacdb7c2 | |
parent | 1180b74b7c61f3f8f2e0f1077c136d44740edf46 (diff) | |
download | gitlab-ce-2dc3d43c6409a7e68c7a952a541955e20dc8c395.tar.gz |
changed which element is hidden
-rw-r--r-- | app/assets/javascripts/ide/components/repo_editor.vue | 27 | ||||
-rw-r--r-- | spec/javascripts/ide/components/repo_editor_spec.js | 27 |
2 files changed, 48 insertions, 6 deletions
diff --git a/app/assets/javascripts/ide/components/repo_editor.vue b/app/assets/javascripts/ide/components/repo_editor.vue index 2d41f0f118e..6b7245bdbc1 100644 --- a/app/assets/javascripts/ide/components/repo_editor.vue +++ b/app/assets/javascripts/ide/components/repo_editor.vue @@ -3,6 +3,7 @@ import { mapState, mapGetters, mapActions } from 'vuex'; import flash from '~/flash'; import ContentViewer from '~/vue_shared/components/content_viewer/content_viewer.vue'; +import { activityBarViews } from '../constants'; import monacoLoader from '../monaco_loader'; import Editor from '../lib/editor'; import IdeFileButtons from './ide_file_buttons.vue'; @@ -19,7 +20,7 @@ export default { }, }, computed: { - ...mapState(['rightPanelCollapsed', 'viewer', 'panelResizing']), + ...mapState(['rightPanelCollapsed', 'viewer', 'panelResizing', 'currentActivityView']), ...mapGetters([ 'currentMergeRequest', 'getStagedFile', @@ -45,6 +46,21 @@ export default { // Compare key to allow for files opened in review mode to be cached differently if (newVal.key !== this.file.key) { this.initMonaco(); + + if (this.currentActivityView !== activityBarViews.edit) { + this.setFileViewMode({ + file: this.file, + viewMode: 'edit', + }); + } + } + }, + currentActivityView() { + if (this.currentActivityView !== activityBarViews.edit) { + this.setFileViewMode({ + file: this.file, + viewMode: 'edit', + }); } }, rightPanelCollapsed() { @@ -172,13 +188,12 @@ export default { id="ide" class="blob-viewer-container blob-editor-container" > - <div - v-show="!isReviewModeActive && !isCommitModeActive" - class="ide-mode-tabs clearfix" - > + <div class="ide-mode-tabs clearfix" > <ul class="nav-links pull-left" - v-if="!shouldHideEditor"> + v-if="!shouldHideEditor" + v-show="!isReviewModeActive && !isCommitModeActive" + > <li :class="editTabCSS"> <a href="javascript:void(0);" diff --git a/spec/javascripts/ide/components/repo_editor_spec.js b/spec/javascripts/ide/components/repo_editor_spec.js index b06a6c62a1c..5a29508b25a 100644 --- a/spec/javascripts/ide/components/repo_editor_spec.js +++ b/spec/javascripts/ide/components/repo_editor_spec.js @@ -5,6 +5,7 @@ import store from '~/ide/stores'; import repoEditor from '~/ide/components/repo_editor.vue'; import monacoLoader from '~/ide/monaco_loader'; import Editor from '~/ide/lib/editor'; +import { activityBarViews } from '~/ide/constants'; import { createComponentWithStore } from '../../helpers/vue_mount_component_helper'; import setTimeoutPromise from '../../helpers/set_timeout_promise_helper'; import { file, resetStore } from '../helpers'; @@ -295,4 +296,30 @@ describe('RepoEditor', () => { }); }); }); + + describe('show tabs', () => { + it('shows tabs in edit mode', () => { + expect(vm.$el.querySelector('.nav-links').style.display).toBe(''); + }); + + it('hides tabs in review mode', done => { + vm.$store.state.currentActivityView = activityBarViews.review; + + vm.$nextTick(() => { + expect(vm.$el.querySelector('.nav-links').style.display).toBe('none'); + + done(); + }); + }); + + it('hides tabs in commit mode', done => { + vm.$store.state.currentActivityView = activityBarViews.commit; + + vm.$nextTick(() => { + expect(vm.$el.querySelector('.nav-links').style.display).toBe('none'); + + done(); + }); + }); + }); }); |