From 15c0e35127c43be87eaf7d8b72eebf924af4628f Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Tue, 8 Oct 2024 15:24:25 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F(service-worker)=20retype?= =?UTF-8?q?=20the=20doc=20creation=20in=20SW?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Recent changes made the doc creation in SW outdated. This commit retype the doc creation in SW. We adapt the main type to fit the new doc type. --- .../features/docs/doc-management/types.tsx | 2 ++ .../src/features/service-worker/ApiPlugin.ts | 23 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) 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 0125cedc7..2e6169837 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 @@ -7,6 +7,7 @@ export interface Access { user: User; abilities: { destroy: boolean; + partial_update: boolean; retrieve: boolean; set_role_to: Role[]; update: boolean; @@ -38,6 +39,7 @@ export interface Doc { created_at: string; updated_at: string; abilities: { + attachment_upload: true; destroy: boolean; link_configuration: boolean; manage_accesses: boolean; 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 ef5cd6fcf..b4fb00345 100644 --- a/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts +++ b/src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts @@ -1,6 +1,6 @@ import { WorkboxPlugin } from 'workbox-core'; -import { Doc, DocsResponse } from '@/features/docs'; +import { Doc, DocsResponse, LinkReach, Role } from '@/features/docs'; import { DBRequest, DocsDB } from './DocsDB'; import { RequestSerializer } from './RequestSerializer'; @@ -181,7 +181,8 @@ export class ApiPlugin implements WorkboxPlugin { .clone() .json()) as Partial; - const newResponse = { + const newResponse: Doc = { + title: '', ...bodyMutate, id: uuid, content: '', @@ -197,13 +198,29 @@ export class ApiPlugin implements WorkboxPlugin { update: true, partial_update: true, retrieve: true, + attachment_upload: true, }, accesses: [ { id: 'dummy-id', + role: Role.OWNER, + team: '', + user: { + id: 'dummy-id', + email: 'dummy-email', + }, + abilities: { + destroy: false, + partial_update: false, + retrieve: true, + set_role_to: [], + update: false, + }, }, ], - } as Doc; + link_reach: LinkReach.RESTRICTED, + link_role: 'reader', + }; await DocsDB.cacheResponse( `${request.url}${uuid}/`,