feat(wordpress): add find post action

This commit is contained in:
Rıdvan Akca
2024-05-29 11:48:54 +02:00
parent 69416c24e2
commit c191b7a3cf
3 changed files with 39 additions and 1 deletions

View File

@@ -0,0 +1,35 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Find post',
key: 'findPost',
description: 'Finds a post.',
arguments: [
{
label: 'Post ID',
key: 'postId',
type: 'dropdown',
required: false,
description: 'Choose a post to update.',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listPosts',
},
],
},
},
],
async run($) {
const { postId } = $.step.parameters;
const response = await $.http.get(`?rest_route=/wp/v2/posts/${postId}`);
$.setActionItem({ raw: response.data });
},
});

View File

@@ -1,4 +1,5 @@
import createPost from './create-post/index.js';
import findPost from './find-post/index.js';
import updatePost from './update-post/index.js';
export default [createPost, updatePost];
export default [createPost, findPost, updatePost];

View File

@@ -3,6 +3,8 @@ favicon: /favicons/wordpress.svg
items:
- name: Create post
desc: Creates a new post.
- name: Find post
desc: Finds a post.
- name: Update post
desc: Updates a post.
---