From f027cd2dc9361ae447c63b69d7c5ca3d495fe0e9 Mon Sep 17 00:00:00 2001 From: Yaxue Guo Date: Thu, 27 Apr 2023 16:35:31 -0400 Subject: [PATCH] #179: added delete all slices button on project - slice table --- src/components/Experiment/Slices.jsx | 13 ++++++++++++- src/components/Slice/SlicesTable.jsx | 11 ++++++++--- src/services/sliceService.js | 12 +++++++++--- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/components/Experiment/Slices.jsx b/src/components/Experiment/Slices.jsx index db65e759..a47629b9 100644 --- a/src/components/Experiment/Slices.jsx +++ b/src/components/Experiment/Slices.jsx @@ -7,7 +7,7 @@ import SlicesTable from "../Slice/SlicesTable"; import SpinnerWithText from "../../components/common/SpinnerWithText"; import { getProjects } from "../../services/projectService.js"; import { autoCreateTokens } from "../../utils/manageTokens"; -import { getSlices } from "../../services/sliceService.js"; +import { getSlices, deleteSlice } from "../../services/sliceService.js"; import { toast } from "react-toastify"; import paginate from "../../utils/paginate"; import checkPortalType from "../../utils/checkPortalType"; @@ -83,6 +83,16 @@ class Slices extends React.Component { this.setState( { includeDeadSlices: !currentChoice }); } + handleDeleteAllSlices = async () => { + try { + await deleteSlice(); + window.location.reload(); + } + catch (err) { + toast.error("Failed to delete all slices of this project.") + } + } + getPageData = () => { const { pageSize, @@ -263,6 +273,7 @@ class Slices extends React.Component { sortColumn={sortColumn} onSort={this.handleSort} parent={this.props.parent} + onDeleteAllSlices={this.handleDeleteAllSlices} /> ( + content: (slice) => - ), + />, }, ], "projectSlices": [ @@ -57,6 +56,12 @@ class SlicesTable extends Component { ) }, { + label: () => , content: (slice) => (