From 86085f87a19c50f16501d73b71e7cc1edaf752b2 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Wed, 9 Oct 2024 14:27:02 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(frontend)=20remove=20share?= =?UTF-8?q?=20button=20when=20not=20logged=20in?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../app-impress/doc-visibility.spec.ts | 1 + .../docs/doc-header/components/DocToolBox.tsx | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/frontend/apps/e2e/__tests__/app-impress/doc-visibility.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/doc-visibility.spec.ts index 5f7a846c..ba2b7ea6 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/doc-visibility.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/doc-visibility.spec.ts @@ -94,6 +94,7 @@ test.describe('Doc Visibility: Not loggued', () => { await page.goto(urlDoc); await expect(page.locator('h2').getByText(docTitle)).toBeVisible(); + await expect(page.getByRole('button', { name: 'Share' })).toBeHidden(); }); test('A private doc redirect to the OIDC when not authentified.', async ({ diff --git a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx index 98dfd638..c74fc3d8 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx @@ -3,6 +3,7 @@ import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Box, DropButton, IconOptions, Text } from '@/components'; +import { useAuthStore } from '@/core'; import { usePanelEditorStore } from '@/features/docs/doc-editor/'; import { Doc, @@ -29,6 +30,7 @@ export const DocToolBox = ({ doc, versionId }: DocToolBoxProps) => { const { setIsPanelOpen, setIsPanelTableContentOpen } = usePanelEditorStore(); const [isModalVersionOpen, setIsModalVersionOpen] = useState(false); const { isSmallMobile } = useResponsiveStore(); + const { authenticated } = useAuthStore(); return ( { )} - + {authenticated && ( + + )}