Merge pull request #603 from automatisch/issue-598
fix: only show apps with actions in action step
This commit is contained in:
@@ -4,6 +4,7 @@ import { IApp } from '@automatisch/types';
|
|||||||
type Params = {
|
type Params = {
|
||||||
name: string;
|
name: string;
|
||||||
onlyWithTriggers: boolean;
|
onlyWithTriggers: boolean;
|
||||||
|
onlyWithActions: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getApps = async (_parent: unknown, params: Params) => {
|
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);
|
return apps.filter((app: IApp) => app.triggers?.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (params.onlyWithActions) {
|
||||||
|
return apps.filter((app: IApp) => app.actions?.length);
|
||||||
|
}
|
||||||
|
|
||||||
return apps;
|
return apps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
type Query {
|
type Query {
|
||||||
getApps(name: String, onlyWithTriggers: Boolean): [App]
|
getApps(name: String, onlyWithTriggers: Boolean, onlyWithActions: Boolean): [App]
|
||||||
getApp(key: AvailableAppsEnumType!): App
|
getApp(key: AvailableAppsEnumType!): App
|
||||||
getConnectedApps(name: String): [App]
|
getConnectedApps(name: String): [App]
|
||||||
testConnection(id: String!): Connection
|
testConnection(id: String!): Connection
|
||||||
|
@@ -49,9 +49,10 @@ function ChooseAppAndEventSubstep(
|
|||||||
const editorContext = React.useContext(EditorContext);
|
const editorContext = React.useContext(EditorContext);
|
||||||
|
|
||||||
const isTrigger = step.type === 'trigger';
|
const isTrigger = step.type === 'trigger';
|
||||||
|
const isAction = step.type === 'action';
|
||||||
|
|
||||||
const { data } = useQuery(GET_APPS, {
|
const { data } = useQuery(GET_APPS, {
|
||||||
variables: { onlyWithTriggers: isTrigger },
|
variables: { onlyWithTriggers: isTrigger, onlyWithActions: isAction },
|
||||||
});
|
});
|
||||||
const apps: IApp[] = data?.getApps;
|
const apps: IApp[] = data?.getApps;
|
||||||
const app = apps?.find((currentApp: IApp) => currentApp.key === step.appKey);
|
const app = apps?.find((currentApp: IApp) => currentApp.key === step.appKey);
|
||||||
|
@@ -31,8 +31,9 @@ export default function ExecutionStep(props: ExecutionStepProps): React.ReactEle
|
|||||||
const [activeTabIndex, setActiveTabIndex] = React.useState(0);
|
const [activeTabIndex, setActiveTabIndex] = React.useState(0);
|
||||||
const step: IStep = executionStep.step;
|
const step: IStep = executionStep.step;
|
||||||
const isTrigger = step.type === 'trigger';
|
const isTrigger = step.type === 'trigger';
|
||||||
|
const isAction = step.type === 'action';
|
||||||
const formatMessage = useFormatMessage();
|
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 apps: IApp[] = data?.getApps;
|
||||||
const app = apps?.find((currentApp: IApp) => currentApp.key === step.appKey);
|
const app = apps?.find((currentApp: IApp) => currentApp.key === step.appKey);
|
||||||
|
|
||||||
|
@@ -108,10 +108,11 @@ export default function FlowStep(
|
|||||||
null
|
null
|
||||||
);
|
);
|
||||||
const isTrigger = step.type === 'trigger';
|
const isTrigger = step.type === 'trigger';
|
||||||
|
const isAction = step.type === 'action';
|
||||||
const formatMessage = useFormatMessage();
|
const formatMessage = useFormatMessage();
|
||||||
const [currentSubstep, setCurrentSubstep] = React.useState<number | null>(0);
|
const [currentSubstep, setCurrentSubstep] = React.useState<number | null>(0);
|
||||||
const { data } = useQuery(GET_APPS, {
|
const { data } = useQuery(GET_APPS, {
|
||||||
variables: { onlyWithTriggers: isTrigger },
|
variables: { onlyWithTriggers: isTrigger, onlyWithActions: isAction },
|
||||||
});
|
});
|
||||||
const [
|
const [
|
||||||
getStepWithTestExecutions,
|
getStepWithTestExecutions,
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
export const GET_APPS = gql`
|
export const GET_APPS = gql`
|
||||||
query GetApps($name: String, $onlyWithTriggers: Boolean) {
|
query GetApps($name: String, $onlyWithTriggers: Boolean, $onlyWithActions: Boolean) {
|
||||||
getApps(name: $name, onlyWithTriggers: $onlyWithTriggers) {
|
getApps(name: $name, onlyWithTriggers: $onlyWithTriggers, onlyWithActions: $onlyWithActions) {
|
||||||
name
|
name
|
||||||
key
|
key
|
||||||
iconUrl
|
iconUrl
|
||||||
|
Reference in New Issue
Block a user