From 221aa8687f92ae291f1f89014b2a6a3ad6eee9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=B1dvan=20Akca?= Date: Mon, 25 Sep 2023 15:20:34 +0300 Subject: [PATCH] feat(miro): add create board action --- .../apps/miro/actions/create-board/index.ts | 94 +++++++++++++++++++ .../backend/src/apps/miro/actions/index.ts | 3 + .../src/apps/miro/auth/refresh-token.ts | 1 + packages/backend/src/apps/miro/index.ts | 2 + packages/docs/pages/.vitepress/config.js | 9 ++ packages/docs/pages/apps/miro/actions.md | 12 +++ packages/docs/pages/apps/miro/connection.md | 19 ++++ packages/docs/pages/public/favicons/miro.svg | 1 + 8 files changed, 141 insertions(+) create mode 100644 packages/backend/src/apps/miro/actions/create-board/index.ts create mode 100644 packages/backend/src/apps/miro/actions/index.ts create mode 100644 packages/docs/pages/apps/miro/actions.md create mode 100644 packages/docs/pages/apps/miro/connection.md create mode 100644 packages/docs/pages/public/favicons/miro.svg diff --git a/packages/backend/src/apps/miro/actions/create-board/index.ts b/packages/backend/src/apps/miro/actions/create-board/index.ts new file mode 100644 index 00000000..435139b5 --- /dev/null +++ b/packages/backend/src/apps/miro/actions/create-board/index.ts @@ -0,0 +1,94 @@ +import defineAction from '../../../../helpers/define-action'; + +export default defineAction({ + name: 'Create board', + key: 'createBoard', + description: 'Creates a new board.', + arguments: [ + { + label: 'Title', + key: 'title', + type: 'string' as const, + required: true, + description: 'Title for the board.', + variables: true, + }, + { + label: 'Description', + key: 'description', + type: 'string' as const, + required: false, + description: 'Description of the board.', + variables: true, + }, + { + label: 'Team Access', + key: 'teamAccess', + type: 'dropdown' as const, + required: false, + description: + 'Team access to the board. Can be private, view, comment or edit. Default: private.', + variables: true, + options: [ + { + label: 'Private - nobody in the team can find and access the board', + value: 'private', + }, + { + label: 'View - any team member can find and view the board', + value: 'view', + }, + { + label: 'Comment - any team member can find and comment the board', + value: 'comment', + }, + { + label: 'Edit - any team member can find and edit the board', + value: 'edit', + }, + ], + }, + { + label: 'Access Via Link', + key: 'accessViaLink', + type: 'dropdown' as const, + required: false, + description: + 'Access to the board by link. Can be private, view, comment. Default: private.', + variables: true, + options: [ + { + label: 'Private - only you have access to the board', + value: 'private', + }, + { + label: 'View - can view, no sign-in required', + value: 'view', + }, + { + label: 'Comment - can comment, no sign-in required', + value: 'comment', + }, + ], + }, + ], + + async run($) { + const body = { + name: $.step.parameters.title, + description: $.step.parameters.description, + policy: { + sharingPolicy: { + access: $.step.parameters.accessViaLink || 'private', + teamAccess: $.step.parameters.teamAccess || 'private', + }, + }, + }; + + const { data } = await $.http.post('/v2/boards', body); + + $.setActionItem({ + raw: data, + }); + }, +}); diff --git a/packages/backend/src/apps/miro/actions/index.ts b/packages/backend/src/apps/miro/actions/index.ts new file mode 100644 index 00000000..3b3c2ee7 --- /dev/null +++ b/packages/backend/src/apps/miro/actions/index.ts @@ -0,0 +1,3 @@ +import createBoard from './create-board'; + +export default [createBoard]; diff --git a/packages/backend/src/apps/miro/auth/refresh-token.ts b/packages/backend/src/apps/miro/auth/refresh-token.ts index 03228573..8c160b73 100644 --- a/packages/backend/src/apps/miro/auth/refresh-token.ts +++ b/packages/backend/src/apps/miro/auth/refresh-token.ts @@ -14,6 +14,7 @@ const refreshToken = async ($: IGlobalVariable) => { await $.auth.set({ accessToken: data.access_token, expiresIn: data.expires_in, + refreshToken: data.refresh_token, scope: data.scope, tokenType: data.token_type, }); diff --git a/packages/backend/src/apps/miro/index.ts b/packages/backend/src/apps/miro/index.ts index f66e808f..4a253905 100644 --- a/packages/backend/src/apps/miro/index.ts +++ b/packages/backend/src/apps/miro/index.ts @@ -1,6 +1,7 @@ import defineApp from '../../helpers/define-app'; import addAuthHeader from './common/add-auth-header'; import auth from './auth'; +import actions from './actions'; export default defineApp({ name: 'Miro', @@ -13,4 +14,5 @@ export default defineApp({ supportsConnections: true, beforeRequest: [addAuthHeader], auth, + actions, }); diff --git a/packages/docs/pages/.vitepress/config.js b/packages/docs/pages/.vitepress/config.js index 3058a946..df3daac3 100644 --- a/packages/docs/pages/.vitepress/config.js +++ b/packages/docs/pages/.vitepress/config.js @@ -178,6 +178,15 @@ export default defineConfig({ { text: 'Connection', link: '/apps/mattermost/connection' }, ], }, + { + text: 'Miro', + collapsible: true, + collapsed: true, + items: [ + { text: 'Actions', link: '/apps/miro/actions' }, + { text: 'Connection', link: '/apps/miro/connection' }, + ], + }, { text: 'Notion', collapsible: true, diff --git a/packages/docs/pages/apps/miro/actions.md b/packages/docs/pages/apps/miro/actions.md new file mode 100644 index 00000000..b7bd7a14 --- /dev/null +++ b/packages/docs/pages/apps/miro/actions.md @@ -0,0 +1,12 @@ +--- +favicon: /favicons/miro.svg +items: + - name: Create board + desc: Creates a new board. +--- + + + + diff --git a/packages/docs/pages/apps/miro/connection.md b/packages/docs/pages/apps/miro/connection.md new file mode 100644 index 00000000..6508637c --- /dev/null +++ b/packages/docs/pages/apps/miro/connection.md @@ -0,0 +1,19 @@ +# Miro + +:::info +This page explains the steps you need to follow to set up the Miro +connection in Automatisch. If any of the steps are outdated, please let us know! +::: + +1. Go to [link](https://miro.com/signup/) to create a user account in Miro. +2. After signin in, go to [link](https://miro.com/app/dashboard/?createDevTeam=1) to create a developer team. +3. In the **Create new team** modal, select the checkbox and then click **Create team** button. +4. After that, click **Create new app** in Your app section. +5. Fill the field of **App Name**. +6. Select the **Expire user authorization token** checkbox and click the **Create app**. +7. Copy **OAuth Redirect URL** from Automatisch to the **Redirect URI for OAuth2.0** field. +8. Give permissions for **boards**, **identity**, and **team** scopes in Permissions field. +9. Copy the **Client ID** value to the `Client ID` field on Automatisch. +10. Copy the **Client secret** value to the `Client Secret` field on Automatisch. +11. Click **Submit** button on Automatisch. +12. Congrats! Start using your new Miro connection within the flows. diff --git a/packages/docs/pages/public/favicons/miro.svg b/packages/docs/pages/public/favicons/miro.svg new file mode 100644 index 00000000..b87ea9a1 --- /dev/null +++ b/packages/docs/pages/public/favicons/miro.svg @@ -0,0 +1 @@ + \ No newline at end of file