Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d5a021d
feat: shows notification when no suitable media type is found
iOvergaard Jan 28, 2025
455992a
chore: rearrange imports
iOvergaard Jan 28, 2025
4f6b4b7
feat: use a forward ref to find the dropzone
iOvergaard Jan 28, 2025
343e771
chore: rearrange imports
iOvergaard Jan 28, 2025
11976a0
chore(mock): send back correct header
iOvergaard Jan 28, 2025
37b3c94
feat: avoid using the context consumer to get a token, but instead mi…
iOvergaard Jan 28, 2025
badf18f
chore(mock): allow more file types
iOvergaard Jan 28, 2025
a79aa2c
chore(mock): create more upload fields
iOvergaard Jan 28, 2025
61abee4
chore(mock): also look for mediaPicker fields
iOvergaard Jan 28, 2025
4990a84
chore(mock): improve media mock db
iOvergaard Jan 28, 2025
9f821e5
chore(mock): add missing endpoints
iOvergaard Jan 28, 2025
38720c0
chore(mock): update media data
iOvergaard Jan 28, 2025
9addb3e
chore(mock): fix aliases for media grid and table
iOvergaard Jan 28, 2025
7cf4d59
chore(mock): add urls to media
iOvergaard Jan 28, 2025
dda7b79
chore(mock): adds missing endpoint for imaging
iOvergaard Jan 28, 2025
a12ec27
fix: reverse order of properties to overwrite existing status
iOvergaard Jan 28, 2025
ddbe415
feat: listen to progress updates on upload and update the `progress` …
iOvergaard Jan 28, 2025
900f57c
feat: adds tracking of upload progress to placeholders
iOvergaard Jan 28, 2025
647232a
feat: bind the progress number up on the temporary file badge to indi…
iOvergaard Jan 28, 2025
c0d67e5
feat: optimises progress calculation and makes the badge bigger to be…
iOvergaard Jan 28, 2025
f57d1ae
feat: allow text to be normal
iOvergaard Jan 28, 2025
e1e5408
chore: use correct localization
iOvergaard Jan 28, 2025
f8a9791
feat: shows error status for anything that isn't waiting or complete
iOvergaard Jan 28, 2025
ea3ea33
feat: makes `progress` optional
iOvergaard Jan 28, 2025
b1a6125
feat: set progress for createTemporaryFiles
iOvergaard Jan 29, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,70 @@ export const data: Array<UmbMockDataTypeModel> = [
values: [
{
alias: 'fileExtensions',
value: ['jpg', 'jpeg', 'png', 'pdf'],
value: ['jpg', 'jpeg', 'png', 'svg'],
},
{
alias: 'multiple',
value: true,
},
],
},
{
name: 'Upload Field (Files)',
id: 'dt-uploadFieldFiles',
parent: null,
editorAlias: 'Umbraco.UploadField',
editorUiAlias: 'Umb.PropertyEditorUi.UploadField',
hasChildren: false,
isFolder: false,
isDeletable: true,
canIgnoreStartNodes: false,
values: [
{
alias: 'fileExtensions',
value: ['pdf', 'iso'],
},
{
alias: 'multiple',
value: true,
},
],
},
{
name: 'Upload Field (Movies)',
id: 'dt-uploadFieldMovies',
parent: null,
editorAlias: 'Umbraco.UploadField',
editorUiAlias: 'Umb.PropertyEditorUi.UploadField',
hasChildren: false,
isFolder: false,
isDeletable: true,
canIgnoreStartNodes: false,
values: [
{
alias: 'fileExtensions',
value: ['mp4', 'mov'],
},
{
alias: 'multiple',
value: true,
},
],
},
{
name: 'Upload Field (Vector)',
id: 'dt-uploadFieldVector',
parent: null,
editorAlias: 'Umbraco.UploadField',
editorUiAlias: 'Umb.PropertyEditorUi.UploadField',
hasChildren: false,
isFolder: false,
isDeletable: true,
canIgnoreStartNodes: false,
values: [
{
alias: 'fileExtensions',
value: ['svg'],
},
{
alias: 'multiple',
Expand Down Expand Up @@ -912,8 +975,16 @@ export const data: Array<UmbMockDataTypeModel> = [
{
alias: 'layouts',
value: [
{ icon: 'icon-grid', isSystem: true, name: 'Grid', path: '', selected: true },
{ icon: 'icon-list', isSystem: true, name: 'Table', path: '', selected: true },
{
icon: 'icon-grid',
name: 'Media Grid Collection View',
collectionView: 'Umb.CollectionView.Media.Grid',
},
{
icon: 'icon-list',
name: 'Media Table Collection View',
collectionView: 'Umb.CollectionView.Media.Table',
},
],
},
{ alias: 'icon', value: 'icon-layers' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type UmbMockMediaTypeUnionModel =

export const data: Array<UmbMockMediaTypeModel> = [
{
name: 'Media Type 1',
name: 'Image',
id: 'media-type-1-id',
parent: null,
description: 'Media type 1 description',
Expand Down Expand Up @@ -105,7 +105,7 @@ export const data: Array<UmbMockMediaTypeModel> = [
aliasCanBeChanged: false,
},
{
name: 'Media Type 2',
name: 'Audio',
id: 'media-type-2-id',
parent: null,
description: 'Media type 2 description',
Expand All @@ -118,7 +118,7 @@ export const data: Array<UmbMockMediaTypeModel> = [
alias: 'umbracoFile',
name: 'File',
description: '',
dataType: { id: 'dt-uploadField' },
dataType: { id: 'dt-uploadFieldFiles' },
variesByCulture: false,
variesBySegment: false,
sortOrder: 0,
Expand Down Expand Up @@ -155,7 +155,7 @@ export const data: Array<UmbMockMediaTypeModel> = [
aliasCanBeChanged: false,
},
{
name: 'Media Type 3',
name: 'Vector Graphics',
id: 'media-type-3-id',
parent: null,
description: 'Media type 3 description',
Expand All @@ -168,7 +168,7 @@ export const data: Array<UmbMockMediaTypeModel> = [
alias: 'umbracoFile',
name: 'File',
description: '',
dataType: { id: 'dt-uploadField' },
dataType: { id: 'dt-uploadFieldVector' },
variesByCulture: false,
variesBySegment: false,
sortOrder: 0,
Expand Down Expand Up @@ -205,7 +205,7 @@ export const data: Array<UmbMockMediaTypeModel> = [
aliasCanBeChanged: false,
},
{
name: 'Media Type 4',
name: 'Movie',
id: 'media-type-4-id',
parent: null,
description: 'Media type 4 description',
Expand All @@ -218,7 +218,7 @@ export const data: Array<UmbMockMediaTypeModel> = [
alias: 'umbracoFile',
name: 'File',
description: '',
dataType: { id: 'dt-uploadField' },
dataType: { id: 'dt-uploadFieldMovies' },
variesByCulture: false,
variesBySegment: false,
sortOrder: 0,
Expand Down Expand Up @@ -268,7 +268,7 @@ export const data: Array<UmbMockMediaTypeModel> = [
alias: 'umbracoFile',
name: 'File',
description: '',
dataType: { id: 'dt-uploadField' },
dataType: { id: 'dt-uploadFieldFiles' },
variesByCulture: false,
variesBySegment: false,
sortOrder: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class UmbMediaTypeMockDB extends UmbEntityMockDbBase<UmbMockMediaTypeModel> {
const allowedTypes = this.data.filter((field) => {
const allProperties = field.properties.flat();

const fileUploadType = allProperties.find((prop) => prop.alias === 'umbracoFile');
const fileUploadType = allProperties.find((prop) => prop.alias === 'umbracoFile' || prop.alias === 'mediaPicker');
if (!fileUploadType) return false;

const dataType = umbDataTypeMockDb.read(fileUploadType.dataType.id);
Expand Down
44 changes: 28 additions & 16 deletions src/Umbraco.Web.UI.Client/src/mocks/data/media/media.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,38 @@ export const data: Array<UmbMockMediaModel> = [
isTrashed: false,
mediaType: {
id: 'media-type-1-id',
icon: 'icon-bug',
icon: 'icon-picture',
},
values: [
{
editorAlias: 'Umbraco.UploadField',
alias: 'mediaPicker',
value: {
src: '/umbraco/backoffice/assets/installer-illustration.svg',
},
},
{
editorAlias: 'Umbraco.TextBox',
alias: 'myMediaHeadline',
alias: 'mediaType1Property1',
value: 'The daily life at Umbraco HQ',
},
],
variants: [
{
publishDate: '2023-02-06T15:31:51.354764',
culture: 'en-us',
culture: null,
segment: null,
name: 'Flipped Car',
createDate: '2023-02-06T15:31:46.876902',
updateDate: '2023-02-06T15:31:51.354764',
},
],
urls: [],
urls: [
{
culture: null,
url: '/umbraco/backoffice/assets/installer-illustration.svg',
},
],
},
{
hasChildren: false,
Expand All @@ -51,14 +63,14 @@ export const data: Array<UmbMockMediaModel> = [
values: [
{
editorAlias: 'Umbraco.TextBox',
alias: 'myMediaDescription',
alias: 'mediaType1Property1',
value: 'Every day, a rabbit in a military costume greets me at the front door',
},
],
variants: [
{
publishDate: '2023-02-06T15:31:51.354764',
culture: 'en-us',
culture: null,
segment: null,
name: 'Umbracoffee',
createDate: '2023-02-06T15:31:46.876902',
Expand All @@ -83,7 +95,7 @@ export const data: Array<UmbMockMediaModel> = [
variants: [
{
publishDate: '2023-02-06T15:31:51.354764',
culture: 'en-us',
culture: null,
segment: null,
name: 'People',
createDate: '2023-02-06T15:31:46.876902',
Expand All @@ -108,7 +120,7 @@ export const data: Array<UmbMockMediaModel> = [
variants: [
{
publishDate: '2023-02-06T15:31:51.354764',
culture: 'en-us',
culture: null,
segment: null,
name: 'John Smith',
createDate: '2023-02-06T15:31:46.876902',
Expand All @@ -131,14 +143,14 @@ export const data: Array<UmbMockMediaModel> = [
values: [
{
editorAlias: 'Umbraco.TextBox',
alias: 'myMediaDescription',
alias: 'mediaType1Property1',
value: 'Every day, a rabbit in a military costume greets me at the front door',
},
],
variants: [
{
publishDate: '2023-02-06T15:31:51.354764',
culture: 'en-us',
culture: null,
segment: null,
name: 'Jane Doe',
createDate: '2023-02-06T15:31:46.876902',
Expand All @@ -161,14 +173,14 @@ export const data: Array<UmbMockMediaModel> = [
values: [
{
editorAlias: 'Umbraco.TextBox',
alias: 'myMediaDescription',
alias: 'mediaType1Property1',
value: 'Every day, a rabbit in a military costume greets me at the front door',
},
],
variants: [
{
publishDate: '2023-02-06T15:31:51.354764',
culture: 'en-us',
culture: null,
segment: null,
name: 'John Doe',
createDate: '2023-02-06T15:31:46.876902',
Expand All @@ -191,14 +203,14 @@ export const data: Array<UmbMockMediaModel> = [
values: [
{
editorAlias: 'Umbraco.TextBox',
alias: 'myMediaDescription',
alias: 'mediaType1Property1',
value: 'Every day, a rabbit in a military costume greets me at the front door',
},
],
variants: [
{
publishDate: '2023-02-06T15:31:51.354764',
culture: 'en-us',
culture: null,
segment: null,
name: 'A very nice hat',
createDate: '2023-02-06T15:31:46.876902',
Expand All @@ -221,14 +233,14 @@ export const data: Array<UmbMockMediaModel> = [
values: [
{
editorAlias: 'Umbraco.TextBox',
alias: 'myMediaDescription',
alias: 'mediaType1Property1',
value: 'Every day, a rabbit in a military costume greets me at the front door',
},
],
variants: [
{
publishDate: '2023-02-06T15:31:51.354764',
culture: 'en-us',
culture: null,
segment: null,
name: 'Fancy old chair',
createDate: '2023-02-06T15:31:46.876902',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
UpdateMediaRequestModel,
} from '@umbraco-cms/backoffice/external/backend-api';
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
import type { UmbMediaDetailModel } from '@umbraco-cms/backoffice/media';

export const detailHandlers = [
rest.post(umbracoPath(`${UMB_SLUG}`), async (req, res, ctx) => {
Expand Down Expand Up @@ -44,6 +45,23 @@ export const detailHandlers = [
return res(ctx.status(200), ctx.json(response));
}),

rest.put<UmbMediaDetailModel>(umbracoPath(`${UMB_SLUG}/:id/validate`), async (req, res, ctx) => {
const id = req.params.id as string;
if (!id) return res(ctx.status(400));
const model = await req.json<UmbMediaDetailModel>();
if (!model) return res(ctx.status(400));

const hasMediaPickerOrFileUploadValue = model.values.some((v) => {
return v.editorAlias === 'Umbraco.UploadField' && v.value;
});

if (!hasMediaPickerOrFileUploadValue) {
return res(ctx.status(400, 'No media picker or file upload value found'));
}

return res(ctx.status(200));
}),

rest.put(umbracoPath(`${UMB_SLUG}/:id`), async (req, res, ctx) => {
const id = req.params.id as string;
if (!id) return res(ctx.status(400));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { rest } = window.MockServiceWorker;
import { umbMediaMockDb } from '../../data/media/media.db.js';
import type { GetImagingResizeUrlsResponse } from '@umbraco-cms/backoffice/external/backend-api';
import { umbracoPath } from '@umbraco-cms/backoffice/utils';

export const imagingHandlers = [
rest.get(umbracoPath('/imaging/resize/urls'), (req, res, ctx) => {
const ids = req.url.searchParams.getAll('id');
if (!ids) return res(ctx.status(404));

const media = umbMediaMockDb.getAll().filter((item) => ids.includes(item.id));

const response: GetImagingResizeUrlsResponse = media.map((item) => ({
id: item.id,
urlInfos: item.urls,
}));

return res(
// Respond with a 200 status code
ctx.status(200),
ctx.json(response),
);
}),
];
2 changes: 2 additions & 0 deletions src/Umbraco.Web.UI.Client/src/mocks/handlers/media/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { treeHandlers } from './tree.handlers.js';
import { itemHandlers } from './item.handlers.js';
import { detailHandlers } from './detail.handlers.js';
import { collectionHandlers } from './collection.handlers.js';
import { imagingHandlers } from './imaging.handlers.js';

export const handlers = [
...recycleBinHandlers,
...treeHandlers,
...itemHandlers,
...detailHandlers,
...collectionHandlers,
...imagingHandlers,
];
Loading
Loading