chore: clean code.

This commit is contained in:
Ivan Li 2021-07-17 21:57:19 +08:00
parent 2efbad4fe5
commit 3644718b19
7 changed files with 114 additions and 134 deletions

View File

@ -39,7 +39,7 @@ export const AuthProvider: FC = ({ children }) => {
}} }}
> >
{children} {children}
{/* {accessToken ? null : <Login />} */} {accessToken ? null : <Login />}
</Context.Provider> </Context.Provider>
); );
}; };

View File

@ -45,7 +45,7 @@ export const Login: FC = () => {
ref={iframeRef} ref={iframeRef}
className={classes.iframe} className={classes.iframe}
title="Auth" title="Auth"
src="http://user.localhost/auth/login" src="https://user.rpi.ivanli.cc/auth/login"
></iframe> ></iframe>
); );
}; };

View File

@ -2,7 +2,7 @@ import { useApolloClient } from "@apollo/client";
import { createRouterComponent } from "@curi/react-dom"; import { createRouterComponent } from "@curi/react-dom";
import { createRouter, announce } from "@curi/router"; import { createRouter, announce } from "@curi/router";
import { browser } from "@hickory/browser"; import { browser } from "@hickory/browser";
import { FC, ReactNode, useEffect, useMemo, useState } from "react"; import { FC, useEffect, useState } from "react";
import routes from "../../routes"; import routes from "../../routes";
import { LinearProgress } from "@material-ui/core"; import { LinearProgress } from "@material-ui/core";

View File

