-
Notifications
You must be signed in to change notification settings - Fork 7
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
Save collaborators to report #272
Conversation
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
Conflicts: src/models/activityReport.js src/routes/apiDirectory.js
Co-authored-by: Daniel Cloud <[email protected]>
Co-authored-by: Daniel Cloud <[email protected]>
…Start-TTADP into js-109-add-collaborators
* 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
Conflicts: src/routes/files/handlers.test.js
Add collaborators
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.
Awesome work. I really like the policies classes.
docs/openapi/index.yaml
Outdated
@@ -107,7 +107,7 @@ components: | |||
description: The type of the activity, Training or Technical Assistance (or both) | |||
items: | |||
type: string | |||
approvingUser: | |||
selectableUser: | |||
type: object | |||
description: Users with permission to approve reports |
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 description should be updated as well, now that this could be a user being selected for any purpose
@@ -3,8 +3,8 @@ import { get, put, post } from './index'; | |||
|
|||
const activityReportUrl = join('/', 'api', 'activity-reports'); | |||
|
|||
export const fetchApprovers = async () => { | |||
const res = await get(join(activityReportUrl, 'approvers')); | |||
export const fetchApprovers = async (region) => { |
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.
For consistency's sake, it looks like we have a couple of getXXX
methods in this file, and then one fetchApprovers
. Can we standardize on getThing
?
@@ -12,7 +12,6 @@ import { | |||
nonGranteeParticipants, | |||
granteeParticipants, | |||
reasons, | |||
otherUsers, |
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.
Can we remove otherUsers
from the constants file now? I think the otherUsers
at https://github.com/HHS/Head-Start-TTADP/pull/272/files/abc99324a9447d29276301c3be5a565a9f2b23bc#diff-2b62e868dda42d114882e1650d272b9d3d5ad973c7f3ac44337acd69152a5127R37 is also now obsolete
// The key in the join table that points to the model defined in this file | ||
foreignKey: 'activityReportId', | ||
// The key in the join table that points to the "target" of the belongs to many (Users in | ||
// this case) |
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.
A+ comment to keep the two keys straight.
], | ||
|
||
it('returns the report', async () => { | ||
ActivityReport.prototype.canUpdate = jest.fn().mockReturnValue(true); |
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 is some of my javascript ignorance showing, but, how does this implementation impact the rest of the tests? Does this pollute everything? Or is it somehow scoped to this test?
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.
That is a good question, I'll look into it.
Stole the pattern from a great ruby library https://github.com/varvet/pundit |
Probably why I like it, I use pundit on all of my ruby apps. |
* Properly mock classes in activity report tests * Update description of API doc "selectableUser" * Rename 'fetchApprovers' to 'getApprovers' * Remove 'otherUsers' from constants
Address PR feedback
Lock user access
commit d1c5786 Merge: 44eeeb8 059425c Author: Ryan Ahearn <[email protected]> Date: Tue Feb 9 17:10:20 2021 -0500 Merge pull request #157 from HHS/user-last-login Allow filtering users by last login and access permissions commit 059425c Author: Ryan Ahearn <[email protected]> Date: Tue Feb 9 15:25:09 2021 -0500 Make eslint happy commit 09e906f Author: Ryan Ahearn <[email protected]> Date: Tue Feb 9 14:46:50 2021 -0500 Refactor user filtering to match access control SOP rules directly commit facfee4 Author: Ryan Ahearn <[email protected]> Date: Tue Feb 9 14:03:29 2021 -0500 Allow filtering by only showing users who do have SITE_ACCESS commit b5b93f0 Author: Ryan Ahearn <[email protected]> Date: Tue Feb 9 13:40:44 2021 -0500 Allow filtering by last login > 60 or 180 days ago Options to match process here: https://github.com/HHS/Head-Start-TTADP/wiki/Access-Control-&-Account-Management-SOP#account-review-frequency-and-process commit 1d08788 Author: Ryan Ahearn <[email protected]> Date: Tue Feb 9 12:18:39 2021 -0500 Display lastLogin on admin user details commit 31883dd Author: Ryan Ahearn <[email protected]> Date: Tue Feb 9 11:12:00 2021 -0500 Add lastLogin to user api response commit 60bbefd Author: Ryan Ahearn <[email protected]> Date: Tue Feb 9 10:20:03 2021 -0500 Add lastLogin value to user model & update on login commit 1a2dd2c Author: Ryan Ahearn <[email protected]> Date: Tue Feb 9 09:36:09 2021 -0500 Prevent validation issues if HSES email updates commit 7554928 Merge: 875f5e2 44eeeb8 Author: Ryan Ahearn <[email protected]> Date: Tue Feb 9 14:15:51 2021 -0500 Merge pull request #286 from adhocteam/main Fix cucumber test on CI commit 875f5e2 Merge: 4bd8566 9f5bb95 Author: Ryan Ahearn <[email protected]> Date: Fri Feb 5 16:31:48 2021 -0500 Merge pull request #284 from adhocteam/main Filter locked users from admin list commit 4bd8566 Merge: 17f9d7f f327246 Author: Ryan Ahearn <[email protected]> Date: Fri Feb 5 16:05:29 2021 -0500 Merge pull request #281 from adhocteam/main Case insensitive admin search, testing updates and manager setting of notes and report status commit 17f9d7f Merge: 16d54e2 8e5d3ef Author: Ryan Ahearn <[email protected]> Date: Wed Feb 3 16:09:21 2021 -0500 Merge pull request #279 from adhocteam/main add frontend for file upload commit 16d54e2 Merge: 541640a e27e7df Author: Ryan Ahearn <[email protected]> Date: Tue Feb 2 15:33:25 2021 -0500 Merge pull request #275 from adhocteam/main Add goal component to frontend commit 541640a Merge: 790ca05 4c3a436 Author: Ryan Ahearn <[email protected]> Date: Fri Jan 29 15:47:13 2021 -0500 Merge pull request #272 from adhocteam/main Save collaborators to report commit 790ca05 Merge: 4948bd3 3cff2f4 Author: Ryan Ahearn <[email protected]> Date: Wed Jan 27 12:04:04 2021 -0500 Merge pull request #267 from adhocteam/main Add file upload api
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.
How to test
Note
I still need to update API docs/DB docs
Issue(s)
Checklist