Compare commits

..

No commits in common. "32421599eaa935b3bb48ede7850e0ce2bdf2c3dd" and "044e74b7ff284d02e73860dcb109862aeebfdf71" have entirely different histories.

6 changed files with 35 additions and 599 deletions

View File

@ -606,324 +606,6 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "PipelineTaskLogs",
"description": null,
"fields": [
{
"name": "unit",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "ENUM",
"name": "PipelineUnits",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "status",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "ENUM",
"name": "PipelineUnits",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "startedAt",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "DateTime",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "endedAt",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "DateTime",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "logs",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "DateTime",
"description": "A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format.",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "PipelineTask",
"description": null,
"fields": [
{
"name": "id",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pipeline",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Pipeline",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pipelineId",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "commit",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "units",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "ENUM",
"name": "PipelineUnits",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "logs",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "PipelineTaskLogs",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "status",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "ENUM",
"name": "TaskStatuses",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "startedAt",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "DateTime",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "endedAt",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "DateTime",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "TaskStatuses",
"description": "任务状态",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "success",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "failed",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "working",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pending",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "PipelineTaskLogMessage",
"description": null,
"fields": [
{
"name": "unit",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "ENUM",
"name": "PipelineUnits",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "WorkUnitInput",
@ -1410,39 +1092,6 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "createPipelineTask",
"description": null,
"args": [
{
"name": "task",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "CreatePipelineTaskInput",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "PipelineTask",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
@ -1766,73 +1415,6 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "CreatePipelineTaskInput",
"description": null,
"fields": null,
"inputFields": [
{
"name": "pipelineId",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "commit",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "units",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "ENUM",
"name": "PipelineUnits",
"ofType": null
}
}
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "Subscription",
@ -1870,39 +1452,6 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pipelineTaskLog",
"description": null,
"args": [
{
"name": "taskId",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "PipelineTaskLogMessage",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,

View File

@ -4,11 +4,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { makeAutoObservable } from 'mobx';
import { ActionButton } from './action-button';
import { gql, useMutation } from '@apollo/client';
import {
Project,
Pipeline,
CreatePipelineTaskInput
} from '../../generated/graphql';
import { Project } from '../../generated/graphql';
import {
CommitActionsStoreProvider,
CommitActionsStore
@ -20,24 +16,12 @@ import {
faVial
} from '@fortawesome/free-solid-svg-icons';
import { useLocalObservable } from 'mobx-react';
import { PipelineTask, PipelineUnits } from '../../generated/graphql';
const CREATE_PIPELINE_TASK = gql`
mutation CreatePipelineTask($task: CreatePipelineTaskInput!) {
pipelineTask: createPipelineTask(task: $task) {
id
units
commit
status
startedAt
endedAt
}
}
`;
const CHECKOUT = '';
interface Props {
pipeline: Pipeline;
commit: string;
project: Project;
commitNumber: string;
branch?: string;
}
@ -48,16 +32,13 @@ class Store {
isTasksWorking = [false, false, false, false];
}
export const CommitActions = ({ pipeline, commit }: Props) => {
const [createTask] = useMutation<
PipelineTask,
{ task: CreatePipelineTaskInput }
>(CREATE_PIPELINE_TASK);
export const CommitActions = ({ project, commitNumber }: Props) => {
const [checkout] = useMutation<CheckoutInput>(CHECKOUT);
const doWork = async (units: PipelineUnits[]) => {
await createTask({
const onCheckoutBtnClick = async () => {
await checkout({
variables: {
task: { pipelineId: pipeline.id, commit, units }
input: { projectId: project.id, commitNumber } as CheckoutInput
}
});
};
@ -66,42 +47,16 @@ export const CommitActions = ({ pipeline, commit }: Props) => {
return (
<section className={[styles.component, 'commit-actions'].join(' ')}>
<CommitActionsStoreProvider value={commitActionsStore}>
<ActionButton onClick={() => doWork([PipelineUnits.Checkout])}>
<ActionButton onClick={onCheckoutBtnClick}>
<FontAwesomeIcon icon={faDownload}></FontAwesomeIcon>
</ActionButton>
<ActionButton
onClick={() =>
doWork([
PipelineUnits.Checkout,
PipelineUnits.InstallDependencies,
PipelineUnits.CleanUp
])
}
>
<ActionButton>
<FontAwesomeIcon icon={faCloudDownloadAlt}></FontAwesomeIcon>
</ActionButton>
<ActionButton
onClick={() =>
doWork([
PipelineUnits.Checkout,
PipelineUnits.InstallDependencies,
PipelineUnits.Test,
PipelineUnits.CleanUp
])
}
>
<ActionButton>
<FontAwesomeIcon icon={faVial}></FontAwesomeIcon>
</ActionButton>
<ActionButton
onClick={() =>
doWork([
PipelineUnits.Checkout,
PipelineUnits.InstallDependencies,
PipelineUnits.Test,
PipelineUnits.Deploy
])
}
>
<ActionButton>
<FontAwesomeIcon icon={faGlobeAsia}></FontAwesomeIcon>
</ActionButton>
</CommitActionsStoreProvider>

View File

@ -8,7 +8,6 @@ import { h } from 'preact';
import { gql, useQuery, useSubscription } from '@apollo/client';
import styles from './commit-log-list.scss';
import { CommitActions } from '../commit-actions/commit-actions';
import { FIND_PIPELINE } from '../pipelines/pipeline-list.constants';
const LIST_LOGS = gql`
subscription listLogsForPipeline($id: String!) {
@ -29,6 +28,7 @@ interface Props {
}
export const CommitLogList = ({ pipelineId }: Props) => {
console.log(pipelineId);
const { data, loading } = useSubscription<
{ listLogs: LogList },
{ id: string }
@ -37,18 +37,13 @@ export const CommitLogList = ({ pipelineId }: Props) => {
id: pipelineId!
}
});
const queryResult = useQuery<{ pipeline: Pipeline }>(FIND_PIPELINE, {
variables: { id: pipelineId }
});
const pipeline = queryResult.data?.pipeline;
const list = data?.listLogs?.all?.map(log => {
return (
<li className={styles.item} key={log.hash}>
<h4>{log.message}</h4>
<time dateTime={log.date}>{log.date}</time>
{pipeline ? (
<CommitActions pipeline={pipeline} commit={log.hash} />
) : null}
{/* <CommitActions pipeline={pipeline} commitNumber={log.hash} /> */}
</li>
);
});

View File

@ -10,21 +10,3 @@ export const LIST_PIPELINES = gql`
}
}
`;
export const FIND_PIPELINE = gql`
query FindPipeline($id: String!) {
pipeline: findPipeline(id: $id) {
id
name
branch
projectId
workUnitMetadata {
version
units {
type
scripts
}
}
}
}
`;

View File

@ -10,8 +10,6 @@ export type Scalars = {
Boolean: boolean;
Int: number;
Float: number;
/** A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format. */
DateTime: any;
};
export type Hello = {
@ -78,42 +76,6 @@ export type LogList = {
latest: LogFields;
};
export type PipelineTaskLogs = {
__typename?: 'PipelineTaskLogs';
unit: PipelineUnits;
status: PipelineUnits;
startedAt?: Maybe<Scalars['DateTime']>;
endedAt?: Maybe<Scalars['DateTime']>;
logs: Scalars['String'];
};
export type PipelineTask = {
__typename?: 'PipelineTask';
id: Scalars['ID'];
pipeline: Pipeline;
pipelineId: Scalars['String'];
commit: Scalars['String'];
units: Array<PipelineUnits>;
logs: Array<PipelineTaskLogs>;
status: TaskStatuses;
startedAt?: Maybe<Scalars['DateTime']>;
endedAt?: Maybe<Scalars['DateTime']>;
};
/** 任务状态 */
export enum TaskStatuses {
Success = 'success',
Failed = 'failed',
Working = 'working',
Pending = 'pending'
}
export type PipelineTaskLogMessage = {
__typename?: 'PipelineTaskLogMessage';
unit: PipelineUnits;
};
export type WorkUnitInput = {
type: PipelineUnits;
scripts: Array<Scalars['String']>;
@ -156,7 +118,6 @@ export type Mutation = {
createPipeline: Pipeline;
modifyPipeline: Pipeline;
deletePipeline: Scalars['Float'];
createPipelineTask: PipelineTask;
};
@ -191,11 +152,6 @@ export type MutationDeletePipelineArgs = {
id: Scalars['String'];
};
export type MutationCreatePipelineTaskArgs = {
task: CreatePipelineTaskInput;
};
export type CreateProjectInput = {
name: Scalars['String'];
comment: Scalars['String'];
@ -226,24 +182,12 @@ export type UpdatePipelineInput = {
workUnitMetadata: WorkUnitMetadataInput;
};
export type CreatePipelineTaskInput = {
pipelineId: Scalars['String'];
commit: Scalars['String'];
units: Array<PipelineUnits>;
};
export type Subscription = {
__typename?: 'Subscription';
listLogsForPipeline: LogList;
pipelineTaskLog: PipelineTaskLogMessage;
};
export type SubscriptionListLogsForPipelineArgs = {
id: Scalars['String'];
};
export type SubscriptionPipelineTaskLogArgs = {
taskId: Scalars['String'];
};

View File

@ -14,10 +14,7 @@ import {
Pipeline
} from '../../generated/graphql';
import { Message } from '../../components/commons/message/index';
import {
FIND_PIPELINE,
LIST_PIPELINES
} from '../../components/pipelines/pipeline-list.constants';
import { LIST_PIPELINES } from '../../components/pipelines/pipeline-list.constants';
const defaultWorkUnitMetadata: WorkUnitMetadata = {
version: 1,
@ -41,6 +38,23 @@ const defaultWorkUnitMetadata: WorkUnitMetadata = {
]
};
const FIND_PIPELINE = gql`
query FindPipeline($id: String!) {
pipeline: findPipeline(id: $id) {
name
branch
projectId
workUnitMetadata {
version
units {
type
scripts
}
}
}
}
`;
const CREATE_PIPELINE = gql`
mutation CreatePipeline($input: CreatePipelineInput!) {
pipeline: createPipeline(pipeline: $input) {
@ -105,10 +119,7 @@ export const PipelineEditor = ({ projectId, id }: Props) => {
delete fd.__typename;
return fd;
}
return {
projectId,
workUnitMetadata: JSON.stringify(defaultWorkUnitMetadata, null, 2)
};
return {};
}, [data, data?.pipeline]);
const [createPipeline] = useMutation<{ pipeline: Pipeline }>(