Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
File renamed without changes.
36 changes: 36 additions & 0 deletions src/common/box-proptypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';

const UserPropType = PropTypes.shape({
avatarUrl: PropTypes.string,
id: PropTypes.number.isRequired,
name: PropTypes.string.isRequired,
});

const SelectorItemPropType = PropTypes.shape({
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
name: PropTypes.string.isRequired,
});

const ActionItemErrorPropType = PropTypes.shape({
title: PropTypes.string.isRequired,
message: PropTypes.string.isRequired,
action: PropTypes.shape({
text: PropTypes.string.isRequired,
onAction: PropTypes.func.isRequired,
}),
});

const SelectorItemsPropType = PropTypes.arrayOf(SelectorItemPropType);

const OptionPropType = {
text: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
} as const;

const OptionsPropType = PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.shape(OptionPropType)),
ImmutablePropTypes.listOf(ImmutablePropTypes.recordOf(OptionPropType)),
]).isRequired;

export { ActionItemErrorPropType, SelectorItemsPropType, SelectorItemPropType, UserPropType, OptionsPropType };
File renamed without changes.
25 changes: 25 additions & 0 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const ITEM_TYPE_FILE = 'file' as const;
const ITEM_TYPE_FOLDER = 'folder' as const;
const ITEM_TYPE_HUBS = 'hubs' as const;
const ITEM_TYPE_WEBLINK = 'web_link' as const;

const JSON_PATCH_OP_ADD = 'add' as const;
const JSON_PATCH_OP_REMOVE = 'remove' as const;
const JSON_PATCH_OP_REPLACE = 'replace' as const;
const JSON_PATCH_OP_TEST = 'test' as const;

const METADATA_FIELD_TYPE_ENUM = 'enum' as const;
const METADATA_FIELD_TYPE_MULTISELECT = 'multiSelect' as const;

export {
ITEM_TYPE_FILE,
ITEM_TYPE_FOLDER,
ITEM_TYPE_HUBS,
ITEM_TYPE_WEBLINK,
JSON_PATCH_OP_ADD,
JSON_PATCH_OP_REMOVE,
JSON_PATCH_OP_REPLACE,
JSON_PATCH_OP_TEST,
METADATA_FIELD_TYPE_ENUM,
METADATA_FIELD_TYPE_MULTISELECT,
};
File renamed without changes.
8 changes: 8 additions & 0 deletions src/common/keyboard-events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const ARROW_DOWN = 'ArrowDown';
const ARROW_UP = 'ArrowUp';
const ESCAPE = 'Escape';
const ENTER = 'Enter';
const SPACE = ' ';
const TAB = 'Tab';

export { ARROW_DOWN, ARROW_UP, ENTER, ESCAPE, SPACE, TAB };
File renamed without changes.
101 changes: 101 additions & 0 deletions src/common/messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { defineMessages } from 'react-intl';

const messages = defineMessages({
cancel: {
defaultMessage: 'Cancel',
description: 'Cancel button text',
id: 'boxui.core.cancel',
},
close: {
defaultMessage: 'Close',
description: 'Close button text',
id: 'boxui.core.close',
},
copy: {
defaultMessage: 'Copy',
description: 'Copy button text',
id: 'boxui.core.copy',
},
copied: {
defaultMessage: 'Copied',
description: 'Copy button text after user clicks on it',
id: 'boxui.core.copied',
},
done: {
defaultMessage: 'Done',
description: 'Done button text',
id: 'boxui.core.done',
},
okay: {
defaultMessage: 'Okay',
description: 'Okay button text',
id: 'boxui.core.okay',
},
save: {
defaultMessage: 'Save',
description: 'Save button text',
id: 'boxui.core.save',
},
send: {
defaultMessage: 'Send',
description: 'Send button text',
id: 'boxui.core.send',
},
optional: {
defaultMessage: 'optional',
description: 'Optional text for labels',
id: 'boxui.core.optional',
},
pillSelectorPlaceholder: {
defaultMessage: 'Add names or email addresses',
description: 'Placeholder text for the pill selector',
id: 'boxui.share.pillSelectorPlaceholder',
},
messageSelectorPlaceholder: {
defaultMessage: 'Add a message',
description: 'Placeholder text for message section',
id: 'boxui.share.messageSelectorPlaceholder',
},
invalidInputError: {
defaultMessage: 'Invalid Input',
description: 'Generic error message for a field is invalid',
id: 'boxui.validation.genericError',
},
minLengthError: {
defaultMessage: 'Input must be at least {min} characters',
description: 'Error message for when an input value is too short. {min} is the minimum length',
id: 'boxui.validation.tooShortError',
},
maxLengthError: {
defaultMessage: 'Input cannot exceed {max} characters',
description: 'Error message for when an input value is too long. {max} is the maximum length',
id: 'boxui.validation.tooLongError',
},
invalidEmailError: {
defaultMessage: 'Invalid Email Address',
description: 'Error message for when an invalid email is entered',
id: 'boxui.validation.emailError',
},
invalidURLError: {
defaultMessage: 'Invalid URL',
description: 'Error message for when an invalid URL is entered',
id: 'boxui.validation.URLError',
},
invalidUserError: {
defaultMessage: 'Invalid User',
description: 'Error message for when an invalid user is entered',
id: 'boxui.validation.invalidUserError',
},
requiredFieldError: {
defaultMessage: 'Required Field',
description: 'Error message for when a required field is missing',
id: 'boxui.validation.requiredError',
},
invalidDateError: {
defaultMessage: 'Invalid Date',
description: 'Error message for when an invalid Date is entered',
id: 'boxui.validation.invalidDateError',
},
});

export default messages;
98 changes: 98 additions & 0 deletions src/common/types/annotations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import type { BoxItemVersionMini, Reply, User } from './core';
import type { ActionItemError, Comment, FeedItemStatus } from './feed';

export type Frame = {
type: 'frame';
value: number;
};

export type Page = {
type: 'page';
value: number;
};

export type Rect = {
fill?: {
color: string;
};
height: number;
stroke?: {
color: string;
size: number;
};
type: 'rect';
width: number;
x: number;
y: number;
};

export type TargetDrawing = {
location: Frame | Page;
type: 'drawing';
};

export type TargetHighlight = {
location: Page;
text?: string;
type: 'highlight';
};

export type TargetRegion = {
location: Frame | Page;
shape?: Rect;
type: 'region';
};

export type TargetPoint = {
location: Page;
type: 'point';
x: number;
y: number;
};

export type Target = TargetDrawing | TargetHighlight | TargetPoint | TargetRegion;

export type AnnotationPermission = {
can_delete?: boolean;
can_edit?: boolean;
can_reply?: boolean;
can_resolve?: boolean;
};

export type Resolution = {
resolved_at?: string | null;
resolved_by?: User | null;
};

export type Annotation = {
created_at: string;
created_by: User;
description?: Reply;
error?: ActionItemError; // Doesn't come from the API but used in the FeedItems,
file_version: BoxItemVersionMini | null;
id: string;
isPending?: boolean; // Doesn't come from the API but used in the FeedItems,
isRepliesLoading?: boolean;
modified_at: string;
modified_by: User;
permissions: AnnotationPermission;
replies?: Array<Comment>;
resolution?: Resolution | null;
status?: FeedItemStatus;
target: Target;
total_reply_count?: number;
type: 'annotation';
};

export type Annotations = {
entries: Array<Annotation>;
limit: number;
next_marker: string | null;
};

export type NewAnnotation = {
description?: {
message: string;
};
target: Target;
};
File renamed without changes.
Loading
Loading