@ -1,8 +1,11 @@
import { gql } from '@apollo/client';
export type Maybe<T> = T | null; export type Maybe<T> = T | null;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }; export type Exact<T extends { [key: string]: unknown }> = {
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> }; [K in keyof T]: T[K];
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> }; };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> &
{ [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> &
{ [SubKey in K]: Maybe<T[SubKey]> };
/** All built-in and custom scalars, mapped to their actual values */ /** All built-in and custom scalars, mapped to their actual values */
export type Scalars = { export type Scalars = {
ID: string; ID: string;
@ -15,174 +18,165 @@ export type Scalars = {
}; };
export type Commit = { export type Commit = {
__typename?: 'Commit'; __typename?: "Commit";
hash: Scalars['String']; hash: Scalars["String"];
date: Scalars['DateTime']; date: Scalars["DateTime"];
message: Scalars['String']; message: Scalars["String"];
refs: Scalars['String']; refs: Scalars["String"];
body: Scalars['String']; body: Scalars["String"];
author_name: Scalars['String']; author_name: Scalars["String"];
author_email: Scalars['String']; author_email: Scalars["String"];
tasks: Array<PipelineTask>; tasks: Array<PipelineTask>;
}; };
export type CreatePipelineInput = { export type CreatePipelineInput = {
projectId: Scalars['String']; projectId: Scalars["String"];
branch: Scalars['String']; branch: Scalars["String"];
name: Scalars['String']; name: Scalars["String"];
workUnitMetadata: WorkUnitMetadataInput; workUnitMetadata: WorkUnitMetadataInput;
}; };
export type CreatePipelineTaskInput = { export type CreatePipelineTaskInput = {
pipelineId: Scalars['String']; pipelineId: Scalars["String"];
commit: Scalars['String']; commit: Scalars["String"];
units: Array<PipelineUnits>; units: Array<PipelineUnits>;
}; };
export type CreateProjectInput = { export type CreateProjectInput = {
name: Scalars['String']; name: Scalars["String"];
comment: Scalars['String']; comment: Scalars["String"];
sshUrl: Scalars['String']; sshUrl: Scalars["String"];
webUrl?: Maybe<Scalars['String']>; webUrl?: Maybe<Scalars["String"]>;
webHookSecret?: Maybe<Scalars['String']>; webHookSecret?: Maybe<Scalars["String"]>;
}; };
export type Hello = { export type Hello = {
__typename?: 'Hello'; __typename?: "Hello";
message: Scalars['String']; message: Scalars["String"];
}; };
export type LogFields = { export type LogFields = {
__typename?: 'LogFields'; __typename?: "LogFields";
hash: Scalars['String']; hash: Scalars["String"];
date: Scalars['String']; date: Scalars["String"];
message: Scalars['String']; message: Scalars["String"];
refs: Scalars['String']; refs: Scalars["String"];
body: Scalars['String']; body: Scalars["String"];
author_name: Scalars['String']; author_name: Scalars["String"];
author_email: Scalars['String']; author_email: Scalars["String"];
tasks: Array<PipelineTask>; tasks: Array<PipelineTask>;
}; };
export type Mutation = { export type Mutation = {
__typename?: 'Mutation'; __typename?: "Mutation";
createProject: Project; createProject: Project;
updateProject: Project; updateProject: Project;
removeProject: Scalars['Float']; removeProject: Scalars["Float"];
createPipeline: Pipeline; createPipeline: Pipeline;
updatePipeline: Pipeline; updatePipeline: Pipeline;
deletePipeline: Scalars['Float']; deletePipeline: Scalars["Float"];
createPipelineTask: PipelineTask; createPipelineTask: PipelineTask;
stopPipelineTask: Scalars['Boolean']; stopPipelineTask: Scalars["Boolean"];
}; };
export type MutationCreateProjectArgs = { export type MutationCreateProjectArgs = {
project: CreateProjectInput; project: CreateProjectInput;
}; };
export type MutationUpdateProjectArgs = { export type MutationUpdateProjectArgs = {
project: UpdateProjectInput; project: UpdateProjectInput;
}; };
export type MutationRemoveProjectArgs = { export type MutationRemoveProjectArgs = {
id: Scalars['String']; id: Scalars["String"];
}; };
export type MutationCreatePipelineArgs = { export type MutationCreatePipelineArgs = {
pipeline: CreatePipelineInput; pipeline: CreatePipelineInput;
}; };
export type MutationUpdatePipelineArgs = { export type MutationUpdatePipelineArgs = {
pipeline: UpdatePipelineInput; pipeline: UpdatePipelineInput;
}; };
export type MutationDeletePipelineArgs = { export type MutationDeletePipelineArgs = {
id: Scalars['String']; id: Scalars["String"];
}; };
export type MutationCreatePipelineTaskArgs = { export type MutationCreatePipelineTaskArgs = {
task: CreatePipelineTaskInput; task: CreatePipelineTaskInput;
}; };
export type MutationStopPipelineTaskArgs = { export type MutationStopPipelineTaskArgs = {
id: Scalars['String']; id: Scalars["String"];
}; };
export type Pipeline = { export type Pipeline = {
__typename?: 'Pipeline'; __typename?: "Pipeline";
id: Scalars['ID']; id: Scalars["ID"];
project: Project; project: Project;
projectId: Scalars['String']; projectId: Scalars["String"];
branch: Scalars['String']; branch: Scalars["String"];
name: Scalars['String']; name: Scalars["String"];
workUnitMetadata: WorkUnitMetadata; workUnitMetadata: WorkUnitMetadata;
}; };
export type PipelineTask = { export type PipelineTask = {
__typename?: 'PipelineTask'; __typename?: "PipelineTask";
id: Scalars['ID']; id: Scalars["ID"];
pipeline: Pipeline; pipeline: Pipeline;
pipelineId: Scalars['String']; pipelineId: Scalars["String"];
commit: Scalars['String']; commit: Scalars["String"];
units: Array<PipelineUnits>; units: Array<PipelineUnits>;
logs: Array<PipelineTaskLogs>; logs: Array<PipelineTaskLogs>;
status: TaskStatuses; status: TaskStatuses;
startedAt?: Maybe<Scalars['DateTime']>; startedAt?: Maybe<Scalars["DateTime"]>;
endedAt?: Maybe<Scalars['DateTime']>; endedAt?: Maybe<Scalars["DateTime"]>;
runOn: Scalars['String']; runOn: Scalars["String"];
}; };
export type PipelineTaskEvent = { export type PipelineTaskEvent = {
__typename?: 'PipelineTaskEvent'; __typename?: "PipelineTaskEvent";
taskId: Scalars['String']; taskId: Scalars["String"];
pipelineId: Scalars['String']; pipelineId: Scalars["String"];
projectId: Scalars['String']; projectId: Scalars["String"];
unit?: Maybe<PipelineUnits>; unit?: Maybe<PipelineUnits>;
emittedAt: Scalars['DateTime']; emittedAt: Scalars["DateTime"];
message: Scalars['String']; message: Scalars["String"];
messageType: Scalars['String']; messageType: Scalars["String"];
status: TaskStatuses; status: TaskStatuses;
}; };
export type PipelineTaskLogs = { export type PipelineTaskLogs = {
__typename?: 'PipelineTaskLogs'; __typename?: "PipelineTaskLogs";
unit: PipelineUnits; unit: PipelineUnits;
status: TaskStatuses; status: TaskStatuses;
startedAt?: Maybe<Scalars['DateTime']>; startedAt?: Maybe<Scalars["DateTime"]>;
endedAt?: Maybe<Scalars['DateTime']>; endedAt?: Maybe<Scalars["DateTime"]>;
logs: Scalars['String']; logs: Scalars["String"];
}; };
/** 流水线单元 */ /** 流水线单元 */
export enum PipelineUnits { export enum PipelineUnits {
Checkout = 'checkout', Checkout = "checkout",
InstallDependencies = 'installDependencies', InstallDependencies = "installDependencies",
Test = 'test', Test = "test",
Deploy = 'deploy', Deploy = "deploy",
CleanUp = 'cleanUp' CleanUp = "cleanUp",
} }
export type Project = { export type Project = {
__typename?: 'Project'; __typename?: "Project";
id: Scalars['ID']; id: Scalars["ID"];
name: Scalars['String']; name: Scalars["String"];
comment: Scalars['String']; comment: Scalars["String"];
sshUrl: Scalars['String']; sshUrl: Scalars["String"];
webUrl?: Maybe<Scalars['String']>; webUrl?: Maybe<Scalars["String"]>;
webHookSecret?: Maybe<Scalars['String']>; webHookSecret?: Maybe<Scalars["String"]>;
}; };
export type Query = { export type Query = {
__typename?: 'Query'; __typename?: "Query";
hello: Hello; hello: Hello;
projects: Array<Project>; projects: Array<Project>;
project: Project; project: Project;
@ -193,101 +187,92 @@ export type Query = {
pipelineTask: PipelineTask; pipelineTask: PipelineTask;
}; };
export type QueryProjectArgs = { export type QueryProjectArgs = {
id: Scalars['String']; id: Scalars["String"];
}; };
export type QueryPipelinesArgs = { export type QueryPipelinesArgs = {
projectId?: Maybe<Scalars['String']>; projectId?: Maybe<Scalars["String"]>;
}; };
export type QueryPipelineArgs = { export type QueryPipelineArgs = {
id: Scalars['String']; id: Scalars["String"];
}; };
export type QueryCommitsArgs = { export type QueryCommitsArgs = {
pipelineId: Scalars['String']; pipelineId: Scalars["String"];
}; };
export type QueryListPipelineTaskByPipelineIdArgs = { export type QueryListPipelineTaskByPipelineIdArgs = {
pipelineId: Scalars['String']; pipelineId: Scalars["String"];
}; };
export type QueryPipelineTaskArgs = { export type QueryPipelineTaskArgs = {
id: Scalars['String']; id: Scalars["String"];
}; };
export type Subscription = { export type Subscription = {
__typename?: 'Subscription'; __typename?: "Subscription";
syncCommits?: Maybe<Scalars['String']>; syncCommits?: Maybe<Scalars["String"]>;
pipelineTaskEvent: PipelineTaskEvent; pipelineTaskEvent: PipelineTaskEvent;
pipelineTaskChanged: PipelineTask; pipelineTaskChanged: PipelineTask;
}; };
export type SubscriptionSyncCommitsArgs = { export type SubscriptionSyncCommitsArgs = {
appInstance?: Maybe<Scalars['String']>; appInstance?: Maybe<Scalars["String"]>;
pipelineId: Scalars['String']; pipelineId: Scalars["String"];
}; };
export type SubscriptionPipelineTaskEventArgs = { export type SubscriptionPipelineTaskEventArgs = {
taskId: Scalars['String']; taskId: Scalars["String"];
}; };
export type SubscriptionPipelineTaskChangedArgs = { export type SubscriptionPipelineTaskChangedArgs = {
id: Scalars['String']; id: Scalars["String"];
}; };
/** 任务状态 */ /** 任务状态 */
export enum TaskStatuses { export enum TaskStatuses {
Success = 'success', Success = "success",
Failed = 'failed', Failed = "failed",
Working = 'working', Working = "working",
Pending = 'pending' Pending = "pending",
} }
export type UpdatePipelineInput = { export type UpdatePipelineInput = {
branch: Scalars['String']; branch: Scalars["String"];
name: Scalars['String']; name: Scalars["String"];
workUnitMetadata: WorkUnitMetadataInput; workUnitMetadata: WorkUnitMetadataInput;
id: Scalars['String']; id: Scalars["String"];
}; };
export type UpdateProjectInput = { export type UpdateProjectInput = {
name: Scalars['String']; name: Scalars["String"];
comment: Scalars['String']; comment: Scalars["String"];
sshUrl: Scalars['String']; sshUrl: Scalars["String"];
webUrl?: Maybe<Scalars['String']>; webUrl?: Maybe<Scalars["String"]>;
webHookSecret?: Maybe<Scalars['String']>; webHookSecret?: Maybe<Scalars["String"]>;
id: Scalars['String']; id: Scalars["String"];
}; };
export type WorkUnit = { export type WorkUnit = {
__typename?: 'WorkUnit'; __typename?: "WorkUnit";
type: PipelineUnits; type: PipelineUnits;
scripts: Array<Scalars['String']>; scripts: Array<Scalars["String"]>;
}; };
export type WorkUnitInput = { export type WorkUnitInput = {
type: PipelineUnits; type: PipelineUnits;
scripts: Array<Scalars['String']>; scripts: Array<Scalars["String"]>;
}; };
export type WorkUnitMetadata = { export type WorkUnitMetadata = {
__typename?: 'WorkUnitMetadata'; __typename?: "WorkUnitMetadata";
version: Scalars['Int']; version: Scalars["Int"];
units: Array<WorkUnit>; units: Array<WorkUnit>;
}; };
export type WorkUnitMetadataInput = { export type WorkUnitMetadataInput = {
version?: Maybe<Scalars['Int']>; version?: Maybe<Scalars["Int"]>;
units: Array<WorkUnitInput>; units: Array<WorkUnitInput>;
}; };

View File

@ -1,4 +1,4 @@
import React, { FC, useCallback, useRef, useState } from "react"; import React, { FC, useCallback, useState } from "react";
import clsx from "clsx"; import clsx from "clsx";
import { import {
createStyles, createStyles,
@ -10,7 +10,6 @@ import Drawer from "@material-ui/core/Drawer";
import AppBar from "@material-ui/core/AppBar"; import AppBar from "@material-ui/core/AppBar";
import Toolbar from "@material-ui/core/Toolbar"; import Toolbar from "@material-ui/core/Toolbar";
import CssBaseline from "@material-ui/core/CssBaseline"; import CssBaseline from "@material-ui/core/CssBaseline";
import Typography from "@material-ui/core/Typography";
import Divider from "@material-ui/core/Divider"; import Divider from "@material-ui/core/Divider";
import IconButton from "@material-ui/core/IconButton"; import IconButton from "@material-ui/core/IconButton";
import MenuIcon from "@material-ui/icons/Menu"; import MenuIcon from "@material-ui/icons/Menu";

View File

@ -11,8 +11,6 @@ import {
import { FC, MouseEventHandler, useMemo } from "react"; import { FC, MouseEventHandler, useMemo } from "react";
import { Pipeline, Project } from "../generated/graphql"; import { Pipeline, Project } from "../generated/graphql";
import { CallMerge, Edit } from "@material-ui/icons"; import { CallMerge, Edit } from "@material-ui/icons";
import { clone } from "ramda";
import { useEffect } from "react";
interface Props { interface Props {
projectId: string; projectId: string;
@ -32,7 +30,7 @@ const PIPELINES = gql`
`; `;
export const PipelineList: FC<Props> = ({ projectId }) => { export const PipelineList: FC<Props> = ({ projectId }) => {
const { data, loading } = useQuery< const { data } = useQuery<
{ pipelines: Pipeline[]; project: Project }, { pipelines: Pipeline[]; project: Project },
{ projectId: string } { projectId: string }
>(PIPELINES, { >(PIPELINES, {

View File

@ -1,7 +1,6 @@
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 { 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";
@ -13,7 +12,6 @@ import {
Pipeline, Pipeline,
PipelineUnits, PipelineUnits,
Project, Project,
WorkUnitInput,
} from "./generated/graphql"; } from "./generated/graphql";
import { PIPELINE } from "./pipelines"; import { PIPELINE } from "./pipelines";