Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Fix invite flow depending on permissions #1182

Merged
merged 4 commits into from
Aug 3, 2017
Merged

Conversation

jcscottiii
Copy link
Contributor

@jcscottiii jcscottiii commented Aug 3, 2017

Before this PR:

  • The help message for asking people to invite users still said that you can only invite existing org users via the CLI. This was no longer the case when the UserSelector was introduced. So it needed to be updated.
  • An org manager could not see the UsersSelector. So they couldn't invite existing org users to the space. So we need to allow org managers to see the selector too.
    image
  • In the case when the user was not an org manager nor a space manager inside a space, they saw two panels with similar info. It was confusing. So let's reduce that to one (yes similar screenshot to the point above that show the same thing).
    image
  • when a space manager was inside their space, they saw the old message saying they could not invite space users and instead needed to use the CLI. Let's get rid of that.
    image

After this PR

Help Message for a user has been split into three cases

  1. When on the org page without org manager permissions
    image

  2. When on the space page as an space manager
    image

  3. When on the space space not as a space manager
    (I didn't bother to go into the difference between existing org users vs new org users because that might be confusing to a non-space manager/ non-org-manager user.)
    image

(The cases when the user is an org manager on either space or org page, there's no help text to ask someone for help or to do things via the CLI)

Org Managers can invite existing org users to space

(This was because the space page didn't load the org roles)
image

The first commit is the tests adds coverage for the desired behavior mentioned above (CI will fail)
The second commit fixes the code to match the behavior.
(A third commit may be required to fix any functional tests + comments from reviewers)

James C. Scott added 2 commits August 3, 2017 09:49
Goes into more detail on what should happen on the org page and the
space page.
entity is either space or org
also make the org roles load on the space page
@jcscottiii
Copy link
Contributor Author

@brittag this addresses number one of your comments here https://favro.com/card/1e11108a2da81e3bd7153a7a/18F-6974

@rememberlenny
Copy link
Contributor

This is really great.

rememberlenny
rememberlenny previously approved these changes Aug 3, 2017
// existing org users but not new ones.
if (this.currentUserIsSpaceManager) {
return (
<PanelDocumentation>
Copy link
Contributor

Choose a reason for hiding this comment

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

In the future, I can imagine there only needing to be one return statement. All the other content can be compiled as a raw variable.

Copy link
Contributor Author

@jcscottiii jcscottiii Aug 3, 2017

Choose a reason for hiding this comment

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

i agree but we need to first clean up this decision tree of branches otherwise it could get confusing and inefficient assigning / reassigning variables.

el-mapache
el-mapache previously approved these changes Aug 3, 2017
Copy link
Contributor

@el-mapache el-mapache left a comment

Choose a reason for hiding this comment

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

This all looks good. I'm not a huge fan of comments describing what the code does, since they require additional maintenance and are a bit more noisy than a well-named method. But its not a deal breaker or anything 😄

@brittag
Copy link
Contributor

brittag commented Aug 3, 2017

Cool! We should be consistent about capitalizing Org Manager and Space Manager throughout the copy (see https://github.com/18F/cg-product/blob/master/ContentGuide.md for list of consistent capitalization/spacing/etc. to use for this kind of thing).

@jcscottiii jcscottiii dismissed stale reviews from el-mapache and rememberlenny via 4539f75 August 3, 2017 16:30
@@ -24,6 +24,14 @@ const ORG_MANAGER = 'org_manager';
const SPACE_MANAGER = 'space_manager';
const ORG_ENTITY = 'organization';
const SPACE_ENTITY = 'space';
const ORG_INVITE_HELP = 'Only an Org Manager can new invite users to this ' +
Copy link
Contributor

Choose a reason for hiding this comment

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

Good move. We might also want to consider moving all strings into a separate file that gets imported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed. there's a constants.js file too we should probably move things there eventually but should make we group them accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

@rememberlenny I actually have a ticket somewhere in the backlog to start rounding up strings and splitting them into constant files! 😄

@@ -24,7 +24,14 @@ const ORG_MANAGER = 'org_manager';
const SPACE_MANAGER = 'space_manager';
const ORG_ENTITY = 'organization';
const SPACE_ENTITY = 'space';
const cfCliLink = 'https://docs.cloudfoundry.org/adminguide/cli-user-management.html#space-roles';
const ORG_INVITE_HELP = 'Only an Org Manager can new invite users to this ' +
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 these long strings aren't being done with dedent and template strings? I can't remember it if there is and wanted to learn for other projects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there was this commit that scarred me after it took a while finding the problem lol 77a78f3

Copy link
Contributor

Choose a reason for hiding this comment

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

In some cases template strings introduce unnecessary spaces, and will fail tests if the strings aren't formatted identically.

If the strings are all moved into constant files, the issue should go away?

@jcscottiii jcscottiii merged commit 8e34923 into master Aug 3, 2017
@jcscottiii jcscottiii deleted the js-fix-org-perms branch August 3, 2017 17:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants