From d6a1d495afbdf7273a3763e13a3ecc2e757f5317 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 23 Aug 2023 11:38:08 +0200 Subject: [PATCH 1/7] refactor: add item settings with maxWidth --- src/services/file/interfaces/extra.ts | 11 ++++++ src/services/items/interfaces/item.ts | 35 +++++-------------- src/services/items/interfaces/itemSettings.ts | 23 ++++++++++++ 3 files changed, 43 insertions(+), 26 deletions(-) create mode 100644 src/services/items/interfaces/itemSettings.ts diff --git a/src/services/file/interfaces/extra.ts b/src/services/file/interfaces/extra.ts index dd0b88a8..a611de73 100644 --- a/src/services/file/interfaces/extra.ts +++ b/src/services/file/interfaces/extra.ts @@ -1,5 +1,12 @@ import { ItemType } from '../../../constants'; import { UnknownExtra } from '../../../interfaces'; +import { ItemSettings } from '@/services/items/interfaces/itemSettings'; + +export enum MaxWidth { + Small = 'xs', + Medium = 'md', + Large = 'lg', +} /** * @deprecated Use FileItemProperties instead @@ -27,3 +34,7 @@ export interface S3FileItemExtra extends UnknownExtra { } export type FileItemExtra = S3FileItemExtra | LocalFileItemExtra; + +export interface FileItemSettings extends ItemSettings { + maxWidth?: MaxWidth | false; +} diff --git a/src/services/items/interfaces/item.ts b/src/services/items/interfaces/item.ts index 63123b68..e04e0267 100644 --- a/src/services/items/interfaces/item.ts +++ b/src/services/items/interfaces/item.ts @@ -7,31 +7,14 @@ import { } from '../../../interfaces/extra'; import { AppItemExtra } from '../../app/'; import { EtherpadItemExtra } from '../../etherpad'; -import { LocalFileItemExtra, S3FileItemExtra } from '../../file'; +import { + FileItemSettings, + LocalFileItemExtra, + S3FileItemExtra, +} from '../../file'; import { H5PItemExtra } from '../../h5p'; -import { CCLicenseAdaptions, Member, OldCCLicenseAdaptations } from '@/index'; - -export interface ItemSettings { - lang?: string; - isPinned?: boolean; - showChatbox?: boolean; - hasThumbnail?: boolean; - isResizable?: boolean; - isCollapsible?: boolean; - enableSaveActions?: boolean; - tags?: string[]; - displayCoEditors?: boolean; - ccLicenseAdaption?: - | `${CCLicenseAdaptions}` - | CCLicenseAdaptions - // todo: these are the old licenses, we might remove them at some point. - | `${OldCCLicenseAdaptations}`; -} - -export interface EmbeddedLinkItemSettings extends ItemSettings { - showLinkIframe?: boolean; - showLinkButton?: boolean; -} +import { EmbeddedLinkItemSettings, ItemSettings } from './itemSettings'; +import { Member } from '@/index'; export interface Item { id: string; @@ -65,11 +48,11 @@ export type EmbeddedLinkItemType = { extra: EmbeddedLinkItemExtra; settings: EmbeddedLinkItemSettings; } & Item; -export type LocalFileItemType = { +export type LocalFileItemType = { type: `${ItemType.LOCAL_FILE}`; extra: LocalFileItemExtra; } & Item; -export type S3FileItemType = { +export type S3FileItemType = { type: `${ItemType.S3_FILE}`; extra: S3FileItemExtra; } & Item; diff --git a/src/services/items/interfaces/itemSettings.ts b/src/services/items/interfaces/itemSettings.ts new file mode 100644 index 00000000..f2dcc717 --- /dev/null +++ b/src/services/items/interfaces/itemSettings.ts @@ -0,0 +1,23 @@ +import { CCLicenseAdaptions, OldCCLicenseAdaptations } from '@/constants'; + +export interface ItemSettings { + lang?: string; + isPinned?: boolean; + showChatbox?: boolean; + hasThumbnail?: boolean; + isResizable?: boolean; + isCollapsible?: boolean; + enableSaveActions?: boolean; + tags?: string[]; + displayCoEditors?: boolean; + ccLicenseAdaption?: + | `${CCLicenseAdaptions}` + | CCLicenseAdaptions + // todo: these are the old licenses, we might remove them at some point. + | `${OldCCLicenseAdaptations}`; +} + +export interface EmbeddedLinkItemSettings extends ItemSettings { + showLinkIframe?: boolean; + showLinkButton?: boolean; +} From b64ae9c1062b65fbdf608257bbe9984e37c9d0f9 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 23 Aug 2023 14:28:16 +0200 Subject: [PATCH 2/7] refactor: export item settings --- src/services/items/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/services/items/index.ts b/src/services/items/index.ts index b4c8bf01..3122142b 100644 --- a/src/services/items/index.ts +++ b/src/services/items/index.ts @@ -1 +1,2 @@ export * from './interfaces/item'; +export * from './interfaces/itemSettings'; From d135407c1c55dc51d79ea2af3200fafeaf2a49d9 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 23 Aug 2023 14:40:05 +0200 Subject: [PATCH 3/7] refactor: add ExtraLarge --- src/services/file/interfaces/extra.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/services/file/interfaces/extra.ts b/src/services/file/interfaces/extra.ts index a611de73..72ba0936 100644 --- a/src/services/file/interfaces/extra.ts +++ b/src/services/file/interfaces/extra.ts @@ -3,9 +3,10 @@ import { UnknownExtra } from '../../../interfaces'; import { ItemSettings } from '@/services/items/interfaces/itemSettings'; export enum MaxWidth { - Small = 'xs', + Small = 'sm', Medium = 'md', Large = 'lg', + ExtraLarge = 'xl', } /** @@ -36,5 +37,5 @@ export interface S3FileItemExtra extends UnknownExtra { export type FileItemExtra = S3FileItemExtra | LocalFileItemExtra; export interface FileItemSettings extends ItemSettings { - maxWidth?: MaxWidth | false; + maxWidth?: MaxWidth; } From 7fd2852bcc7688eaabcb44933aa806ebb61b5898 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 23 Aug 2023 14:52:08 +0200 Subject: [PATCH 4/7] refactor: refactor item settings --- src/services/items/interfaces/item.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/items/interfaces/item.ts b/src/services/items/interfaces/item.ts index e04e0267..80bce7d3 100644 --- a/src/services/items/interfaces/item.ts +++ b/src/services/items/interfaces/item.ts @@ -48,9 +48,10 @@ export type EmbeddedLinkItemType = { extra: EmbeddedLinkItemExtra; settings: EmbeddedLinkItemSettings; } & Item; -export type LocalFileItemType = { +export type LocalFileItemType = { type: `${ItemType.LOCAL_FILE}`; extra: LocalFileItemExtra; + settings: FileItemSettings; } & Item; export type S3FileItemType = { type: `${ItemType.S3_FILE}`; From 4bbe84a4ff88baa7041e52297d9da4a5ffd70663 Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 28 Aug 2023 11:55:45 +0200 Subject: [PATCH 5/7] refactor: apply PR requested changes --- src/services/file/interfaces/extra.ts | 5 ----- src/services/items/interfaces/item.ts | 13 ++++++------- src/services/items/interfaces/itemSettings.ts | 5 +++++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/services/file/interfaces/extra.ts b/src/services/file/interfaces/extra.ts index 72ba0936..f9fbdbb2 100644 --- a/src/services/file/interfaces/extra.ts +++ b/src/services/file/interfaces/extra.ts @@ -1,6 +1,5 @@ import { ItemType } from '../../../constants'; import { UnknownExtra } from '../../../interfaces'; -import { ItemSettings } from '@/services/items/interfaces/itemSettings'; export enum MaxWidth { Small = 'sm', @@ -35,7 +34,3 @@ export interface S3FileItemExtra extends UnknownExtra { } export type FileItemExtra = S3FileItemExtra | LocalFileItemExtra; - -export interface FileItemSettings extends ItemSettings { - maxWidth?: MaxWidth; -} diff --git a/src/services/items/interfaces/item.ts b/src/services/items/interfaces/item.ts index 80bce7d3..cae88bd0 100644 --- a/src/services/items/interfaces/item.ts +++ b/src/services/items/interfaces/item.ts @@ -48,15 +48,14 @@ export type EmbeddedLinkItemType = { extra: EmbeddedLinkItemExtra; settings: EmbeddedLinkItemSettings; } & Item; -export type LocalFileItemType = { +export type LocalFileItemType = { type: `${ItemType.LOCAL_FILE}`; extra: LocalFileItemExtra; - settings: FileItemSettings; -} & Item; -export type S3FileItemType = { +} & Item; +export type S3FileItemType = { type: `${ItemType.S3_FILE}`; extra: S3FileItemExtra; -} & Item; +} & Item; export type ShortcutItemType = { type: `${ItemType.SHORTCUT}`; extra: ShortcutItemExtra; @@ -72,7 +71,7 @@ export type DiscriminatedItem = | FolderItemType | H5PItemType | EmbeddedLinkItemType - | LocalFileItemType - | S3FileItemType + | LocalFileItemType + | S3FileItemType | ShortcutItemType | EtherpadItemType; diff --git a/src/services/items/interfaces/itemSettings.ts b/src/services/items/interfaces/itemSettings.ts index f2dcc717..0e47592d 100644 --- a/src/services/items/interfaces/itemSettings.ts +++ b/src/services/items/interfaces/itemSettings.ts @@ -1,4 +1,5 @@ import { CCLicenseAdaptions, OldCCLicenseAdaptations } from '@/constants'; +import { MaxWidth } from '@/services'; export interface ItemSettings { lang?: string; @@ -21,3 +22,7 @@ export interface EmbeddedLinkItemSettings extends ItemSettings { showLinkIframe?: boolean; showLinkButton?: boolean; } + +export interface FileItemSettings extends ItemSettings { + maxWidth?: MaxWidth; +} From 3aae4e1207cb8a7f29fe30803568076991181661 Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 28 Aug 2023 11:59:53 +0200 Subject: [PATCH 6/7] refactor: fix error --- src/services/items/interfaces/item.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/items/interfaces/item.ts b/src/services/items/interfaces/item.ts index cae88bd0..c0c364ef 100644 --- a/src/services/items/interfaces/item.ts +++ b/src/services/items/interfaces/item.ts @@ -7,13 +7,13 @@ import { } from '../../../interfaces/extra'; import { AppItemExtra } from '../../app/'; import { EtherpadItemExtra } from '../../etherpad'; +import { LocalFileItemExtra, S3FileItemExtra } from '../../file'; +import { H5PItemExtra } from '../../h5p'; import { + EmbeddedLinkItemSettings, FileItemSettings, - LocalFileItemExtra, - S3FileItemExtra, -} from '../../file'; -import { H5PItemExtra } from '../../h5p'; -import { EmbeddedLinkItemSettings, ItemSettings } from './itemSettings'; + ItemSettings, +} from './itemSettings'; import { Member } from '@/index'; export interface Item { From d82ea2d1b68725285ae88388605f8e6c89ce683f Mon Sep 17 00:00:00 2001 From: kim Date: Tue, 29 Aug 2023 10:33:53 +0200 Subject: [PATCH 7/7] refactor: apply PR requested changes --- src/services/file/interfaces/extra.ts | 7 ------- src/services/file/interfaces/settings.ts | 12 ++++++++++++ src/services/items/interfaces/item.ts | 7 ++----- src/services/items/interfaces/itemSettings.ts | 5 ----- 4 files changed, 14 insertions(+), 17 deletions(-) create mode 100644 src/services/file/interfaces/settings.ts diff --git a/src/services/file/interfaces/extra.ts b/src/services/file/interfaces/extra.ts index f9fbdbb2..dd0b88a8 100644 --- a/src/services/file/interfaces/extra.ts +++ b/src/services/file/interfaces/extra.ts @@ -1,13 +1,6 @@ import { ItemType } from '../../../constants'; import { UnknownExtra } from '../../../interfaces'; -export enum MaxWidth { - Small = 'sm', - Medium = 'md', - Large = 'lg', - ExtraLarge = 'xl', -} - /** * @deprecated Use FileItemProperties instead */ diff --git a/src/services/file/interfaces/settings.ts b/src/services/file/interfaces/settings.ts new file mode 100644 index 00000000..2528e895 --- /dev/null +++ b/src/services/file/interfaces/settings.ts @@ -0,0 +1,12 @@ +import { ItemSettings } from '@/services'; + +export enum MaxWidth { + Small = 'sm', + Medium = 'md', + Large = 'lg', + ExtraLarge = 'xl', +} + +export interface FileItemSettings extends ItemSettings { + maxWidth?: MaxWidth; +} diff --git a/src/services/items/interfaces/item.ts b/src/services/items/interfaces/item.ts index c0c364ef..45537649 100644 --- a/src/services/items/interfaces/item.ts +++ b/src/services/items/interfaces/item.ts @@ -9,12 +9,9 @@ import { AppItemExtra } from '../../app/'; import { EtherpadItemExtra } from '../../etherpad'; import { LocalFileItemExtra, S3FileItemExtra } from '../../file'; import { H5PItemExtra } from '../../h5p'; -import { - EmbeddedLinkItemSettings, - FileItemSettings, - ItemSettings, -} from './itemSettings'; +import { EmbeddedLinkItemSettings, ItemSettings } from './itemSettings'; import { Member } from '@/index'; +import { FileItemSettings } from '@/services/file/interfaces/settings'; export interface Item { id: string; diff --git a/src/services/items/interfaces/itemSettings.ts b/src/services/items/interfaces/itemSettings.ts index 0e47592d..f2dcc717 100644 --- a/src/services/items/interfaces/itemSettings.ts +++ b/src/services/items/interfaces/itemSettings.ts @@ -1,5 +1,4 @@ import { CCLicenseAdaptions, OldCCLicenseAdaptations } from '@/constants'; -import { MaxWidth } from '@/services'; export interface ItemSettings { lang?: string; @@ -22,7 +21,3 @@ export interface EmbeddedLinkItemSettings extends ItemSettings { showLinkIframe?: boolean; showLinkButton?: boolean; } - -export interface FileItemSettings extends ItemSettings { - maxWidth?: MaxWidth; -}