diff --git a/src/constants/default.ts b/src/constants/default.ts index e568d52..1eaaddb 100644 --- a/src/constants/default.ts +++ b/src/constants/default.ts @@ -53,21 +53,6 @@ export const RESET_CODE_DEFAULT = `console.log(context.panel.data, context.panel */ export const INITIAL_PAYLOAD_DEFAULT = `return {}`; -/** - * Update Payload - */ -export const UPDATE_PAYLOAD_DEFAULT = `const payload = {}; - -context.panel.elements.forEach((element) => { - if (!element.value) { - return; - } - - payload[element.id] = element.value; -}) - -return payload;`; - /** * Initial Request */ diff --git a/src/module.ts b/src/module.ts index 40f9cec..bfc1cc5 100644 --- a/src/module.ts +++ b/src/module.ts @@ -45,7 +45,6 @@ import { SUBMIT_BUTTON_DEFAULT, UPDATE_CODE_DEFAULT, UPDATE_ENABLED_OPTIONS, - UPDATE_PAYLOAD_DEFAULT, UPDATE_REQUEST_METHOD_OPTIONS, } from './constants'; import { getMigratedOptions } from './migration'; @@ -464,7 +463,7 @@ export const plugin = new PanelPlugin(FormPanel) type: CodeEditorType.GET_PAYLOAD, variablesSuggestions: true, }, - defaultValue: UPDATE_PAYLOAD_DEFAULT, + defaultValue: '', showIf: (config) => isRequestConfigured(config.update) && config.update.payloadMode === PayloadMode.CUSTOM, }) .addCustomEditor({ @@ -477,7 +476,7 @@ export const plugin = new PanelPlugin(FormPanel) settings: { datasourceKey: 'update.datasource', }, - defaultValue: UPDATE_PAYLOAD_DEFAULT, + defaultValue: '', showIf: (config) => isRequestConfigured(config.update) && config.update.method === RequestMethod.DATASOURCE &&