Skip to content

Commit

Permalink
Merge pull request #598 from SUI-Components/feat/result-work-data-tas…
Browse files Browse the repository at this point in the history
…k-manager

feat(components/tool/taskManager): Expose state reference and add method to get a specific task
  • Loading branch information
oegea committed May 30, 2023
2 parents 5df5973 + fc5899f commit e750978
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions components/tool/taskManager/src/hooks/useState.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const useState = () => {
})
const stateRef = useRef(state)
stateRef.current = state

const getState = () => stateRef.current
const setState = state => dispatch({type: ACTIONS.SET_STATE, payload: state})
const toggleTab = () => dispatch({type: ACTIONS.TOOGLE_TAB})

Expand All @@ -51,6 +53,8 @@ const useState = () => {

useDomainEventSubscriptions(domain, executeUseCase)

const getTask = taskId => getState().tasks.find(task => task.id === taskId)

const runSimpleTask = task =>
executeUseCase('run_simple_task_use_case', {
localState: stateRef.current,
Expand Down Expand Up @@ -95,13 +99,14 @@ const useState = () => {
})

return {
state,
cancelWork,
errorWork,
runTask,
finishWork,
getState,
getTask,
runSimpleTask,
runTask,
setPercentage,
finishWork,
toggleTab
}
}
Expand Down
3 changes: 2 additions & 1 deletion components/tool/taskManager/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import useContext from './hooks/useContext.js'

export default function ToolTaskManager({isVisible = true}) {
window.taskManager = useContext()
const {state, toggleTab} = window.taskManager
const {getState, toggleTab} = window.taskManager
const state = getState()
const drawerRef = useRef()
const _onClick = () => {
toggleTab()
Expand Down

0 comments on commit e750978

Please sign in to comment.