diff options
author | Denys Mishunov <dmishunov@gitlab.com> | 2019-07-03 14:14:44 +0200 |
---|---|---|
committer | Denys Mishunov <dmishunov@gitlab.com> | 2019-07-05 15:37:33 +0200 |
commit | ff1a4a4241f1628491a1aec05b440ff650ba66ad (patch) | |
tree | bd2cf63f652d1cfc911c1e98b8c41bc414b81c75 /app/assets/javascripts/ide/stores | |
parent | 4c954a5c9e54e768aaca0eb787d8d9d2f63ebcae (diff) | |
download | gitlab-ce-ff1a4a4241f1628491a1aec05b440ff650ba66ad.tar.gz |
Initiate editor for any file without content60856-deleting-binary-file
Important to get file data for any file that has no content set yet: we
need this information in order to build a previe for changed/staged
files if they were not yet opened in the editor
Diffstat (limited to 'app/assets/javascripts/ide/stores')
-rw-r--r-- | app/assets/javascripts/ide/stores/mutations/file.js | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/app/assets/javascripts/ide/stores/mutations/file.js b/app/assets/javascripts/ide/stores/mutations/file.js index c88244492e0..a52f1e235ed 100644 --- a/app/assets/javascripts/ide/stores/mutations/file.js +++ b/app/assets/javascripts/ide/stores/mutations/file.js @@ -1,6 +1,7 @@ import * as types from '../mutation_types'; import { sortTree } from '../utils'; import { diffModes } from '../../constants'; +import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; export default { [types.SET_FILE_ACTIVE](state, { path, active }) { @@ -35,19 +36,18 @@ export default { } }, [types.SET_FILE_DATA](state, { data, file }) { - Object.assign(state.entries[file.path], { - id: data.id, - blamePath: data.blame_path, - commitsPath: data.commits_path, - permalink: data.permalink, - rawPath: data.raw_path, - binary: data.binary, - renderError: data.render_error, - raw: (state.entries[file.path] && state.entries[file.path].raw) || null, - baseRaw: null, - html: data.html, - size: data.size, - lastCommitSha: data.last_commit_sha, + const stateEntry = state.entries[file.path]; + const stagedFile = state.stagedFiles.find(f => f.path === file.path); + const openFile = state.openFiles.find(f => f.path === file.path); + const changedFile = state.changedFiles.find(f => f.path === file.path); + + [stateEntry, stagedFile, openFile, changedFile].forEach(f => { + if (f) { + Object.assign(f, convertObjectPropsToCamelCase(data, { dropKeys: ['raw', 'baseRaw'] }), { + raw: (stateEntry && stateEntry.raw) || null, + baseRaw: null, + }); + } }); }, [types.SET_FILE_RAW_DATA](state, { file, raw }) { |