feat: Create empty trigger step when the flow is created
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
247b25cfc4
commit
c07b377de1
@@ -0,0 +1,16 @@
|
||||
import { Knex } from "knex";
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
return knex.schema.alterTable('steps', table => {
|
||||
table.string('key').nullable().alter();
|
||||
table.string('app_key').nullable().alter();
|
||||
})
|
||||
}
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
return knex.schema.alterTable('steps', table => {
|
||||
table.string('key').notNullable().alter();
|
||||
table.string('app_key').notNullable().alter();
|
||||
})
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import Flow from '../../models/flow';
|
||||
import Step from '../../models/step';
|
||||
import flowType from '../types/flow';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
@@ -7,6 +8,11 @@ const createFlowResolver = async (req: RequestWithCurrentUser) => {
|
||||
userId: req.currentUser.id
|
||||
});
|
||||
|
||||
await Step.query().insert({
|
||||
flowId: flow.id,
|
||||
type: 'trigger'
|
||||
})
|
||||
|
||||
return flow;
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { GraphQLNonNull, GraphQLString } from 'graphql';
|
||||
import { GraphQLNonNull, GraphQLInt } from 'graphql';
|
||||
import Flow from '../../models/flow';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
import flowType from '../types/flow';
|
||||
@@ -19,7 +19,7 @@ const getFlowResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
const getFlow = {
|
||||
type: flowType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
id: { type: GraphQLNonNull(GraphQLInt) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => getFlowResolver(params, req)
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ const stepType = new GraphQLObjectType({
|
||||
name: 'Step',
|
||||
fields: {
|
||||
id: { type: GraphQLInt },
|
||||
key: { type: GraphQLNonNull(GraphQLString) },
|
||||
appKey: { type: GraphQLNonNull(GraphQLString) },
|
||||
key: { type: GraphQLString },
|
||||
appKey: { type: GraphQLString },
|
||||
type: {
|
||||
type: new GraphQLEnumType({
|
||||
name: 'StepEnumType',
|
||||
|
@@ -10,8 +10,8 @@ enum StepEnumType {
|
||||
class Step extends Base {
|
||||
id!: number
|
||||
flowId!: number
|
||||
key!: string
|
||||
appKey!: string
|
||||
key: string
|
||||
appKey: string
|
||||
type!: StepEnumType
|
||||
connectionId!: number
|
||||
parameters: any
|
||||
@@ -20,7 +20,7 @@ class Step extends Base {
|
||||
|
||||
static jsonSchema = {
|
||||
type: 'object',
|
||||
required: ['key', 'appKey', 'type', 'connectionId'],
|
||||
required: ['type'],
|
||||
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
|
@@ -22,7 +22,7 @@ type EditorLayoutProps = {
|
||||
export default function EditorLayout(props: EditorLayoutProps) {
|
||||
const { flowId } = useParams();
|
||||
const formatMessage = useFormatMessage();
|
||||
const { data } = useQuery(GET_FLOW, { variables: { id: flowId }});
|
||||
const { data } = useQuery(GET_FLOW, { variables: { id: Number(flowId) }});
|
||||
const flow: Flow = data?.getFlow;
|
||||
|
||||
return (
|
||||
@@ -58,4 +58,4 @@ export default function EditorLayout(props: EditorLayoutProps) {
|
||||
</Stack>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user