Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add item settings with maxWidth #250

Merged
merged 7 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/services/file/interfaces/extra.ts
pyphilia marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { ItemType } from '../../../constants';
import { UnknownExtra } from '../../../interfaces';

export enum MaxWidth {
Small = 'sm',
Medium = 'md',
Large = 'lg',
ExtraLarge = 'xl',
}

pyphilia marked this conversation as resolved.
Show resolved Hide resolved
/**
* @deprecated Use FileItemProperties instead
*/
Expand Down
1 change: 1 addition & 0 deletions src/services/items/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './interfaces/item';
export * from './interfaces/itemSettings';
41 changes: 12 additions & 29 deletions src/services/items/interfaces/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,12 @@ import { AppItemExtra } from '../../app/';
import { EtherpadItemExtra } from '../../etherpad';
import { 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,
FileItemSettings,
ItemSettings,
} from './itemSettings';
import { Member } from '@/index';

export interface Item<S = ItemSettings> {
id: string;
Expand Down Expand Up @@ -65,14 +48,14 @@ export type EmbeddedLinkItemType<S = ItemSettings> = {
extra: EmbeddedLinkItemExtra;
settings: EmbeddedLinkItemSettings;
} & Item<S>;
export type LocalFileItemType<S = ItemSettings> = {
export type LocalFileItemType = {
type: `${ItemType.LOCAL_FILE}`;
extra: LocalFileItemExtra;
} & Item<S>;
export type S3FileItemType<S = ItemSettings> = {
} & Item<FileItemSettings>;
export type S3FileItemType = {
type: `${ItemType.S3_FILE}`;
extra: S3FileItemExtra;
} & Item<S>;
} & Item<FileItemSettings>;
export type ShortcutItemType<S = ItemSettings> = {
type: `${ItemType.SHORTCUT}`;
extra: ShortcutItemExtra;
Expand All @@ -88,7 +71,7 @@ export type DiscriminatedItem<S = ItemSettings> =
| FolderItemType<S>
| H5PItemType<S>
| EmbeddedLinkItemType<S>
| LocalFileItemType<S>
| S3FileItemType<S>
| LocalFileItemType
| S3FileItemType
| ShortcutItemType<S>
| EtherpadItemType<S>;
28 changes: 28 additions & 0 deletions src/services/items/interfaces/itemSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { CCLicenseAdaptions, OldCCLicenseAdaptations } from '@/constants';
import { MaxWidth } from '@/services';

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;
}

export interface FileItemSettings extends ItemSettings {
maxWidth?: MaxWidth;
}