Skip to content

Commit 86085f8

Browse files
committed
♻️(frontend) remove share button when not logged in
We remove the share button if the user is not logged in. Most of the elements in the share modal nececessitate the user to be logged in.
1 parent ebdcb4b commit 86085f8

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ test.describe('Doc Visibility: Not loggued', () => {
9494
await page.goto(urlDoc);
9595

9696
await expect(page.locator('h2').getByText(docTitle)).toBeVisible();
97+
await expect(page.getByRole('button', { name: 'Share' })).toBeHidden();
9798
});
9899

99100
test('A private doc redirect to the OIDC when not authentified.', async ({

src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { useState } from 'react';
33
import { useTranslation } from 'react-i18next';
44

55
import { Box, DropButton, IconOptions, Text } from '@/components';
6+
import { useAuthStore } from '@/core';
67
import { usePanelEditorStore } from '@/features/docs/doc-editor/';
78
import {
89
Doc,
@@ -29,6 +30,7 @@ export const DocToolBox = ({ doc, versionId }: DocToolBoxProps) => {
2930
const { setIsPanelOpen, setIsPanelTableContentOpen } = usePanelEditorStore();
3031
const [isModalVersionOpen, setIsModalVersionOpen] = useState(false);
3132
const { isSmallMobile } = useResponsiveStore();
33+
const { authenticated } = useAuthStore();
3234

3335
return (
3436
<Box
@@ -52,14 +54,16 @@ export const DocToolBox = ({ doc, versionId }: DocToolBoxProps) => {
5254
</Box>
5355
)}
5456
<Box $direction="row" $margin={{ left: 'auto' }} $gap="1rem">
55-
<Button
56-
onClick={() => {
57-
setIsModalShareOpen(true);
58-
}}
59-
size={isSmallMobile ? 'small' : 'medium'}
60-
>
61-
{t('Share')}
62-
</Button>
57+
{authenticated && (
58+
<Button
59+
onClick={() => {
60+
setIsModalShareOpen(true);
61+
}}
62+
size={isSmallMobile ? 'small' : 'medium'}
63+
>
64+
{t('Share')}
65+
</Button>
66+
)}
6367
<DropButton
6468
button={
6569
<IconOptions

0 commit comments

Comments
 (0)