Skip to content

Commit d079383

Browse files
pyphiliakim
andauthored
feat: allow switching from folder to capsule (#2052)
* feat: allow changing isCapsule of folder extra * feat: add create capsule and update to capsule endpoints * feat: add specific endpoints to switch * refactor: apply some fixes * docs: add a capsule doc * refactor: rename switching to converting * refactor: apply PR requested changes * refactor: fix tests * refactor: fix tests --------- Co-authored-by: kim <kim.phanhoang@epfl.ch>
1 parent 3908c39 commit d079383

14 files changed

Lines changed: 1056 additions & 9 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"@fastify/type-provider-typebox": "5.1.0",
6868
"@fastify/websocket": "11.0.2",
6969
"@graasp/etherpad-api": "2.1.1",
70-
"@graasp/sdk": "5.17.0",
70+
"@graasp/sdk": "5.18.0",
7171
"@rapideditor/country-coder": "5.4.0",
7272
"@sentry/node": "7.119.2",
7373
"@sentry/tracing": "7.120.3",

src/plugins/swagger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default async function (instance: FastifyInstance): Promise<void> {
1919
{ name: 'app-action', description: 'Endpoints related to actions created in apps' },
2020
{ name: 'app-data', description: 'Endpoints related to data created in apps' },
2121
{ name: 'app-setting', description: 'Endpoints related to settings created in apps' },
22+
{ name: 'capsule', description: 'Endpoints related to capsules' },
2223
{ name: 'chat', description: 'Endpoints related to chats' },
2324
{ name: 'app-chatbot', description: 'Endpoints related to chatbots in apps' },
2425
{ name: 'current', description: 'Endpoints related to current user' },

src/services/item/discrimination.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export type AppItem = ItemWithType<typeof ItemType.APP>;
66
export type DocumentItem = ItemWithType<typeof ItemType.DOCUMENT>;
77
export type EtherpadItem = ItemWithType<typeof ItemType.ETHERPAD>;
88
export type FolderItem = ItemWithType<typeof ItemType.FOLDER>;
9+
// For now a capsule is a folder with one different setting
10+
export type CapsuleItem = FolderItem;
911
export type PageItem = ItemWithType<typeof ItemType.PAGE>;
1012
export type H5PItem = ItemWithType<typeof ItemType.H5P>;
1113
export type EmbeddedLinkItem = ItemWithType<typeof ItemType.LINK>;

src/services/item/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import itemController from './item.controller';
1111
import actionItemPlugin from './plugins/action/itemAction.controller';
1212
import graaspApps from './plugins/app/app.controller';
1313
import { plugin as graaspAppItem } from './plugins/app/appItem.controller';
14+
import { capsulePlugin } from './plugins/capsule/capsule.controller';
1415
import graaspDocumentItem from './plugins/document/document.controller';
1516
import { PREFIX_DOCUMENT } from './plugins/document/document.service';
1617
import graaspEmbeddedLinkItem from './plugins/embeddedLink/link.controller';
@@ -74,6 +75,8 @@ const plugin: FastifyPluginAsync = async (fastify) => {
7475

7576
fastify.register(graaspFolderItem);
7677

78+
fastify.register(capsulePlugin);
79+
7780
fastify.register(graaspAppItem);
7881

7982
fastify.register(ShortLinkService, {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Capsules
2+
3+
Capsules are identical to regular folders but are marked with a special flag to indicate their capsule status (`isCapsule=true`).
4+
5+
Folders can be converted to capsules by toggling the `isCapsule` property and vice versa. It does not affect contents or structure.

0 commit comments

Comments
 (0)