Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

dex 1341 - add collaboration from user page #464

Merged
merged 12 commits into from
Oct 6, 2022

Conversation

Emily-Ke
Copy link
Contributor

@Emily-Ke Emily-Ke commented Oct 5, 2022

Pull request checklist:

  • Features and bugfixes should be PRed into the develop branch, not main
  • All text is internationalized
  • There are no linter errors
  • New features support all states (loading, error, etc)

Which JIRA ticket(s) and/or GitHub issues does this PR address?

  • DEX-1341: Make it easier for a researcher to find another user and issue a collaboration invite

Pull Request Overview

  • Enables a user to find and add a collaborator from the user's home page. A user manager can also add a collaborator for a given user from that user's page.
  • Fixes the no-unstable-nested-components lint error in CollaborationsCard

Review notes

  • I'm not sure if adding the prop viewerIsUserManager to UserProfile is the right choice. It seemed to simplify some of the logic, but at the expense of a more complicated API.
  • There are a few places where I backed out of some of our abstractions, like the React Query mutation and the CollaborationCards. I think that these are easier to work with for now.
user view user manager view
standard-view user-manager-view

error-add

@Emily-Ke Emily-Ke marked this pull request as ready for review October 5, 2022 18:26
@Emily-Ke Emily-Ke requested a review from Atticus29 October 5, 2022 18:26
@Emily-Ke Emily-Ke mentioned this pull request Oct 5, 2022
4 tasks
Copy link
Contributor

@Atticus29 Atticus29 left a comment

Choose a reason for hiding this comment

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

Approved with suggestions and questions.

src/components/cards/MyCollaborationsCard.jsx Show resolved Hide resolved
src/utils/axiosUtils.js Outdated Show resolved Hide resolved
@@ -0,0 +1,31 @@
import { useIntl } from 'react-intl';
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like I have been told not to import react libraries into files that aren't react components. Did the linter yell about this?

I think the pattern elsewhere might involve passing intl as an argument into the (in this case) useHandleRequestError method.

Copy link
Contributor Author

@Emily-Ke Emily-Ke Oct 5, 2022

Choose a reason for hiding this comment

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

I feel like I have been told not to import react libraries into files that aren't react components. Did the linter yell about this?

No, because this isn't a vanilla utility function. It is a custom hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if it makes more sense as a custom hook or a utility function, so I just left it as a hook for now.

src/components/cards/MyCollaborationsCard.jsx Show resolved Hide resolved
async function mutationFn({ userGuid: secondUserGuid }) {
try {
const result = await axios.request({
url: prefixApiUrl('/collaborations/'),
Copy link
Contributor

Choose a reason for hiding this comment

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

this method name makes it sound like it's gonna turn whatever input into a prefixApiUrl... perhaps rename to appendToPrefixUrl or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to withApiPrefix in b8110f0. Hopefully that name makes more sense.

setSelectedUserGuid(null);
}

function handleSubmitCollaborator() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like maybe an unnecessary wrapper method? Perhaps pass an anonymous () => addCollaboration(
{ userGuid: selectedUserGuid },
{ onSuccess: handleCloseDialog },
)

To the button's onClick prop instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved in 2815915

}}
>
{users && (
<form
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious why a normal form element here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would you use instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know. I see FormControl more often in the code base. Mostly I was hoping to learn whether it was a conscious choice to not use FormControl and why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FormControls are wrappers that provide functionality for inputs. The TextField that I am using in this form "is a complete form control". The form could have multiple FormControls, one for each input. I did intentionally use a form because I think it is semantically correct and because it provides some nice behavior by default.
https://v4.mui.com/components/text-fields/#textfield

I picked TextField because that is what was used in IndividualSelector.

src/models/users/useGetUsers.js Show resolved Hide resolved
@Emily-Ke Emily-Ke merged commit 93c9bf0 into develop Oct 6, 2022
@Emily-Ke Emily-Ke deleted the dex-1341-add-collaboration-from-user-page branch October 6, 2022 00:39
@Atticus29 Atticus29 mentioned this pull request Oct 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants