Skip to content
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

Remove GraphQL / GitHub / Keystone links in production #7546

Merged
merged 3 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tall-months-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-6/core': minor
---

Removed all Keystone Links, i.e. API explorer, GitHub repository and Keystone documentation, from the popover and replacing the popover button with `Sign out` button in production
62 changes: 34 additions & 28 deletions packages/core/src/admin-ui/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,38 +76,44 @@ const AuthenticatedItemDialog = ({ item }: { item: AuthenticatedItem | undefined
>
{item && item.state === 'authenticated' ? (
<div css={{ fontSize: typography.fontSize.small }}>
Signed in as <strong>{item.label}</strong>
Signed in as <strong css={{ display: 'block' }}>{item.label}</strong>
Achisingh marked this conversation as resolved.
Show resolved Hide resolved
</div>
) : (
<div css={{ fontSize: typography.fontSize.small }}>GraphQL Playground and Docs</div>
process.env.NODE_ENV !== 'production' && (
<div css={{ fontSize: typography.fontSize.small }}>GraphQL Playground and Docs</div>
)
)}

<Popover
placement="bottom"
triggerRenderer={({ triggerProps }) => (
<Button
size="small"
style={{ padding: 0, width: 36 }}
aria-label="Links and signout"
{...triggerProps}
>
<MoreHorizontalIcon />
</Button>
)}
>
<Stack gap="medium" padding="large" dividers="between">
<PopoverLink target="_blank" href={apiPath}>
API Explorer
</PopoverLink>
<PopoverLink target="_blank" href="https://github.com/keystonejs/keystone">
GitHub Repository
</PopoverLink>
<PopoverLink target="_blank" href="https://keystonejs.com">
Keystone Documentation
</PopoverLink>
{item && item.state === 'authenticated' && <SignoutButton />}
</Stack>
</Popover>
{process.env.NODE_ENV === 'production' ? (
item && item.state === 'authenticated' && <SignoutButton />
) : (
<Popover
placement="bottom"
triggerRenderer={({ triggerProps }) => (
<Button
size="small"
style={{ padding: 0, width: 36 }}
aria-label="Links and signout"
{...triggerProps}
>
<MoreHorizontalIcon />
</Button>
)}
>
<Stack gap="medium" padding="large" dividers="between">
<PopoverLink target="_blank" href={apiPath}>
API Explorer
</PopoverLink>
<PopoverLink target="_blank" href="https://github.com/keystonejs/keystone">
GitHub Repository
</PopoverLink>
<PopoverLink target="_blank" href="https://keystonejs.com">
Keystone Documentation
</PopoverLink>
{item && item.state === 'authenticated' && <SignoutButton />}
</Stack>
</Popover>
)}
</div>
);
};
Expand Down
6 changes: 4 additions & 2 deletions tests/examples-smoke-tests/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Browser, Page } from 'playwright';
import fetch from 'node-fetch';
import { exampleProjectTests, initFirstItemTest, loadIndex } from './utils';

exampleProjectTests('../examples-staging/basic', browserType => {
exampleProjectTests('../examples-staging/basic', (browserType, mode) => {
let browser: Browser = undefined as any;
let page: Page = undefined as any;
beforeAll(async () => {
Expand All @@ -12,7 +12,9 @@ exampleProjectTests('../examples-staging/basic', browserType => {
});
initFirstItemTest(() => page);
test('sign out and sign in', async () => {
await page.click('[aria-label="Links and signout"]');
if (mode === 'dev') {
await page.click('[aria-label="Links and signout"]');
}
await Promise.all([page.waitForNavigation(), page.click('button:has-text("Sign out")')]);
await page.fill('[placeholder="email"]', 'admin@keystonejs.com');
await page.fill('[placeholder="password"]', 'password');
Expand Down
4 changes: 2 additions & 2 deletions tests/examples-smoke-tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const initFirstItemTest = (getPage: () => playwright.Page) => {

export const exampleProjectTests = (
exampleName: string,
tests: (browser: playwright.BrowserType<playwright.Browser>) => void
tests: (browser: playwright.BrowserType<playwright.Browser>, mode: 'dev' | 'prod') => void
) => {
const projectDir = path.join(__dirname, '..', '..', 'examples', exampleName);
describe.each(['dev', 'prod'] as const)('%s', mode => {
Expand Down Expand Up @@ -151,7 +151,7 @@ export const exampleProjectTests = (
beforeAll(async () => {
await deleteAllData(projectDir);
});
tests(playwright[browserName]);
tests(playwright[browserName], mode);
});
});
};