Commit 1bafad51 authored by Paul Slaughter's avatar Paul Slaughter

IDE trigger files change event

- On CMD+S when editor is focused
- On editor blur
- When file is created in tree
- When file is removed in tree
- When file is renamed in tree
parent f08abfcc
......@@ -125,6 +125,7 @@ export default {
'setFileEOL',
'updateViewer',
'removePendingTab',
'triggerFilesChange',
]),
initEditor() {
if (this.shouldHideEditor) return;
......@@ -256,6 +257,7 @@ export default {
'is-added': file.tempFile,
}"
class="multi-file-editor-holder"
@focusout="triggerFilesChange"
></div>
<content-viewer
v-if="showContentViewer"
......
......@@ -7,5 +7,13 @@
"name": "toggleFileFinder",
"params": true
}
},
{
"id": "save-files",
"label": "Save files",
"bindings": ["CtrlCmd+KEY_S"],
"action": {
"name": "triggerFilesChange"
}
}
]
......@@ -99,6 +99,7 @@ export const createTempEntry = (
commit(types.TOGGLE_FILE_OPEN, file.path);
commit(types.ADD_FILE_TO_CHANGED, file.path);
dispatch('setFileActive', file.path);
dispatch('triggerFilesChange');
}
if (parentPath && !state.entries[parentPath].opened) {
......@@ -210,6 +211,8 @@ export const deleteEntry = ({ commit, dispatch, state }, path) => {
if (entry.parentPath && state.entries[entry.parentPath].tree.length === 0) {
dispatch('deleteEntry', entry.parentPath);
}
dispatch('triggerFilesChange');
};
export const resetOpenFiles = ({ commit }) => commit(types.RESET_OPEN_FILES);
......@@ -240,6 +243,8 @@ export const renameEntry = (
if (!entryPath && !entry.tempFile) {
dispatch('deleteEntry', path);
}
dispatch('triggerFilesChange');
};
export const getBranchData = ({ commit, state }, { projectId, branchId, force = false } = {}) =>
......
......@@ -265,3 +265,8 @@ export const removePendingTab = ({ commit }, file) => {
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', () => {
.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', () => {
'path',
store.state,
[{ type: types.DELETE_ENTRY, payload: 'path' }],
[{ type: 'burstUnusedSeal' }],
[{ type: 'burstUnusedSeal' }, { type: 'triggerFilesChange' }],
done,
);
});
......@@ -510,7 +510,7 @@ describe('Multi-file store actions', () => {
payload: { path: 'test', name: 'new-name', entryPath: null, parentPath: 'parent-path' },
},
],
[{ type: 'deleteEntry', payload: 'test' }],
[{ type: 'deleteEntry', payload: 'test' }, { type: 'triggerFilesChange' }],
done,
);
});
......@@ -558,6 +558,7 @@ describe('Multi-file store actions', () => {
},
},
{ type: 'deleteEntry', payload: 'test' },
{ type: 'triggerFilesChange' },
],
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