Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -34,14 +34,14 @@ export interface TableFilterableCellProps {
value: string;
filters: Filter[];
onFiltersChange(filters: Filter[]): void;
disableComparisons?: boolean;
enableComparisons?: boolean;
children?: ReactNode;
}

export const TableFilterableCell = React.memo(function TableFilterableCell(
props: TableFilterableCellProps,
) {
const { field, value, children, filters, disableComparisons, onFiltersChange } = props;
const { field, value, children, filters, enableComparisons, onFiltersChange } = props;

return (
<Popover2
Expand All @@ -51,7 +51,7 @@ export const TableFilterableCell = React.memo(function TableFilterableCell(
content={() => (
<Menu>
<MenuDivider title="Filter" />
{(disableComparisons ? FILTER_MODES_NO_COMPARISONS : FILTER_MODES).map((mode, i) => (
{(enableComparisons ? FILTER_MODES : FILTER_MODES_NO_COMPARISONS).map((mode, i) => (
<MenuItem
key={i}
icon={filterModeToIcon(mode)}
Expand Down
4 changes: 2 additions & 2 deletions web-console/src/react-table/react-table-inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function GenericFilterInput({ column, filter, onChange, key }: FilterRend
const [menuOpen, setMenuOpen] = useState(false);
const [focused, setFocused] = useState(false);

const disableComparisons = String(column.headerClassName).includes('disable-comparisons');
const enableComparisons = String(column.headerClassName).includes('enable-comparisons');

const { mode, needle } = (filter ? parseFilterModeAndNeedle(filter, true) : undefined) || {
mode: '~',
Expand All @@ -64,7 +64,7 @@ export function GenericFilterInput({ column, filter, onChange, key }: FilterRend
onInteraction={setMenuOpen}
content={
<Menu>
{(disableComparisons ? FILTER_MODES_NO_COMPARISON : FILTER_MODES).map((m, i) => (
{(enableComparisons ? FILTER_MODES : FILTER_MODES_NO_COMPARISON).map((m, i) => (
<MenuItem
key={i}
icon={filterModeToIcon(m)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ exports[`SegmentsView matches snapshot 1`] = `
"accessor": "start",
"defaultSortDesc": true,
"filterable": true,
"headerClassName": "enable-comparisons",
"show": true,
"sortable": true,
"width": 160,
Expand All @@ -179,6 +180,7 @@ exports[`SegmentsView matches snapshot 1`] = `
"accessor": "end",
"defaultSortDesc": true,
"filterable": true,
"headerClassName": "enable-comparisons",
"show": true,
"sortable": true,
"width": 160,
Expand Down Expand Up @@ -206,7 +208,6 @@ exports[`SegmentsView matches snapshot 1`] = `
"Cell": [Function],
"Header": "Shard type",
"accessor": [Function],
"headerClassName": "disable-comparisons",
"id": "shard_type",
"show": true,
"sortable": false,
Expand Down
11 changes: 6 additions & 5 deletions web-console/src/views/segments-view/segments-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ END AS "time_span"`,
});
}

private renderFilterableCell(field: string, disableComparisons = false) {
private renderFilterableCell(field: string, enableComparisons = false) {
const { segmentFilter } = this.state;

return (row: { value: any }) => (
Expand All @@ -494,7 +494,7 @@ END AS "time_span"`,
value={row.value}
filters={segmentFilter}
onFiltersChange={filters => this.setState({ segmentFilter: filters })}
disableComparisons={disableComparisons}
enableComparisons={enableComparisons}
>
{row.value}
</TableFilterableCell>
Expand Down Expand Up @@ -582,21 +582,23 @@ END AS "time_span"`,
Header: 'Start',
show: visibleColumns.shown('Start'),
accessor: 'start',
headerClassName: 'enable-comparisons',
width: 160,
sortable: hasSql,
defaultSortDesc: true,
filterable: allowGeneralFilter,
Cell: this.renderFilterableCell('start'),
Cell: this.renderFilterableCell('start', true),
},
{
Header: 'End',
show: visibleColumns.shown('End'),
accessor: 'end',
headerClassName: 'enable-comparisons',
width: 160,
sortable: hasSql,
defaultSortDesc: true,
filterable: allowGeneralFilter,
Cell: this.renderFilterableCell('end'),
Cell: this.renderFilterableCell('end', true),
},
{
Header: 'Version',
Expand All @@ -623,7 +625,6 @@ END AS "time_span"`,
id: 'shard_type',
width: 100,
sortable: false,
headerClassName: 'disable-comparisons',
accessor: d => {
let v: any;
try {
Expand Down