Skip to content

feat: add auth styling and 'extra actions' menu #3

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 18 commits into from
Feb 23, 2024

Conversation

Parkreiner
Copy link
Member

@Parkreiner Parkreiner commented Feb 21, 2024

Closes #1. First major commit for the new repo.

Screen.Recording.2024-02-20.at.7.35.50.PM.mov

Changes made

  • Adds a `CoderAuthWrapper component
  • Removes the RefreshButton component in favor of an ExtraActionsButton component. Moves the old refresh functionality and the new eject token functionality under that menu
  • Updates parts of the CoderAuth API to compute the initializing status more accurately

Notes

  • Renamed logout to ejectToken to make it more clear that calling it does not log the user out of the whole Backstage deployment

@Parkreiner Parkreiner self-assigned this Feb 21, 2024
@Kira-Pilot
Copy link
Member

Could we add an onKeyDown to our SearchBox component so that when I hit Enter, the search is initiated? Right now, the kebab menu opens instead - maybe because it's the first actionable element?

@Kira-Pilot
Copy link
Member

I think the VisuallyHidden component's forceShow state might have a unexpected UI for anyone developing on a MacOS. I'm stuck in the below state when I open devtools in Chrome, I guess because Alt maps to Option?
Maybe this was intended but the result is a little visually jarring.
Screenshot 2024-02-21 at 3 52 49 PM

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

If my deployment is down I get an infinite loop of requests to /me, does anyone else see that?

},
}));

function CoderAuthCard({ children }: PropsWithChildren<unknown>) {
Copy link
Member

Choose a reason for hiding this comment

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

The auth card is looking slick!

<div>
<CoderLogo className={styles.coderLogo} />
<p>
Unable to verify token authenticity. Please check your internet
Copy link
Member

Choose a reason for hiding this comment

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

I like this! Having the user choose whether to discard the token or not makes a lot of sense.

@Kira-Pilot
Copy link
Member

If my deployment is down I get an infinite loop of requests to /me, does anyone else see that?

@code-asher I do not but I'm testing against dev.coder.com. Is there an easy way to repo?

@Parkreiner
Copy link
Member Author

Parkreiner commented Feb 21, 2024

I think the VisuallyHidden component's forceShow state might have a unexpected UI for anyone developing on a MacOS. I'm stuck in the below state when I open devtools in Chrome, I guess because Alt maps to Option? Maybe this was intended but the result is a little visually jarring.

@Kira-Pilot So, it is a little jarring (especially since some of the visually-hidden labels are a bit on the long side), but it is intentional. It gives you a quick way of scanning which icons do and don't have accessible text associated with them (which is normally impossible to eyeball, since the elements are supposed to be invisible)

Unless you mean that just opening the devtools at all does that, in which case, that definitely isn't intentional

@Kira-Pilot
Copy link
Member

Unless you mean that just opening the devtools at all does that, in which case, that definitely isn't intentional

This is what I mean :)
I like the idea overall though!

@Parkreiner
Copy link
Member Author

Parkreiner commented Feb 21, 2024

Could we add an onKeyDown to our SearchBox component so that when I hit Enter, the search is initiated? Right now, the kebab menu opens instead - maybe because it's the first actionable element?

That's definitely a bug. Off the top of my head, I'm not sure how it's happening – even when the event from the input bubbles up, it should miss the button for opening the menu, but I'll get this fixed

@Kira-Pilot
Copy link
Member

Very small details:
Screenshot 2024-02-21 at 4 07 45 PM

Can we add some padding to this helper text which gets smooshed on smaller screens?
🤔 is 'searchbar' one word? I feel like I usually see a space but I might be missing something.
Can we use a cursor: pointer style on the clear search icon?

@Kira-Pilot
Copy link
Member

Looking lovely! It's really coming together! 🚀

@code-asher
Copy link
Member

code-asher commented Feb 21, 2024

@code-asher I do not but I'm testing against dev.coder.com. Is there an easy way to repo?

What I do is edit app-config.yaml and change the proxy endpoint to https://localhost:4000 then restart yarn dev. Any random endpoint will work though, as long as there is nothing actually listening there so that the requests fail.

@Kira-Pilot
Copy link
Member

What I do is edit app-config.yaml and change the proxy endpoint to https://localhost:4000 then restart yarn dev. Any random endpoint will work though, as long as there is nothing actually listening there so that the requests fail.

Oh yeahhhh i see that

@Parkreiner
Copy link
Member Author

@Kira-Pilot Almost all your points of feedback should be addressed. The only one that should be left is the VisuallyHidden toggle. I've always been opening it up with F12, so I didn't realize there were shortcuts involving Alt/Option. Not sure if it'll make it in this PR, but I will see if there might be a better way to customize which key triggers things

@code-asher And the last thing from your feedback should be the infinite loop when a deployment's down. Looking at that right now

@Parkreiner
Copy link
Member Author

Parkreiner commented Feb 22, 2024

One last set of additions I had to add to the PR: the majority of the tests had to be updated to make sure they don't flake out.

Turns out, all components that you directly wire up to a Backstage plugin and export through it have a lot more metadata attached to them. And depending on the component or the type of functionality you're exposing, you might need to bring in a whole test app to provide all the dependencies. But it's a toss-up, and components don't always fail consistently

Took me a bit of time to track down the issue, but all the test helpers have been updated to use wrapInTestApp, so we shouldn't need to worry about this again. Only change is that the functions will need to be async when they weren't before.

We weren't running into this issue with the previous repo because not all the components were going through this process yet. This is 100% on me for not making sure the exports weren't fully squared away and were going through the plugin

Comment on lines +234 to +252
wrapInTestApp(
<TestApiProvider
apis={[
[errorApiRef, mockErrorApi],
[scmIntegrationsApiRef, mockSourceControl],
[configApiRef, mockConfigApi],
]}
>
<EntityProvider entity={mockEntity}>{children}</EntityProvider>
</CoderProviderWithMockAuth>
</TestApiProvider>
),
<CoderProviderWithMockAuth
appConfig={mockAppConfig}
queryClient={mockQueryClient}
authStatus={authStatus}
>
<EntityProvider entity={mockEntity}>
<>{children}</>
</EntityProvider>
</CoderProviderWithMockAuth>
</TestApiProvider>,
),
Copy link
Member Author

Choose a reason for hiding this comment

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

Code is almost exactly the same – only change is that now it's wrapped inside wrapInTestApp

}

isRefetchingTokenQuery = true;
await queryClient.refetchQueries({ queryKey: authQueryKey });
Copy link
Member Author

@Parkreiner Parkreiner Feb 23, 2024

Choose a reason for hiding this comment

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

One important detail: even though refetchQueries is an async function, it never throws. The promise only indicates when a query is done, even if it's not successful, so there's no need for a try/catch

Copy link
Member

@Kira-Pilot Kira-Pilot left a comment

Choose a reason for hiding this comment

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

LGTM! Nice job figuring out the test flakes

@Parkreiner Parkreiner merged commit f2b82a1 into main Feb 23, 2024
@Parkreiner Parkreiner deleted the mes/workspaces-list-8 branch February 23, 2024 23:28
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.

Add UI elements for Coder auth code (tokens/oauth)
3 participants