Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

App selections should update current auth states #220

Merged
merged 20 commits into from
Dec 6, 2019

Conversation

domharrington
Copy link
Member

@domharrington domharrington commented May 31, 2019

  • Changing a selection in the Logs dropdown should update current auth states and code sample.
  • A dropdown of the user's apps/API keys should be put into the auth box and experience the same state changes as the Logs dropdown.
  • Password inputs on Basic HTTP auth are now input[type=password] inputs.

g6JHsGGj7c

🚧 Revised design

Screen Shot 2019-11-25 at 10 42 22 AM

This breaks lots of tests in index.test.jsx because now you cannot update auth
We need to come up with a way to apply changes to this object after getAuth()
is called. Maybe we need to merge changes made to the form with the oas files
@mjcuva
Copy link
Member

mjcuva commented Nov 8, 2019

Two issues with this for the next time @domharrington and I talk about this (forgetting we've done this twice now):

  • API Key isn't editable in the auth dropdown
    • We should make it editable if logged out/no api keys in jwt
    • We should make it a picker for the api key if logged in with jwt
  • Logs dropdown doesn't update api key (or variables)

@erunion erunion self-assigned this Nov 20, 2019
@erunion erunion added the type:enhancement A potential new feature to be added, or an improvement we could make label Nov 20, 2019
@erunion erunion changed the title Wired up getAuth() to pass in selected app App selections should update current auth states Nov 21, 2019
@erunion erunion added the type:bug Something isn't working label Nov 21, 2019
@@ -353,7 +356,6 @@ Doc.propTypes = {
}),
auth: PropTypes.shape({}).isRequired,
baseUrl: PropTypes.string,
changeGroup: PropTypes.func.isRequired,
Copy link
Member

Choose a reason for hiding this comment

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

Renamed this throughout so it's clearer that this is intended for an onChange event.

@@ -88,7 +88,7 @@ class Logs extends React.Component {
}

onSelect(event) {
this.changeGroup(event.target.value);
this.onGroupChange(event.target.value, event.target.options[event.target.selectedIndex].text);
Copy link
Member

Choose a reason for hiding this comment

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

Since getAuth asks for a selectedApp param, it makes more sense to push back the group name as well instead of only the group ID/api key to the explorer.

@erunion erunion marked this pull request as ready for review November 22, 2019 00:35
@erunion
Copy link
Member

erunion commented Nov 22, 2019

@domharrington @mjcuva I'm working on adding some more unit tests, but this is ready for review.

@rafegoldberg We might want to change the font color of the dropdown in the AuthBox to match the color of it in the Logs module.

@erunion
Copy link
Member

erunion commented Nov 22, 2019

With multiple securities on an operation, it kind of looks like garbage. @madisonyocum @mjcuva @rafegoldberg ideas?

Screen Shot 2019-11-22 at 9 59 06 AM

Also changing those dropdowns right now in that example updates both securities. That seems wrong.

Copy link
Member Author

@domharrington domharrington left a comment

Choose a reason for hiding this comment

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

The code for this looks sound, but I've not tested.

What does this do when there's no logged in user?

Not sure what to do about the multiple schemes thing either. I think in your example it's worse because they're named the same thing, would it be any better if they were different?

Is there value in showing both the and the dropdown? Maybe just showing the dropdown is enough, since they'd see the API key in the code sample?

Is the disabled right now when it's coming from one of these dropdown values?

packages/api-explorer/src/AuthBox.jsx Outdated Show resolved Hide resolved
{
...oas.components.securitySchemes[scheme],
_key: scheme,
selectedApp,
Copy link
Member Author

Choose a reason for hiding this comment

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

Is this needed?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, getSingle needs to know the current app so it can pick out the right key.

@@ -88,7 +88,7 @@ class Logs extends React.Component {
}

onSelect(event) {
this.changeGroup(event.target.value);
this.onGroupChange(event.target.value, event.target.options[event.target.selectedIndex].text);
Copy link
Member Author

Choose a reason for hiding this comment

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

Can the group name be inferred from the value higher up the stack? Or does it make sense to always have to pass in the pair here?

packages/api-logs/package.json Show resolved Hide resolved
@erunion
Copy link
Member

erunion commented Nov 22, 2019

Talked offline with @mjcuva about the dupe dropdown issue and we're going to play with moving the dropdown into the top right of the authbox and only show it once.

Screen Shot 2019-11-22 at 3 09 12 PM

@erunion
Copy link
Member

erunion commented Nov 25, 2019

@domharrington @rafegoldberg @mjcuva @madisonyocum This is good for review again. The design has slightly changed per our conversation last week to move the groups dropdown up into the first auth header:

69568681-eae74400-0f70-11ea-8b0f-924d4bc1670a

Functionality remains the same though, and changing a group in there will swap out the auth state in the app and update both inputs.

@rafegoldberg
Copy link
Contributor

rafegoldberg commented Nov 25, 2019

@madisonyocum how about something like this?

@erunion
Copy link
Member

erunion commented Nov 25, 2019

I really, really, really like that. The toggle on the auth scheme entry should probably only show up if there's more than one though.

@erunion
Copy link
Member

erunion commented Nov 26, 2019

@rafegoldberg @madisonyocum That dropdown isn't going to be present for logged out users, so we should take that into consideration.

erunion and others added 2 commits November 27, 2019 09:34
- restructure markup and add classes
- move in to AuthBox/ directory; add stylesheet
@rafegoldberg
Copy link
Contributor

rafegoldberg commented Dec 6, 2019

Moved the <AuthBox> component JSX in to AuthBox/index.jsx and added an AuthBox.scss for styling per my prior mockup!

Copy link
Contributor

@rafegoldberg rafegoldberg left a comment

Choose a reason for hiding this comment

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

Tested locally; e'erything runs well and looks good on my end. Only question I have is whether the group selector will/should be visible in the auth box if there's only a single project? (Couldn't quite figure out how to test this locally...) But it's nothing to hold your merge over!

@erunion
Copy link
Member

erunion commented Dec 6, 2019

@rafegoldberg We definitely shouldn't show the dropdown if they just have a single project. That looks to be the current behavior in GroupsList, just the demo site always uses two projects to test with. We should make sure the lack of a dropdown in the authbox still looks ok.

This all looks great, though on endpoints with only a single auth scheme, there's a scrollbar that shows up:

Screen Shot 2019-12-06 at 11 13 32 AM

@rafegoldberg
Copy link
Contributor

@erunion fixed the erroneous scrollbars and moved the <GroupList> in to a conditional on groups.length; this should be good to go now!

@erunion
Copy link
Member

erunion commented Dec 6, 2019

Looks good!

@erunion erunion merged commit c97ff83 into master Dec 6, 2019
@erunion erunion deleted the feature/wire-up-selected-app-to-auth branch December 6, 2019 19:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:bug Something isn't working type:enhancement A potential new feature to be added, or an improvement we could make
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants