From bc0b739aea1b8377ff10c86c110b60961d72b327 Mon Sep 17 00:00:00 2001 From: Artur Fedorov <afedorov@gitlab.com> Date: Fri, 22 Mar 2024 19:48:12 +0000 Subject: [PATCH] Remove Vue delete for vue 3 migration Vue.delete is no longer supported in Vue 3 has to be replaced with common mutation --- .../ide/stores/modules/editor/mutations.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/ide/stores/modules/editor/mutations.js b/app/assets/javascripts/ide/stores/modules/editor/mutations.js index f332fe9dce969..88b0fe769b16e 100644 --- a/app/assets/javascripts/ide/stores/modules/editor/mutations.js +++ b/app/assets/javascripts/ide/stores/modules/editor/mutations.js @@ -2,6 +2,13 @@ import Vue from 'vue'; import * as types from './mutation_types'; import { getFileEditorOrDefault } from './utils'; +const deletePropertyAndReturnNewCopy = (source, property) => { + const fileEditorsCopy = { ...source }; + delete fileEditorsCopy[property]; + + return fileEditorsCopy; +}; + export default { [types.UPDATE_FILE_EDITOR](state, { path, data }) { const editor = getFileEditorOrDefault(state.fileEditors, path); @@ -9,7 +16,7 @@ export default { Vue.set(state.fileEditors, path, Object.assign(editor, data)); }, [types.REMOVE_FILE_EDITOR](state, path) { - Vue.delete(state.fileEditors, path); + state.fileEditors = deletePropertyAndReturnNewCopy(state.fileEditors, path); }, [types.RENAME_FILE_EDITOR](state, { path, newPath }) { const existing = state.fileEditors[path]; @@ -19,7 +26,7 @@ export default { return; } - Vue.delete(state.fileEditors, path); + state.fileEditors = deletePropertyAndReturnNewCopy(state.fileEditors, path); Vue.set(state.fileEditors, newPath, existing); }, }; -- GitLab