feat(pipelines): edit view.

This commit is contained in:
Ivan Li
2021-06-27 00:27:57 +08:00
parent 120a720be5
commit 653d779efb
10 changed files with 464 additions and 33 deletions

View File

@@ -1,12 +1,19 @@
import { ApolloClient, InMemoryCache } from "@apollo/client";
import { prepareRoutes } from "@curi/router";
import { omit } from 'ramda';
import React from 'react';
import { CreateProjectInput, Pipeline, Project } from './generated/graphql';
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 { PipelineEditor } from "./pipelines/pipeline-editor";
import {
CreatePipelineInput,
CreateProjectInput,
Pipeline,
Project,
} from "./generated/graphql";
import { PIPELINE } from "./pipelines";
export default prepareRoutes([
{
@@ -51,6 +58,49 @@ export default prepareRoutes([
return resolved;
},
}, // edit-project
{
name: "create-pipeline",
path: "projects/:projectId/pipelines/create",
async resolve(
matched,
{ client }: { client: ApolloClient<InMemoryCache> }
) {
const input: CreatePipelineInput = {
name: "",
branch: "",
projectId: matched!.params.projectId,
workUnitMetadata: {
version: 1,
units: [],
},
};
return {
body: () => <PipelineEditor pipeline={input as any} />,
};
},
respond({ resolved }) {
return resolved;
},
}, // create-pipeline
{
name: "edit-pipeline",
path: "projects/:projectId/pipelines/:pipelineId/edit",
async resolve(
matched,
{ client }: { client: ApolloClient<InMemoryCache> }
) {
const { data } = await client.query<{ pipeline: Pipeline }>({
query: PIPELINE,
variables: { id: matched?.params.pipelineId },
});
return {
body: () => <PipelineEditor pipeline={data.pipeline} />,
};
},
respond({ resolved }) {
return resolved;
},
}, // edit-pipeline
{
name: "project-detail",
path: "projects/:projectId",
@@ -100,7 +150,7 @@ export default prepareRoutes([
respond({ resolved, error }) {
return resolved || <div>Failed</div>;
},
},
}, // pipeline-commits
{
name: "pipeline-task-detail",
path: "pipelines/:pipelineId/tasks/:taskId",
@@ -129,7 +179,7 @@ export default prepareRoutes([
respond({ resolved, error }) {
return resolved || <div>Failed</div>;
},
},
}, // pipeline-task-detail
],
}, // project-detail
]);