Skip to content

Add org selection dropdown to org auth token button #7716

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

Merged
merged 10 commits into from
Aug 31, 2023

Conversation

lforst
Copy link
Contributor

@lforst lforst commented Aug 31, 2023

Added a dropdown to select an organization for the org auth token button. This should help make it more clear for which org a token is gonna be generated. Especially on pages where we don't have ___ORG_SLUG___ or ___PROJECT_SLUG___ magic strings.

Looks like this:

Screenshot 2023-08-31 at 14 29 26

@vercel
Copy link

vercel bot commented Aug 31, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 31, 2023 2:41pm

@mydea
Copy link
Member

mydea commented Aug 31, 2023

Since this is sadly hard to test on the preview 😬 Just to clarify

  • When there is only one org, we do not show the dropdown at all
  • When there is more than one org, we show the same select UI as in the org/project select thingy, but only show the org (not the project) in there to select

I like it!

@lforst
Copy link
Contributor Author

lforst commented Aug 31, 2023

  • When there is only one org, we do not show the dropdown at all

Correct! See

if (orgs.length === 1) {
createToken(orgs[0]);
} else {
setIsOpen(!isOpen);
}

  • When there is more than one org, we show the same select UI as in the org/project select thingy, but only show the org (not the project) in there to select

Also correct! (See screenshot in PR description)

@mydea

@mydea
Copy link
Member

mydea commented Aug 31, 2023

Nice, that's what I figured but just to be extra clear :D Maybe @ArthurKnaus can also give it a review from a React perspective. From an outcome-perspective, I think this is great and will make this much more flexible to be used 🎉

@lforst lforst requested a review from ArthurKnaus August 31, 2023 12:56
Copy link
Member

@ArthurKnaus ArthurKnaus left a comment

Choose a reason for hiding this comment

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

Nice feature, love it! 🎉
Mostly nitpicking from my side:

Comment on lines 110 to 113
| {status: 'none'}
| {status: 'loading'}
| {status: 'success'; token: string}
| {status: 'error'}
Copy link
Member

Choose a reason for hiding this comment

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

nit: I would probably define the type TokenState outside the component to keep the component cleaner 🤷
Same goes for the popper options.

const [isOpen, setIsOpen] = useState(false);
const [referenceEl, setReferenceEl] = useState<HTMLSpanElement>(null);
const [dropdownEl, setDropdownEl] = useState<HTMLElement>(null);
const {codeKeywords} = useContext(CodeContext);
Copy link
Member

Choose a reason for hiding this comment

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

nit: I would move the context subscription to the first line then it is easier to spot.
(as it is a dependency that component has)

codeKeywords?.PROJECT?.forEach(projectKeyword => {
orgSet.add(projectKeyword.ORG_SLUG);
});
const orgs = [...orgSet];
Copy link
Member

Choose a reason for hiding this comment

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

So it is clear further down the component that those are the slugs and not whole objects.

Suggested change
const orgs = [...orgSet];
const orgSlugs = [...orgSet];

@lforst lforst merged commit ed088bb into master Aug 31, 2023
@lforst lforst deleted the lforst-org-selector-org-auth-token-button branch August 31, 2023 14:42
@github-actions github-actions bot locked and limited conversation to collaborators Sep 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants