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 Flow from '../../models/flow';
|
||||||
|
import Step from '../../models/step';
|
||||||
import flowType from '../types/flow';
|
import flowType from '../types/flow';
|
||||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||||
|
|
||||||
@@ -7,6 +8,11 @@ const createFlowResolver = async (req: RequestWithCurrentUser) => {
|
|||||||
userId: req.currentUser.id
|
userId: req.currentUser.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await Step.query().insert({
|
||||||
|
flowId: flow.id,
|
||||||
|
type: 'trigger'
|
||||||
|
})
|
||||||
|
|
||||||
return flow;
|
return flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { GraphQLNonNull, GraphQLString } from 'graphql';
|
import { GraphQLNonNull, GraphQLInt } from 'graphql';
|
||||||
import Flow from '../../models/flow';
|
import Flow from '../../models/flow';
|
||||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||||
import flowType from '../types/flow';
|
import flowType from '../types/flow';
|
||||||
@@ -19,7 +19,7 @@ const getFlowResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
|||||||
const getFlow = {
|
const getFlow = {
|
||||||
type: flowType,
|
type: flowType,
|
||||||
args: {
|
args: {
|
||||||
id: { type: GraphQLNonNull(GraphQLString) },
|
id: { type: GraphQLNonNull(GraphQLInt) },
|
||||||
},
|
},
|
||||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => getFlowResolver(params, req)
|
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => getFlowResolver(params, req)
|
||||||
}
|
}
|
||||||
|
@@ -5,8 +5,8 @@ const stepType = new GraphQLObjectType({
|
|||||||
name: 'Step',
|
name: 'Step',
|
||||||
fields: {
|
fields: {
|
||||||
id: { type: GraphQLInt },
|
id: { type: GraphQLInt },
|
||||||
key: { type: GraphQLNonNull(GraphQLString) },
|
key: { type: GraphQLString },
|
||||||
appKey: { type: GraphQLNonNull(GraphQLString) },
|
appKey: { type: GraphQLString },
|
||||||
type: {
|
type: {
|
||||||
type: new GraphQLEnumType({
|
type: new GraphQLEnumType({
|
||||||
name: 'StepEnumType',
|
name: 'StepEnumType',
|
||||||
|
@@ -10,8 +10,8 @@ enum StepEnumType {
|
|||||||
class Step extends Base {
|
class Step extends Base {
|
||||||
id!: number
|
id!: number
|
||||||
flowId!: number
|
flowId!: number
|
||||||
key!: string
|
key: string
|
||||||
appKey!: string
|
appKey: string
|
||||||
type!: StepEnumType
|
type!: StepEnumType
|
||||||
connectionId!: number
|
connectionId!: number
|
||||||
parameters: any
|
parameters: any
|
||||||
@@ -20,7 +20,7 @@ class Step extends Base {
|
|||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
required: ['key', 'appKey', 'type', 'connectionId'],
|
required: ['type'],
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
id: { type: 'integer' },
|
id: { type: 'integer' },
|
||||||
|
@@ -22,7 +22,7 @@ type EditorLayoutProps = {
|
|||||||
export default function EditorLayout(props: EditorLayoutProps) {
|
export default function EditorLayout(props: EditorLayoutProps) {
|
||||||
const { flowId } = useParams();
|
const { flowId } = useParams();
|
||||||
const formatMessage = useFormatMessage();
|
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;
|
const flow: Flow = data?.getFlow;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user