Skip to content

Commit 638e1ae

Browse files
committed
🏷️(service-worker) retype the doc creation in SW
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.
1 parent dcbef96 commit 638e1ae

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/frontend/apps/impress/src/features/docs/doc-management/types.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface Access {
77
user: User;
88
abilities: {
99
destroy: boolean;
10+
partial_update: boolean;
1011
retrieve: boolean;
1112
set_role_to: Role[];
1213
update: boolean;
@@ -38,6 +39,7 @@ export interface Doc {
3839
created_at: string;
3940
updated_at: string;
4041
abilities: {
42+
attachment_upload: true;
4143
destroy: boolean;
4244
link_configuration: boolean;
4345
manage_accesses: boolean;

src/frontend/apps/impress/src/features/service-worker/ApiPlugin.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { WorkboxPlugin } from 'workbox-core';
22

3-
import { Doc, DocsResponse } from '@/features/docs';
3+
import {
4+
Doc,
5+
DocsResponse,
6+
LinkReach,
7+
Role,
8+
} from '@/features/docs/doc-management';
49

510
import { DBRequest, DocsDB } from './DocsDB';
611
import { RequestSerializer } from './RequestSerializer';
@@ -181,7 +186,8 @@ export class ApiPlugin implements WorkboxPlugin {
181186
.clone()
182187
.json()) as Partial<Doc>;
183188

184-
const newResponse = {
189+
const newResponse: Doc = {
190+
title: '',
185191
...bodyMutate,
186192
id: uuid,
187193
content: '',
@@ -197,13 +203,29 @@ export class ApiPlugin implements WorkboxPlugin {
197203
update: true,
198204
partial_update: true,
199205
retrieve: true,
206+
attachment_upload: true,
200207
},
201208
accesses: [
202209
{
203210
id: 'dummy-id',
211+
role: Role.OWNER,
212+
team: '',
213+
user: {
214+
id: 'dummy-id',
215+
email: 'dummy-email',
216+
},
217+
abilities: {
218+
destroy: false,
219+
partial_update: false,
220+
retrieve: true,
221+
set_role_to: [],
222+
update: false,
223+
},
204224
},
205225
],
206-
} as Doc;
226+
link_reach: LinkReach.RESTRICTED,
227+
link_role: 'reader',
228+
};
207229

208230
await DocsDB.cacheResponse(
209231
`${request.url}${uuid}/`,

0 commit comments

Comments
 (0)