Merge branch 'develop' of ssh://git.ivanli.cc:7018/Fennec/fennec-fe into develop

This commit is contained in:
Ivan Li 2021-07-10 19:03:14 +08:00
commit de24645436
4 changed files with 41 additions and 14 deletions

View File

@ -1,5 +1,5 @@
overwrite: true overwrite: true
schema: "http://api.fennec.localhost/graphql" schema: "http://localhost:7122/graphql"
# documents: "src/**/*.graphql" # documents: "src/**/*.graphql"
generates: generates:
src/generated/graphql.tsx: src/generated/graphql.tsx:

View File

@ -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 { useRouter } from "@curi/react-dom";
import { import {
Button, Button,
@ -13,21 +13,17 @@ import {
import { Delete } from "@material-ui/icons"; import { Delete } from "@material-ui/icons";
import { FormikHelpers, Formik, Form, Field } from "formik"; import { FormikHelpers, Formik, Form, Field } from "formik";
import { TextField, TextFieldProps } from "formik-material-ui"; import { TextField, TextFieldProps } from "formik-material-ui";
import { TextField as MuiTextField } from "@material-ui/core";
import { useConfirm } from "material-ui-confirm"; import { useConfirm } from "material-ui-confirm";
import { useSnackbar } from "notistack"; import { useSnackbar } from "notistack";
import { not, omit } from "ramda"; import { not, omit } from "ramda";
import { ChangeEvent, FC } from "react"; import { ChangeEvent, FC } from "react";
import { import {
Pipeline, Pipeline,
WorkUnitMetadata,
PipelineUnits, PipelineUnits,
} from "../generated/graphql"; } from "../generated/graphql";
import { useHeaderContainer } from "../layouts"; import { useHeaderContainer } from "../layouts";
import { CREATE_PIPELINE, DELETE_PIPELINE, UPDATE_PIPELINE } from "./mutations"; import { CREATE_PIPELINE, DELETE_PIPELINE, UPDATE_PIPELINE } from "./mutations";
import { PIPELINE } from "./queries";
import * as Yup from "yup"; import * as Yup from "yup";
import { useField } from "formik";
type Values = Partial<Pipeline>; type Values = Partial<Pipeline>;
@ -108,7 +104,7 @@ export const PipelineEditor: FC<Props> = ({ pipeline }) => {
if (isCreate) { if (isCreate) {
await createPipeline({ await createPipeline({
variables: { variables: {
input: values, pipeline: values,
}, },
}).then(({ data }) => { }).then(({ data }) => {
pipelineId = data!.createPipeline.id; pipelineId = data!.createPipeline.id;
@ -277,7 +273,7 @@ const ScriptsField: FC<TextFieldProps> = ({ field, form, meta, ...props }) => {
onChange: (ev: ChangeEvent<HTMLInputElement>) => onChange: (ev: ChangeEvent<HTMLInputElement>) =>
form.setFieldValue( form.setFieldValue(
field.name, field.name,
ev.target.value?.split("\n").map((it) => it.trim()) ?? [] ev.target.value?.split("\n").map((it) => it) ?? []
), ),
}} }}
/> />

View File

@ -1,10 +1,20 @@
import { Project } from "../generated/graphql"; import { Project } from "../generated/graphql";
import React, { FC, Fragment } from "react"; 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 { useHeaderContainer } from "../layouts";
import { PipelineList } from "../pipelines/pipeline-list"; import { PipelineList } from "../pipelines/pipeline-list";
import { Edit } from '@material-ui/icons'; import { Edit } from '@material-ui/icons';
import { Link } from '@curi/react-dom'; import { Link } from '@curi/react-dom';
import { Button } from "@material-ui/core";
import { AddBox } from "@material-ui/icons";
interface Props { interface Props {
project: Project; project: Project;
@ -62,6 +72,18 @@ export const ProjectDetail: FC<Props> = ({ project, children }) => {
> >
<Grid item xs={3} lg={2} style={{ height: "100%", display: "flex" }}> <Grid item xs={3} lg={2} style={{ height: "100%", display: "flex" }}>
<Paper className={classes.pipelineListContainer}> <Paper className={classes.pipelineListContainer}>
<Box m={2}>
<Link name="create-pipeline" params={{ projectId: project.id }}>
<Button
variant="contained"
color="primary"
title="New Pipeline"
startIcon={<AddBox />}
>
New Pipeline
</Button>
</Link>
</Box>
<PipelineList projectId={project.id} /> <PipelineList projectId={project.id} />
</Paper> </Paper>
</Grid> </Grid>

View File

@ -1,17 +1,19 @@
import { ApolloClient, InMemoryCache } from "@apollo/client"; import { ApolloClient, InMemoryCache } from "@apollo/client";
import { prepareRoutes } from "@curi/router"; import { prepareRoutes } from "@curi/router";
import { omit } from 'ramda'; import { omit } from "ramda";
import React from "react"; import React from "react";
import { ProjectDetail, ProjectEditor, PROJECT } from "./projects"; import { ProjectDetail, ProjectEditor, PROJECT } from "./projects";
import { COMMIT_LIST_QUERY } from './commons/graphql/queries'; import { COMMIT_LIST_QUERY } from "./commons/graphql/queries";
import { CommitList } from './commits/commit-list'; import { CommitList } from "./commits/commit-list";
import { PipelineTaskDetail } from './pipeline-tasks/pipeline-task-detail'; import { PipelineTaskDetail } from "./pipeline-tasks/pipeline-task-detail";
import { PipelineEditor } from "./pipelines/pipeline-editor"; import { PipelineEditor } from "./pipelines/pipeline-editor";
import { import {
CreatePipelineInput, CreatePipelineInput,
CreateProjectInput, CreateProjectInput,
Pipeline, Pipeline,
PipelineUnits,
Project, Project,
WorkUnitInput,
} from "./generated/graphql"; } from "./generated/graphql";
import { PIPELINE } from "./pipelines"; import { PIPELINE } from "./pipelines";
@ -65,13 +67,20 @@ export default prepareRoutes([
matched, matched,
{ client }: { client: ApolloClient<InMemoryCache> } { client }: { client: ApolloClient<InMemoryCache> }
) { ) {
const units = [
PipelineUnits.Checkout,
PipelineUnits.InstallDependencies,
PipelineUnits.Test,
PipelineUnits.Deploy,
PipelineUnits.CleanUp,
];
const input: CreatePipelineInput = { const input: CreatePipelineInput = {
name: "", name: "",
branch: "", branch: "",
projectId: matched!.params.projectId, projectId: matched!.params.projectId,
workUnitMetadata: { workUnitMetadata: {
version: 1, version: 1,
units: [], units: units.map((util) => ({ type: util, scripts: [] })),
}, },
}; };
return { return {