Skip to content

Commit

Permalink
Admin UI menu available for unauthenticated users (keystonejs#6459)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored and Nikitoring committed Sep 14, 2021
1 parent c10f427 commit 96a2ab9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/swift-feet-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/keystone': minor
---

Updated Navigation component to show docs and playground links irrespective of authentication.
22 changes: 13 additions & 9 deletions packages/keystone/src/admin-ui/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Button } from '@keystone-ui/button';
import { Popover } from '@keystone-ui/popover';
import { MoreHorizontalIcon } from '@keystone-ui/icons/icons/MoreHorizontalIcon';
import { ChevronRightIcon } from '@keystone-ui/icons/icons/ChevronRightIcon';
import { NavigationProps, ListMeta } from '../../types';
import { NavigationProps, ListMeta, AuthenticatedItem } from '../../types';

import { useKeystone } from '../context';
import { Link } from '../router';
Expand Down Expand Up @@ -60,7 +60,7 @@ export const NavItem = ({ href, children, isSelected: _isSelected }: NavItemProp
);
};

const AuthenticatedItem = ({ item }: { item: { id: string; label: string } }) => {
const AuthenticatedItemDialog = ({ item }: { item: AuthenticatedItem | undefined }) => {
const { spacing, typography } = useTheme();
return (
<div
Expand All @@ -73,9 +73,14 @@ const AuthenticatedItem = ({ item }: { item: { id: string; label: string } }) =>
marginBottom: 0,
}}
>
<div css={{ fontSize: typography.fontSize.small }}>
Signed in as <strong>{item.label}</strong>
</div>
{item && item.state === 'authenticated' ? (
<div css={{ fontSize: typography.fontSize.small }}>
Signed in as <strong>{item.label}</strong>
</div>
) : (
<div css={{ fontSize: typography.fontSize.small }}>Graqhql Playground and Docs</div>
)}

<Popover
placement="bottom"
triggerRenderer={({ triggerProps }) => (
Expand All @@ -100,7 +105,7 @@ const AuthenticatedItem = ({ item }: { item: { id: string; label: string } }) =>
<PopoverLink target="_blank" href="https://keystonejs.com">
Keystone Documentation
</PopoverLink>
<SignoutButton />
{item && item.state === 'authenticated' && <SignoutButton />}
</Stack>
</Popover>
</div>
Expand Down Expand Up @@ -138,11 +143,10 @@ export const NavigationContainer = ({ authenticatedItem, children }: NavigationC
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
position: 'relative',
}}
>
{authenticatedItem?.state === 'authenticated' && (
<AuthenticatedItem item={authenticatedItem} />
)}
<AuthenticatedItemDialog item={authenticatedItem} />
<nav role="navigation" aria-label="Side Navigation" css={{ marginTop: spacing.xlarge }}>
<ul
css={{
Expand Down

0 comments on commit 96a2ab9

Please sign in to comment.