refactor: Use only arguments for action definitions

This commit is contained in:
Faruk AYDIN
2022-10-31 18:26:58 +01:00
parent bcfc9beb99
commit 1cfe84fc3d
10 changed files with 246 additions and 321 deletions

View File

@@ -4,46 +4,32 @@ export default defineAction({
name: 'Send a message to channel',
key: 'sendMessageToChannel',
description: 'Send a message to a specific channel you specify.',
substeps: [
arguments: [
{
key: 'chooseConnection',
name: 'Choose connection',
},
{
key: 'chooseAction',
name: 'Set up action',
arguments: [
{
label: 'Channel',
key: 'channel',
type: 'dropdown' as const,
required: true,
description: 'Pick a channel to send the message to.',
variables: false,
source: {
type: 'query',
name: 'getData',
arguments: [
{
name: 'key',
value: 'listChannels',
},
],
label: 'Channel',
key: 'channel',
type: 'dropdown' as const,
required: true,
description: 'Pick a channel to send the message to.',
variables: false,
source: {
type: 'query',
name: 'getData',
arguments: [
{
name: 'key',
value: 'listChannels',
},
},
{
label: 'Message text',
key: 'message',
type: 'string' as const,
required: true,
description: 'The content of your new message.',
variables: true,
}
],
],
},
},
{
key: 'testStep',
name: 'Test action',
label: 'Message text',
key: 'message',
type: 'string' as const,
required: true,
description: 'The content of your new message.',
variables: true,
},
],
@@ -51,7 +37,10 @@ export default defineAction({
const data = {
content: $.step.parameters.message as string,
};
const response = await $.http?.post(`/channels/${$.step.parameters.channel}/messages`, data);
const response = await $.http?.post(
`/channels/${$.step.parameters.channel}/messages`,
data
);
$.setActionItem({ raw: response.data });
},