diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-05-09 12:04:38 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-05-09 12:04:38 +0000 |
commit | 58086f822f181f49c309458d8357f96236d6cf4d (patch) | |
tree | 9b8d120f0e9e2e7fff3a838b3c8d9cc398bac494 | |
parent | f29e69375f303ac021b28a1d8ca314f10cb3037e (diff) | |
parent | 96785e7713de958de8c7786545aea66caf1557f1 (diff) | |
download | gitlab-ce-58086f822f181f49c309458d8357f96236d6cf4d.tar.gz |
Merge branch 'fix-ide-empty-editor' into 'master'
Fixed empty editors in the IDE
Closes #46153
See merge request gitlab-org/gitlab-ce!18842
-rw-r--r-- | app/assets/javascripts/ide/lib/common/model.js | 6 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/file.js | 2 | ||||
-rw-r--r-- | spec/javascripts/ide/lib/common/model_spec.js | 4 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/actions/file_spec.js | 16 |
4 files changed, 25 insertions, 3 deletions
diff --git a/app/assets/javascripts/ide/lib/common/model.js b/app/assets/javascripts/ide/lib/common/model.js index 016dcda1fa1..b1e43a1e38c 100644 --- a/app/assets/javascripts/ide/lib/common/model.js +++ b/app/assets/javascripts/ide/lib/common/model.js @@ -14,12 +14,12 @@ export default class Model { (this.originalModel = this.monaco.editor.createModel( head ? head.content : this.file.raw, undefined, - new this.monaco.Uri(null, null, `original/${this.file.key}`), + new this.monaco.Uri(null, null, `original/${this.path}`), )), (this.model = this.monaco.editor.createModel( this.content, undefined, - new this.monaco.Uri(null, null, this.file.key), + new this.monaco.Uri(null, null, this.path), )), ); if (this.file.mrChange) { @@ -27,7 +27,7 @@ export default class Model { (this.baseModel = this.monaco.editor.createModel( this.file.baseRaw, undefined, - new this.monaco.Uri(null, null, `target/${this.file.path}`), + new this.monaco.Uri(null, null, `target/${this.path}`), )), ); } diff --git a/app/assets/javascripts/ide/stores/actions/file.js b/app/assets/javascripts/ide/stores/actions/file.js index 3ac9b9222ca..b6baa693104 100644 --- a/app/assets/javascripts/ide/stores/actions/file.js +++ b/app/assets/javascripts/ide/stores/actions/file.js @@ -196,6 +196,8 @@ export const unstageChange = ({ commit }, path) => { }; export const openPendingTab = ({ commit, getters, dispatch, state }, { file, keyPrefix }) => { + if (getters.activeFile && getters.activeFile.key === `${keyPrefix}-${file.key}`) return false; + state.openFiles.forEach(f => eventHub.$emit(`editor.update.model.dispose.${f.key}`)); commit(types.ADD_PENDING_TAB, { file, keyPrefix }); diff --git a/spec/javascripts/ide/lib/common/model_spec.js b/spec/javascripts/ide/lib/common/model_spec.js index 7a6c22b6d27..c278bf92b08 100644 --- a/spec/javascripts/ide/lib/common/model_spec.js +++ b/spec/javascripts/ide/lib/common/model_spec.js @@ -28,6 +28,10 @@ describe('Multi-file editor library model', () => { expect(model.originalModel).not.toBeNull(); expect(model.model).not.toBeNull(); expect(model.baseModel).not.toBeNull(); + + expect(model.originalModel.uri.path).toBe('original/path--path'); + expect(model.model.uri.path).toBe('path--path'); + expect(model.baseModel.uri.path).toBe('target/path--path'); }); it('creates model with head file to compare against', () => { diff --git a/spec/javascripts/ide/stores/actions/file_spec.js b/spec/javascripts/ide/stores/actions/file_spec.js index 3ef5a859001..7bebc2288e3 100644 --- a/spec/javascripts/ide/stores/actions/file_spec.js +++ b/spec/javascripts/ide/stores/actions/file_spec.js @@ -569,6 +569,22 @@ describe('IDE store file actions', () => { .catch(done.fail); }); + it('returns false when already opened', done => { + store.state.openFiles.push({ + ...f, + active: true, + key: `pending-${f.key}`, + }); + + store + .dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }) + .then(added => { + expect(added).toBe(false); + }) + .then(done) + .catch(done.fail); + }); + it('pushes router URL when added', done => { store.state.currentBranchId = 'master'; |