Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
salazarm committed Sep 19, 2023
1 parent 4e5d4ba commit 2e09dde
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions js_modules/dagster-ui/packages/ui-core/src/runs/LogsToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@ interface ILogsToolbarProps {
computeLogUrl: string | null;

children?: React.ReactNode;
}

interface WithExpandCollapseProps extends ILogsToolbarProps {
isSectionExpanded: boolean;
toggleExpanded: () => void;
}

const logQueryToString = (logQuery: LogFilterValue[]) =>
logQuery.map(({token, value}) => (token ? `${token}:${value}` : value)).join(' ');

export const LogsToolbar: React.FC<ILogsToolbarProps> = (props) => {
export const LogsToolbar: React.FC<ILogsToolbarProps | WithExpandCollapseProps> = (props) => {
const {
steps,
metadata,
Expand All @@ -64,10 +66,15 @@ export const LogsToolbar: React.FC<ILogsToolbarProps> = (props) => {
computeLogFileKey,
onSetComputeLogKey,
computeLogUrl,
isSectionExpanded,
toggleExpanded,
children,
} = props;
let isSectionExpanded;
let toggleExpanded;

if ('isSectionExpanded' in props) {
isSectionExpanded = props.isSectionExpanded;
toggleExpanded = props.toggleExpanded;
}

const activeItems = React.useMemo(() => new Set([logType]), [logType]);

Expand Down Expand Up @@ -101,12 +108,14 @@ 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>
{toggleExpanded ? (
<Tooltip content={isSectionExpanded ? 'Collapse' : 'Expand'}>
<Button
icon={<Icon name={isSectionExpanded ? 'collapse_arrows' : 'expand_arrows'} />}
onClick={toggleExpanded}
/>
</Tooltip>
) : null}
</OptionsContainer>
);
};
Expand Down

0 comments on commit 2e09dde

Please sign in to comment.