MCPcopy Index your code
hub / github.com/bugy/script-server / save

Function save

web-src/src/admin/store/script-config-module.js:59–83  ·  view source on GitHub ↗
({dispatch, state})

Source from the content-addressed store, hash-verified

57 },
58
59 save({dispatch, state}) {
60 const oldName = state.scriptName;
61 const newName = state.scriptConfig.name;
62
63 const formData = prepareConfigForSave(state.scriptConfig, state.scriptFilename)
64
65 const axiosAction = state.new ? axiosInstance.post : axiosInstance.put;
66
67 return axiosAction('admin/scripts', formData)
68 .then(() => {
69 if (oldName === newName) {
70 dispatch('init', newName);
71 } else {
72 router.push({
73 path: `/scripts/${encodeURIComponent(newName)}`
74 });
75 }
76 })
77 .catch(e => {
78 if ((e.response.status === 422) || (e.response.status === 403)) {
79 e.userMessage = e.response.data;
80 }
81 throw e;
82 });
83 },
84
85 deleteScript({state}) {
86 const oldName = state.scriptName;

Callers

nothing calls this directly

Calls 2

prepareConfigForSaveFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected