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

feat: improve datatable #238

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aldbr
Copy link
Collaborator

@aldbr aldbr commented Oct 21, 2024

diracx-web-components tables are managed by tan stack. It is used to:

  • select rows
  • resize columns
  • hide/show columns
  • pagination

tan stack also provides a library to virtualize tables but it does not seem to nicely work with MUI Table, so I kept react virtuoso.

I modified the stories accordingly and added some integration tests to make sure the main features of the Job Monitor keeps working.

@aldbr aldbr force-pushed the main_FEAT_improve-datatable branch 3 times, most recently from 2780923 to 5858dab Compare October 30, 2024 17:32
@ryuwd ryuwd self-requested a review October 31, 2024 10:47
@aldbr aldbr force-pushed the main_FEAT_improve-datatable branch from 5858dab to 594b21a Compare October 31, 2024 13:15
@aldbr aldbr marked this pull request as ready for review October 31, 2024 13:30
@aldbr aldbr mentioned this pull request Nov 13, 2024
7 tasks
Copy link

@ryuwd ryuwd left a comment

Choose a reason for hiding this comment

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

Looks like very sensible refactoring and improvements throughout. I have only small suggestions about style and the login UI

selectedGroup ||
metadata.virtual_organizations[selectedVO].default_group
}
label="Select a Group"
Copy link

Choose a reason for hiding this comment

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

Suggested change
label="Select a Group"
label="Select your Virtual Organization"

Unless the terminology Virtual Organisation/VO is outdated, it might be better to be consistent so people don't get confused

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 Virtual Organization is selected before:

Here user can select the group within the Virtual Organization (e.g. VO: LHCb, groups: [lhcb_user, lhcb_admin]).

Though I could add a a in Select Virtual Organization (I would not add your since a given physical person can be part of different VOs).

What do you think?

Copy link

Choose a reason for hiding this comment

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

I completely misread - that's what I get for skim-reading - apologies :D sounds good

onClick={handleConfigurationChanges}
data-testid="button-login"
>
Login through your Identity Provider
Copy link

Choose a reason for hiding this comment

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

Suggested change
Login through your Identity Provider
Login via your Identity Provider

this is just a suggestion

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, I will apply it 🙂


const handleCloseContextMenu = () => {
const handleCloseContextMenu = React.useCallback(() => {
Copy link

Choose a reason for hiding this comment

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

would it be better just to import useCallback ? again just a style suggestion

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From what I understand (and please correct me if I am wrong), there is no clear advantage of one way against the other (React.use... vs use...) so it's mostly a question of personal preference.

Now it's true that we write both React.use... and use... throughout the code and it would be better to be consistent. Though, if we choose one way I think it would be better to enforce it with an automated check using ESLint for instance (because else I am pretty sure this will be forgotten in a few months/years).

I don't find any easy way to enforce that but I will better check, thanks!

const VirtuosoTableComponents: TableComponents<
Row<T>,
unknown
> = React.useMemo(
Copy link

Choose a reason for hiding this comment

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

similarly here

Comment on lines +36 to +46
export function FilterToolbar<T extends Record<string, unknown>>(
props: FilterToolbarProps<T>,
) {
const {
columns,
filters,
setFilters,
appliedFilters,
handleApplyFilters,
handleClearFilters,
} = props;
Copy link

Choose a reason for hiding this comment

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

how about something like this?

Suggested change
export function FilterToolbar<T extends Record<string, unknown>>(
props: FilterToolbarProps<T>,
) {
const {
columns,
filters,
setFilters,
appliedFilters,
handleApplyFilters,
handleClearFilters,
} = props;
export function FilterToolbar<T extends Record<string, unknown>>(
{
columns,
filters,
setFilters,
appliedFilters,
handleApplyFilters,
handleClearFilters,
}: FilterToolbarProps<T>,
) {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From what I understand (again, don't hesitate to correct me if you think I am wrong), this also comes down to personal preference most of the time. Now in our case, I think the structured props has a few advantage over the "destructured" one:

  • in your suggestion, you did not add the types of the parameters, and they would make the signature less readable given the number of parameters.
  • the props and the comments associated are used by Storybook to provide an interactive documentation about the components for the communities that will have to develop their extensions (e.g. LHCb), I am not sure (I have not checked though) Storybook would be able to read the parameters from there.

Again, no matter our final choice, may be it would deserve a consistency check? (I think there is a destructuring check for that)

Copy link

@ryuwd ryuwd Nov 20, 2024

Choose a reason for hiding this comment

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

you did not add the types of the parameters

I'd thought that i'd specified the types (line 44) }: FilterToolbarProps<T>

No biggie if you prefer the current form - I'd thought it might be a nicer way to write out the component props

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.

2 participants