Skip to content

Commit

Permalink
Update delete to archive. Allow archive of project w/stages.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedson committed May 31, 2019
1 parent 4911536 commit 61fface
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 57 deletions.
26 changes: 12 additions & 14 deletions client/components/projects/ProjectTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface IProjectTableProps {

updateProject?(project: IProject): any;
duplicateProject?(id: string): any;
deleteProject?(id: string): any;
archiveProject?(id: string): any;
}

interface IProjectTableState {
Expand Down Expand Up @@ -162,20 +162,20 @@ export class ProjectTable extends React.Component<IProjectTableProps, IProjectTa
}

private onCompleteDeleteProject = (data) => {
if (data.deleteProject.error) {
toast.error(toastError("Delete", data.deleteProject.error), {autoClose: false});
if (data.archiveProject.error) {
toast.error(toastError("Archive", data.archiveProject.error), {autoClose: false});
} else {
if (PreferencesManager.Instance.PreferredProjectId === this.state.selectedProject.id) {
this.setState({selectedProject: null});
PreferencesManager.Instance.PreferredProjectId = AllProjectsId;
}

toast.success(toastSuccess("Delete"), {autoClose: 3000});
toast.success(toastSuccess("Archive"), {autoClose: 3000});
}
};

private onDeleteProjectError = (error) => {
toast.error(toastError("Delete", error), {autoClose: false});
toast.error(toastError("Archive", error), {autoClose: false});
};

private onClearDeleteConfirmation() {
Expand All @@ -186,23 +186,23 @@ export class ProjectTable extends React.Component<IProjectTableProps, IProjectTa
return (
<Mutation mutation={DeleteProjectMutation} onCompleted={this.onCompleteDeleteProject}
onError={this.onDeleteProjectError}
update={(cache, {data: {deleteProject: {id}}}) => {
update={(cache, {data: {archiveProject: {id}}}) => {
const data: any = cache.readQuery({query: BaseQuery});
cache.writeQuery({
query: BaseQuery,
data: Object.assign(data, {projects: data.projects.filter(t => t.id !== id)})
});
}}>
{(deleteProject) => {
{(archiveProject) => {
if (!this.state.isDeleteDialogShown) {
return null;
}
return (
<Confirm open={this.state.isDeleteDialogShown} header="Delete Pipeline"
content={`Are you sure you want to delete ${this.state.selectedProject.name} as a pipeline?`}
confirmButton="Delete" onCancel={() => this.onClearDeleteConfirmation()}
<Confirm open={this.state.isDeleteDialogShown} header="Archive Pipeline"
content={`Are you sure you want to archive ${this.state.selectedProject.name}?`}
confirmButton="Archive" onCancel={() => this.onClearDeleteConfirmation()}
onConfirm={() => {
deleteProject({variables: {id: this.state.selectedProject.id}});
archiveProject({variables: {id: this.state.selectedProject.id}});
this.setState({isDeleteDialogShown: false});
}}/>
)
Expand All @@ -219,8 +219,6 @@ export class ProjectTable extends React.Component<IProjectTableProps, IProjectTa

const disabled_active = disabled || this.state.selectedProject.is_processing;

const disabled_stages = disabled_active || this.state.selectedProject.stages.length > 0;

return (
<Menu size="mini" style={{borderBottom: "none", borderRadius: 0, marginBottom: 0, boxShadow: "none"}}>
<Mutation mutation={UpdateProjectMutation} onCompleted={this.onCompleteUpdateProject}
Expand Down Expand Up @@ -250,7 +248,7 @@ export class ProjectTable extends React.Component<IProjectTableProps, IProjectTa
PreferencesManager.Instance.PreferredProjectId = AllProjectsId;
}}/>
<Menu.Menu position="right">
<MenuItem size="mini" content="Delete" icon="trash" disabled={disabled_stages}
<MenuItem size="mini" content="Archive" icon="trash" disabled={disabled_active}
onClick={(evt) => this.onClickDeleteProject(evt)}/>
</Menu.Menu>
</Menu>
Expand Down
30 changes: 15 additions & 15 deletions client/components/stages/PipelineStageTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Mutation} from "react-apollo";
import ReactTable from "react-table";
import {toast} from "react-toastify";

import {IPipelineStage, IPipelineStageTileStatus} from "../../models/pipelineStage";
import {IPipelineStage} from "../../models/pipelineStage";
import {AllProjectsId} from "../helpers/ProjectMenu";
import {ITaskDefinition} from "../../models/taskDefinition";
import {IProject} from "../../models/project";
Expand Down Expand Up @@ -83,19 +83,19 @@ export class PipelineStageTable extends React.Component<IPipelineStageTableProps
}

private onCompleteDeletePipelineStage = (data) => {
if (data.deletePipelineStage.error) {
toast.error(toastError("Delete", data.deletePipelineStage.error), {autoClose: false});
if (data.archivePipelineStage.error) {
toast.error(toastError("Archive", data.archivePipelineStage.error), {autoClose: false});
} else {
if (PreferencesManager.Instance.PreferredProjectId === this.state.selectedStage.id) {
if (this.state.selectedStage && PreferencesManager.Instance.PreferredStageId === this.state.selectedStage.id) {
this.setState({selectedStage: null});
}

toast.success(toastSuccess("Delete"), {autoClose: 3000});
toast.success(toastSuccess("Archive"), {autoClose: 3000});
}
};

private onDeletePipelineStageError = (error) => {
toast.error(toastError("Delete", error), {autoClose: false});
toast.error(toastError("Archive", error), {autoClose: false});
};

private onClearDeleteConfirmation() {
Expand All @@ -106,23 +106,23 @@ export class PipelineStageTable extends React.Component<IPipelineStageTableProps
return (
<Mutation mutation={DeletePipelineStageMutation} onCompleted={this.onCompleteDeletePipelineStage}
onError={this.onDeletePipelineStageError}
update={(cache, {data: {deletePipelineStage: {id}}}) => {
update={(cache, {data: {archivePipelineStage: {id}}}) => {
const data: any = cache.readQuery({query: BaseQuery});
cache.writeQuery({
query: BaseQuery,
data: Object.assign(data, {pipelineStages: data.pipelineStages.filter(t => t.id !== id)})
});
}}>
{(deletePipelineStage) => {
{(archivePipelineStage) => {
if (!this.state.isDeleteDialogShown) {
return null;
}

return (<Confirm open={this.state.isDeleteDialogShown} header="Delete Stage"
content={`Are you sure you want to delete ${this.state.selectedStage.name} as a stage?`}
confirmButton="Delete" onCancel={() => this.onClearDeleteConfirmation()}
return (<Confirm open={this.state.isDeleteDialogShown} header="Archive Stage"
content={`Are you sure you want to archive ${this.state.selectedStage.name}?`}
confirmButton="Archive" onCancel={() => this.onClearDeleteConfirmation()}
onConfirm={() => {
deletePipelineStage({variables: {id: this.state.selectedStage.id}});
archivePipelineStage({variables: {id: this.state.selectedStage.id}});
this.setState({isDeleteDialogShown: false});
}}/>
)
Expand Down Expand Up @@ -164,7 +164,7 @@ export class PipelineStageTable extends React.Component<IPipelineStageTableProps
<TableSelectionHeader item={this.state.selectedStage}
onClick={() => this.setState({selectedStage: null})}/>
<Menu.Menu position="right">
<MenuItem size="mini" content="Delete" icon="trash" disabled={disabled_active}
<MenuItem size="mini" content="Archive" icon="trash" disabled={disabled_active}
onClick={(evt) => this.onClickDeletePipelineStage(evt)}/>
</Menu.Menu>
</Menu>
Expand All @@ -185,13 +185,13 @@ export class PipelineStageTable extends React.Component<IPipelineStageTableProps
if (this.state.selectedStage === null) {
const id = PreferencesManager.Instance.PreferredStageId;

const stages = this.filterStages(props).filter(s => s.id === id);
const stages = this.filterStages(props).filter(s => s.id === id) || null;

if (stages.length > 0) {
this.onSelectStage(stages[0]);
}
} else {
const stage = this.filterStages(props).find(s => s.id === this.state.selectedStage.id);
const stage = this.filterStages(props).find(s => s.id === this.state.selectedStage.id) || null;
this.onSelectStage(stage);
}

Expand Down
22 changes: 11 additions & 11 deletions client/components/tasks/definitions/TaskDefinitionTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ export class TaskDefinitionsTable extends React.Component<ITaskDefinitionsTableP
}

private onCompleteDeleteDefinition = (data) => {
if (data.deleteTaskDefinition.error) {
toast.error(toastError("Delete", data.deleteTaskDefinition.error), {autoClose: false});
if (data.archiveTaskDefinition.error) {
toast.error(toastError("Archive", data.archiveTaskDefinition.error), {autoClose: false});
} else {
this.setState({selectedTask: null});
toast.success(toastSuccess("Delete"), {autoClose: 3000});
toast.success(toastSuccess("Archive"), {autoClose: 3000});
}
};

private onDeleteDefinitionError = (error) => {
toast.error(toastError("Delete", error), {autoClose: false});
toast.error(toastError("Archive", error), {autoClose: false});
};

private onClearDeleteConfirmation() {
Expand All @@ -161,23 +161,23 @@ export class TaskDefinitionsTable extends React.Component<ITaskDefinitionsTableP
return (
<Mutation mutation={DeleteTaskDefinitionMutation} onCompleted={this.onCompleteDeleteDefinition}
onError={this.onDeleteDefinitionError}
update={(cache, {data: {deleteTaskDefinition: {id}}}) => {
update={(cache, {data: {archiveTaskDefinition: {id}}}) => {
const data: any = cache.readQuery({query: BaseQuery});
cache.writeQuery({
query: BaseQuery,
data: Object.assign(data, {taskDefinitions: data.taskDefinitions.filter(t => t.id !== id)})
});
}}>
{(deleteTaskDefinition) => {
{(archiveTaskDefinition) => {
if (!this.state.isDeleteDialogShown) {
return null;
}
return (
<Confirm open={this.state.isDeleteDialogShown} header="Delete Task"
content={`Are you sure you want to delete ${this.state.selectedTask.name} as a task?`}
confirmButton="Delete" onCancel={() => this.onClearDeleteConfirmation()}
<Confirm open={this.state.isDeleteDialogShown} header="Archive Task"
content={`Are you sure you want to archive ${this.state.selectedTask.name}?`}
confirmButton="Archive" onCancel={() => this.onClearDeleteConfirmation()}
onConfirm={() => {
deleteTaskDefinition({variables: {id: this.state.selectedTask.id}});
archiveTaskDefinition({variables: {id: this.state.selectedTask.id}});
this.setState({isDeleteDialogShown: false});
}}/>
)
Expand Down Expand Up @@ -227,7 +227,7 @@ export class TaskDefinitionsTable extends React.Component<ITaskDefinitionsTableP
<MenuItem size="mini" content="Duplicate" icon="clone" disabled={disabled}
onClick={(evt) => this.onDuplicateTask(evt)}/>
<Menu.Menu position="right">
<MenuItem size="mini" content="Delete" icon="trash" disabled={disabled_delete}
<MenuItem size="mini" content="Archive" icon="trash" disabled={disabled_delete}
onClick={(evt) => this.onClickDeleteTaskDefinition(evt)}/>
</Menu.Menu>
</Menu>
Expand Down
22 changes: 11 additions & 11 deletions client/components/tasks/repository/TaskRepositoryTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ export class TaskRepositoryTable extends React.Component<ITaskRepositoryTablePro
}

private onCompleteDeleteRepository = (data) => {
if (data.deleteTaskRepository.error) {
toast.error(toastError("Delete", data.deleteTaskRepository.error), {autoClose: false});
if (data.archiveTaskRepository.error) {
toast.error(toastError("Archive", data.archiveTaskRepository.error), {autoClose: false});
} else {
this.setState({selectedRepository: null});
toast.success(toastSuccess("Delete"), {autoClose: 3000});
toast.success(toastSuccess("Archive"), {autoClose: 3000});
}
};

private onDeleteRepositoryError = (error) => {
toast.error(toastError("Delete", error), {autoClose: false});
toast.error(toastError("Archive", error), {autoClose: false});
};

private onClearDeleteConfirmation() {
Expand All @@ -79,23 +79,23 @@ export class TaskRepositoryTable extends React.Component<ITaskRepositoryTablePro
return (
<Mutation mutation={DeleteTaskRepositoryMutation} onCompleted={this.onCompleteDeleteRepository}
onError={this.onDeleteRepositoryError}
update={(cache, {data: {deleteTaskRepository: {id}}}) => {
update={(cache, {data: {archiveTaskRepository: {id}}}) => {
const data: any = cache.readQuery({query: BaseQuery});
cache.writeQuery({
query: BaseQuery,
data: Object.assign(data, {taskRepositories: data.taskRepositories.filter(t => t.id !== id)})
});
}}>
{(deleteTaskRepository) => {
{(archiveTaskRepository) => {
if (!this.state.isDeleteDialogShown) {
return null;
}
return (
<Confirm open={this.state.isDeleteDialogShown} header="Delete Repository"
content={`Are you sure you want to delete ${this.state.selectedRepository.name} as a repository?`}
confirmButton="Delete" onCancel={() => this.onClearDeleteConfirmation()}
<Confirm open={this.state.isDeleteDialogShown} header="Archive Repository"
content={`Are you sure you want to archive ${this.state.selectedRepository.name}?`}
confirmButton="Archive" onCancel={() => this.onClearDeleteConfirmation()}
onConfirm={() => {
deleteTaskRepository({variables: {id: this.state.selectedRepository.id}});
archiveTaskRepository({variables: {id: this.state.selectedRepository.id}});
this.setState({isDeleteDialogShown: false});
}}/>
)
Expand Down Expand Up @@ -141,7 +141,7 @@ export class TaskRepositoryTable extends React.Component<ITaskRepositoryTablePro
</div>
</Menu.Header> : null}
<Menu.Menu position="right">
<MenuItem size="mini" content="Delete" icon="trash" disabled={disabled_delete}
<MenuItem size="mini" content="Archive" icon="trash" disabled={disabled_delete}
onClick={(evt) => this.onClickDeleteRepository(evt)}/>
</Menu.Menu>
</Menu>
Expand Down
2 changes: 1 addition & 1 deletion client/graphql/pipelineStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ ${PipelineStageRequiredFieldsFragment}

export const DeletePipelineStageMutation = gql`
mutation DeletePipelineStageMutation($id: String!) {
deletePipelineStage(id: $id) {
archivePipelineStage(id: $id) {
id
error
}
Expand Down
2 changes: 1 addition & 1 deletion client/graphql/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ${PipelineStageRequiredFieldsFragment}

export const DeleteProjectMutation = gql`
mutation DeleteProjectMutation($id: String!) {
deleteProject(id: $id) {
archiveProject(id: $id) {
id
error
}
Expand Down
2 changes: 1 addition & 1 deletion client/graphql/taskDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ${TaskDefinitionFragment}
`;

export const DeleteTaskDefinitionMutation = gql`mutation DeleteTaskDefinition($id: String!) {
deleteTaskDefinition(id: $id) {
archiveTaskDefinition(id: $id) {
id
error
}
Expand Down
2 changes: 1 addition & 1 deletion client/graphql/taskRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ${TaskRepositoryFragment}
`;

export const DeleteTaskRepositoryMutation = gql`mutation DeleteTaskRepository($id: String!) {
deleteTaskRepository(id: $id) {
archiveTaskRepository(id: $id) {
id
error
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pipeline-ui",
"version": "1.4.3",
"version": "1.4.4",
"description": "",
"keywords": [],
"author": "Patrick Edson <[email protected]> (http://github.com/pedson)",
Expand Down
1 change: 0 additions & 1 deletion server/pipelineClientServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ function startSocketIOServer(server = null) {
const io = require("socket.io")(server);

io.on("connection", (socket) => {
debug("socket.io connection");
socket.on("stopMicroscopeAcquisition", () => {
});
socket.on("restartHubProxy", () => {
Expand Down

0 comments on commit 61fface

Please sign in to comment.