Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable workflow editing #194

Merged
merged 9 commits into from
Dec 21, 2023
19 changes: 13 additions & 6 deletions frontend/src/components/Workspace/Experiment/ExperimentTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,16 @@ import {
selectExperimentHasNWB,
} from "store/slice/Experiments/ExperimentsSelectors"
import { ExperimentSortKeys } from "store/slice/Experiments/ExperimentsType"
import { selectPipelineLatestUid } from "store/slice/Pipeline/PipelineSelectors"
import {
selectPipelineIsStartedSuccess,
selectPipelineLatestUid,
} from "store/slice/Pipeline/PipelineSelectors"
import { clearCurrentPipeline } from "store/slice/Pipeline/PipelineSlice"
import {
selectCurrentWorkspaceId,
selectIsWorkspaceOwner,
} from "store/slice/Workspace/WorkspaceSelector"
import { AppDispatch } from "store/store"
import { AppDispatch, RootState } from "store/store"

export const ExperimentUidContext = createContext<string>("")

Expand Down Expand Up @@ -112,6 +115,13 @@ const TableImple = memo(function TableImple() {
const experimentListValues = Object.values(experimentList)
const experimentListKeys = Object.keys(experimentList)
const dispatch = useDispatch<AppDispatch>()
const [checkedList, setCheckedList] = useState<string[]>([])
const [open, setOpen] = useState(false)
const isRunning = useSelector((state: RootState) => {
const currentUid = selectPipelineLatestUid(state)
const isPending = selectPipelineIsStartedSuccess(state)
return checkedList.includes(currentUid as string) && isPending
})
const onClickReload = () => {
dispatch(getExperiments())
}
Expand All @@ -124,9 +134,6 @@ const TableImple = memo(function TableImple() {
setSortTarget(property)
}

const [checkedList, setCheckedList] = useState<string[]>([])
const [open, setOpen] = useState(false)

const onCheckBoxClick = (uid: string) => {
if (checkedList.includes(uid)) {
setCheckedList(checkedList.filter((v) => v !== uid))
Expand Down Expand Up @@ -214,7 +221,7 @@ const TableImple = memo(function TableImple() {
color="error"
endIcon={<DeleteIcon />}
onClick={onClickDelete}
disabled={checkedList.length === 0}
disabled={checkedList.length === 0 || isRunning}
>
Delete
</Button>
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { memo, ChangeEvent, useRef } from "react"
import { useDispatch } from "react-redux"
import { useDispatch, useSelector } from "react-redux"

import { useSnackbar } from "notistack"

import { UploadFile } from "@mui/icons-material"
import { IconButton, Tooltip } from "@mui/material"

import { selectPipelineIsStartedSuccess } from "store/slice/Pipeline/PipelineSelectors"
import { reset } from "store/slice/VisualizeItem/VisualizeItemSlice"
import { importWorkflowConfig } from "store/slice/Workflow/WorkflowActions"
import { AppDispatch } from "store/store"
Expand All @@ -16,6 +17,8 @@ export const ImportWorkflowConfigButton = memo(
const inputRef = useRef<HTMLInputElement>(null)
const { enqueueSnackbar } = useSnackbar()

const isPending = useSelector(selectPipelineIsStartedSuccess)

const onClick = () => {
inputRef.current?.click()
}
Expand All @@ -40,7 +43,7 @@ export const ImportWorkflowConfigButton = memo(

return (
<Tooltip title="Import workflow yaml file">
<IconButton onClick={onClick}>
<IconButton onClick={onClick} disabled={!!isPending}>
<UploadFile color="primary" />
<input
hidden
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/components/Workspace/FlowChart/Buttons/NWB.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { memo } from "react"
import { useDispatch } from "react-redux"
import { useDispatch, useSelector } from "react-redux"

import TuneIcon from "@mui/icons-material/Tune"
import { IconButton, Tooltip } from "@mui/material"

import { selectPipelineIsStartedSuccess } from "store/slice/Pipeline/PipelineSelectors"
import { toggleNwb } from "store/slice/RightDrawer/RightDrawerSlice"

export const NWBSettingButton = memo(function NWBSettingButton() {
const dispatch = useDispatch()
const handleClick = () => {
dispatch(toggleNwb())
}
const isPending = useSelector(selectPipelineIsStartedSuccess)
return (
<Tooltip title="NWB settings">
<IconButton onClick={handleClick}>
<TuneIcon color="primary" />
<IconButton onClick={handleClick} color="primary" disabled={!!isPending}>
<TuneIcon />
</IconButton>
</Tooltip>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import { memo } from "react"
import { useDispatch } from "react-redux"
import { useDispatch, useSelector } from "react-redux"

import RouteIcon from "@mui/icons-material/Route"
import { IconButton, Tooltip } from "@mui/material"

import { selectPipelineIsStartedSuccess } from "store/slice/Pipeline/PipelineSelectors"
import { toggleSnakemake } from "store/slice/RightDrawer/RightDrawerSlice"

export const SnakemakeButton = memo(function SnakemakeButton() {
const dispatch = useDispatch()
const handleClick = () => {
dispatch(toggleSnakemake())
}
const isPending = useSelector(selectPipelineIsStartedSuccess)
return (
<Tooltip title="Snakemake settings">
<IconButton onClick={handleClick}>
<RouteIcon color="primary" />
<IconButton
onClick={handleClick}
color={"primary"}
disabled={!!isPending}
>
<RouteIcon />
</IconButton>
</Tooltip>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,17 @@ const AlgorithmNodeImple = memo(function AlgorithmNodeImple({
</Grid>
</Grid>
<ButtonGroup>
<Button size="small" onClick={onClickParamButton}>
<Button
size="small"
onClick={onClickParamButton}
disabled={status === NODE_RESULT_STATUS.PENDING}
>
Param
</Button>
<Button
size="small"
onClick={onClickOutputButton}
disabled={status !== NODE_RESULT_STATUS.SUCCESS}
disabled={status === NODE_RESULT_STATUS.PENDING}
>
Output
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { LinearProgressWithLabel } from "components/Workspace/FlowChart/FlowChar
import { useFileUploader } from "store/slice/FileUploader/FileUploaderHook"
import { getLabelByPath } from "store/slice/FlowElement/FlowElementUtils"
import { FILE_TYPE } from "store/slice/InputNode/InputNodeType"
import { selectPipelineLatestUid } from "store/slice/Pipeline/PipelineSelectors"
import {
selectPipelineIsStartedSuccess,
selectPipelineLatestUid,
} from "store/slice/Pipeline/PipelineSelectors"

interface FileSelectProps {
multiSelect?: boolean
Expand Down Expand Up @@ -84,6 +87,7 @@ export const FileSelectImple = memo(function FileSelectImple({
const { onOpenFileSelectDialog, onOpenClearWorkflowIdDialog } =
useContext(DialogContext)
const currentWorkflowId = useSelector(selectPipelineLatestUid)
const isPending = useSelector(selectPipelineIsStartedSuccess)

const onFileInputChange = (event: ChangeEvent<HTMLInputElement>) => {
event.preventDefault()
Expand Down Expand Up @@ -122,6 +126,7 @@ export const FileSelectImple = memo(function FileSelectImple({
<ButtonGroup size="small" style={{ marginRight: 4 }}>
<Button
variant="outlined"
disabled={!!isPending}
onClick={() => {
onOpenFileSelectDialog({
open: true,
Expand All @@ -134,7 +139,7 @@ export const FileSelectImple = memo(function FileSelectImple({
>
{selectButtonLabel ? selectButtonLabel : "Select File"}
</Button>
<Button onClick={onClick} variant="outlined">
<Button onClick={onClick} variant="outlined" disabled={!!isPending}>
{uploadButtonLabel ? uploadButtonLabel : "Load"}
</Button>
</ButtonGroup>
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/Workspace/WorkspaceTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useDispatch, useSelector } from "react-redux"
import Tab from "@mui/material/Tab"
import Tabs from "@mui/material/Tabs"

import { selectPipelineIsStartedSuccess } from "store/slice/Pipeline/PipelineSelectors"
import { selectActiveTab } from "store/slice/Workspace/WorkspaceSelector"
import { setActiveTab } from "store/slice/Workspace/WorkspaceSlice"

Expand All @@ -14,6 +15,8 @@ const WorkspaceTabs: FC = () => {
dispatch(setActiveTab(newValue))
}

const isPending = useSelector(selectPipelineIsStartedSuccess)

return (
<Tabs
sx={{ width: "100%" }}
Expand All @@ -23,7 +26,7 @@ const WorkspaceTabs: FC = () => {
textColor="primary"
>
<Tab label="Workflow" {...a11yProps(0)} />
<Tab label="Visualize" {...a11yProps(1)} />
<Tab disabled={!!isPending} label="Visualize" {...a11yProps(1)} />
<Tab label="Record" {...a11yProps(2)} />
</Tabs>
)
Expand Down