@@ -4,7 +4,7 @@ import { useEffect, useState } from 'react';
4
4
import { ExperimentData } from '../../../../lib/db_types' ;
5
5
import { MdEdit } from 'react-icons/md' ;
6
6
import Chart from './Chart' ;
7
- import { addShareLink , unfollowExperiment , updateExperimentNameById } from '../../../../lib/mongodb_funcs' ;
7
+ import { addShareLink , unfollowExperiment , updateExperimentNameById , cancelExperimentById } from '../../../../lib/mongodb_funcs' ;
8
8
import toast from 'react-hot-toast' ;
9
9
import { useSession } from 'next-auth/react' ;
10
10
@@ -248,13 +248,28 @@ export const ExperimentListing = ({ projectData: projectData, onCopyExperiment,
248
248
</button> */ }
249
249
{
250
250
project . creator == session ?. user ?. id ! ?
251
- < button type = "button"
252
- className = 'inline-flex items-center justify-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 xl:w-full'
253
- onClick = { ( ) => {
254
- openDeleteModal ( ) ;
255
- } } >
256
- Delete Experiment
257
- </ button > :
251
+ (
252
+ project . finished ?
253
+ < button type = "button"
254
+ className = 'inline-flex items-center justify-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 xl:w-full'
255
+ onClick = { ( ) => {
256
+ openDeleteModal ( ) ;
257
+ } } >
258
+ Delete Experiment
259
+ </ button >
260
+ :
261
+ < button type = "button"
262
+ className = 'inline-flex items-center justify-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 xl:w-full'
263
+ onClick = { ( ) => {
264
+ toast . promise ( cancelExperimentById ( project . expId ) , {
265
+ success : 'Cancelled experiment' , error : 'Failed to cancel experiment' , loading : 'Cancelling experiment...'
266
+ } ) ;
267
+ } }
268
+ >
269
+ Cancel Experiment
270
+ </ button >
271
+ )
272
+ :
258
273
< button type = "button"
259
274
className = 'inline-flex items-center justify-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 xl:w-full'
260
275
onClick = { ( ) => {
@@ -267,12 +282,12 @@ export const ExperimentListing = ({ projectData: projectData, onCopyExperiment,
267
282
</ button >
268
283
}
269
284
{ project . finished ?
270
- < button type = "button"
271
- className = 'inline-flex items-center justify-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 xl:w-full'
272
- onClick = { openGraphModal }
273
- >
274
- See Graph
275
- </ button > : null
285
+ < button type = "button"
286
+ className = 'inline-flex items-center justify-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 xl:w-full'
287
+ onClick = { openGraphModal }
288
+ >
289
+ See Graph
290
+ </ button > : null
276
291
}
277
292
{
278
293
project . creator == session ?. user ?. id ! ?
0 commit comments