Commit 431de5a6 authored by Phil Hughes's avatar Phil Hughes

change editor when opening file from sidebar

parent 6f892d41
...@@ -231,7 +231,6 @@ ...@@ -231,7 +231,6 @@
} }
.monaco-diff-editor.vs .diffOverview { .monaco-diff-editor.vs .diffOverview {
margin-top: -1px;
background-color: $white-light; background-color: $white-light;
border-left: 1px solid $white-dark; border-left: 1px solid $white-dark;
} }
...@@ -239,6 +238,14 @@ ...@@ -239,6 +238,14 @@
.monaco-diff-editor.vs .diffViewport { .monaco-diff-editor.vs .diffViewport {
display: none; display: none;
} }
.monaco-diff-editor .char-insert {
background-color: #c7f0d2;
}
.monaco-diff-editor .char-delete {
background-color: #fac5cd;
}
} }
.multi-file-editor-holder { .multi-file-editor-holder {
......
...@@ -16,6 +16,7 @@ export default { ...@@ -16,6 +16,7 @@ export default {
'rightPanelCollapsed', 'rightPanelCollapsed',
'panelResizing', 'panelResizing',
'viewer', 'viewer',
'delayViewerUpdated',
]), ]),
shouldHideEditor() { shouldHideEditor() {
return this.activeFile && this.activeFile.binary && !this.activeFile.raw; return this.activeFile && this.activeFile.binary && !this.activeFile.raw;
...@@ -63,6 +64,8 @@ export default { ...@@ -63,6 +64,8 @@ export default {
'setFileLanguage', 'setFileLanguage',
'setEditorPosition', 'setEditorPosition',
'setFileEOL', 'setFileEOL',
'updateViewer',
'updateDelayViewerUpdated',
]), ]),
initMonaco() { initMonaco() {
if (this.shouldHideEditor) return; if (this.shouldHideEditor) return;
...@@ -70,7 +73,15 @@ export default { ...@@ -70,7 +73,15 @@ export default {
this.editor.clearEditor(); this.editor.clearEditor();
this.getRawFileData(this.activeFile) this.getRawFileData(this.activeFile)
.then(() => this.createEditorInstance()) .then(() => {
const viewerPromise = this.delayViewerUpdated ? this.updateViewer('editor') : Promise.resolve();
return viewerPromise;
})
.then(() => {
this.updateDelayViewerUpdated(false);
this.createEditorInstance();
})
.catch((err) => { .catch((err) => {
flash('Error setting up monaco. Please try again.', 'alert', document, null, false, true); flash('Error setting up monaco. Please try again.', 'alert', document, null, false, true);
throw err; throw err;
......
<script> <script>
import { mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import timeAgoMixin from '~/vue_shared/mixins/timeago'; import timeAgoMixin from '~/vue_shared/mixins/timeago';
import skeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue'; import skeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue';
...@@ -70,6 +70,9 @@ ...@@ -70,6 +70,9 @@
} }
}, },
methods: { methods: {
...mapActions([
'updateDelayViewerUpdated',
]),
clickFile(row) { clickFile(row) {
// Manual Action if a tree is selected/opened // Manual Action if a tree is selected/opened
if (this.file.type === 'tree' && this.$router.currentRoute.path === `/project${row.url}`) { if (this.file.type === 'tree' && this.$router.currentRoute.path === `/project${row.url}`) {
...@@ -78,7 +81,13 @@ ...@@ -78,7 +81,13 @@
tree: this.file, tree: this.file,
}); });
} }
this.$router.push(`/project${row.url}`);
const delayPromise = this.file.changed ?
Promise.resolve() : this.updateDelayViewerUpdated(true);
return delayPromise.then(() => {
this.$router.push(`/project${row.url}`);
});
}, },
}, },
}; };
......
...@@ -6,6 +6,8 @@ export default { ...@@ -6,6 +6,8 @@ export default {
rules: [], rules: [],
colors: { colors: {
'editorLineNumber.foreground': '#CCCCCC', 'editorLineNumber.foreground': '#CCCCCC',
'diffEditor.insertedTextBackground': '#ecfdf0',
'diffEditor.removedTextBackground': '#fbe9eb',
}, },
}, },
}; };
...@@ -88,6 +88,10 @@ export const updateViewer = ({ commit }, viewer) => { ...@@ -88,6 +88,10 @@ export const updateViewer = ({ commit }, viewer) => {
commit(types.UPDATE_VIEWER, viewer); commit(types.UPDATE_VIEWER, viewer);
}; };
export const updateDelayViewerUpdated = ({ commit }, delay) => {
commit(types.UPDATE_DELAY_VIEWER_CHANGE, delay);
};
export * from './actions/tree'; export * from './actions/tree';
export * from './actions/file'; export * from './actions/file';
export * from './actions/project'; export * from './actions/project';
......
...@@ -48,3 +48,4 @@ export const TOGGLE_EDIT_MODE = 'TOGGLE_EDIT_MODE'; ...@@ -48,3 +48,4 @@ export const TOGGLE_EDIT_MODE = 'TOGGLE_EDIT_MODE';
export const SET_CURRENT_BRANCH = 'SET_CURRENT_BRANCH'; export const SET_CURRENT_BRANCH = 'SET_CURRENT_BRANCH';
export const UPDATE_VIEWER = 'UPDATE_VIEWER'; export const UPDATE_VIEWER = 'UPDATE_VIEWER';
export const UPDATE_DELAY_VIEWER_CHANGE = 'UPDATE_DELAY_VIEWER_CHANGE';
...@@ -62,6 +62,11 @@ export default { ...@@ -62,6 +62,11 @@ export default {
viewer, viewer,
}); });
}, },
[types.UPDATE_DELAY_VIEWER_CHANGE](state, delayViewerUpdated) {
Object.assign(state, {
delayViewerUpdated,
});
},
...projectMutations, ...projectMutations,
...fileMutations, ...fileMutations,
...treeMutations, ...treeMutations,
......
...@@ -21,4 +21,5 @@ export default () => ({ ...@@ -21,4 +21,5 @@ export default () => ({
rightPanelCollapsed: false, rightPanelCollapsed: false,
panelResizing: false, panelResizing: false,
viewer: 'editor', viewer: 'editor',
delayViewerUpdated: false,
}); });
...@@ -2,6 +2,7 @@ import Vue from 'vue'; ...@@ -2,6 +2,7 @@ import Vue from 'vue';
import store from 'ee/ide/stores'; import store from 'ee/ide/stores';
import service from 'ee/ide/services'; import service from 'ee/ide/services';
import router from 'ee/ide/ide_router'; import router from 'ee/ide/ide_router';
import eventHub from 'ee/ide/eventhub';
import { file, resetStore } from '../../helpers'; import { file, resetStore } from '../../helpers';
describe('Multi-file store file actions', () => { describe('Multi-file store file actions', () => {
...@@ -457,6 +458,8 @@ describe('Multi-file store file actions', () => { ...@@ -457,6 +458,8 @@ describe('Multi-file store file actions', () => {
let tmpFile; let tmpFile;
beforeEach(() => { beforeEach(() => {
spyOn(eventHub, '$on');
tmpFile = file(); tmpFile = file();
tmpFile.content = 'testing'; tmpFile.content = 'testing';
......
...@@ -401,6 +401,8 @@ describe('IDE commit module actions', () => { ...@@ -401,6 +401,8 @@ describe('IDE commit module actions', () => {
}); });
it('redirects to new merge request page', (done) => { it('redirects to new merge request page', (done) => {
spyOn(eventHub, '$on');
store.state.commit.commitAction = '3'; store.state.commit.commitAction = '3';
store.dispatch('commit/commitChanges') store.dispatch('commit/commitChanges')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment