From eec8b4d2c3c73a4f117873ac7f94c8a4b6e66f7c Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Thu, 28 Nov 2024 15:34:18 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(frontend)=20adapt=20frontend?= =?UTF-8?q?=20with=20new=20access=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't get the accesses anymore from the backeend, instead we get the number of accesses. We remove the list of owners in the doc header because we don't have easily this informations anymore and we will have to do a bigger refacto. --- .../__tests__/app-impress/doc-header.spec.ts | 3 -- .../docs/doc-header/components/DocHeader.tsx | 22 +------------- .../features/docs/doc-management/types.tsx | 4 ++- .../docs/docs-grid/components/DocsGrid.tsx | 2 +- .../src/features/service-worker/ApiPlugin.ts | 29 +++---------------- 5 files changed, 9 insertions(+), 51 deletions(-) diff --git a/src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts index c09bce40..37a98764 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts @@ -65,9 +65,6 @@ test.describe('Doc Header', () => { await expect( card.getByText('Created at 09/01/2021, 11:00 AM'), ).toBeVisible(); - await expect( - card.getByText('Owners: Super Owner / super2@owner.com'), - ).toBeVisible(); await expect(card.getByText('Your role: Owner')).toBeVisible(); await expect(page.getByRole('button', { name: 'Share' })).toBeVisible(); }); diff --git a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocHeader.tsx b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocHeader.tsx index 96bd1b3f..0e565b10 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocHeader.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocHeader.tsx @@ -4,12 +4,7 @@ import { css } from 'styled-components'; import { Box, Card, StyledLink, Text } from '@/components'; import { useCunninghamTheme } from '@/cunningham'; -import { - Doc, - Role, - currentDocRole, - useTrans, -} from '@/features/docs/doc-management'; +import { Doc, currentDocRole, useTrans } from '@/features/docs/doc-management'; import { Versions } from '@/features/docs/doc-versioning'; import { useDate } from '@/hook'; import { useResponsiveStore } from '@/stores'; @@ -100,21 +95,6 @@ export const DocHeader = ({ doc, versionId }: DocHeaderProps) => { {t('Created at')} {formatDate(doc.created_at)} - - {t('Owners:')}{' '} - - {doc.accesses - .filter( - (access) => access.role === Role.OWNER && access.user.email, - ) - .map((access, index, accesses) => ( - - {access.user.full_name || access.user.email}{' '} - {index < accesses.length - 1 ? ' / ' : ''} - - ))} - - {t('Your role:')}{' '} diff --git a/src/frontend/apps/impress/src/features/docs/doc-management/types.tsx b/src/frontend/apps/impress/src/features/docs/doc-management/types.tsx index cedd477c..6c645240 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-management/types.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-management/types.tsx @@ -38,9 +38,11 @@ export interface Doc { id: string; title: string; content: Base64; + creator: string; + is_favorite: boolean; link_reach: LinkReach; link_role: LinkRole; - accesses: Access[]; + nb_accesses: number; created_at: string; updated_at: string; abilities: { diff --git a/src/frontend/apps/impress/src/features/docs/docs-grid/components/DocsGrid.tsx b/src/frontend/apps/impress/src/features/docs/docs-grid/components/DocsGrid.tsx index 3aa67e42..50069ee3 100644 --- a/src/frontend/apps/impress/src/features/docs/docs-grid/components/DocsGrid.tsx +++ b/src/frontend/apps/impress/src/features/docs/docs-grid/components/DocsGrid.tsx @@ -166,7 +166,7 @@ export const DocsGrid = () => { renderCell: ({ row }) => { return ( - {row.accesses.length} + {row.nb_accesses} ); }, diff --git a/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts b/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts index 5e13d743..2195c00b 100644 --- a/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts +++ b/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts @@ -1,11 +1,7 @@ import { WorkboxPlugin } from 'workbox-core'; import { Doc, DocsResponse } from '@/features/docs/doc-management'; -import { - LinkReach, - LinkRole, - Role, -} from '@/features/docs/doc-management/types'; +import { LinkReach, LinkRole } from '@/features/docs/doc-management/types'; import { DBRequest, DocsDB } from './DocsDB'; import { RequestSerializer } from './RequestSerializer'; @@ -192,6 +188,9 @@ export class ApiPlugin implements WorkboxPlugin { id: uuid, content: '', created_at: new Date().toISOString(), + creator: 'dummy-id', + is_favorite: false, + nb_accesses: 1, updated_at: new Date().toISOString(), abilities: { accesses_manage: true, @@ -206,26 +205,6 @@ export class ApiPlugin implements WorkboxPlugin { versions_list: true, versions_retrieve: true, }, - accesses: [ - { - id: 'dummy-id', - role: Role.OWNER, - team: '', - user: { - id: 'dummy-id', - email: 'dummy-email', - full_name: 'dummy-full-name', - short_name: 'dummy-short-name', - }, - abilities: { - destroy: false, - partial_update: false, - retrieve: true, - set_role_to: [], - update: false, - }, - }, - ], link_reach: LinkReach.RESTRICTED, link_role: LinkRole.READER, };