-
Notifications
You must be signed in to change notification settings - Fork 151
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
share modal: add groups tab by feature flag #2649
Conversation
087542f
to
5d7273a
Compare
onClick={handleDelete} | ||
icon | ||
labelPosition="left" | ||
{error ? ( |
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.
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?
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.
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?
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.
ok I see, that was not obvious from the code, thanks for explaining.
What about ternary operators?
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.
Replaced ternany operators with
{error && <ErrorMessage />}
{!error && <... />}
I agree looks more readable now!
..._app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/ShareOptions/ShareModal.js
Outdated
Show resolved
Hide resolved
<Modal.Content className="share-content"> | ||
{loading && <Loader isLoading active />} | ||
{!loading && results !== undefined && ( | ||
<UserGroupAccessSearchResult |
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.
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 |
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.
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; |
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.
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?
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.
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) => { |
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.
if there are many results, could it have issues with performance?
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.
I don't think we are expecting to have more than ~10-20 results in each tab, so I think this should be ok!
..._app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/ShareOptions/ShareModal.js
Outdated
Show resolved
Hide resolved
..._app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/ShareOptions/ShareModal.js
Outdated
Show resolved
Hide resolved
..._app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/ShareOptions/ShareModal.js
Outdated
Show resolved
Hide resolved
if (entityType === this.linksType) await this.fetchLinks(callbackEndpoint, true); | ||
}; | ||
|
||
fetchUsersGroups = async (endpoint, entityType, isDataChanged) => { |
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.
general observation for this component: it has too many responsibilities, especially
- fetching different types of data,
- taking care of different tabs display
- handles updates
I think it should be split into smaller components
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.
Split the responsibilities between the components! Does it look better now?
...ssets/semantic-ui/js/invenio_app_rdm/landing_page/ShareOptions/AccessLinks/AccessDropdown.js
Outdated
Show resolved
Hide resolved
...ic-ui/js/invenio_app_rdm/landing_page/ShareOptions/AccessLinks/LinksSearchResultContainer.js
Outdated
Show resolved
Hide resolved
..._app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/ShareOptions/ShareModal.js
Outdated
Show resolved
Hide resolved
..._app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/ShareOptions/ShareModal.js
Outdated
Show resolved
Hide resolved
if (entityType === this.groupType) await this.fetchGroups(endpoint, isDataChanged); | ||
}; | ||
|
||
fetchUsers = async (endpoint, isDataChanged) => { |
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.
I am not understanding the param isDataChanged
: what is the purpose?
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.
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.
..._app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/ShareOptions/ShareModal.js
Outdated
Show resolved
Hide resolved
invenio_app_rdm/theme/assets/semantic-ui/less/invenio_app_rdm/theme/modules/modal.overrides
Show resolved
Hide resolved
invenio_app_rdm/theme/assets/semantic-ui/less/invenio_app_rdm/theme/modules/modal.overrides
Show resolved
Hide resolved
cd4747d
to
95cbc58
Compare
adbc3fb
to
e3d3aff
Compare
tests outcome (mainly UX improvements, can be implemented in a separate PR):
|
* avoid fetching data of each tab pane on opening of the modal * fetch only the data of the opened pane * add missing error handlings
e3d3aff
to
9e1e6a0
Compare
See most of the screenshots here inveniosoftware/invenio-communities#1127
Some error handlers:
On delete: