Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update expand/collapse section buttons on Runs page #16622

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import checklist from '../icon-svgs/checklist.svg';
import chevron_left from '../icon-svgs/chevron_left.svg';
import chevron_right from '../icon-svgs/chevron_right.svg';
import close from '../icon-svgs/close.svg';
import collapse_arrows from '../icon-svgs/collapse_arrows.svg';
import concept_book from '../icon-svgs/concept-book.svg';
import console_icon from '../icon-svgs/console.svg';
import content_copy from '../icon-svgs/content_copy.svg';
Expand All @@ -55,6 +56,7 @@ import error from '../icon-svgs/error.svg';
import error_outline from '../icon-svgs/error_outline.svg';
import execute from '../icon-svgs/execute.svg';
import expand from '../icon-svgs/expand.svg';
import expand_arrows from '../icon-svgs/expand_arrows.svg';
import expand_less from '../icon-svgs/expand_less.svg';
import expand_more from '../icon-svgs/expand_more.svg';
import filter_alt from '../icon-svgs/filter_alt.svg';
Expand Down Expand Up @@ -246,6 +248,7 @@ export const Icons = {
close,
console: console_icon,
content_copy,
collapse_arrows,
delete: deleteSVG,
done,
dot,
Expand All @@ -257,6 +260,7 @@ export const Icons = {
error,
error_outline,
expand,
expand_arrows,
expand_less,
expand_more,
filter_alt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export class SplitPanelContainer extends React.Component<
window.localStorage.setItem(this.state.key, `${size}`);
};

getSize = () => {
return this.state.size;
};

render() {
const {firstMinSize, first, second} = this.props;
const {size: _size, resizing} = this.state;
Expand Down Expand Up @@ -137,41 +141,6 @@ interface PanelToggleProps {
container: React.RefObject<SplitPanelContainer>;
}

export const FirstOrSecondPanelToggle = ({container, axis}: PanelToggleProps) => {
const onClick = (id: string) => {
let size = 50;
if (id === 'first-pane') {
size = 100;
} else if (id === 'second-pane') {
size = 0;
}
container.current?.onChangeSize(size);
};

return (
<ButtonGroup
buttons={[
{
id: 'first-pane',
icon: axis === 'vertical' ? 'panel_show_top' : 'panel_show_left',
tooltip: axis === 'vertical' ? 'Show only top pane' : 'Show only left pane',
},
{
id: 'split',
icon: 'panel_show_both',
tooltip: 'Show both panes',
},
{
id: 'second-pane',
icon: axis === 'vertical' ? 'panel_show_bottom' : 'panel_show_right',
tooltip: axis === 'vertical' ? 'Show only bottom pane' : 'Show only right pane',
},
]}
onClick={onClick}
/>
);
};

// Todo: This component attempts to sync itself with the container, but it can't
// observe the container's width without a React context or adding a listener, etc.
// If we keep making components that manipulate panel state we may want to move it
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions js_modules/dagster-ui/packages/ui-core/src/runs/LogsToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Tooltip,
Suggest,
ExternalAnchorButton,
Button,
} from '@dagster-io/ui-components';
import * as React from 'react';
import styled from 'styled-components';
Expand Down Expand Up @@ -43,6 +44,9 @@ interface ILogsToolbarProps {
computeLogUrl: string | null;

children?: React.ReactNode;

isSectionExpanded: boolean;
toggleExpanded: () => void;
}

const logQueryToString = (logQuery: LogFilterValue[]) =>
Expand All @@ -60,6 +64,8 @@ export const LogsToolbar: React.FC<ILogsToolbarProps> = (props) => {
computeLogFileKey,
onSetComputeLogKey,
computeLogUrl,
isSectionExpanded,
toggleExpanded,
children,
} = props;

Expand Down Expand Up @@ -95,6 +101,12 @@ export const LogsToolbar: React.FC<ILogsToolbarProps> = (props) => {
/>
)}
{children}
<Tooltip content={isSectionExpanded ? 'Collapse' : 'Expand'}>
<Button
icon={<Icon name={isSectionExpanded ? 'collapse_arrows' : 'expand_arrows'} />}
onClick={toggleExpanded}
/>
</Tooltip>
</OptionsContainer>
);
};
Expand Down
50 changes: 46 additions & 4 deletions js_modules/dagster-ui/packages/ui-core/src/runs/Run.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {
Box,
NonIdealState,
FirstOrSecondPanelToggle,
SplitPanelContainer,
ErrorBoundary,
Button,
Icon,
Tooltip,
} from '@dagster-io/ui-components';
import * as React from 'react';
import styled from 'styled-components';
Expand Down Expand Up @@ -166,7 +168,6 @@ const RunWithData: React.FC<RunWithDataProps> = ({
onSetSelectionQuery,
}) => {
const onLaunch = useJobReExecution(run);
const splitPanelContainer = React.createRef<SplitPanelContainer>();

const [queryLogType, setQueryLogType] = useQueryPersistedState<string>({
queryKey: 'logType',
Expand Down Expand Up @@ -242,6 +243,38 @@ const RunWithData: React.FC<RunWithDataProps> = ({
onSetSelectionQuery(newSelected.join(', ') || '*');
};

const [splitPanelContainer, setSplitPanelContainer] = React.useState<null | SplitPanelContainer>(
null,
);
React.useEffect(() => {
const initialSize = splitPanelContainer?.getSize();
switch (initialSize) {
case 100:
setExpandedPanel('top');
return;
case 0:
setExpandedPanel('bottom');
return;
}
}, [splitPanelContainer]);

const [expandedPanel, setExpandedPanel] = React.useState<null | 'top' | 'bottom'>(null);
const isTopExpanded = expandedPanel === 'top';
const isBottomExpanded = expandedPanel === 'bottom';

const expandBottomPanel = () => {
splitPanelContainer?.onChangeSize(0);
setExpandedPanel('bottom');
};
const expandTopPanel = () => {
splitPanelContainer?.onChangeSize(100);
setExpandedPanel('top');
};
const resetPanels = () => {
splitPanelContainer?.onChangeSize(50);
setExpandedPanel(null);
};

const gantt = (metadata: IRunMetadataDict) => {
if (!run) {
return <GanttChartLoadingState runId={runId} />;
Expand All @@ -260,7 +293,12 @@ const RunWithData: React.FC<RunWithDataProps> = ({
}}
toolbarActions={
<Box flex={{direction: 'row', alignItems: 'center', gap: 12}}>
<FirstOrSecondPanelToggle axis="vertical" container={splitPanelContainer} />
<Tooltip content={isTopExpanded ? 'Collapse' : 'Expand'}>
<Button
icon={<Icon name={isTopExpanded ? 'collapse_arrows' : 'expand_arrows'} />}
onClick={isTopExpanded ? resetPanels : expandTopPanel}
/>
</Tooltip>
<RunActionButtons
run={run}
onLaunch={onLaunch}
Expand Down Expand Up @@ -288,7 +326,9 @@ const RunWithData: React.FC<RunWithDataProps> = ({
return (
<>
<SplitPanelContainer
ref={splitPanelContainer}
ref={(container) => {
setSplitPanelContainer(container);
}}
axis="vertical"
identifier="run-gantt"
firstInitialPercent={35}
Expand All @@ -308,6 +348,8 @@ const RunWithData: React.FC<RunWithDataProps> = ({
onSetComputeLogKey={setComputeLogFileKey}
computeLogUrl={computeLogUrl}
counts={logs.counts}
isSectionExpanded={isBottomExpanded}
toggleExpanded={isBottomExpanded ? resetPanels : expandBottomPanel}
/>
{logType !== LogType.structured ? (
!computeLogFileKey ? (
Expand Down