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

[ENG-6669] Institutional Access project Request Modal #2433

Conversation

Johnetordoff
Copy link
Collaborator

@Johnetordoff Johnetordoff commented Dec 17, 2024

⚠️ Needs feature/instituional_access branch and migrations to fully work.

  • Ticket: [https://openscience.atlassian.net/browse/ENG-6669]
  • Feature flag: n/a

https://openscience.atlassian.net/browse/ENG-6669

Purpose

Allows institutional admins to request access to projects from the institutional dashboard projects tab. Also allows them to message thier institutional users.

Summary of Changes

  • add node-request model
  • add node-request adapter
  • add two tabbed model with Send Message and Request Access tabs
  • add css for style
  • standardize casing and verbage for BccSender and MessageRecipent

Screenshot(s)

Request access disabled behavior

Screen.Recording.2024-12-17.at.10.06.33.AM.mov

Side Effects

QA Notes

I used mirage to simulate a SHARE locally here's a gist with all the unstaged files I needed to run this code:
https://gist.github.com/Johnetordoff/d32d8b6772508d7130e88d154fcd4fd7

@Johnetordoff Johnetordoff force-pushed the institutional-access-project-request-modal branch from fa41842 to e80b7f9 Compare December 17, 2024 20:54
@Johnetordoff Johnetordoff force-pushed the institutional-access-project-request-modal branch from e80b7f9 to 5a7fe94 Compare December 18, 2024 14:25
@Johnetordoff Johnetordoff changed the title [ENG-6669] Institutional Access project Request Modal [ENG-6669][WIP] Institutional Access project Request Modal Dec 18, 2024
John Tordoff and others added 13 commits December 18, 2024 09:52
…terForOpenScience/ember-osf-web into institutional-access-project-request-modal

* 'feature/institutional-access' of https://github.com/CenterForOpenScience/ember-osf-web:
  use proper Ember input tags, remove extra close modal command
  make message types an enum
  update language and fix modal closing bug.
  update to fit Product language and styling
  add checkboxes for reply-to and ccing
  Add type annotations for belongs to
  update text area for Ember type area
  update sendMessage to task
  fix label for message box
  add aira-label.
  fix en-us typo
  Add user messaging modal to user's tab on institutional dashboard
* [ENG-6823] Explicitly list columns for SHARE download (CenterForOpenScience#2450)

-   Ticket: [ENG-6823]
-   Feature flag: n/a

## Purpose
- Tell SHARE what information to download when downloading institutional dashboard data

## Summary of Changes
- Add a new `propertyPathKey` property to the object-list columns
 - this is used to tell SHARE the format of each column
- Remove `sortKey` property from column, and replace it with `isSortable` boolean property since `sortKey` is the same as `propertyPathKey`

* Use proper key for DOI field download (CenterForOpenScience#2455)
Update request params for SHARE download
* [ENG-6823] Explicitly list columns for SHARE download (CenterForOpenScience#2450)

-   Ticket: [ENG-6823]
-   Feature flag: n/a

## Purpose
- Tell SHARE what information to download when downloading institutional dashboard data

## Summary of Changes
- Add a new `propertyPathKey` property to the object-list columns
 - this is used to tell SHARE the format of each column
- Remove `sortKey` property from column, and replace it with `isSortable` boolean property since `sortKey` is the same as `propertyPathKey`

* Use proper key for DOI field download (CenterForOpenScience#2455)
…er-osf-web into institutional-access-project-request-modal

* 'develop' of https://github.com/CenterForOpenScience/ember-osf-web:
  Bump version no. Add CHANGELOG.
  Feature/share download integration (CenterForOpenScience#2457)
…er-osf-web into institutional-access-project-request-modal

* 'develop' of https://github.com/CenterForOpenScience/ember-osf-web:
  Update CHANGELOG, bump version
  Fix funder column propertyPathKey
  Bump version no. Add CHANGELOG.
  Feature/share download integration (CenterForOpenScience#2457)
@Johnetordoff Johnetordoff force-pushed the institutional-access-project-request-modal branch from 524eef0 to 16a4476 Compare January 7, 2025 19:39
@Johnetordoff Johnetordoff marked this pull request as ready for review January 7, 2025 19:51
@Johnetordoff Johnetordoff force-pushed the institutional-access-project-request-modal branch from 16a4476 to 4057df3 Compare January 7, 2025 20:20
@Johnetordoff Johnetordoff changed the title [ENG-6669][WIP] Institutional Access project Request Modal [ENG-6669] Institutional Access project Request Modal Jan 7, 2025
Copy link
Contributor

@futa-ikeda futa-ikeda left a comment

Choose a reason for hiding this comment

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

Looks good over all! Just some minor things here and there

app/adapters/node-request.ts Outdated Show resolved Hide resolved
handleBackToSendMessage() {
this.activeTab = 'send-message';
this.showSendMessagePrompt = false;
setTimeout(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why we have a setTimeout here? I'd like to avoid any unneeded timeouts if possible

Copy link
Collaborator Author

@Johnetordoff Johnetordoff Jan 9, 2025

Choose a reason for hiding this comment

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

Yes, I'll leave a comment here, I clarified this but only later on line 243, and not very well. The reason for the timeout is that ember bans having two dialogue modals open at the same time and the modal closing animation happens too slowly, so just

modal1.close()
modal2.open()

opens modal2 before the modal1 close animation is complete. Causing the framework to produce an error because there are technically two open modals. Product wanted a modal on this, because the toast message is not enough.

Comment on lines 237 to 259
} catch (error) {
const errorDetail = error?.errors?.[0]?.detail.user || error?.errors?.[0]?.detail || '';
const errorCode = parseInt(error?.errors?.[0]?.status, 10);

if (errorCode === 400 && errorDetail.includes('does not have Access Requests enabled')) {
setTimeout(() => {
this.showSendMessagePrompt = true; // Timeout to allow the modal to exit
}, 200);
} else if ([409, 400, 403].includes(errorCode)) {
// Handle specific errors
this.toast.error(errorDetail);
} else if (errorDetail.includes('Request was throttled')) {
this.toast.error(errorDetail);
} else if (errorDetail === 'You cannot request access to a node you contribute to.') {
this.toast.error(errorDetail);
} else {
this.toast.error(
this.intl.t('institutions.dashboard.object-list.request-project-message-modal.message_sent_failed'),
);
}
} finally {
this.projectRequestModalShown = false; // Close the main modal
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like there's some redundant conditions here in this catch block as most of these seem to just result in the same toast message. Some of the conditions may be a bit fragile as well if they are doing a String.includes
and if the language returned from the API changes, these could break as well. I would recommend using getApiErrorMessage(error) and this should just find the appropriate error message from the API. Then at the end, you could just call this.toast.error(getApiErrorMessage(error), someOptionalToastTitle)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes this is because there isn't standardization of error messages, so some http response codes are in the payload and some are simply not there. the 429s and some 409s are not standard, however looking at this now and I think I can improve, so that it reads the response header instead of the payload.

Comment on lines +242 to +244
setTimeout(() => {
this.showSendMessagePrompt = true; // Timeout to allow the modal to exit
}, 200);
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to a comment above, I would avoid using setTimeout to set page states if possible. In this case, I think you can just add this bit of logic in to the finally block like:

} finally {
  this.projectRequestModalShown = false; // Close the main modal
  if (relevantCondition) {
     this.showSendMessagePrompt = true;
  }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As mentioned in the comment above this actual will temporarily cause where both modals are open simultaneously.

Copy link
Contributor

Choose a reason for hiding this comment

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

We typically discourage the use of !important in css files, as these could lead to weird one-off styles. If you can achieve the same styles without the !important (which at first glance, I don't see anything that needs it), that would be appreciated. If it is needed, I usually leave a little comment to indicate what it is overriding or why it's needed

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 keep having issues with Ember "Uppercase" component's css, especially <Button> button's need !important to override the no border rule, because (I believe) buttons had an accessibility requirement to have boarders at some point. I'll try to fix it, but I'll leave a long comment if I can't fix it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, on this CSS file, there's a couple "mystery colors" floating around. We typically try to use color variables like $color-border-gray instead of say #ddd. You might find colors that match in app/styles/_variables.scss, so I would encourage the use of the color variables in there

app/models/node-request.ts Outdated Show resolved Hide resolved
translations/en-us.yml Outdated Show resolved Hide resolved
translations/en-us.yml Outdated Show resolved Hide resolved
John Tordoff added 4 commits January 9, 2025 07:37
…github.com/CenterForOpenScience/ember-osf-web into institutional-access-project-request-modal

* 'institutional-access-project-request-modal' of https://github.com/CenterForOpenScience/ember-osf-web:
  integrations fixes and refactors
  Update CHANGELOG, bump version
  Fix funder column propertyPathKey
  Bump version no. Add CHANGELOG.
  Feature/share download integration (CenterForOpenScience#2457)
  Bump version no. Add CHANGELOG.
  Feature/share download integration (CenterForOpenScience#2457)
  add Project request modal with user messaging tab to the institutional dashboard

# Conflicts:
#	app/institutions/dashboard/-components/object-list/component.ts
#	app/institutions/dashboard/-components/object-list/template.hbs
#	app/models/node-request.ts
Copy link
Contributor

@futa-ikeda futa-ikeda left a comment

Choose a reason for hiding this comment

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

Just one translation key that I noticed. Looks good otherwise

translations/en-us.yml Outdated Show resolved Hide resolved
@Johnetordoff Johnetordoff force-pushed the institutional-access-project-request-modal branch from bee035c to 9a3e056 Compare January 10, 2025 20:50
Copy link
Contributor

@futa-ikeda futa-ikeda left a comment

Choose a reason for hiding this comment

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

🐍

@Johnetordoff Johnetordoff merged commit 497b301 into CenterForOpenScience:feature/institutional-access Jan 10, 2025
9 checks passed
@futa-ikeda futa-ikeda added this to the 25.02.0 milestone Jan 22, 2025
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.

4 participants