({
workspace,
onActionSuccess,
onActionError,
})
| 390 | }; |
| 391 | |
| 392 | const WorkspaceActionsCell: FC<WorkspaceActionsCellProps> = ({ |
| 393 | workspace, |
| 394 | onActionSuccess, |
| 395 | onActionError, |
| 396 | }) => { |
| 397 | const { user } = useAuthenticated(); |
| 398 | |
| 399 | const queryClient = useQueryClient(); |
| 400 | const abilities = abilitiesByWorkspaceStatus(workspace, { |
| 401 | canDebug: false, |
| 402 | isOwner: user.roles.find((role) => role.name === "owner") !== undefined, |
| 403 | }); |
| 404 | |
| 405 | const startWorkspaceOptions = startWorkspace(workspace, queryClient); |
| 406 | const startWorkspaceMutation = useMutation({ |
| 407 | ...startWorkspaceOptions, |
| 408 | onSuccess: async (build) => { |
| 409 | startWorkspaceOptions.onSuccess(build); |
| 410 | await onActionSuccess(); |
| 411 | }, |
| 412 | onError: onActionError, |
| 413 | }); |
| 414 | |
| 415 | const stopWorkspaceOptions = stopWorkspace(workspace, queryClient); |
| 416 | const stopWorkspaceMutation = useMutation({ |
| 417 | ...stopWorkspaceOptions, |
| 418 | onSuccess: async (build) => { |
| 419 | stopWorkspaceOptions.onSuccess(build); |
| 420 | await onActionSuccess(); |
| 421 | }, |
| 422 | onError: onActionError, |
| 423 | }); |
| 424 | |
| 425 | const cancelJobOptions = cancelBuild(workspace, queryClient); |
| 426 | const cancelBuildMutation = useMutation({ |
| 427 | ...cancelJobOptions, |
| 428 | onSuccess: async () => { |
| 429 | cancelJobOptions.onSuccess(); |
| 430 | await onActionSuccess(); |
| 431 | }, |
| 432 | onError: onActionError, |
| 433 | }); |
| 434 | |
| 435 | const { data: latestVersion } = useQuery({ |
| 436 | ...templateVersion(workspace.template_active_version_id), |
| 437 | enabled: workspace.outdated, |
| 438 | }); |
| 439 | const workspaceUpdate = useWorkspaceUpdate({ |
| 440 | workspace, |
| 441 | latestVersion, |
| 442 | onSuccess: onActionSuccess, |
| 443 | onError: onActionError, |
| 444 | }); |
| 445 | |
| 446 | const deleteWorkspaceOptions = deleteWorkspace(workspace, queryClient); |
| 447 | const deleteWorkspaceMutation = useMutation({ |
| 448 | ...deleteWorkspaceOptions, |
| 449 | onSuccess: async (build) => { |
nothing calls this directly
no test coverage detected