Commit 08babfe8 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'ce-5276-2-update-stores-for-terminal-file-sync' into 'master'

[CE of Part 2] 5276 Update existing stores for file terminal sync

See merge request gitlab-org/gitlab-ce!29333
parents 1994a375 1bafad51
...@@ -125,6 +125,7 @@ export default { ...@@ -125,6 +125,7 @@ export default {
'setFileEOL', 'setFileEOL',
'updateViewer', 'updateViewer',
'removePendingTab', 'removePendingTab',
'triggerFilesChange',
]), ]),
initEditor() { initEditor() {
if (this.shouldHideEditor) return; if (this.shouldHideEditor) return;
...@@ -256,6 +257,7 @@ export default { ...@@ -256,6 +257,7 @@ export default {
'is-added': file.tempFile, 'is-added': file.tempFile,
}" }"
class="multi-file-editor-holder" class="multi-file-editor-holder"
@focusout="triggerFilesChange"
></div> ></div>
<content-viewer <content-viewer
v-if="showContentViewer" v-if="showContentViewer"
......
...@@ -7,5 +7,13 @@ ...@@ -7,5 +7,13 @@
"name": "toggleFileFinder", "name": "toggleFileFinder",
"params": true "params": true
} }
},
{
"id": "save-files",
"label": "Save files",
"bindings": ["CtrlCmd+KEY_S"],
"action": {
"name": "triggerFilesChange"
}
} }
] ]
...@@ -99,6 +99,7 @@ export const createTempEntry = ( ...@@ -99,6 +99,7 @@ export const createTempEntry = (
commit(types.TOGGLE_FILE_OPEN, file.path); commit(types.TOGGLE_FILE_OPEN, file.path);
commit(types.ADD_FILE_TO_CHANGED, file.path); commit(types.ADD_FILE_TO_CHANGED, file.path);
dispatch('setFileActive', file.path); dispatch('setFileActive', file.path);
dispatch('triggerFilesChange');
} }
if (parentPath && !state.entries[parentPath].opened) { if (parentPath && !state.entries[parentPath].opened) {
...@@ -210,6 +211,8 @@ export const deleteEntry = ({ commit, dispatch, state }, path) => { ...@@ -210,6 +211,8 @@ export const deleteEntry = ({ commit, dispatch, state }, path) => {
if (entry.parentPath && state.entries[entry.parentPath].tree.length === 0) { if (entry.parentPath && state.entries[entry.parentPath].tree.length === 0) {
dispatch('deleteEntry', entry.parentPath); dispatch('deleteEntry', entry.parentPath);
} }
dispatch('triggerFilesChange');
}; };
export const resetOpenFiles = ({ commit }) => commit(types.RESET_OPEN_FILES); export const resetOpenFiles = ({ commit }) => commit(types.RESET_OPEN_FILES);
...@@ -240,6 +243,8 @@ export const renameEntry = ( ...@@ -240,6 +243,8 @@ export const renameEntry = (
if (!entryPath && !entry.tempFile) { if (!entryPath && !entry.tempFile) {
dispatch('deleteEntry', path); dispatch('deleteEntry', path);
} }
dispatch('triggerFilesChange');
}; };
export const getBranchData = ({ commit, state }, { projectId, branchId, force = false } = {}) => export const getBranchData = ({ commit, state }, { projectId, branchId, force = false } = {}) =>
......
...@@ -265,3 +265,8 @@ export const removePendingTab = ({ commit }, file) => { ...@@ -265,3 +265,8 @@ export const removePendingTab = ({ commit }, file) => {
eventHub.$emit(`editor.update.model.dispose.${file.key}`); eventHub.$emit(`editor.update.model.dispose.${file.key}`);
}; };
export const triggerFilesChange = () => {
// Used in EE for file mirroring
eventHub.$emit('ide.files.change');
};
...@@ -719,4 +719,20 @@ describe('IDE store file actions', () => { ...@@ -719,4 +719,20 @@ describe('IDE store file actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
}); });
describe('triggerFilesChange', () => {
beforeEach(() => {
spyOn(eventHub, '$emit');
});
it('emits event that files have changed', done => {
store
.dispatch('triggerFilesChange')
.then(() => {
expect(eventHub.$emit).toHaveBeenCalledWith('ide.files.change');
})
.then(done)
.catch(done.fail);
});
});
}); });
...@@ -488,7 +488,7 @@ describe('Multi-file store actions', () => { ...@@ -488,7 +488,7 @@ describe('Multi-file store actions', () => {
'path', 'path',
store.state, store.state,
[{ type: types.DELETE_ENTRY, payload: 'path' }], [{ type: types.DELETE_ENTRY, payload: 'path' }],
[{ type: 'burstUnusedSeal' }], [{ type: 'burstUnusedSeal' }, { type: 'triggerFilesChange' }],
done, done,
); );
}); });
...@@ -510,7 +510,7 @@ describe('Multi-file store actions', () => { ...@@ -510,7 +510,7 @@ describe('Multi-file store actions', () => {
payload: { path: 'test', name: 'new-name', entryPath: null, parentPath: 'parent-path' }, payload: { path: 'test', name: 'new-name', entryPath: null, parentPath: 'parent-path' },
}, },
], ],
[{ type: 'deleteEntry', payload: 'test' }], [{ type: 'deleteEntry', payload: 'test' }, { type: 'triggerFilesChange' }],
done, done,
); );
}); });
...@@ -558,6 +558,7 @@ describe('Multi-file store actions', () => { ...@@ -558,6 +558,7 @@ describe('Multi-file store actions', () => {
}, },
}, },
{ type: 'deleteEntry', payload: 'test' }, { type: 'deleteEntry', payload: 'test' },
{ type: 'triggerFilesChange' },
], ],
done, done,
); );
......
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