mirror of https://github.com/apache/druid.git
Web console: Column counter (#9334)
* Column counter * more general test
This commit is contained in:
parent
ef3d24e886
commit
c294e0b7c6
|
@ -14,7 +14,12 @@ exports[`table column matches snapshot 1`] = `
|
|||
<span
|
||||
class="bp3-button-text"
|
||||
>
|
||||
Columns
|
||||
Columns
|
||||
<span
|
||||
class="counter"
|
||||
>
|
||||
(2/3)
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="bp3-icon bp3-icon-caret-down"
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
position: absolute;
|
||||
right: 0;
|
||||
margin: 0;
|
||||
|
||||
.counter {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
// This will be mounted in a portal
|
||||
|
|
|
@ -27,7 +27,7 @@ describe('table column', () => {
|
|||
<TableColumnSelector
|
||||
columns={['a', 'b', 'c']}
|
||||
onChange={() => {}}
|
||||
tableColumnsHidden={['a', 'b', 'c']}
|
||||
tableColumnsHidden={['b']}
|
||||
/>
|
||||
);
|
||||
const { container } = render(tableColumn);
|
||||
|
|
|
@ -34,26 +34,33 @@ export const TableColumnSelector = React.memo(function TableColumnSelector(
|
|||
props: TableColumnSelectorProps,
|
||||
) {
|
||||
const { columns, onChange, tableColumnsHidden } = props;
|
||||
|
||||
const isColumnShown = (column: string) => !tableColumnsHidden.includes(column);
|
||||
|
||||
const checkboxes = (
|
||||
<Menu className="table-column-selector-menu">
|
||||
{columns.map(column => (
|
||||
<MenuCheckbox
|
||||
label={column}
|
||||
key={column}
|
||||
checked={!tableColumnsHidden.includes(column)}
|
||||
checked={isColumnShown(column)}
|
||||
onChange={() => onChange(column)}
|
||||
/>
|
||||
))}
|
||||
</Menu>
|
||||
);
|
||||
|
||||
const counterText = `(${columns.filter(isColumnShown).length}/${columns.length})`;
|
||||
|
||||
return (
|
||||
<Popover
|
||||
className="table-column-selector"
|
||||
content={checkboxes}
|
||||
position={Position.BOTTOM_RIGHT}
|
||||
>
|
||||
<Button rightIcon={IconNames.CARET_DOWN} text="Columns" />
|
||||
<Button rightIcon={IconNames.CARET_DOWN}>
|
||||
Columns <span className="counter">{counterText}</span>
|
||||
</Button>
|
||||
</Popover>
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue