14096-move-to-process
[arvados-workbench2.git] / src / views / process-log-panel / process-log-panel.tsx
index 1ce06afdf80a031814b8e62f9f46ee92c26b7215..2b2d6842774fdc168a200864df22dc7df15bfe48 100644 (file)
@@ -10,17 +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' }
-];
+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;
@@ -35,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: string[]
+        selectedFilter: { label: processLogsPanel.selectedFilter, value: processLogsPanel.selectedFilter },
+        filters: processLogsPanel.filters.map(filter => ({ label: filter, value: filter })),
+        lines: getProcessPanelLogs(processLogsPanel)
     };
 };
 
@@ -51,7 +42,9 @@ const mapDispatchToProps = (dispatch: Dispatch): ProcessLogPanelRootActionProps
     onContextMenu: (event: React.MouseEvent<HTMLElement>) => {
         dispatch<any>(openProcessContextMenu(event));
     },
-    onChange: (filter: FilterOption) => { return; }
+    onChange: (filter: FilterOption) => {
+        dispatch(setProcessLogsPanelFilter(filter.value));
+    }
 });
 
 export const ProcessLogPanel = connect(mapStateToProps, mapDispatchToProps)(ProcessLogPanelRoot);