Skip to content

Commit 2ede746

Browse files
PanchoutNathanAntoLC
authored andcommitted
✨(frontend) hide search and create doc button if not logged
- Added visibility checks for 'search' and 'New doc' buttons in the document visibility tests. - Updated LeftPanelHeader to conditionally render 'search' and 'New doc' buttons based on user authentication status, improving user experience and access control.
1 parent 5bd0764 commit 2ede746

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to
3232
## Fixed
3333

3434
- 🐛(backend) fix create document via s2s if sub unknown but email found #543
35+
- 🐛(frontend) hide search and create doc button if not authenticated #555
3536

3637
## [1.10.0] - 2024-12-17
3738

src/frontend/apps/e2e/__tests__/app-impress/doc-visibility.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ test.describe('Doc Visibility: Public', () => {
232232
cardContainer.getByText('Public document', { exact: true }),
233233
).toBeVisible();
234234

235+
await expect(page.getByRole('button', { name: 'search' })).toBeVisible();
236+
await expect(page.getByRole('button', { name: 'New doc' })).toBeVisible();
237+
235238
const urlDoc = page.url();
236239

237240
await page
@@ -245,6 +248,8 @@ test.describe('Doc Visibility: Public', () => {
245248
await page.goto(urlDoc);
246249

247250
await expect(page.locator('h2').getByText(docTitle)).toBeVisible();
251+
await expect(page.getByRole('button', { name: 'search' })).toBeHidden();
252+
await expect(page.getByRole('button', { name: 'New doc' })).toBeHidden();
248253
await expect(page.getByRole('button', { name: 'Share' })).toBeHidden();
249254
const card = page.getByLabel('It is the card information');
250255
await expect(card).toBeVisible();

src/frontend/apps/impress/src/features/docs/docs-grid/components/DocsGrid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const DocsGrid = ({
8989
{title}
9090
</Text>
9191

92-
{!hasDocs && (
92+
{!hasDocs && !loading && (
9393
<Box $padding={{ vertical: 'sm' }} $align="center" $justify="center">
9494
<Text $size="sm" $variation="600" $weight="700">
9595
{t('No documents found')}

src/frontend/apps/impress/src/features/left-panel/components/LeftPanelHeader.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useRouter } from 'next/navigation';
44
import { PropsWithChildren } from 'react';
55

66
import { Box, Icon, SeparatedSection } from '@/components';
7+
import { useAuthStore } from '@/core';
78
import { useCreateDoc } from '@/features/docs/doc-management';
89
import { DocSearchModal } from '@/features/docs/doc-search';
910
import { useCmdK } from '@/hook/useCmdK';
@@ -13,6 +14,7 @@ import { useLeftPanelStore } from '../stores';
1314
export const LeftPanelHeader = ({ children }: PropsWithChildren) => {
1415
const router = useRouter();
1516
const searchModal = useModal();
17+
const auth = useAuthStore();
1618
useCmdK(searchModal.open);
1719
const { togglePanel } = useLeftPanelStore();
1820

@@ -52,16 +54,20 @@ export const LeftPanelHeader = ({ children }: PropsWithChildren) => {
5254
<Icon $variation="800" $theme="primary" iconName="house" />
5355
}
5456
/>
55-
<Button
56-
onClick={searchModal.open}
57-
size="medium"
58-
color="tertiary-text"
59-
icon={
60-
<Icon $variation="800" $theme="primary" iconName="search" />
61-
}
62-
/>
57+
{auth.authenticated && (
58+
<Button
59+
onClick={searchModal.open}
60+
size="medium"
61+
color="tertiary-text"
62+
icon={
63+
<Icon $variation="800" $theme="primary" iconName="search" />
64+
}
65+
/>
66+
)}
6367
</Box>
64-
<Button onClick={createNewDoc}>{t('New doc')}</Button>
68+
{auth.authenticated && (
69+
<Button onClick={createNewDoc}>{t('New doc')}</Button>
70+
)}
6571
</Box>
6672
</SeparatedSection>
6773
{children}

0 commit comments

Comments
 (0)