get rest from window
This commit is contained in:
@@ -44,7 +44,7 @@ The frontend has an API formatter that takes the OpenAPI schema file and convert
|
||||
|
||||
**How to convert it:**
|
||||
|
||||
* Run `npm run generate:api`
|
||||
- Run `npm run generate:api`
|
||||
|
||||
## A contribution example
|
||||
|
||||
@@ -56,9 +56,9 @@ The frontend has an API formatter that takes the OpenAPI schema file and convert
|
||||
|
||||
Links for Lit examples and documentation:
|
||||
|
||||
* [https://lit.dev](https://lit.dev)
|
||||
* [https://lit.dev/docs/](https://lit.dev/docs/)
|
||||
* [https://lit.dev/playground/](https://lit.dev/playground/)
|
||||
- [https://lit.dev](https://lit.dev)
|
||||
- [https://lit.dev/docs/](https://lit.dev/docs/)
|
||||
- [https://lit.dev/playground/](https://lit.dev/playground/)
|
||||
|
||||
### Functionality
|
||||
|
||||
@@ -128,28 +128,29 @@ To declare the Published Cache Status Dashboard as a new manifest, we need to ad
|
||||
|
||||
Let’s go through each of these properties…
|
||||
|
||||
* Type: can be one of the following:
|
||||
* section - examples include: `Content`, `Media`
|
||||
* dashboard - a view within a section. Examples include: the welcome dashboard
|
||||
* propertyEditorUI
|
||||
* editorView
|
||||
* propertyAction
|
||||
* tree
|
||||
* editor
|
||||
* treeItemAction
|
||||
- Type: can be one of the following:
|
||||
|
||||
* Alias: is the unique key used to identify this item.
|
||||
* Name: is the human-readable name for this item.
|
||||
- section - examples include: `Content`, `Media`
|
||||
- dashboard - a view within a section. Examples include: the welcome dashboard
|
||||
- propertyEditorUI
|
||||
- editorView
|
||||
- propertyAction
|
||||
- tree
|
||||
- editor
|
||||
- treeItemAction
|
||||
|
||||
* ElementName: this is the customElementName declared on the element at the top of the file i.e
|
||||
- Alias: is the unique key used to identify this item.
|
||||
- Name: is the human-readable name for this item.
|
||||
|
||||
- ElementName: this is the customElementName declared on the element at the top of the file i.e
|
||||
|
||||
```typescript
|
||||
@customElement('umb-dashboard-published-status')
|
||||
```
|
||||
|
||||
* Loader: references a function call to import the file that the element is declared within
|
||||
- Loader: references a function call to import the file that the element is declared within
|
||||
|
||||
* Meta: allows us to reference additional data - in our case we can specify the section that our dashboard will sit within, the pathname that will be displayed in the url and the weight of the section
|
||||
- Meta: allows us to reference additional data - in our case we can specify the section that our dashboard will sit within, the pathname that will be displayed in the url and the weight of the section
|
||||
|
||||
## API mock handlers
|
||||
|
||||
@@ -162,19 +163,19 @@ From the existing functionality, we can see that this is a string message that i
|
||||
So to define this, we must first add a handler for the Published Status called `published-status.handlers.ts` within the mocks/domains folder. In this file we will have code that looks like the following:
|
||||
|
||||
```typescript
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbracoPath } from '@umbraco-cms/utils';
|
||||
|
||||
export const handlers = [
|
||||
rest.get(umbracoPath('/published-cache/status'), (_req, res, ctx) => {
|
||||
return res(
|
||||
// Respond with a 200 status code
|
||||
ctx.status(200),
|
||||
ctx.json<string>(
|
||||
'Database cache is ok. ContentStore contains 1 item and has 1 generation and 0 snapshot. MediaStore contains 5 items and has 1 generation and 0 snapshot.'
|
||||
)
|
||||
);
|
||||
}),
|
||||
rest.get(umbracoPath('/published-cache/status'), (_req, res, ctx) => {
|
||||
return res(
|
||||
// Respond with a 200 status code
|
||||
ctx.status(200),
|
||||
ctx.json<string>(
|
||||
'Database cache is ok. ContentStore contains 1 item and has 1 generation and 0 snapshot. MediaStore contains 5 items and has 1 generation and 0 snapshot.'
|
||||
)
|
||||
);
|
||||
}),
|
||||
];
|
||||
```
|
||||
|
||||
@@ -211,7 +212,7 @@ In depth: [https://storybook.js.org/docs/web-components/get-started/introduction
|
||||
|
||||
Reference: [https://ambitious-stone-0033b3603.1.azurestaticapps.net/](https://ambitious-stone-0033b3603.1.azurestaticapps.net/)
|
||||
|
||||
* Locally: `npm run storybook`
|
||||
- Locally: `npm run storybook`
|
||||
|
||||
For Umbraco UI stories, please navigate to [https://uui.umbraco.com/](https://uui.umbraco.com/)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
import { ProblemDetailsModel, RuntimeLevelModel, ServerStatusResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
import { ProblemDetailsModel, RuntimeLevelModel, ServerStatusResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { expect, test } from './test';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
|
||||
import { umbCulturesData } from '../data/culture.data';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbDataTypeData } from '../../data/data-type.data';
|
||||
import { slug } from './slug';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbDataTypeData } from '../../data/data-type.data';
|
||||
import { slug } from './slug';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbDataTypeData } from '../../data/data-type.data';
|
||||
import { slug } from './slug';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbDataTypeData } from '../../data/data-type.data';
|
||||
import { slug } from './slug';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbDataTypeData } from '../../data/data-type.data';
|
||||
import { slug } from './slug';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbDataTypeData } from '../../data/data-type.data';
|
||||
import { slug } from './slug';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbDictionaryData } from '../data/dictionary.data';
|
||||
import {
|
||||
ImportDictionaryRequestModel,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbDocumentTypeData } from '../data/document-type.data';
|
||||
import type { DocumentTypeResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbDocumentData } from '../data/document.data';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { searchResultMockData, getIndexByName, PagedIndexers } from '../data/examine.data';
|
||||
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
import { IndexResponseModel, PagedIndexResponseModel, PagedSearcherResponseModel, PagedSearchResultResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import {
|
||||
IndexResponseModel,
|
||||
PagedIndexResponseModel,
|
||||
PagedSearcherResponseModel,
|
||||
PagedSearchResultResponseModel,
|
||||
} from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
export const handlers = [
|
||||
rest.get(umbracoPath('/indexer'), (_req, res, ctx) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
|
||||
import {
|
||||
getGroupByName,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import {
|
||||
DatabaseInstallResponseModel,
|
||||
InstallVResponseModel,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbLanguagesData } from '../data/languages.data';
|
||||
import { LanguageResponseModel, ProblemDetailsModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbLogViewerData } from '../data/log-viewer.data';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
import { SavedLogSearchRequestModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
|
||||
import type { PackageManifestResponse } from '../../../backoffice/packages/types';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbMediaTypeData } from '../data/media-type.data';
|
||||
|
||||
// TODO: add schema
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbMediaData } from '../data/media.data';
|
||||
import type { MediaDetails } from '../../../backoffice/media/media';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbMemberGroupData } from '../data/member-group.data';
|
||||
|
||||
// TODO: add schema
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbMemberTypeData } from '../data/member-type.data';
|
||||
|
||||
// TODO: add schema
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbMemberData } from '../data/member.data';
|
||||
|
||||
// TODO: add schema
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
import { ModelsBuilderResponseModel, ModelsModeModel, OutOfDateStatusResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import {
|
||||
ModelsBuilderResponseModel,
|
||||
ModelsModeModel,
|
||||
OutOfDateStatusResponseModel,
|
||||
} from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
export const handlers = [
|
||||
rest.post(umbracoPath('/models-builder/build'), async (_req, res, ctx) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { UmbId } from '@umbraco-cms/backoffice/id';
|
||||
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbPartialViewsData } from '../data/partial-views.data';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
import type { ProfilingStatusResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
import {
|
||||
PagedRedirectUrlResponseModel,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbRelationTypeData } from '../data/relation-type.data';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { OEmbedResult, OEmbedStatus } from '@umbraco-cms/backoffice/modal';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { rest } from 'msw';
|
||||
import { RuntimeLevelModel, ServerStatusResponseModel, VersionResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import {
|
||||
RuntimeLevelModel,
|
||||
ServerStatusResponseModel,
|
||||
VersionResponseModel,
|
||||
} from '@umbraco-cms/backoffice/backend-api';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
export const serverRunningHandler = rest.get(umbracoPath('/server/status'), (_req, res, ctx) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbStylesheetData } from '../data/stylesheet.data';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
import { PagedTagResponseModel, TagResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
import { PagedTelemetryResponseModel, TelemetryResponseModel, TelemetryLevelModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import {
|
||||
PagedTelemetryResponseModel,
|
||||
TelemetryResponseModel,
|
||||
TelemetryLevelModel,
|
||||
} from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
let telemetryLevel = TelemetryLevelModel.BASIC;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbTemplateData } from '../data/template.data';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
import { CreateTemplateRequestModel, UpdateTemplateRequestModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbMediaData } from '../data/media.data';
|
||||
|
||||
// TODO: add schema
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
import type { UpgradeSettingsResponseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
import { umbUserGroupsData } from '../data/user-groups.data';
|
||||
import type { UserGroupDetails } from '../../../backoffice/users/user-groups/types';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
|
||||
import { umbUsersData } from '../data/users.data';
|
||||
import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
@@ -2,7 +2,7 @@ import './installer-database.element';
|
||||
|
||||
import { Meta, Story } from '@storybook/web-components';
|
||||
import { html } from 'lit';
|
||||
import { rest } from 'msw';
|
||||
const { rest } = window.MockServiceWorker;
|
||||
|
||||
import { installerContextProvider } from '../shared/utils.story-helpers';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user