Skip to content
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

move dataset_split and task filter to system table header #528

Merged
merged 3 commits into from
Nov 27, 2022

Conversation

qjiang002
Copy link
Collaborator

This is a sub-component of PR #518

Move dataset split and task filter to the system table header

  • It supports updating and reading from the url. If the column is filtered, the filter icon next to the column name is highlighted in blue.

Screen Shot 2022-11-21 at 5 06 07 PM

filters: Record<string, FilterValue | null>,
_sorter: SorterResult<SystemModel> | SorterResult<SystemModel>[]
) => {
console.log(filters);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please remove the console log?

_sorter: SorterResult<SystemModel> | SorterResult<SystemModel>[]
) => {
console.log(filters);
for (const k in filters) {
Copy link
Member

@lyuyangh lyuyangh Nov 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This for loop has a couple of minor bugs/typos. I think we can fix them and simplify the code to something like this

const filterUpdate: Partial<SystemFilter> = {};
const dataset_split = filters["dataset.split"]
  ? (filters["dataset.split"][0] as string)
  : undefined;
if (dataset_split !== filterValue.split) {
  filterUpdate.split = dataset_split;
}
const task = filters["task"] ? (filters["task"][0] as string) : undefined;
if (task !== filterValue.task) {
  filterUpdate.task = task;
}
onFilterChange(filterUpdate);

Note that I changed the following things:

  1. I don't think we need a for loop here. Loops are for repetitive things but we want to handle each key differently here.
  2. filters["task"] and filters["dataset.split"] are arrays if the filters are active. I don't think we can typecast them to string.
  3. To check whether the new filter value is different from the current one, I converted filters[key] to the value we want with an assignment and then this check is just an equality check.
  4. onFilterChange() is only called once at the end. This makes it easier to track the states because filterValue is only updated once.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much! This looks much clearer. I add another boolean flag before onFilterChange because onFilterChange will set the pagination to page one even when filterUpdate is empty.

@qjiang002 qjiang002 requested a review from lyuyangh November 27, 2022 17:37
Copy link
Member

@lyuyangh lyuyangh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks!

@qjiang002 qjiang002 merged commit 8178ed4 into main Nov 27, 2022
@qjiang002 qjiang002 deleted the refactor-datasetsplit-task-filters branch November 27, 2022 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants