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

Add collaborators #127

Merged
merged 16 commits into from
Jan 28, 2021
Merged

Add collaborators #127

merged 16 commits into from
Jan 28, 2021

Conversation

jasalisbury
Copy link

@jasalisbury jasalisbury commented Jan 22, 2021

Description of change

Includes a few additional improvements, got bigger because I refactored some tests to hopefully make them easier to deal with in the future.

  • Collaborators join table added.
  • Collaborators hooked up on the frontend. Available collaborators depends on the report's region (hardcoded to 1 for now)
  • Activity report checks permissions
  • Added the first "policies" which can be used for authorization. Should be easier to test separated from controllers
  • Route tests that hit the DB moved to the services folder, only deal with the DB interactions
  • Route tests mock out DB and authorization calls focusing on constructing correct responses based on (mocked) calls to the DB/policies
  • Multiselect sets null values to an empty array, allowing collaborators/recipients to be "zeroed" in the report
  • Approvers are scoped to region
  • The activity report now makes all API calls up front in parallel. Should keep other components simpler and cuts down on calls to the API (they can be made once instead on every form page load)
  • Added Krys and I to seeders as Admins so we should be admins in sandbox/dev until HSES resets again. (can add others to the seeders but we were the only two who currently have accounts on sandbox, so the only two I know HSES ids)
  • Updated swagger/API docs

How to test

  1. Browse to sandbox
  2. Fill out a report, add Krys or Josh as a collaborator (If you aren't on the list I can add you, just ping me)
  3. Verify collaborators persist across reloads
  4. Send the ID of the report to someone who isn't a collaborator and verify they can't access the report

Note
I still need to update API docs/DB docs

Issue(s)

Checklist

  • Meets issue criteria
  • Code tested
  • Meets accessibility standards (WCAG 2.1 Levels A, AA)
  • Documentation updated

Includes a few additional imporvements

 * Collaborators join table added.
 * Collaborators hooked up on the frontend. Avaliable collaborators
depends on the report's region (hardcoded to 1 for now)
 * Activity report checks permissions
 * Added the first "policies" which can be used for authorization.
Should be easier to test separated from controllers
 * Route tests that hit the DB moved to the services folder, only deal
with the DB ineractions
 * Route tests mock out DB and authorization calls focusing on
constructing correct responses based on (mocked) calls to the DB/policies
 * Multiselect sets null values to an empty array, allowing
collaborators/recipients to be "zeroed" in the report
 * Approvers are scoped to region
 * The activity report now makes all API calls up front in parallel.
Should keep other components simpler and cuts down on calls to the API
(they can be made once instead on every form page load)
 * Added Krys and I to seeders as Admins so we should be admins in
sandbox/dev until HSES resets again. (can add others to the seeders but
we were the only two who currently have accounts on sandbox, so the only
two I know HSES ids)
Conflicts:
	.circleci/config.yml
	frontend/src/pages/ActivityReport/Pages/ReviewSubmit.js
	frontend/src/pages/ActivityReport/Pages/__tests__/ReviewSubmit.js
	frontend/src/pages/ActivityReport/Pages/index.js
	frontend/src/pages/ActivityReport/index.js
	src/services/activityReports.js
@jasalisbury jasalisbury marked this pull request as ready for review January 25, 2021 17:14
@dcmcand
Copy link

dcmcand commented Jan 25, 2021

Screenshot from 2021-01-25 16-19-51

When I login to the sandbox, this is what I get.

@jasalisbury
Copy link
Author

Screenshot from 2021-01-25 16-19-51

When I login to the sandbox, this is what I get.

Yeah you didn't have permissions to create reports, you should be able to load the reports page now (I also made you a sandbox admin)

Copy link
Collaborator

@dcloud dcloud left a comment

Choose a reason for hiding this comment

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

I think this looks great so far. I noticed a lot of cleanup/refactoring that makes things easier to understand, along with the improvements you were creating. Nice work!

I don't think I have a login for the sandbox yet, so I will be in touch about getting set up there.

Here's the feedback I have at this time. I saw a few minor typos; one was breaking the API docs for me. I also have feelings about using lodash (when es201x or even es5 should be able to handle most things), but I can see it is used throughout, so NBD.

frontend/src/pages/ActivityReport/index.js Outdated Show resolved Hide resolved
src/routes/activityReports/handlers.js Outdated Show resolved Hide resolved
docs/openapi/paths/index.yaml Outdated Show resolved Hide resolved
docs/openapi/paths/activity-reports/approvers.yaml Outdated Show resolved Hide resolved
docs/openapi/paths/collaborators.yaml Outdated Show resolved Hide resolved
src/policies/user.js Outdated Show resolved Hide resolved
src/services/activityReports.js Outdated Show resolved Hide resolved
@kryswisnaskas
Copy link
Collaborator

When I login to the sandbox, this is what I get.

hmm...I get the same message "Unable to load..."

}

isApprovingManager() {
return this.activityReport.approvingManagerId === this.user.id;
Copy link
Collaborator

Choose a reason for hiding this comment

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

For MVP there will only be one manager, but I wonder if designing for future expansion could be worth it at this point, e.g. include the manager in the collaborators table with a flag. That's just one way.
But, if you think this would add a lot of extra work for now, we can postpone.

Copy link
Author

Choose a reason for hiding this comment

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

That feels like something we can leave until after the MVP, especially because we aren't 100% sure how multiple managers are going to work at this point. I'd hate to start down a path now and have it turn out to be the wrong path. Should be easy to update this class once we add the ability for a report to have multiple managers.

Copy link
Collaborator

@kryswisnaskas kryswisnaskas Jan 27, 2021

Choose a reason for hiding this comment

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

Should be easy to update this class once we add the ability for a report to have multiple managers.

Once we are in prod we are going to have to deal with the data migration as well.

@jasalisbury
Copy link
Author

When I login to the sandbox, this is what I get.

hmm...I get the same message "Unable to load..."

Yeah I seem to have lost admin permissions on sandbox as well

 * Add unique indexes to Activity Recipient and collaborators join
   tables
 * Replace lodash functions in two places
 * collaborators and recipients are "upsert"ed instead of all removed
   and recreated
 * Add FIXME to comment
import _ from 'lodash';
import SCOPES from '../middleware/scopeConstants';

export default class ActivityReport {
Copy link
Collaborator

Choose a reason for hiding this comment

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

🎉

@jasalisbury
Copy link
Author

When I login to the sandbox, this is what I get.

hmm...I get the same message "Unable to load..."

Yeah I seem to have lost admin permissions on sandbox as well

Migrations weren't running properly. It is now fixed and you should be able to create reports. All previously entered reports have were deleted.

Copy link
Collaborator

@kryswisnaskas kryswisnaskas 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! 👍

Note for the future - if there is time before the MVP launch to clarify how we are going to using multiple managers on the report, it might be worth refactoring the db schema to create a many to many relationship between ar(s) and managers, to avoid potential data migration in prod.

Conflicts:
	src/routes/files/handlers.test.js
@jasalisbury jasalisbury merged commit abc9932 into main Jan 28, 2021
@jasalisbury jasalisbury deleted the js-109-add-collaborators branch January 28, 2021 15:40
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