Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mutations.js « editor « modules « stores « ide « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f332fe9dce96931f858ae860b5b6940682adf781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import Vue from 'vue';
import * as types from './mutation_types';
import { getFileEditorOrDefault } from './utils';

export default {
  [types.UPDATE_FILE_EDITOR](state, { path, data }) {
    const editor = getFileEditorOrDefault(state.fileEditors, path);

    Vue.set(state.fileEditors, path, Object.assign(editor, data));
  },
  [types.REMOVE_FILE_EDITOR](state, path) {
    Vue.delete(state.fileEditors, path);
  },
  [types.RENAME_FILE_EDITOR](state, { path, newPath }) {
    const existing = state.fileEditors[path];

    // Gracefully do nothing if fileEditor isn't found.
    if (!existing) {
      return;
    }

    Vue.delete(state.fileEditors, path);
    Vue.set(state.fileEditors, newPath, existing);
  },
};