umbracopaths

This commit is contained in:
Lone Iversen
2023-10-05 12:53:38 +02:00
parent c8c7d08d80
commit 9eca5a4462

View File

@@ -1,6 +1,6 @@
const { rest } = window.MockServiceWorker;
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
import { umbDictionaryData } from '../data/dictionary.data.js';
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
import {
ImportDictionaryRequestModel,
DictionaryOverviewResponseModel,
@@ -49,7 +49,7 @@ const overviewData: Array<DictionaryOverviewResponseModel> = [
// TODO: add schema
export const handlers = [
rest.get('/umbraco/management/api/v1/dictionary/:id', (req, res, ctx) => {
rest.get(umbracoPath('/dictionary/:id'), (req, res, ctx) => {
const id = req.params.id as string;
if (!id) return;
@@ -57,7 +57,7 @@ export const handlers = [
return res(ctx.status(200), ctx.json(dictionary));
}),
rest.get('/umbraco/management/api/v1/dictionary', (req, res, ctx) => {
rest.get(umbracoPath('/dictionary'), (req, res, ctx) => {
const skip = req.url.searchParams.get('skip');
const take = req.url.searchParams.get('take');
if (!skip || !take) return;
@@ -75,7 +75,7 @@ export const handlers = [
return res(ctx.status(200), ctx.json(response));
}),
rest.post('/umbraco/management/api/v1/dictionary', async (req, res, ctx) => {
rest.post(umbracoPath('/dictionary'), async (req, res, ctx) => {
const data = await req.json();
if (!data) return;
@@ -94,7 +94,7 @@ export const handlers = [
return res(ctx.status(200), ctx.json(createdResult));
}),
rest.patch('/umbraco/management/api/v1/dictionary/:id', async (req, res, ctx) => {
rest.patch(umbracoPath('/dictionary/:id'), async (req, res, ctx) => {
const data = await req.json();
if (!data) return;
@@ -119,7 +119,7 @@ export const handlers = [
return res(ctx.status(200), ctx.json(saved));
}),
rest.get('/umbraco/management/api/v1/tree/dictionary/root', (req, res, ctx) => {
rest.get(umbracoPath('/tree/dictionary/root'), (req, res, ctx) => {
const items = umbDictionaryData.getTreeRoot();
const response = {
total: items.length,
@@ -128,7 +128,7 @@ export const handlers = [
return res(ctx.status(200), ctx.json(response));
}),
rest.get('/umbraco/management/api/v1/tree/dictionary/children', (req, res, ctx) => {
rest.get(umbracoPath('/tree/dictionary/children'), (req, res, ctx) => {
const parentId = req.url.searchParams.get('parentId');
if (!parentId) return;
@@ -142,7 +142,7 @@ export const handlers = [
return res(ctx.status(200), ctx.json(response));
}),
rest.get('/umbraco/management/api/v1/tree/dictionary/item', (req, res, ctx) => {
rest.get(umbracoPath('/tree/dictionary/item'), (req, res, ctx) => {
const ids = req.url.searchParams.getAll('id');
if (!ids) return;
@@ -151,7 +151,7 @@ export const handlers = [
return res(ctx.status(200), ctx.json(items));
}),
rest.delete('/umbraco/management/api/v1/dictionary/:id', (req, res, ctx) => {
rest.delete(umbracoPath('/dictionary/:id'), (req, res, ctx) => {
const id = req.params.id as string;
if (!id) return;
@@ -161,7 +161,7 @@ export const handlers = [
}),
// TODO => handle properly, querystring breaks handler
rest.get('/umbraco/management/api/v1/dictionary/:id/export', (req, res, ctx) => {
rest.get(umbracoPath('/dictionary/:id/export'), (req, res, ctx) => {
const id = req.params.id as string;
if (!id) return;
@@ -174,13 +174,13 @@ export const handlers = [
return res(ctx.status(200));
}),
rest.post('/umbraco/management/api/v1/dictionary/upload', async (req, res, ctx) => {
rest.post(umbracoPath('/dictionary/upload'), async (req, res, ctx) => {
if (!req.arrayBuffer()) return;
return res(ctx.status(200), ctx.json(uploadResponse));
}),
rest.post('/umbraco/management/api/v1/dictionary/import', async (req, res, ctx) => {
rest.post(umbracoPath('/dictionary/import'), async (req, res, ctx) => {
const file = req.url.searchParams.get('file');
if (!file || !importResponse.id) return;