-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix(column-configurator): convert to using the taxonomic filter #8726
Merged
Merged
Changes from 27 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
d121a0f
copy array in selector to trigger change detection
pauldambra 689b2e8
use taxonomic filter for the column configurator
pauldambra 10770fc
fix column configurator tests
pauldambra de18065
fix weird test failure
pauldambra 16bff88
ensure the taxonomic popup isn't showing row 0 when then column confi…
pauldambra d135e1a
rename visible columns now there are no hidden columns
pauldambra df30ad3
rename visible columns now there are no hidden columns
pauldambra ea8bb34
tidy up column configurator
pauldambra ebddc4a
which allows removal of a use of the property definitions model
pauldambra f674c28
Merge branch 'master' into empty-columns
pauldambra 757e7d6
more specific prop to disable popper on taxonomic filter
pauldambra e389bee
better column name
pauldambra 918f9ab
don't allow duplicate column selections
pauldambra 7e730af
Merge branch 'master' into empty-columns
pauldambra 6ddc641
use autosizer height and width and flex display to have infinite list…
pauldambra 5587ae4
set text overflow for long rows in the infinite list
pauldambra bab97a7
update column configurator columns when resetting
pauldambra 8cf08c5
Merge branch 'master' into empty-columns
pauldambra 9982f01
select initial row based on props
pauldambra f58b2af
don't create css if height and width are not provided
pauldambra 0bae446
limit scope of change to propertykeyinfo width
pauldambra 32c17c0
alter column configurator reset behaviour
pauldambra ac1d347
set popper enabled without breaking text search
pauldambra 016f866
don't need to pass popper enabled two different ways to infinite list
pauldambra bf26aea
allow taxonomic filter value consumers to configure it not to clear s…
pauldambra 21500ad
clear the taxonomic filter search when the column configurator is saved
pauldambra e91c407
fix tests
pauldambra ce40e3a
default column configurator to an empty array of columns
pauldambra ceb69c8
Revert "default column configurator to an empty array of columns"
pauldambra 2198563
Revert "fix tests"
pauldambra b040f04
Revert "clear the taxonomic filter search when the column configurato…
pauldambra 1755198
rename popper to popover
pauldambra ce85c12
move taxonomic filter config onto its props
pauldambra b0ead05
tidier declaration of style
pauldambra 1ab117b
make selecting the first item explicit
pauldambra 3504c00
always clear taxonomic filter on select but do it so infinite list ca…
pauldambra a3232d1
fix tests
pauldambra e0653e6
use the constant for no item selected, since it is available
pauldambra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 8 additions & 47 deletions
55
frontend/src/lib/components/ResizableTable/columnConfiguratorLogic.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,33 @@ | ||
import { columnConfiguratorLogicType } from './columnConfiguratorLogicType' | ||
import { tableConfigLogic } from 'lib/components/ResizableTable/tableConfigLogic' | ||
import { kea } from 'kea' | ||
|
||
export interface ColumnConfiguratorLogicProps { | ||
availableColumns: string[] // all of the columns the table could display | ||
selectedColumns: string[] //the columns the table is currently displaying | ||
selectedColumns: string[] // the columns the table is currently displaying | ||
} | ||
|
||
import { columnConfiguratorLogicType } from './columnConfiguratorLogicType' | ||
import { tableConfigLogic } from 'lib/components/ResizableTable/tableConfigLogic' | ||
import Fuse from 'fuse.js' | ||
|
||
const filterColumns = (columnFilter: string, columns: string[]): string[] => | ||
columnFilter | ||
? new Fuse(columns, { | ||
threshold: 0.3, | ||
}) | ||
.search(columnFilter) | ||
.map(({ item }) => item) | ||
: columns | ||
|
||
export const columnConfiguratorLogic = kea<columnConfiguratorLogicType<ColumnConfiguratorLogicProps>>({ | ||
path: ['lib', 'components', 'ResizableTable', 'columnConfiguratorLogic'], | ||
props: { availableColumns: [], selectedColumns: [] } as ColumnConfiguratorLogicProps, | ||
props: { selectedColumns: [] } as ColumnConfiguratorLogicProps, | ||
actions: { | ||
selectColumn: (column: string) => ({ column }), | ||
unselectColumn: (column: string) => ({ column }), | ||
resetColumns: (columns: string[]) => ({ columns }), | ||
save: true, | ||
setColumnFilter: (searchTerm: string) => ({ searchTerm }), | ||
}, | ||
reducers: ({ props }) => ({ | ||
columnFilter: [ | ||
'', | ||
{ | ||
setColumnFilter: (_, { searchTerm }) => searchTerm, | ||
}, | ||
], | ||
visibleColumns: [ | ||
selectedColumns: [ | ||
props.selectedColumns, | ||
{ | ||
selectColumn: (state, { column }) => [...state, column], | ||
selectColumn: (state, { column }) => Array.from(new Set([...state, column])), | ||
unselectColumn: (state, { column }) => state.filter((c) => c !== column), | ||
}, | ||
], | ||
hiddenColumns: [ | ||
props.availableColumns.filter((c) => !props.selectedColumns.includes(c)), | ||
{ | ||
selectColumn: (state, { column }) => state.filter((c) => c !== column), | ||
unselectColumn: (state, { column }) => [...state, column], | ||
resetColumns: (_, { columns }) => columns, | ||
}, | ||
], | ||
}), | ||
selectors: { | ||
scrollIndex: [(selectors) => [selectors.visibleColumns], (visibleColumns) => visibleColumns.length], | ||
filteredVisibleColumns: [ | ||
(selectors) => [selectors.columnFilter, selectors.visibleColumns], | ||
(columnFilter, visibleColumns) => filterColumns(columnFilter, visibleColumns), | ||
], | ||
filteredHiddenColumns: [ | ||
(selectors) => [selectors.columnFilter, selectors.hiddenColumns], | ||
(columnFilter, hiddenColumns) => filterColumns(columnFilter, hiddenColumns), | ||
], | ||
}, | ||
listeners: ({ values }) => ({ | ||
save: () => { | ||
tableConfigLogic.actions.setSelectedColumns(values.visibleColumns) | ||
}, | ||
resetColumns: ({ columns }) => { | ||
tableConfigLogic.actions.setSelectedColumns(columns) | ||
tableConfigLogic.actions.setSelectedColumns(values.selectedColumns) | ||
}, | ||
}), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... Will this test fail without it? If so, it's coupled in a strange way. Something to improve?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's too yucky, I'll remove