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

user component now integrated with /api/users GET endpoint #583

Conversation

ForrestLonganecker
Copy link
Contributor

This PR now is pulling users from our database: #91

Notes:

  • Adjusted the initial users populated in the Developer database: "[email protected]" is no longer an Admin.
  • Adjusted the response object for the /api/users GET to match up with expected variable names in the front-end. changed: user_id to id and group_name to group.
    Previously I had a function that was converting the snake_case to the proper format but this solution allows us to pass the response object in directly.
  • Converted <Spinner /> component to a generic <LoadingSpinner inputString={} /> we are now able to use this loading spinner in anywhere we need to have it and pass in a string such as "Users" or "your search results".

To-Do:

  • currently I am displaying errors for this component, it would be good to isolate this logic and connect it to the redux-store so we can plug the error component in wherever we need it. I have created an issue for this: Create reusable error component  #582

Copy link
Member

@KentShikama KentShikama left a comment

Choose a reason for hiding this comment

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

Given the following set of events occur

1. Admin A opens the users page
2. Admin A switches to the search page
3. Admin B creates a new account User C
4. Admin A opens the users page

Should it show User C or not?

Edit: Ignore the above; I thought I saw a potential issue.

return (
<p className="bg-white mv4 pa4 br3 fw6 tc shadow br3">
You are not authorized to view this content, please contact system
administraitor.
Copy link
Member

Choose a reason for hiding this comment

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

administrator

render() {
return (
<p className="bg-white mv4 pa4 br3 fw6 tc shadow br3">
Something went wrong, please contact system administraitor to report
Copy link
Member

Choose a reason for hiding this comment

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

administrator

public render() {
return (
render() {
return this.props.users.userList.length > 0 ? (
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: I think the True case can be wrapped in its own function just like displayNoUsers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simple fix! I will make that change.

<NotAuthorized />
) : (
<TechnicalDifficulties />
);
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer not chaining ternary operators

@ForrestLonganecker
Copy link
Contributor Author

ForrestLonganecker commented Nov 26, 2019

@KentShikama Thank you for the review!

I realized that a non-admin user could see the userlist if:

  • Admin logs in and views userList page
  • Admin logs out
  • User logs in and navigates to userList page
  • The state is not cleared so the list is still visible

I added a CLEAR_USERS action that is now called on logout and will fix this issue.

@KentShikama
Copy link
Member

Are you referring to if the non-admin happens to use the same browser as the admin (aka they share a computer)?

@ForrestLonganecker
Copy link
Contributor Author

ForrestLonganecker commented Nov 26, 2019 via email

Copy link
Member

@KentShikama KentShikama left a comment

Choose a reason for hiding this comment

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

I would prefer if clearing was done on unmount given how each time the user goes to the users page they get a fresh set of users (between the time they swapped tabs a new user could have been created). See https://github.com/codeforpdx/recordexpungPDX/blob/master/src/frontend/src/containers/AllRecords.tsx#L20-L22 for a similar pattern.

…ungPDX into users-component/get-integration

pulled upstream changes
@ForrestLonganecker ForrestLonganecker merged commit fa42a8e into codeforpdx:master Nov 30, 2019
KentShikama pushed a commit that referenced this pull request Mar 20, 2020
* user component now integrated with /api/users GET endpoint

* changed /api/users GET test to expect updated response object

* added CLEAR_USERS action, refactored displayUsers(), displayUserList() and displayNoUsers(), fixed typo

* moved clearUsers() call to componentWillUnmount()
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.

2 participants