-
Notifications
You must be signed in to change notification settings - Fork 15
Shenanigans required for serving console from nexus #532
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
Changes from all commits
8c50a74
7b0f5f8
b6f271d
c6833fd
5be70d7
a6a958c
8fb05c9
634a71f
9d717b9
8b35439
df66e4d
e2f6434
f0d5161
bd616ab
2908194
2053110
248a946
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import React from 'react' | ||
| import { useNavigate } from 'react-router' | ||
|
|
||
| import { useApiMutation } from '@oxide/api' | ||
| import { Button, Warning12Icon, Success16Icon } from '@oxide/ui' | ||
| import { useToast } from '../hooks' | ||
|
|
||
| /** | ||
| * Placeholder login page for demo purposes. | ||
| * | ||
| * The demo login form is only in the console bundle for the convenience of | ||
| * using existing tooling and using the generated API client. In the real rack, | ||
| * login will go through the customer's IdP; no form controlled by us will be | ||
| * involved. If Nexus *does* end up serving a login form, e.g., for use by | ||
| * admins before the IdP is set up, that will be a separate bundle with minimal | ||
| * JS (ideally so minimal we could inline it in the HTML response) and it would | ||
| * not use the generated API client at all. It could even use an HTML form POST. | ||
| * | ||
| * Login and logout endpoints are only a temporary addition to the OpenAPI spec. | ||
| */ | ||
| export default function LoginPage() { | ||
| const navigate = useNavigate() | ||
| const addToast = useToast() | ||
| const loginPost = useApiMutation('spoofLogin', { | ||
| onSuccess: () => { | ||
| addToast({ | ||
| title: 'Logged in', | ||
| icon: <Success16Icon />, | ||
| timeout: 4000, | ||
| }) | ||
| navigate('/') | ||
| }, | ||
| onError: () => { | ||
| addToast({ | ||
| title: 'Bad credentials', | ||
| icon: <Warning12Icon />, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd definitely like to update the icon apis a bit. This was the most expedient implementation, but eventually I'd like to at least have |
||
| variant: 'error', | ||
| timeout: 4000, | ||
| }) | ||
| }, | ||
| }) | ||
|
|
||
| const logout = useApiMutation('logout', { | ||
| onSuccess: () => { | ||
| addToast({ | ||
| title: 'Logged out', | ||
| icon: <Success16Icon />, | ||
| timeout: 4000, | ||
| }) | ||
| }, | ||
| }) | ||
| return ( | ||
| <div className="w-full justify-center flex"> | ||
| <div className="my-48 w-96 space-y-4"> | ||
| <h3 className="text-display-xl mb-2 text-center">Log in as</h3> | ||
| <Button | ||
| type="submit" | ||
| variant="solid" | ||
| className="w-full" | ||
| disabled={loginPost.isLoading} | ||
| onClick={() => | ||
| loginPost.mutate({ loginParams: { username: 'privileged' } }) | ||
| } | ||
| > | ||
| Privileged | ||
| </Button> | ||
| <Button | ||
| type="submit" | ||
| variant="dim" | ||
| className="w-full" | ||
| disabled={loginPost.isLoading} | ||
| onClick={() => | ||
| loginPost.mutate({ loginParams: { username: 'unprivileged' } }) | ||
| } | ||
| > | ||
| Unprivileged | ||
| </Button> | ||
| <Button | ||
| type="submit" | ||
| variant="ghost" | ||
| className="w-full" | ||
| disabled={loginPost.isLoading} | ||
| onClick={() => | ||
| loginPost.mutate({ loginParams: { username: 'other' } }) | ||
| } | ||
| > | ||
| Bad Request | ||
| </Button> | ||
| <Button | ||
| type="submit" | ||
| variant="link" | ||
| className="w-full" | ||
| disabled={loginPost.isLoading} | ||
| onClick={() => logout.mutate({})} | ||
| > | ||
| Log out | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,7 +22,7 @@ export default function OrgPage() { | |||||||
| </PageHeader> | ||||||||
|
|
||||||||
| <div className="space-x-4"> | ||||||||
| <Link to={`/orgs/${orgName}/projects/new`} className={buttonStyle()}> | ||||||||
| <Link to="projects/new" className={buttonStyle()}> | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this because the link is relative to the current location?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Almost, it's relative to the parent node in the route tree, in this case Lines 71 to 73 in c1378a6
Originally I did this because it made the link totally indifferent to the |
||||||||
| Create project | ||||||||
| </Link> | ||||||||
| </div> | ||||||||
|
|
||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this eventually goes away? It seems like while we may still want the capability for dev, we definitely wouldn't want it in the public api spec.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct. The demo login form is really only in the console bundle in the first place because of the convenience of using existing styles. Login will really be through the customer's IdP, but If Nexus does end up serving some kind of login form, e.g., for use by admins before the IdP is set up, I think that should be a separate bundle with minimal JS (ideally so minimal we could inline it in the HTML response) and it would not use the generated API client at all. It could even use an HTML form POST.
I'll make a comment about this in the LoginPage file.