From edab87d3f1144fbc619fa0c0db361fb0de5ab5cd Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 6 Jul 2021 16:04:33 +0800 Subject: [PATCH 1/2] feat: add create pipeline button. --- codegen.yml | 2 +- src/generated/graphql.schema.json | 16 ---------------- src/generated/graphql.tsx | 1 - src/projects/project-detail.tsx | 24 +++++++++++++++++++++++- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/codegen.yml b/codegen.yml index f3cd08d..433cbdd 100644 --- a/codegen.yml +++ b/codegen.yml @@ -1,5 +1,5 @@ overwrite: true -schema: "http://api.fennec.localhost/graphql" +schema: "http://localhost:7122/graphql" # documents: "src/**/*.graphql" generates: src/generated/graphql.tsx: diff --git a/src/generated/graphql.schema.json b/src/generated/graphql.schema.json index 3db904b..13deebf 100644 --- a/src/generated/graphql.schema.json +++ b/src/generated/graphql.schema.json @@ -1949,22 +1949,6 @@ "description": null, "fields": null, "inputFields": [ - { - "name": "projectId", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "branch", "description": null, diff --git a/src/generated/graphql.tsx b/src/generated/graphql.tsx index ce2e159..736d229 100644 --- a/src/generated/graphql.tsx +++ b/src/generated/graphql.tsx @@ -255,7 +255,6 @@ export enum TaskStatuses { } export type UpdatePipelineInput = { - projectId: Scalars['String']; branch: Scalars['String']; name: Scalars['String']; workUnitMetadata: WorkUnitMetadataInput; diff --git a/src/projects/project-detail.tsx b/src/projects/project-detail.tsx index 81320de..6d221f7 100644 --- a/src/projects/project-detail.tsx +++ b/src/projects/project-detail.tsx @@ -1,10 +1,20 @@ import { Project } from "../generated/graphql"; import React, { FC, Fragment } from "react"; -import { IconButton, Grid, makeStyles, Paper, Portal, Typography } from "@material-ui/core"; +import { + IconButton, + Grid, + makeStyles, + Paper, + Portal, + Typography, + Box, +} from "@material-ui/core"; import { useHeaderContainer } from "../layouts"; import { PipelineList } from "../pipelines/pipeline-list"; import { Edit } from '@material-ui/icons'; import { Link } from '@curi/react-dom'; +import { Button } from "@material-ui/core"; +import { AddBox } from "@material-ui/icons"; interface Props { project: Project; @@ -62,6 +72,18 @@ export const ProjectDetail: FC = ({ project, children }) => { > + + + + + From 8e8c93ef2cb454d9c02b7c595937c28b2db03bcf Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 6 Jul 2021 16:49:30 +0800 Subject: [PATCH 2/2] fix(pipelines): create pipeline is not woring. --- src/pipelines/pipeline-editor.tsx | 10 +++------- src/routes.tsx | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/pipelines/pipeline-editor.tsx b/src/pipelines/pipeline-editor.tsx index f7911c5..a37cedc 100644 --- a/src/pipelines/pipeline-editor.tsx +++ b/src/pipelines/pipeline-editor.tsx @@ -1,4 +1,4 @@ -import { gql, Reference, useMutation, useQuery } from "@apollo/client"; +import { gql, Reference, useMutation } from "@apollo/client"; import { useRouter } from "@curi/react-dom"; import { Button, @@ -13,21 +13,17 @@ import { import { Delete } from "@material-ui/icons"; import { FormikHelpers, Formik, Form, Field } from "formik"; import { TextField, TextFieldProps } from "formik-material-ui"; -import { TextField as MuiTextField } from "@material-ui/core"; import { useConfirm } from "material-ui-confirm"; import { useSnackbar } from "notistack"; import { not, omit } from "ramda"; import { ChangeEvent, FC } from "react"; import { Pipeline, - WorkUnitMetadata, PipelineUnits, } from "../generated/graphql"; import { useHeaderContainer } from "../layouts"; import { CREATE_PIPELINE, DELETE_PIPELINE, UPDATE_PIPELINE } from "./mutations"; -import { PIPELINE } from "./queries"; import * as Yup from "yup"; -import { useField } from "formik"; type Values = Partial; @@ -108,7 +104,7 @@ export const PipelineEditor: FC = ({ pipeline }) => { if (isCreate) { await createPipeline({ variables: { - input: values, + pipeline: values, }, }).then(({ data }) => { pipelineId = data!.createPipeline.id; @@ -277,7 +273,7 @@ const ScriptsField: FC = ({ field, form, meta, ...props }) => { onChange: (ev: ChangeEvent) => form.setFieldValue( field.name, - ev.target.value?.split("\n").map((it) => it.trim()) ?? [] + ev.target.value?.split("\n").map((it) => it) ?? [] ), }} /> diff --git a/src/routes.tsx b/src/routes.tsx index 2a90456..7abfa58 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -1,17 +1,19 @@ import { ApolloClient, InMemoryCache } from "@apollo/client"; import { prepareRoutes } from "@curi/router"; -import { omit } from 'ramda'; +import { omit } from "ramda"; import React from "react"; import { ProjectDetail, ProjectEditor, PROJECT } from "./projects"; -import { COMMIT_LIST_QUERY } from './commons/graphql/queries'; -import { CommitList } from './commits/commit-list'; -import { PipelineTaskDetail } from './pipeline-tasks/pipeline-task-detail'; +import { COMMIT_LIST_QUERY } from "./commons/graphql/queries"; +import { CommitList } from "./commits/commit-list"; +import { PipelineTaskDetail } from "./pipeline-tasks/pipeline-task-detail"; import { PipelineEditor } from "./pipelines/pipeline-editor"; import { CreatePipelineInput, CreateProjectInput, Pipeline, + PipelineUnits, Project, + WorkUnitInput, } from "./generated/graphql"; import { PIPELINE } from "./pipelines"; @@ -65,13 +67,20 @@ export default prepareRoutes([ matched, { client }: { client: ApolloClient } ) { + const units = [ + PipelineUnits.Checkout, + PipelineUnits.InstallDependencies, + PipelineUnits.Test, + PipelineUnits.Deploy, + PipelineUnits.CleanUp, + ]; const input: CreatePipelineInput = { name: "", branch: "", projectId: matched!.params.projectId, workUnitMetadata: { version: 1, - units: [], + units: units.map((util) => ({ type: util, scripts: [] })), }, }; return {