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

share modal: add groups tab by feature flag #2649

Merged

Conversation

anikachurilova
Copy link
Member

@anikachurilova anikachurilova commented Apr 16, 2024

See most of the screenshots here inveniosoftware/invenio-communities#1127

Some error handlers:
On delete:
Screenshot 2024-04-18 at 16 47 36
Screenshot 2024-04-18 at 16 48 35

@anikachurilova anikachurilova force-pushed the add-ui-tab-for-groups branch from 087542f to 5d7273a Compare April 16, 2024 14:41
onClick={handleDelete}
icon
labelPosition="left"
{error ? (
Copy link
Contributor

@kpsherva kpsherva Apr 19, 2024

Choose a reason for hiding this comment

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

minor: could we discuss not using ternary operators with big blocks of code? it is a bit unreadable, an if statement even before the return statement would be probably better. Do we need the error message displayed inside the table row?

Copy link
Member Author

Choose a reason for hiding this comment

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

I put the message inside the row because it's an error that occurred on deleting a specific secret link. Do you mean we should put the error message on top of the modal?

Copy link
Contributor

Choose a reason for hiding this comment

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

ok I see, that was not obvious from the code, thanks for explaining.
What about ternary operators?

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced ternany operators with

{error && <ErrorMessage />}
{!error && <... />}

I agree looks more readable now!

<Modal.Content className="share-content">
{loading && <Loader isLoading active />}
{!loading && results !== undefined && (
<UserGroupAccessSearchResult
Copy link
Contributor

@kpsherva kpsherva Apr 19, 2024

Choose a reason for hiding this comment

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

understanding just from props, I have a feeling that this component has either too many responsibilities or is just a wrapper which is passing down props, could it be simplified somehow?
when we have too many responsibilities on one component, it becomes impossible to decouple functionalities and reuse the code.
Some of the props are redundant, for example record and recOwner, you can retrieve the owner inside the component using record. callbackEndpoint and endpoint would be potentially another example.
Some of the other props are just passed down from the parent component to UserGroupAccessSearchResult, maybe that would be an indicator to split this component and use some of the subcomponents directly here, without wrapping them with UserGroupAccessSearchResult.
Generally it looks to me there is some potential for simplification. The easiest would be to look for possible presentation vs data fetch components separation

return (
<Table.Row>
{error ? (
<ErrorMessage
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as somewhere before: do we need the error message to be displayed inside the table?


results.forEach((result) => {
if (result.id === id) {
result.permission = permission;
Copy link
Contributor

Choose a reason for hiding this comment

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

just for my understanding on how it works: I am not sure I fully understand why permission is set on the result, shouldn't the permission be already there?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was done to update the list of results that won't require refetching the whole tab pane. As the only way to update the grant/link is to change a permission, that is why I am only updating it here.

results = linksResults;
}

results.forEach((result) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

if there are many results, could it have issues with performance?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we are expecting to have more than ~10-20 results in each tab, so I think this should be ok!

if (entityType === this.linksType) await this.fetchLinks(callbackEndpoint, true);
};

fetchUsersGroups = async (endpoint, entityType, isDataChanged) => {
Copy link
Contributor

@kpsherva kpsherva Apr 19, 2024

Choose a reason for hiding this comment

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

general observation for this component: it has too many responsibilities, especially

  1. fetching different types of data,
  2. taking care of different tabs display
  3. handles updates

I think it should be split into smaller components

Copy link
Member Author

Choose a reason for hiding this comment

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

Split the responsibilities between the components! Does it look better now?

if (entityType === this.groupType) await this.fetchGroups(endpoint, isDataChanged);
};

fetchUsers = async (endpoint, isDataChanged) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not understanding the param isDataChanged: what is the purpose?

Copy link
Member Author

Choose a reason for hiding this comment

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

The purpose is to mark that data was added/deleted and the table of results needs refetching.
isDataChanged will be equal to false when clicking between tabs for more than 1 time. As a result the whole list is not being fetched every time user clicks on the tab.

@anikachurilova anikachurilova force-pushed the add-ui-tab-for-groups branch 2 times, most recently from cd4747d to 95cbc58 Compare April 24, 2024 08:25
@anikachurilova anikachurilova force-pushed the add-ui-tab-for-groups branch 5 times, most recently from adbc3fb to e3d3aff Compare April 26, 2024 06:52
@kpsherva
Copy link
Contributor

tests outcome (mainly UX improvements, can be implemented in a separate PR):

  1. Active tab label should have brand colour (pinkish), otherwise it looks strange, like inactive tab
    Screenshot 2024-04-29 at 16 34 42

  2. Owner should be counted in the number on the label, otherwise the numbers don't add up:
    Screenshot 2024-04-29 at 16 37 28

  3. The permission level field does not stand out, therefore someone can just choose users and click "Add", which results in:
    Screenshot 2024-04-29 at 14 54 42
    We need to either block the add button, until all required fields are filled or improve the error message, because it does not state which field is missing - the user won't associate permission with Access field

  4. Search needs improvement, ticket already created Some users cannot be found when inviting or setting restrictions CERNDocumentServer/cds-rdm#114

  5. When adding multiple users, the search works quite badly, it should favour users not yet added to the access grants:
    Screenshot 2024-04-29 at 14 55 32 ( I was expecting to see user Test 2, which showed up only when typing the full name, otherwise the dropdown is taken over by the already added entries)

  6. when clicking remove, we should have confirmation monit ("Are you sure you want to remove...?"), like everywhere else. The button should be red, since our actions are color-coded.
    Screenshot 2024-04-29 at 16 37 28

  7. When clicking on remove, the whole modal goes to loading state, we should only display loading on the specific button, why to block all the rows, is there any specific reason? Otherwise the UI "jumps" due to unspecified minimal height while loader is displaying
    Screenshot 2024-04-29 at 16 37 28

* avoid fetching data of each tab pane on opening of the modal
* fetch only the data of the opened pane
* add missing error handlings
@anikachurilova anikachurilova force-pushed the add-ui-tab-for-groups branch from e3d3aff to 9e1e6a0 Compare May 7, 2024 09:58
@ntarocco ntarocco merged commit 8d13662 into inveniosoftware:master May 7, 2024
2 checks passed
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.

access-requests: add UI tab for groups
3 participants