Skip to content

Commit

Permalink
Improve reactflow workspace to fit entire available page (#145) (#146)
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
(cherry picked from commit b44adc1)

Co-authored-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and ohltyler committed Apr 22, 2024
1 parent 8a6fe08 commit ae39c2e
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 41 deletions.
80 changes: 44 additions & 36 deletions public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

import React from 'react';
import { Route, RouteComponentProps, Switch } from 'react-router-dom';
import { EuiPageSideBar, EuiSideNav, EuiPageTemplate } from '@elastic/eui';
import {
EuiPageSideBar,
EuiSideNav,
EuiFlexGroup,
EuiFlexItem,
} from '@elastic/eui';
import { Navigation, APP_PATH } from './utils';
import {
Workflows,
Expand All @@ -14,6 +19,9 @@ import {
WorkflowsRouterProps,
} from './pages';

// styling
import './global-styles.scss';

interface Props extends RouteComponentProps {}

export const FlowFrameworkDashboardsApp = (props: Props) => {
Expand Down Expand Up @@ -41,44 +49,44 @@ export const FlowFrameworkDashboardsApp = (props: Props) => {

// Render the application DOM.
return (
<EuiPageTemplate
template="empty"
paddingSize="none"
grow={true}
restrictWidth={false}
pageContentProps={{ paddingSize: 's' }}
pageSideBar={sidebar}
<EuiFlexGroup
direction="row"
gutterSize="none"
className="stretch-relative"
>
<Switch>
<Route
path={APP_PATH.WORKFLOW_DETAIL}
render={(
routeProps: RouteComponentProps<WorkflowDetailRouterProps>
) => <WorkflowDetail {...routeProps} />}
/>
<Route
path={APP_PATH.WORKFLOWS}
render={(routeProps: RouteComponentProps<WorkflowsRouterProps>) => (
<Workflows {...routeProps} />
)}
/>
{/*
<EuiFlexItem grow={false}>{sidebar}</EuiFlexItem>
<EuiFlexItem>
<Switch>
<Route
path={APP_PATH.WORKFLOW_DETAIL}
render={(
routeProps: RouteComponentProps<WorkflowDetailRouterProps>
) => <WorkflowDetail {...routeProps} />}
/>
<Route
path={APP_PATH.WORKFLOWS}
render={(routeProps: RouteComponentProps<WorkflowsRouterProps>) => (
<Workflows {...routeProps} />
)}
/>
{/*
Defaulting to Workflows page. The pathname will need to be updated
to handle the redirection and get the router props consistent.
*/}
<Route
path={`${APP_PATH.HOME}`}
render={(routeProps: RouteComponentProps<WorkflowsRouterProps>) => {
if (props.history.location.pathname !== APP_PATH.WORKFLOWS) {
props.history.replace({
...history,
pathname: APP_PATH.WORKFLOWS,
});
}
return <Workflows {...routeProps} />;
}}
/>
</Switch>
</EuiPageTemplate>
<Route
path={`${APP_PATH.HOME}`}
render={(routeProps: RouteComponentProps<WorkflowsRouterProps>) => {
if (props.history.location.pathname !== APP_PATH.WORKFLOWS) {
props.history.replace({
...history,
pathname: APP_PATH.WORKFLOWS,
});
}
return <Workflows {...routeProps} />;
}}
/>
</Switch>
</EuiFlexItem>
</EuiFlexGroup>
);
};
13 changes: 13 additions & 0 deletions public/global-styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Maximize space given its relative position
.stretch-relative {
position: relative;
height: 100%;
width: 100%;
}

// Maximize space given its absolute position
.stretch-absolute {
position: absolute;
height: 100%;
width: 100%;
}
5 changes: 3 additions & 2 deletions public/pages/workflow_detail/workflow_detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ import {
NEW_WORKFLOW_ID_URL,
} from '../../../common';
import { Resources } from './resources';
import { Prototype } from './prototype';

// styling
import './workflow-detail-styles.scss';
import { Prototype } from './prototype';
import '../../global-styles.scss';

export interface WorkflowDetailRouterProps {
workflowId: string;
Expand Down Expand Up @@ -161,7 +162,7 @@ export function WorkflowDetail(props: WorkflowDetailProps) {
return (
<ReactFlowProvider>
<EuiPage>
<EuiPageBody className="workflow-detail">
<EuiPageBody className="workflow-detail stretch-relative">
<WorkflowDetailHeader
workflow={workflow}
isNewWorkflow={isNewWorkflow}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { ComponentDetails } from '../component_details';

// styling
import './workspace-styles.scss';
import '../../../global-styles.scss';

interface ResizableWorkspaceProps {
isNewWorkflow: boolean;
Expand Down Expand Up @@ -444,6 +445,7 @@ export function ResizableWorkspace(props: ResizableWorkspaceProps) {
/>
<EuiResizableContainer
direction="horizontal"
className="stretch-absolute"
style={{
marginLeft: '-8px',
}}
Expand Down
4 changes: 1 addition & 3 deletions public/pages/workflow_detail/workspace/workspace-styles.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.workspace-panel {
// this ratio will allow the workspace to render on a standard
// laptop (3024 x 1964) without introducing overflow/scrolling
height: 55vh;
height: 100%;
}
5 changes: 5 additions & 0 deletions public/render_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ import { AppMountParameters, CoreStart } from '../../../src/core/public';
import { FlowFrameworkDashboardsApp } from './app';
import { store } from './store';

// styling
import './global-styles.scss';

export const renderApp = (
coreStart: CoreStart,
{ appBasePath, element }: AppMountParameters
) => {
// This is so our base element stretches to fit the entire webpage
element.className = 'stretch-absolute';
ReactDOM.render(
<Provider store={store}>
<Router basename={appBasePath + '#/'}>
Expand Down

0 comments on commit ae39c2e

Please sign in to comment.