Skip to content

Commit acabbaa

Browse files
authored
feat: Move actions filter to toolbar (#38231)
1 parent af45107 commit acabbaa

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

packages/trace-viewer/src/ui/workbench.css

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@
3939
color: var(--vscode-editorCodeLens-foreground);
4040
}
4141

42-
.workbench-actions-status-bar {
43-
padding: 2px;
44-
flex: none;
45-
display: flex;
46-
align-items: center;
47-
justify-content: flex-end;
48-
border-top: 1px solid var(--vscode-panel-border);
49-
}
50-
5142
.workbench-actions-hidden-count {
5243
padding-right: 4px;
5344
user-select: none;

packages/trace-viewer/src/ui/workbench.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,6 @@ const PartitionedWorkbench: React.FunctionComponent<WorkbenchProps & { partition
335335
revealConsole={() => selectPropertiesTab('console')}
336336
isLive={isLive}
337337
/>
338-
<div className='workbench-actions-status-bar'>
339-
{!!hiddenActionsCount && <span className='workbench-actions-hidden-count' title={hiddenActionsCount + ' actions hidden by filters'}>{hiddenActionsCount} hidden</span>}
340-
<ActionsFilterButton counters={model?.actionCounters} />
341-
</div>
342338
</div>
343339
};
344340
const metadataTab: TabbedPaneTabModel = {
@@ -347,6 +343,8 @@ const PartitionedWorkbench: React.FunctionComponent<WorkbenchProps & { partition
347343
component: <MetadataView model={model}/>
348344
};
349345

346+
const actionsFilterWithCount = selectedNavigatorTab === 'actions' && <ActionsFilterButton counters={model?.actionCounters} hiddenActionsCount={hiddenActionsCount} />;
347+
350348
return <div className='vbox workbench' {...(inert ? { inert: true } : {})}>
351349
{!hideTimeline && <Timeline
352350
model={model}
@@ -381,6 +379,7 @@ const PartitionedWorkbench: React.FunctionComponent<WorkbenchProps & { partition
381379
sidebar={
382380
<TabbedPane
383381
tabs={[actionsTab, metadataTab]}
382+
rightToolbar={[actionsFilterWithCount]}
384383
selectedTab={selectedNavigatorTab}
385384
setSelectedTab={setSelectedNavigatorTab}
386385
/>
@@ -405,9 +404,16 @@ const PartitionedWorkbench: React.FunctionComponent<WorkbenchProps & { partition
405404
</div>;
406405
};
407406

408-
const ActionsFilterButton: React.FC<{ counters?: Map<string, number> }> = ({ counters }) => {
407+
const ActionsFilterButton: React.FC<{ counters?: Map<string, number>; hiddenActionsCount: number }> = ({ counters, hiddenActionsCount }) => {
409408
const [actionsFilter, setActionsFilter] = useSetting<ActionGroup[]>('actionsFilter', []);
410-
return <DialogToolbarButton icon='filter' title='Filter actions' dialogDataTestId='actions-filter-dialog'>
409+
410+
const iconRef = React.useRef<HTMLButtonElement>(null);
411+
const buttonChildren = <>
412+
{hiddenActionsCount > 0 && <span className='workbench-actions-hidden-count' title={hiddenActionsCount + ' actions hidden by filters'}>{hiddenActionsCount} hidden</span>}
413+
<span ref={iconRef} className='codicon codicon-filter'></span>
414+
</>;
415+
416+
return <DialogToolbarButton title='Filter actions' dialogDataTestId='actions-filter-dialog' buttonChildren={buttonChildren} anchorRef={iconRef} >
411417
<SettingsView
412418
settings={[
413419
{

packages/web/src/components/dialogToolbarButton.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,27 @@ import { Dialog } from '../shared/dialog';
2121
export interface DialogToolbarButtonProps {
2222
title?: string;
2323
icon?: string;
24+
buttonChildren?: React.ReactNode;
25+
anchorRef?: React.RefObject<HTMLElement | null>;
2426
dialogDataTestId?: string;
2527
}
2628

27-
export const DialogToolbarButton: React.FC<React.PropsWithChildren<DialogToolbarButtonProps>> = ({ title, icon, dialogDataTestId, children }) => {
28-
const hostingRef = React.useRef<HTMLButtonElement>(null);
29+
export const DialogToolbarButton: React.FC<React.PropsWithChildren<DialogToolbarButtonProps>> = ({ title, icon, buttonChildren, anchorRef, dialogDataTestId, children }) => {
30+
const buttonRef = React.useRef<HTMLButtonElement>(null);
31+
const anchor = anchorRef ?? buttonRef;
32+
2933
const [open, setOpen] = React.useState(false);
3034
return (
3135
<>
3236
<ToolbarButton
33-
ref={hostingRef}
37+
ref={buttonRef}
3438
icon={icon}
3539
title={title}
3640
onClick={() => setOpen(current => !current)}
37-
/>
41+
>
42+
{buttonChildren}
43+
</ToolbarButton>
44+
3845
<Dialog
3946
style={{
4047
backgroundColor: 'var(--vscode-sideBar-background)',
@@ -44,7 +51,7 @@ export const DialogToolbarButton: React.FC<React.PropsWithChildren<DialogToolbar
4451
// TODO: Temporary spacing until design of toolbar buttons is revisited
4552
verticalOffset={8}
4653
requestClose={() => setOpen(false)}
47-
anchor={hostingRef}
54+
anchor={anchor}
4855
dataTestId={dialogDataTestId}
4956
>
5057
{children}

packages/web/src/components/tabbedPane.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export interface TabbedPaneTabModel {
3030

3131
export const TabbedPane: React.FunctionComponent<{
3232
tabs: TabbedPaneTabModel[],
33-
leftToolbar?: React.ReactElement[],
34-
rightToolbar?: React.ReactElement[],
33+
leftToolbar?: React.ReactNode[],
34+
rightToolbar?: React.ReactNode[],
3535
selectedTab?: string,
3636
setSelectedTab?: (tab: string) => void,
3737
dataTestId?: string,

0 commit comments

Comments
 (0)