From c0dfc101b2a4e1fe248a2abdedaf3e799376a947 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Sat, 15 Oct 2022 13:35:14 +0200 Subject: [PATCH] fix: only show apps with actions in action step --- packages/backend/src/graphql/queries/get-apps.ts | 5 +++++ packages/backend/src/graphql/schema.graphql | 2 +- .../web/src/components/ChooseAppAndEventSubstep/index.tsx | 3 ++- packages/web/src/components/ExecutionStep/index.tsx | 3 ++- packages/web/src/components/FlowStep/index.tsx | 3 ++- packages/web/src/graphql/queries/get-apps.ts | 4 ++-- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/graphql/queries/get-apps.ts b/packages/backend/src/graphql/queries/get-apps.ts index d0928b44..95de6f0a 100644 --- a/packages/backend/src/graphql/queries/get-apps.ts +++ b/packages/backend/src/graphql/queries/get-apps.ts @@ -4,6 +4,7 @@ import { IApp } from '@automatisch/types'; type Params = { name: string; onlyWithTriggers: boolean; + onlyWithActions: boolean; }; const getApps = async (_parent: unknown, params: Params) => { @@ -13,6 +14,10 @@ const getApps = async (_parent: unknown, params: Params) => { return apps.filter((app: IApp) => app.triggers?.length); } + if (params.onlyWithActions) { + return apps.filter((app: IApp) => app.actions?.length); + } + return apps; }; diff --git a/packages/backend/src/graphql/schema.graphql b/packages/backend/src/graphql/schema.graphql index 689f660c..98c7ef73 100644 --- a/packages/backend/src/graphql/schema.graphql +++ b/packages/backend/src/graphql/schema.graphql @@ -1,5 +1,5 @@ type Query { - getApps(name: String, onlyWithTriggers: Boolean): [App] + getApps(name: String, onlyWithTriggers: Boolean, onlyWithActions: Boolean): [App] getApp(key: AvailableAppsEnumType!): App getConnectedApps(name: String): [App] testConnection(id: String!): Connection diff --git a/packages/web/src/components/ChooseAppAndEventSubstep/index.tsx b/packages/web/src/components/ChooseAppAndEventSubstep/index.tsx index 3b53c52e..3a50c4bd 100644 --- a/packages/web/src/components/ChooseAppAndEventSubstep/index.tsx +++ b/packages/web/src/components/ChooseAppAndEventSubstep/index.tsx @@ -49,9 +49,10 @@ function ChooseAppAndEventSubstep( const editorContext = React.useContext(EditorContext); const isTrigger = step.type === 'trigger'; + const isAction = step.type === 'action'; const { data } = useQuery(GET_APPS, { - variables: { onlyWithTriggers: isTrigger }, + variables: { onlyWithTriggers: isTrigger, onlyWithActions: isAction }, }); const apps: IApp[] = data?.getApps; const app = apps?.find((currentApp: IApp) => currentApp.key === step.appKey); diff --git a/packages/web/src/components/ExecutionStep/index.tsx b/packages/web/src/components/ExecutionStep/index.tsx index 3159679a..b11caaaa 100644 --- a/packages/web/src/components/ExecutionStep/index.tsx +++ b/packages/web/src/components/ExecutionStep/index.tsx @@ -31,8 +31,9 @@ export default function ExecutionStep(props: ExecutionStepProps): React.ReactEle const [activeTabIndex, setActiveTabIndex] = React.useState(0); const step: IStep = executionStep.step; const isTrigger = step.type === 'trigger'; + const isAction = step.type === 'action'; const formatMessage = useFormatMessage(); - const { data } = useQuery(GET_APPS, { variables: { onlyWithTriggers: isTrigger }}); + const { data } = useQuery(GET_APPS, { variables: { onlyWithTriggers: isTrigger, onlyWithActions: isAction }}); const apps: IApp[] = data?.getApps; const app = apps?.find((currentApp: IApp) => currentApp.key === step.appKey); diff --git a/packages/web/src/components/FlowStep/index.tsx b/packages/web/src/components/FlowStep/index.tsx index 0910378a..ece980f9 100644 --- a/packages/web/src/components/FlowStep/index.tsx +++ b/packages/web/src/components/FlowStep/index.tsx @@ -108,10 +108,11 @@ export default function FlowStep( null ); const isTrigger = step.type === 'trigger'; + const isAction = step.type === 'action'; const formatMessage = useFormatMessage(); const [currentSubstep, setCurrentSubstep] = React.useState(0); const { data } = useQuery(GET_APPS, { - variables: { onlyWithTriggers: isTrigger }, + variables: { onlyWithTriggers: isTrigger, onlyWithActions: isAction }, }); const [ getStepWithTestExecutions, diff --git a/packages/web/src/graphql/queries/get-apps.ts b/packages/web/src/graphql/queries/get-apps.ts index f22a3adf..6c6df728 100644 --- a/packages/web/src/graphql/queries/get-apps.ts +++ b/packages/web/src/graphql/queries/get-apps.ts @@ -1,8 +1,8 @@ import { gql } from '@apollo/client'; export const GET_APPS = gql` - query GetApps($name: String, $onlyWithTriggers: Boolean) { - getApps(name: $name, onlyWithTriggers: $onlyWithTriggers) { + query GetApps($name: String, $onlyWithTriggers: Boolean, $onlyWithActions: Boolean) { + getApps(name: $name, onlyWithTriggers: $onlyWithTriggers, onlyWithActions: $onlyWithActions) { name key iconUrl