split partial view handlers
This commit is contained in:
@@ -29,7 +29,7 @@ import { handlers as packageHandlers } from './handlers/package.handlers.js';
|
||||
import { handlers as rteEmbedHandlers } from './handlers/rte-embed.handlers.js';
|
||||
import { handlers as staticFileHandlers } from './handlers/static-file.handlers.js';
|
||||
import { handlers as stylesheetHandlers } from './handlers/stylesheet/index.js';
|
||||
import { handlers as partialViewsHandlers } from './handlers/partial-views.handlers.js';
|
||||
import { handlers as partialViewHandlers } from './handlers/partial-view/index.js';
|
||||
import { handlers as tagHandlers } from './handlers/tag-handlers.js';
|
||||
import { handlers as configHandlers } from './handlers/config.handlers.js';
|
||||
import { handlers as scriptHandlers } from './handlers/script/index.js';
|
||||
@@ -54,7 +54,7 @@ const handlers = [
|
||||
...memberTypeHandlers,
|
||||
...modelsBuilderHandlers,
|
||||
...packageHandlers,
|
||||
...partialViewsHandlers,
|
||||
...partialViewHandlers,
|
||||
...profilingHandlers,
|
||||
...publishedStatusHandlers,
|
||||
...redirectManagementHandlers,
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbPartialViewMockDB } from '../../data/partial-view/partial-view.db.js';
|
||||
import { UMB_SLUG } from './slug.js';
|
||||
import { CreateStylesheetRequestModel, UpdateStylesheetRequestModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
export const detailHandlers = [
|
||||
rest.post(umbracoPath(UMB_SLUG), async (req, res, ctx) => {
|
||||
const requestBody = (await req.json()) as CreateStylesheetRequestModel;
|
||||
if (!requestBody) return res(ctx.status(400, 'no body found'));
|
||||
const path = umbPartialViewMockDB.file.create(requestBody);
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.set({
|
||||
Location: path,
|
||||
}),
|
||||
);
|
||||
}),
|
||||
|
||||
rest.get(umbracoPath(`${UMB_SLUG}/:path`), (req, res, ctx) => {
|
||||
const path = req.params.path as string;
|
||||
if (!path) return res(ctx.status(400));
|
||||
const response = umbPartialViewMockDB.file.read(path);
|
||||
return res(ctx.status(200), ctx.json(response));
|
||||
}),
|
||||
|
||||
rest.delete(umbracoPath(`${UMB_SLUG}/:path`), (req, res, ctx) => {
|
||||
const path = req.params.path as string;
|
||||
if (!path) return res(ctx.status(400));
|
||||
umbPartialViewMockDB.file.delete(path);
|
||||
return res(ctx.status(200));
|
||||
}),
|
||||
|
||||
rest.put(umbracoPath(`${UMB_SLUG}/:path`), async (req, res, ctx) => {
|
||||
const path = req.params.path as string;
|
||||
if (!path) return res(ctx.status(400));
|
||||
const requestBody = (await req.json()) as UpdateStylesheetRequestModel;
|
||||
if (!requestBody) return res(ctx.status(400, 'no body found'));
|
||||
umbPartialViewMockDB.file.update(path, requestBody);
|
||||
return res(ctx.status(200));
|
||||
}),
|
||||
];
|
||||
@@ -0,0 +1,28 @@
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbPartialViewMockDB } from '../../data/partial-view/partial-view.db.js';
|
||||
import { UMB_SLUG } from './slug.js';
|
||||
import { CreatePathFolderRequestModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
export const folderHandlers = [
|
||||
rest.get(umbracoPath(`${UMB_SLUG}/folder`), (req, res, ctx) => {
|
||||
const path = req.url.searchParams.get('path');
|
||||
if (!path) return res(ctx.status(400));
|
||||
const response = umbPartialViewMockDB.folder.read(path);
|
||||
return res(ctx.status(200), ctx.json(response));
|
||||
}),
|
||||
|
||||
rest.post(umbracoPath(`${UMB_SLUG}/folder`), async (req, res, ctx) => {
|
||||
const requestBody = (await req.json()) as CreatePathFolderRequestModel;
|
||||
if (!requestBody) return res(ctx.status(400, 'no body found'));
|
||||
umbPartialViewMockDB.folder.create(requestBody);
|
||||
return res(ctx.status(200));
|
||||
}),
|
||||
|
||||
rest.delete(umbracoPath(`${UMB_SLUG}/folder`), (req, res, ctx) => {
|
||||
const path = req.url.searchParams.get('path');
|
||||
if (!path) return res(ctx.status(400));
|
||||
umbPartialViewMockDB.folder.delete(path);
|
||||
return res(ctx.status(200));
|
||||
}),
|
||||
];
|
||||
@@ -0,0 +1,6 @@
|
||||
import { folderHandlers } from './folder.handlers.js';
|
||||
import { treeHandlers } from './tree.handlers.js';
|
||||
import { detailHandlers } from './detail.handlers.js';
|
||||
import { itemHandlers } from './item.handlers.js';
|
||||
|
||||
export const handlers = [...treeHandlers, ...itemHandlers, ...folderHandlers, ...detailHandlers];
|
||||
@@ -0,0 +1,13 @@
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbPartialViewMockDB } from '../../data/partial-view/partial-view.db.js';
|
||||
import { UMB_SLUG } from './slug.js';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
export const itemHandlers = [
|
||||
rest.get(umbracoPath(`${UMB_SLUG}/item`), (req, res, ctx) => {
|
||||
const paths = req.url.searchParams.getAll('paths');
|
||||
if (!paths) return res(ctx.status(400, 'no body found'));
|
||||
const items = umbPartialViewMockDB.item.getItems(paths);
|
||||
return res(ctx.status(200), ctx.json(items));
|
||||
}),
|
||||
];
|
||||
@@ -0,0 +1 @@
|
||||
export const UMB_SLUG = '/partial-view';
|
||||
@@ -0,0 +1,18 @@
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbPartialViewMockDB } from '../../data/partial-view/partial-view.db.js';
|
||||
import { UMB_SLUG } from './slug.js';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
export const treeHandlers = [
|
||||
rest.get(umbracoPath(`/tree${UMB_SLUG}/root`), (req, res, ctx) => {
|
||||
const response = umbPartialViewMockDB.tree.getRoot();
|
||||
return res(ctx.status(200), ctx.json(response));
|
||||
}),
|
||||
|
||||
rest.get(umbracoPath(`/tree${UMB_SLUG}/children`), (req, res, ctx) => {
|
||||
const path = req.url.searchParams.get('path');
|
||||
if (!path) return res(ctx.status(400));
|
||||
const response = umbPartialViewMockDB.tree.getChildrenOf(path);
|
||||
return res(ctx.status(200), ctx.json(response));
|
||||
}),
|
||||
];
|
||||
Reference in New Issue
Block a user