update handlers to mimick server format
This commit is contained in:
@@ -34,7 +34,6 @@ const handlers = [
|
||||
...mediaHandlers,
|
||||
...dataTypeHandlers,
|
||||
...documentTypeHandlers,
|
||||
...manifestsHandlers.default,
|
||||
...telemetryHandlers,
|
||||
...publishedStatusHandlers,
|
||||
...usersHandlers,
|
||||
|
||||
@@ -1,58 +1,77 @@
|
||||
import { rest } from 'msw';
|
||||
|
||||
import { umbracoPath } from '@umbraco-cms/utils';
|
||||
import { ManifestTypes } from '@umbraco-cms/extensions-registry';
|
||||
|
||||
type ManifestsResponse = Record<string, any>;
|
||||
type ManifestsPackagesInstalledResponse = ManifestsResponse;
|
||||
// TODO: Update to server API types when they are available
|
||||
type Package = {
|
||||
name?: string;
|
||||
version?: string;
|
||||
extensions?: ManifestTypes[];
|
||||
};
|
||||
type ManifestsResponse = Package[];
|
||||
|
||||
export const manifestDevelopmentHandler = rest.get(umbracoPath('/manifests'), (_req, res, ctx) => {
|
||||
return res(
|
||||
// Respond with a 200 status code
|
||||
ctx.status(200),
|
||||
ctx.json<ManifestsResponse>({
|
||||
manifests: [
|
||||
{
|
||||
type: 'section',
|
||||
alias: 'My.Section.Custom',
|
||||
name: 'Custom Section',
|
||||
js: '/App_Plugins/section.js',
|
||||
elementName: 'my-section-custom',
|
||||
weight: 1,
|
||||
meta: {
|
||||
label: 'Custom',
|
||||
pathname: 'my-custom',
|
||||
ctx.json<ManifestsResponse>([
|
||||
{
|
||||
name: 'Named Package',
|
||||
version: '1.0.0',
|
||||
extensions: [
|
||||
{
|
||||
type: 'section',
|
||||
alias: 'My.Section.Custom',
|
||||
name: 'Custom Section',
|
||||
js: '/App_Plugins/section.js',
|
||||
elementName: 'my-section-custom',
|
||||
weight: 1,
|
||||
meta: {
|
||||
label: 'Custom',
|
||||
pathname: 'my-custom',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'propertyEditorUI',
|
||||
alias: 'My.PropertyEditorUI.Custom',
|
||||
name: 'My Custom Property Editor UI',
|
||||
js: '/App_Plugins/property-editor.js',
|
||||
elementName: 'my-property-editor-ui-custom',
|
||||
meta: {
|
||||
label: 'My Custom Property',
|
||||
icon: 'document',
|
||||
group: 'Common',
|
||||
propertyEditorModel: 'Umbraco.JSON',
|
||||
{
|
||||
type: 'propertyEditorUI',
|
||||
alias: 'My.PropertyEditorUI.Custom',
|
||||
name: 'My Custom Property Editor UI',
|
||||
js: '/App_Plugins/property-editor.js',
|
||||
elementName: 'my-property-editor-ui-custom',
|
||||
meta: {
|
||||
label: 'My Custom Property',
|
||||
icon: 'document',
|
||||
group: 'Common',
|
||||
propertyEditorModel: 'Umbraco.JSON',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'entrypoint',
|
||||
name: 'My Custom Entry Point',
|
||||
alias: 'My.Entrypoint.Custom',
|
||||
js: '/App_Plugins/custom-entrypoint.js',
|
||||
},
|
||||
{
|
||||
type: 'packageView',
|
||||
alias: 'My.PackageView.Custom',
|
||||
name: 'My Custom Package View',
|
||||
js: '/App_Plugins/package-view.js',
|
||||
meta: {
|
||||
packageAlias: 'my.package',
|
||||
],
|
||||
},
|
||||
{
|
||||
extensions: [
|
||||
{
|
||||
type: 'entrypoint',
|
||||
name: 'My Custom Entry Point',
|
||||
alias: 'My.Entrypoint.Custom',
|
||||
js: '/App_Plugins/custom-entrypoint.js',
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Package with a view',
|
||||
extensions: [
|
||||
{
|
||||
type: 'packageView',
|
||||
alias: 'My.PackageView.Custom',
|
||||
name: 'My Custom Package View',
|
||||
js: '/App_Plugins/package-view.js',
|
||||
meta: {
|
||||
packageAlias: 'my.package',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
@@ -60,39 +79,6 @@ export const manifestEmptyHandler = rest.get(umbracoPath('/manifests'), (_req, r
|
||||
return res(
|
||||
// Respond with a 200 status code
|
||||
ctx.status(200),
|
||||
ctx.json<ManifestsResponse>({
|
||||
manifests: [],
|
||||
})
|
||||
ctx.json<ManifestsResponse>([])
|
||||
);
|
||||
});
|
||||
|
||||
export default [
|
||||
rest.get(umbracoPath('/manifests/packages/installed'), (_req, res, ctx) => {
|
||||
return res(
|
||||
// Respond with a 200 status code
|
||||
ctx.status(200),
|
||||
ctx.json<ManifestsPackagesInstalledResponse>({
|
||||
packages: [
|
||||
{
|
||||
id: '2a0181ec-244b-4068-a1d7-2f95ed7e6da6',
|
||||
name: 'My very own package',
|
||||
alias: 'my.package',
|
||||
version: '1.0.0',
|
||||
hasMigrations: false,
|
||||
hasPendingMigrations: false,
|
||||
plans: [],
|
||||
},
|
||||
{
|
||||
id: '240d95be-bfdb-4ca2-a601-ed2bfd5ed069',
|
||||
name: 'Some other community package',
|
||||
alias: 'our.package',
|
||||
version: '2.0.1',
|
||||
hasMigrations: false,
|
||||
hasPendingMigrations: false,
|
||||
plans: [],
|
||||
},
|
||||
],
|
||||
})
|
||||
);
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -23,7 +23,6 @@ export const handlers = [
|
||||
...userHandlers,
|
||||
...dataTypeHandlers,
|
||||
...documentTypeHandlers,
|
||||
...manifestsHandlers.default,
|
||||
...telemetryHandlers,
|
||||
...publishedStatusHandlers,
|
||||
...examineManagementHandlers,
|
||||
|
||||
Reference in New Issue
Block a user