-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Carina Ursu <[email protected]>
- Loading branch information
1 parent
730a04b
commit c9d8678
Showing
36 changed files
with
1,441 additions
and
1,129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 16 additions & 93 deletions
109
packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeViews.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,32 @@ | ||
import React, { useContext } from 'react'; | ||
import { Tab, Tabs } from '@material-ui/core'; | ||
import { makeStyles, Theme } from '@material-ui/core/styles'; | ||
import { useTabState } from 'components/hooks/useTabState'; | ||
import { secondaryBackgroundColor } from 'components/Theme/constants'; | ||
import { WaitForQuery } from 'components/common'; | ||
import { DataError } from 'components/Errors/DataError'; | ||
import { LargeLoadingSpinner } from 'components/common/LoadingSpinner'; | ||
import { useQuery, useQueryClient } from 'react-query'; | ||
import { Workflow } from 'models/Workflow/types'; | ||
import { makeWorkflowQuery } from 'components/Workflow/workflowQueries'; | ||
import { | ||
NodeExecutionDetailsContextProvider, | ||
NodeExecutionsByIdContextProvider, | ||
} from '../contextProvider/NodeExecutionDetails'; | ||
import { LargeLoadingComponent } from 'components/common/LoadingSpinner'; | ||
import { ExecutionContext } from '../contexts'; | ||
import { ExecutionFilters } from '../ExecutionFilters'; | ||
import { useNodeExecutionFiltersState } from '../filters/useExecutionFiltersState'; | ||
import { tabs } from './constants'; | ||
import { ExecutionTab } from './ExecutionTab'; | ||
import { useExecutionNodeViewsState } from './useExecutionNodeViewsState'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ | ||
filters: { | ||
paddingLeft: theme.spacing(3), | ||
}, | ||
nodesContainer: { | ||
borderTop: `1px solid ${theme.palette.divider}`, | ||
display: 'flex', | ||
flex: '1 1 100%', | ||
flexDirection: 'column', | ||
minHeight: 0, | ||
}, | ||
tabs: { | ||
background: secondaryBackgroundColor, | ||
paddingLeft: theme.spacing(3.5), | ||
}, | ||
})); | ||
import { useExecutionNodeViewsStatePoll } from './useExecutionNodeViewsState'; | ||
import { ExecutionTabView } from './ExecutionTabView'; | ||
import { WorkflowNodeExecutionsProvider } from '../contextProvider/NodeExecutionDetails'; | ||
|
||
/** Contains the available ways to visualize the nodes of a WorkflowExecution */ | ||
export const ExecutionNodeViews: React.FC = () => { | ||
const defaultTab = tabs.nodes.id; | ||
const styles = useStyles(); | ||
const filterState = useNodeExecutionFiltersState(); | ||
const tabState = useTabState(tabs, defaultTab); | ||
export const ExecutionNodeViews: React.FC<{}> = () => { | ||
const { execution } = useContext(ExecutionContext); | ||
|
||
const { | ||
closure: { workflowId }, | ||
} = execution; | ||
const workflowQuery = useQuery<Workflow, Error>( | ||
makeWorkflowQuery(useQueryClient(), workflowId), | ||
); | ||
// query to get all data to build Graph and Timeline | ||
const { nodeExecutionsQuery } = useExecutionNodeViewsState(execution); | ||
// query to get filtered data to narrow down Table outputs | ||
const { nodeExecutionsQuery: filteredNodeExecutionsQuery } = | ||
useExecutionNodeViewsState(execution, filterState?.appliedFilters); | ||
const { nodeExecutionsQuery } = useExecutionNodeViewsStatePoll(execution); | ||
|
||
return ( | ||
<> | ||
<Tabs className={styles.tabs} {...tabState}> | ||
<Tab value={tabs.nodes.id} label={tabs.nodes.label} /> | ||
<Tab value={tabs.graph.id} label={tabs.graph.label} /> | ||
<Tab value={tabs.timeline.id} label={tabs.timeline.label} /> | ||
</Tabs> | ||
|
||
<WaitForQuery errorComponent={DataError} query={workflowQuery}> | ||
{() => | ||
filterState ? ( | ||
<NodeExecutionDetailsContextProvider workflowId={workflowId}> | ||
<NodeExecutionsByIdContextProvider | ||
filterState={filterState} | ||
nodeExecutionsQuery={nodeExecutionsQuery} | ||
filteredNodeExecutionsQuery={filteredNodeExecutionsQuery} | ||
> | ||
<div className={styles.nodesContainer}> | ||
{tabState.value === tabs.nodes.id && ( | ||
<div className={styles.filters}> | ||
<ExecutionFilters {...filterState} /> | ||
</div> | ||
)} | ||
|
||
<WaitForQuery | ||
errorComponent={DataError} | ||
query={nodeExecutionsQuery} | ||
loadingComponent={LoadingComponent} | ||
> | ||
{() => <ExecutionTab tabType={tabState.value} />} | ||
</WaitForQuery> | ||
</div> | ||
</NodeExecutionsByIdContextProvider> | ||
</NodeExecutionDetailsContextProvider> | ||
) : ( | ||
<LoadingComponent /> | ||
) | ||
} | ||
<WaitForQuery | ||
query={nodeExecutionsQuery} | ||
errorComponent={DataError} | ||
loadingComponent={LargeLoadingComponent} | ||
> | ||
{data => ( | ||
<WorkflowNodeExecutionsProvider initialNodeExecutions={data}> | ||
<ExecutionTabView /> | ||
</WorkflowNodeExecutionsProvider> | ||
)} | ||
</WaitForQuery> | ||
</> | ||
); | ||
}; | ||
|
||
const LoadingComponent = () => { | ||
return ( | ||
<div style={{ margin: 'auto' }}> | ||
<LargeLoadingSpinner /> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.