Skip to content

Commit

Permalink
Fix [Workflow] Wrong redirection (#2476)
Browse files Browse the repository at this point in the history
  • Loading branch information
mavdryk authored May 26, 2024
1 parent fe90132 commit f62a029
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/common/ReactFlow/mlReactFlow.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
width: 100%;
font-size: 1.5rem;
text-align: center;
overflow: hidden;
}

.react-flow__node-sub-label {
Expand Down
22 changes: 17 additions & 5 deletions src/elements/WorkflowsTable/WorkflowsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,23 +378,35 @@ const WorkflowsTable = React.forwardRef(
[modifyAndSelectRun, params.jobName]
)

const findSelectedWorkflowFunction = useCallback(() => {
const findSelectedWorkflowFunction = useCallback((withoutRunType) => {
if (workflowsStore.activeWorkflow?.data) {
const workflow = { ...workflowsStore.activeWorkflow.data }

return find(workflow.graph, workflowItem => {
return (
let workflowItemIsFound = (
workflowItem.function?.includes(`${params.functionName}@${params.functionHash}`) ||
workflowItem.function?.includes(params.functionName) ||
workflowItem.function?.includes(params.jobId)
)

if (withoutRunType) {
workflowItemIsFound = workflowItemIsFound && workflowItem.run_type !== 'run'
}

return workflowItemIsFound
})
}
}, [params.functionName, params.functionHash, params.jobId, workflowsStore.activeWorkflow.data])

const checkIfWorkflowItemIsJob = useCallback(() => {
if (workflowsStore.activeWorkflow?.data?.graph) {
return !['deploy', 'build'].includes(findSelectedWorkflowFunction()?.run_type)
let selectedWorkflowItem = findSelectedWorkflowFunction(true)

if (isEmpty(selectedWorkflowItem)) {
selectedWorkflowItem = findSelectedWorkflowFunction(false)
}

return !['deploy', 'build'].includes(selectedWorkflowItem?.run_type)
}
}, [workflowsStore.activeWorkflow.data.graph, findSelectedWorkflowFunction])

Expand Down Expand Up @@ -436,7 +448,7 @@ const WorkflowsTable = React.forwardRef(
}, [fetchRun, params.jobId, selectedJob, checkIfWorkflowItemIsJob])

useEffect(() => {
const functionToBeSelected = findSelectedWorkflowFunction()
const functionToBeSelected = findSelectedWorkflowFunction(true)

if (isWorkflowStepExecutable(functionToBeSelected)) {
const workflow = { ...workflowsStore.activeWorkflow?.data }
Expand Down Expand Up @@ -472,7 +484,7 @@ const WorkflowsTable = React.forwardRef(
} else if (
workflow.graph &&
params.jobId &&
isEmpty(selectedFunction) &&
(isEmpty(selectedFunction) || params.jobId !== selectedFunction.name) &&
!checkIfWorkflowItemIsJob()
) {
const customFunctionState = functionToBeSelected?.phase?.toLowerCase()
Expand Down

0 comments on commit f62a029

Please sign in to comment.