2021-10-28 11:08:58 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2022-11-16 15:31:54 +01:00
|
|
|
import { getTrad } from './utils';
|
2021-10-28 11:08:58 +02:00
|
|
|
|
2021-09-16 13:48:21 +02:00
|
|
|
export const AssetType = {
|
|
|
|
Video: 'video',
|
|
|
|
Image: 'image',
|
|
|
|
Document: 'doc',
|
2022-02-06 11:49:57 +01:00
|
|
|
Audio: 'audio',
|
2021-09-16 13:48:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export const AssetSource = {
|
|
|
|
Url: 'url',
|
|
|
|
Computer: 'computer',
|
|
|
|
};
|
2021-10-28 11:08:58 +02:00
|
|
|
|
2022-10-24 16:29:47 +02:00
|
|
|
const ParentFolderShape = {
|
2022-05-18 09:43:01 +02:00
|
|
|
id: PropTypes.number.isRequired,
|
|
|
|
createdAt: PropTypes.string.isRequired,
|
|
|
|
name: PropTypes.string.isRequired,
|
|
|
|
updatedAt: PropTypes.string.isRequired,
|
2022-08-23 13:52:09 +02:00
|
|
|
pathId: PropTypes.number.isRequired,
|
2022-05-18 09:43:01 +02:00
|
|
|
path: PropTypes.string.isRequired,
|
2022-10-24 16:29:47 +02:00
|
|
|
};
|
2022-05-18 09:43:01 +02:00
|
|
|
|
2022-10-24 16:29:47 +02:00
|
|
|
ParentFolderShape.parent = PropTypes.shape(ParentFolderShape);
|
2022-07-31 16:39:47 +02:00
|
|
|
|
2022-10-24 16:29:47 +02:00
|
|
|
const FolderShape = {
|
2022-06-22 11:05:48 +02:00
|
|
|
id: PropTypes.number.isRequired,
|
2022-06-22 17:00:30 +02:00
|
|
|
children: PropTypes.shape({
|
|
|
|
count: PropTypes.number.isRequired,
|
|
|
|
}),
|
2022-06-22 11:05:48 +02:00
|
|
|
createdAt: PropTypes.string.isRequired,
|
2022-06-22 17:00:30 +02:00
|
|
|
createdBy: PropTypes.shape(),
|
|
|
|
files: PropTypes.shape({
|
|
|
|
count: PropTypes.number.isRequired,
|
|
|
|
}),
|
2022-06-22 11:05:48 +02:00
|
|
|
name: PropTypes.string.isRequired,
|
|
|
|
updatedAt: PropTypes.string.isRequired,
|
2022-06-22 17:00:30 +02:00
|
|
|
updatedBy: PropTypes.shape(),
|
2022-08-23 13:52:09 +02:00
|
|
|
pathId: PropTypes.number.isRequired,
|
2022-06-22 11:05:48 +02:00
|
|
|
path: PropTypes.string.isRequired,
|
2022-10-24 16:29:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
FolderShape.parent = PropTypes.shape(ParentFolderShape);
|
|
|
|
|
|
|
|
export const FolderDefinition = PropTypes.shape(FolderShape);
|
2022-06-22 11:05:48 +02:00
|
|
|
|
2022-05-18 09:43:01 +02:00
|
|
|
const FolderStructure = PropTypes.shape({
|
|
|
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
|
|
label: PropTypes.string.isRequired,
|
|
|
|
children: PropTypes.array,
|
|
|
|
});
|
|
|
|
|
|
|
|
FolderStructure.children = PropTypes.arrayOf(PropTypes.shape(FolderStructure));
|
|
|
|
FolderStructure.defaultProps = {
|
|
|
|
children: undefined,
|
|
|
|
};
|
|
|
|
|
|
|
|
export const FolderStructureDefinition = PropTypes.arrayOf(FolderStructure);
|
|
|
|
|
2021-10-28 11:08:58 +02:00
|
|
|
export const AssetDefinition = PropTypes.shape({
|
|
|
|
id: PropTypes.number,
|
|
|
|
height: PropTypes.number,
|
|
|
|
width: PropTypes.number,
|
|
|
|
size: PropTypes.number,
|
|
|
|
createdAt: PropTypes.string,
|
|
|
|
ext: PropTypes.string,
|
|
|
|
mime: PropTypes.string,
|
|
|
|
name: PropTypes.string,
|
|
|
|
url: PropTypes.string,
|
|
|
|
updatedAt: PropTypes.string,
|
|
|
|
alternativeText: PropTypes.string,
|
|
|
|
caption: PropTypes.string,
|
2022-05-18 09:43:01 +02:00
|
|
|
folder: PropTypes.shape(FolderDefinition),
|
2021-10-28 11:08:58 +02:00
|
|
|
formats: PropTypes.shape({
|
|
|
|
thumbnail: PropTypes.shape({
|
|
|
|
url: PropTypes.string,
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
});
|
2022-07-31 16:39:47 +02:00
|
|
|
|
|
|
|
export const CrumbDefinition = PropTypes.shape({
|
|
|
|
id: PropTypes.number,
|
2022-08-23 13:39:32 +02:00
|
|
|
label: PropTypes.oneOfType([
|
|
|
|
PropTypes.string,
|
|
|
|
PropTypes.shape({
|
|
|
|
id: PropTypes.string.isRequired,
|
|
|
|
defaultMessage: PropTypes.string.isRequired,
|
|
|
|
}),
|
|
|
|
]).isRequired,
|
2022-07-31 16:39:47 +02:00
|
|
|
href: PropTypes.string,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const CrumbMenuDefinition = PropTypes.arrayOf(CrumbDefinition);
|
|
|
|
|
|
|
|
export const BreadcrumbsDefinition = PropTypes.arrayOf(
|
|
|
|
PropTypes.oneOfType([CrumbDefinition, CrumbMenuDefinition])
|
|
|
|
);
|
2022-11-16 15:31:54 +01:00
|
|
|
|
|
|
|
export const tableHeaders = [
|
|
|
|
{
|
|
|
|
name: 'preview',
|
|
|
|
key: 'preview',
|
|
|
|
metadatas: {
|
|
|
|
label: { id: getTrad('list-table-header-preview'), defaultMessage: 'preview' },
|
|
|
|
sortable: false,
|
|
|
|
},
|
2022-11-21 10:54:43 +01:00
|
|
|
type: 'image',
|
2022-11-16 15:31:54 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'name',
|
|
|
|
key: 'name',
|
|
|
|
metadatas: {
|
|
|
|
label: { id: getTrad('list-table-header-name'), defaultMessage: 'name' },
|
|
|
|
sortable: true,
|
|
|
|
},
|
2022-11-21 10:54:43 +01:00
|
|
|
type: 'text',
|
2022-11-16 15:31:54 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'ext',
|
|
|
|
key: 'extension',
|
|
|
|
metadatas: {
|
|
|
|
label: { id: getTrad('list-table-header-ext'), defaultMessage: 'extension' },
|
|
|
|
sortable: false,
|
|
|
|
},
|
2022-11-21 10:54:43 +01:00
|
|
|
type: 'ext',
|
2022-11-16 15:31:54 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'size',
|
|
|
|
key: 'size',
|
|
|
|
metadatas: {
|
|
|
|
label: { id: getTrad('list-table-header-size'), defaultMessage: 'size' },
|
|
|
|
sortable: false,
|
|
|
|
},
|
2022-11-21 10:54:43 +01:00
|
|
|
type: 'size',
|
2022-11-16 15:31:54 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'createdAt',
|
|
|
|
key: 'createdAt',
|
|
|
|
metadatas: {
|
|
|
|
label: { id: getTrad('list-table-header-createdAt'), defaultMessage: 'created' },
|
|
|
|
sortable: true,
|
|
|
|
},
|
2022-11-21 10:54:43 +01:00
|
|
|
type: 'date',
|
2022-11-16 15:31:54 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'updatedAt',
|
|
|
|
key: 'updatedAt',
|
|
|
|
metadatas: {
|
|
|
|
label: { id: getTrad('list-table-header-updatedAt'), defaultMessage: 'last update' },
|
|
|
|
sortable: true,
|
|
|
|
},
|
2022-11-21 10:54:43 +01:00
|
|
|
type: 'date',
|
2022-11-16 15:31:54 +01:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export const pageSizes = [10, 20, 50, 100];
|
|
|
|
|
|
|
|
export const sortOptions = [
|
|
|
|
{ key: 'sort.created_at_desc', value: 'createdAt:DESC' },
|
|
|
|
{ key: 'sort.created_at_asc', value: 'createdAt:ASC' },
|
|
|
|
{ key: 'sort.name_asc', value: 'name:ASC' },
|
|
|
|
{ key: 'sort.name_desc', value: 'name:DESC' },
|
|
|
|
{ key: 'sort.updated_at_desc', value: 'updatedAt:DESC' },
|
|
|
|
{ key: 'sort.updated_at_asc', value: 'updatedAt:ASC' },
|
|
|
|
];
|