Skip to content

Commit

Permalink
Merge pull request #146 from onattech/Pipeline_UI_Improvements
Browse files Browse the repository at this point in the history
Pipeline UI improvements
  • Loading branch information
saul-data authored Mar 3, 2022
2 parents a73c1aa + 9890dab commit 577e7d5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ const PipelineTable = ({ data, filter, setPipelineCount, environmentID }) => {
<Box component="table" mt={4} width="100%" {...getTableProps()}>
<Box component="tbody" display="flex" sx={{ flexDirection: 'column' }} {...getTableBodyProps()}>
{rows.map((row, i) => {
console.log(row);
prepareRow(row);
return (
<Box
Expand Down
20 changes: 9 additions & 11 deletions frontend/src/pages/Flow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ export const edgeTypes = {
const useAddUpdatePipelineFlowfunc = () => {
// GraphQL hook
const addUpdatePipelineFlow = useAddUpdatePipelineFlow();

// URI parameter
const { pipelineId } = useParams();

// React router
const history = useHistory();

const { enqueueSnackbar, closeSnackbar } = useSnackbar();

// Update pipeline flow
return async (rawInput, environmentID) => {
return async (rawInput, environmentID, pipeline) => {
// Prepare input to match the structure in the backend
const input = prepareInputForBackend(rawInput);

Expand All @@ -78,6 +82,7 @@ const useAddUpdatePipelineFlowfunc = () => {
response.errors.map((err) => enqueueSnackbar(err.message + ': update flow failed', { variant: 'error' }));
} else {
enqueueSnackbar('Success', { variant: 'success' });
history.push({ pathname: `/pipelines/view/${pipelineId}`, state: pipeline });
}
};
};
Expand All @@ -93,18 +98,12 @@ const Flow = () => {
const authState = useGlobalAuthState();
const jwt = authState.authToken.get();

// Ref for scroll to top
const scrollRef = useRef(null);

// URI parameter
const { pipelineId } = useParams();

useEffect(() => {
if (!pipeline || Object.keys(pipeline).length === 0) {
history.push('/');
return null;
}
scrollRef.current.parentElement.scrollIntoView();
document.querySelector('#root div').scrollTo(0, 0);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down Expand Up @@ -240,11 +239,10 @@ const Flow = () => {
if (reactFlowInstance) {
const flowElements = reactFlowInstance.toObject();
FlowState.elements.set([...flowElements.elements]);
updatePipelineFlow(flowElements.elements, Environment.id.get());
updatePipelineFlow(flowElements.elements, Environment.id.get(), pipeline);
FlowState.isEditorPage.set(false);
FlowState.selectedElement.set(null);
RunState.run_id.set(0);
history.push({ pathname: `/pipelines/view/${pipelineId}`, state: pipeline });
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [reactFlowInstance, jwt]);
Expand Down Expand Up @@ -298,7 +296,7 @@ const Flow = () => {
};

return (
<Box className="page" height="calc(100vh - 100px)" minHeight="min-content" ref={scrollRef}>
<Box className="page" height="calc(100vh - 100px)" minHeight="min-content">
<Box ref={offsetRef}>
<Grid container alignItems="center" justifyContent="space-between" wrap="nowrap">
<Box display="flex">
Expand Down
11 changes: 4 additions & 7 deletions frontend/src/pages/Pipelines.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Grid, Typography, TextField, MenuItem, Button, Drawer } from '@mui/material';
import { Box, Grid, Typography, Button, Drawer } from '@mui/material';
import Search from '../components/Search';
import CustomChip from '../components/CustomChip';
import PipelineTable from '../components/TableContent/PipelineTable';
Expand All @@ -7,7 +7,7 @@ import PipelinePageItem from '../components/MoreInfoContent/PipelinePageItem';
import { useGlobalEnvironmentState } from '../components/EnviromentDropdown';
import AddPipelineDrawer from '../components/DrawerContent/AddPipelineDrawer';
import { useGetPipelines } from '../graphql/getPipelines';
import { useEffect, useRef, useState } from 'react';
import { useEffect, useState } from 'react';
import { useSnackbar } from 'notistack';
import { useGlobalFlowState } from './Flow';
import { useGlobalRunState } from './View/useWebSocket';
Expand All @@ -28,9 +28,6 @@ const Pipelines = () => {
const [filter, setFilter] = useState();
const [pipelineCount, setPipelineCount] = useState();

// Ref for scroll to top
const scrollRef = useRef(null);

// Custom GraphQL hook
const getPipelines = useGetPipelines_(setPipelines, Environment.id.get());

Expand All @@ -50,13 +47,13 @@ const Pipelines = () => {
triggerDelete: 1,
});
RunState.set({});
scrollRef.current.parentElement.scrollIntoView();
document.querySelector('#root div').scrollTo(0, 0);

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [Environment.id.get()]);

return (
<Box className="page" position="relative" ref={scrollRef}>
<Box className="page" position="relative">
<Box sx={{ width: { xl: '85%' } }}>
<Grid container alignItems="center" justifyContent="space-between">
<Box>
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/pages/View/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const View = () => {
//Offset states and refs
const [offsetHeight, setOffsetHeight] = useState(0);
const offsetRef = useRef(null);
const scrollRef = useRef(null);

useEffect(() => {
setOffsetHeight(offsetRef.current.clientHeight);
Expand Down Expand Up @@ -68,7 +67,7 @@ const View = () => {
history.push('/');
return null;
}
scrollRef.current.parentElement.scrollIntoView();
document.querySelector('#root div').scrollTo(0, 0);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down Expand Up @@ -128,7 +127,7 @@ const View = () => {
};

return (
<Box className="page" height="calc(100vh - 100px)" minHeight="min-content" ref={scrollRef}>
<Box className="page" height="calc(100vh - 100px)" minHeight="min-content">
<Box ref={offsetRef}>
<Grid container alignItems="center" justifyContent="space-between" wrap="nowrap">
<Box display="flex" alignItems="center">
Expand Down Expand Up @@ -180,6 +179,9 @@ const View = () => {
onMoveEnd={onMoveEnd}
nodeTypes={nodeTypes}
elements={elements}
nodesDraggable={false}
nodesConnectable={false}
preventScrolling={false}
onLoad={onLoad}
onConnect={onConnect}
onConnectStart={onConnectStart}
Expand Down

0 comments on commit 577e7d5

Please sign in to comment.