feat(commits): commit and task list.

This commit is contained in:
Ivan Li
2021-05-09 15:29:11 +08:00
parent 5d3f97667a
commit dbb81fa952
16 changed files with 784 additions and 32 deletions

View File

@@ -2,8 +2,12 @@ import { ApolloClient, InMemoryCache } from "@apollo/client";
import { prepareRoutes } from "@curi/router";
import { omit } from 'ramda';
import React from 'react';
import { CreateProjectInput, Project } from './generated/graphql';
import { CreateProjectInput, Pipeline, Project } from './generated/graphql';
import { PipelineDetail } from './pipelines';
import { ProjectDetail, ProjectEditor, PROJECT } from "./projects";
import { COMMIT_LIST_QUERY } from './commons/graphql/queries';
import { CommitList } from './commits/commit-list';
import { COMMITS } from './commits/queries';
export default prepareRoutes([
{
@@ -12,7 +16,7 @@ export default prepareRoutes([
respond() {
return { body: () => <div>DashBoard</div> };
},
},
}, // dashboard
{
name: "create-project",
path: "projects/create",
@@ -26,7 +30,7 @@ export default prepareRoutes([
};
return { body: () => <ProjectEditor project={input} /> };
},
},
}, // create-project
{
name: "edit-project",
path: "projects/:projectId/edit",
@@ -47,7 +51,7 @@ export default prepareRoutes([
respond({ resolved }) {
return resolved;
},
},
}, // edit-project
{
name: "project-detail",
path: "projects/:projectId",
@@ -68,5 +72,38 @@ export default prepareRoutes([
respond({ resolved }) {
return resolved;
},
},
children: [
{
name: "pipeline-commits",
path: "pipelines/:pipelineId/commits",
async resolve(
matched,
{ client }: { client: ApolloClient<InMemoryCache> }
) {
const { data } = await client.query<{
pipeline: Pipeline;
project: Project;
}>({
query: COMMIT_LIST_QUERY,
variables: {
projectId: matched?.params.projectId,
pipelineId: matched?.params.pipelineId,
},
});
return {
body: () => (
<ProjectDetail project={omit(["__typename"], data.project)}>
<CommitList
pipeline={omit(["__typename"], data.pipeline)}
/>
</ProjectDetail>
),
};
},
respond({ resolved, error }) {
return resolved || <div>Failed</div>;
},
},
],
}, // project-detail
]);