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

Allow to filter user by display_name #821

Merged
merged 18 commits into from Jan 22, 2023

Conversation

notmd
Copy link
Collaborator

@notmd notmd commented Jan 18, 2023

close #766
DO NOT MERGE, depend on #851 It's ready now.

  • Implement a new DataTable component. I implement our own filter and paginate logic cause the built-in doesn't really useful when fetching data from server side and is inflexible.
  • Use react-table v8. I plan to migrate other components currently using v7 to v8 when I complete Admin Enhancement: Make it easier to find specific users #766.
  • Allow searching for the user by display_name.
  • Use UUID based cursor. It now provided by the backend.
  • Fix a bug when querying the user in the backward direction.

Note that this PR doesn't support filtering users by prefix and the api/v1/frontend_users/by_display_name endpoint doesn't support pagination yet. I'm going to address this in the next PR.
Here is the new UI

image

@fozziethebeat
Copy link
Collaborator

I like the look of the new table!

@@ -161,10 +161,10 @@ def query_users(
users = users.order_by(User.display_name)

if gt:
users = users.filter(User.display_name > gt)
users = users.filter(User.id > gt)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure what the intention here is, but it doesn't look right.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought we want to cursor based on the user id?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is the user id column monotonically increasing?

Copy link
Collaborator

Choose a reason for hiding this comment

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

UUID V4 isn't guaranteed to be monotonically increasing. I think only UUID V6 or V7 have that property. V4 is random in it's ordering.

{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
{(header.column.columnDef as DataTableColumnDef<T>).filterable && (
<FilterModal
value={filterValues.find((value) => value.id === header.id)?.value ?? ""}
Copy link
Contributor

Choose a reason for hiding this comment

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

If filterValues was an object and not an array could we avoid using find and findIndex?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The filter API is temporary for now. It will change significantly in the next PR. I want to have something like MUI Grid. It will be an array to support multiple filters in 1 column.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you,

I was mainly referring to a suggestion to use object for items and not an array which would enable memorable look up of filters.

const filters = {
  linkOperator: 'is',
  items: {
    1: {
      id: 1,
      columnField: 'rating',
      operatorValue: '>',
      value: '4',
    },
    2: {
      id: 2,
      columnField: 'isAdmin',
      operatorValue: 'is',
      value: 'true',
    },
  },
}

const getFilterById = (id) => filters.items[id]

@notmd notmd requested review from andreaskoepf and fozziethebeat and removed request for andreaskoepf and fozziethebeat January 21, 2023 13:14
@@ -207,6 +207,7 @@ def query_users_ordered_by_display_name(
limit: Optional[int] = 100,
desc: bool = False,
) -> list[User]:

Copy link
Collaborator

Choose a reason for hiding this comment

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

this newline triggers my review as code owner. it's a very beautiful newline. I approve ;)

Copy link
Collaborator

@fozziethebeat fozziethebeat left a comment

Choose a reason for hiding this comment

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

Time to merge and see all the glory

@fozziethebeat fozziethebeat merged commit cc4d131 into LAION-AI:main Jan 22, 2023
@notmd notmd deleted the 766_admin_enhancement branch January 23, 2023 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Admin Enhancement: Make it easier to find specific users
5 participants