Skip to content

Commit

Permalink
Add resizable side panel for workspace component details
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Oct 6, 2023
1 parent f30ac98 commit ed3c058
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 23 deletions.
7 changes: 5 additions & 2 deletions public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface Props extends RouteComponentProps {}

export const AiFlowDashboardsApp = (props: Props) => {
const sidebar = (
<EuiPageSideBar style={{ minWidth: 190 }} hidden={false}>
<EuiPageSideBar style={{ minWidth: 190 }} hidden={false} paddingSize="l">
<EuiSideNav
style={{ width: 190 }}
items={[
Expand Down Expand Up @@ -50,7 +50,10 @@ export const AiFlowDashboardsApp = (props: Props) => {
return (
<EuiPageTemplate
template="empty"
pageContentProps={{ paddingSize: 'm' }}
paddingSize="none"
grow={true}
restrictWidth={false}
pageContentProps={{ paddingSize: 's' }}
pageSideBar={sidebar}
>
<Switch>
Expand Down
4 changes: 2 additions & 2 deletions public/pages/workflow_detail/workflow_detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { EuiPage, EuiPageBody } from '@elastic/eui';
import { BREADCRUMBS } from '../../utils';
import { getCore } from '../../services';
import { WorkflowDetailHeader } from './components';
import { Workspace } from './workspace';
import { AppState } from '../../store';
import { ResizableWorkspace } from './workspace';

export interface WorkflowDetailRouterProps {
workflowId: string;
Expand Down Expand Up @@ -40,7 +40,7 @@ export function WorkflowDetail(props: WorkflowDetailProps) {
<EuiPage>
<EuiPageBody>
<WorkflowDetailHeader workflow={workflow} />
<Workspace workflow={workflow} />
<ResizableWorkspace workflow={workflow} />
</EuiPageBody>
</EuiPage>
);
Expand Down
28 changes: 28 additions & 0 deletions public/pages/workflow_detail/workspace/component_inputs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
import { Workflow } from '../../../../common';

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

interface ComponentInputsProps {}

export function ComponentInputs(props: ComponentInputsProps) {
return (
<EuiFlexGroup
direction="column"
gutterSize="none"
justifyContent="spaceBetween"
className="workspace-panel"
>
<EuiFlexItem className="resizable-panel-border">
<EuiText>Side panel</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
);
}
2 changes: 1 addition & 1 deletion public/pages/workflow_detail/workspace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

export { Workspace } from './workspace';
export { ResizableWorkspace } from './resizable_workspace';
12 changes: 3 additions & 9 deletions public/pages/workflow_detail/workspace/reactflow-styles.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$handle-color: #5a5a5a;
$handle-color-valid: #55dd99;
$handle-color-invalid: #ff6060;
$handle-color: $euiColorDarkestShade;
$handle-color-valid: $euiColorSuccess;
$handle-color-invalid: $euiColorDanger;

.reactflow-parent-wrapper {
display: flex;
Expand All @@ -13,12 +13,6 @@ $handle-color-invalid: #ff6060;
height: 100%;
}

.workspace {
width: 80vh;
height: 50vh;
padding: 0;
}

.reactflow-workspace .react-flow__node {
width: 300px;
}
Expand Down
40 changes: 40 additions & 0 deletions public/pages/workflow_detail/workspace/resizable_workspace.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { EuiResizableContainer } from '@elastic/eui';
import { Workflow } from '../../../../common';
import { Workspace } from './workspace';
import { ComponentInputs } from './component_inputs';

interface ResizableWorkspaceProps {
workflow?: Workflow;
}

export function ResizableWorkspace(props: ResizableWorkspaceProps) {
return (
<EuiResizableContainer
direction="horizontal"
style={{ marginLeft: '-14px' }}
>
{(EuiResizablePanel, EuiResizableButton) => (
<>
<EuiResizablePanel
mode="main"
initialSize={80}
minSize="50%"
style={{ margin: 0, padding: 0 }}
>
<Workspace workflow={props.workflow} />
</EuiResizablePanel>
<EuiResizableButton />
<EuiResizablePanel mode="collapsible" initialSize={20} minSize="10%">
<ComponentInputs />
</EuiResizablePanel>
</>
)}
</EuiResizableContainer>
);
}
12 changes: 12 additions & 0 deletions public/pages/workflow_detail/workspace/workspace-styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.workspace-panel {
// this ratio will allow the workspace to render on a standard
// laptop (3024 x 1964) without introducing overflow/scrolling
height: 60vh;
padding: 0;
}

.resizable-panel-border {
border-style: groove;
border-color: gray;
border-width: 1px;
}
13 changes: 4 additions & 9 deletions public/pages/workflow_detail/workspace/workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { DeletableEdge } from '../workspace_edge';
// styling
import 'reactflow/dist/style.css';
import './reactflow-styles.scss';
import './workspace-styles.scss';
import '../workspace_edge/deletable-edge-styles.scss';

interface WorkspaceProps {
Expand Down Expand Up @@ -117,17 +118,11 @@ export function Workspace(props: WorkspaceProps) {
return (
<EuiFlexGroup
direction="column"
gutterSize="m"
gutterSize="none"
justifyContent="spaceBetween"
className="workspace"
className="workspace-panel"
>
<EuiFlexItem
style={{
borderStyle: 'groove',
borderColor: 'gray',
borderWidth: '1px',
}}
>
<EuiFlexItem className="resizable-panel-border">
{/**
* We have these wrapper divs & reactFlowWrapper ref to control and calculate the
* ReactFlow bounds when calculating node positioning.
Expand Down

0 comments on commit ed3c058

Please sign in to comment.