MCPcopy
hub / github.com/FlowiseAI/Flowise / deleteVariable

Function deleteVariable

packages/ui/src/views/variables/index.jsx:146–191  ·  view source on GitHub ↗
(variable)

Source from the content-addressed store, hash-verified

144 }
145
146 const deleteVariable = async (variable) => {
147 const confirmPayload = {
148 title: `Delete`,
149 description: `Delete variable ${variable.name}?`,
150 confirmButtonName: 'Delete',
151 cancelButtonName: 'Cancel'
152 }
153 const isConfirmed = await confirm(confirmPayload)
154
155 if (isConfirmed) {
156 try {
157 const deleteResp = await variablesApi.deleteVariable(variable.id)
158 if (deleteResp.data) {
159 enqueueSnackbar({
160 message: 'Variable deleted',
161 options: {
162 key: new Date().getTime() + Math.random(),
163 variant: 'success',
164 action: (key) => (
165 <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}>
166 <IconX />
167 </Button>
168 )
169 }
170 })
171 onConfirm()
172 }
173 } catch (error) {
174 enqueueSnackbar({
175 message: `Failed to delete Variable: ${
176 typeof error.response.data === 'object' ? error.response.data.message : error.response.data
177 }`,
178 options: {
179 key: new Date().getTime() + Math.random(),
180 variant: 'error',
181 persist: true,
182 action: (key) => (
183 <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}>
184 <IconX />
185 </Button>
186 )
187 }
188 })
189 }
190 }
191 }
192
193 const onConfirm = () => {
194 setShowVariableDialog(false)

Callers 1

VariablesFunction · 0.70

Calls 5

enqueueSnackbarFunction · 0.90
closeSnackbarFunction · 0.90
confirmFunction · 0.85
onConfirmFunction · 0.70
getTimeMethod · 0.45

Tested by

no test coverage detected