X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/08968efce07d609c16dd8a086bfd0a4d69ad6f3d..8805314e7327cda30d455d0c05075ee37f3a490e:/src/views/process-log-panel/process-log-panel.tsx diff --git a/src/views/process-log-panel/process-log-panel.tsx b/src/views/process-log-panel/process-log-panel.tsx index 0936d3bd..2b2d6842 100644 --- a/src/views/process-log-panel/process-log-panel.tsx +++ b/src/views/process-log-panel/process-log-panel.tsx @@ -10,19 +10,9 @@ import { Dispatch } from 'redux'; import { openProcessContextMenu } from '~/store/context-menu/context-menu-actions'; import { matchProcessLogRoute } from '~/routes/routes'; import { ProcessLogPanelRootDataProps, ProcessLogPanelRootActionProps, ProcessLogPanelRoot } from './process-log-panel-root'; - -const SELECT_OPTIONS = [ - { label: 'Dispatch', value: 'dispatch' }, - { label: 'Crunch-run', value: 'crunch-run' }, - { label: 'Crunchstat', value: 'crunchstat' }, - { label: 'Hoststat', value: 'hoststat' }, - { label: 'Node-info', value: 'node-info' }, - { label: 'Arv-mount', value: 'arv-mount' }, - { label: 'Stdout', value: 'stdout' }, - { label: 'Stderr', value: 'stderr' } -]; - -const lines = ['Lorem Ipsum', 'Lorem Ipsum', 'Lorem Ipsum', 'Lorem Ipsum', 'Lorem Ipsum', 'Lorem Ipsum', 'Lorem Ipsum', 'Lorem Ipsum']; +import { getProcessPanelLogs } from '~/store/process-logs-panel/process-logs-panel'; +import { setProcessLogsPanelFilter } from '~/store/process-logs-panel/process-logs-panel-actions'; +import { getProcessLogsPanelCurrentUuid } from '../../store/process-logs-panel/process-logs-panel'; export interface Log { object_uuid: string; @@ -37,15 +27,14 @@ export interface FilterOption { value: string; } -const mapStateToProps = ({ router, resources }: RootState): ProcessLogPanelRootDataProps => { - const pathname = router.location ? router.location.pathname : ''; - const match = matchProcessLogRoute(pathname); - const uuid = match ? match.params.id : ''; +const mapStateToProps = (state: RootState): ProcessLogPanelRootDataProps => { + const { resources, processLogsPanel } = state; + const uuid = getProcessLogsPanelCurrentUuid(state) || ''; return { process: getProcess(uuid)(resources), - selectedFilter: SELECT_OPTIONS[0], - filters: SELECT_OPTIONS, - lines + selectedFilter: { label: processLogsPanel.selectedFilter, value: processLogsPanel.selectedFilter }, + filters: processLogsPanel.filters.map(filter => ({ label: filter, value: filter })), + lines: getProcessPanelLogs(processLogsPanel) }; }; @@ -53,7 +42,9 @@ const mapDispatchToProps = (dispatch: Dispatch): ProcessLogPanelRootActionProps onContextMenu: (event: React.MouseEvent) => { dispatch(openProcessContextMenu(event)); }, - onChange: (filter: FilterOption) => { return; } + onChange: (filter: FilterOption) => { + dispatch(setProcessLogsPanelFilter(filter.value)); + } }); export const ProcessLogPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessLogPanelRoot);