remove ManifestElementTypes use ManifestElement
This commit is contained in:
@@ -3,8 +3,7 @@ import { css, html, nothing } from 'lit';
|
||||
import { customElement, state } from 'lit/decorators.js';
|
||||
import { UmbModalService } from '../../../../../../core/modal';
|
||||
import { UmbWorkspaceDataTypeContext } from '../../workspace-data-type.context';
|
||||
import { UmbDataTypeStoreItemType } from '../../../data-type.store';
|
||||
import type { DataTypeDetails, ManifestPropertyEditorUI } from '@umbraco-cms/models';
|
||||
import type { DataTypeDetails } from '@umbraco-cms/models';
|
||||
import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry';
|
||||
|
||||
import '../../../../../shared/property-editors/shared/property-editor-config/property-editor-config.element';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { nothing } from 'lit';
|
||||
import { customElement, property, state } from 'lit/decorators.js';
|
||||
import { map } from 'rxjs';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
import { ManifestBase, ManifestTypes, umbExtensionsRegistry } from '@umbraco-cms/extensions-registry';
|
||||
import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry';
|
||||
import { createExtensionElement } from '@umbraco-cms/extensions-api';
|
||||
import { isManifestElementableType } from 'src/core/extensions-api/is-manifest-elementable-type.function';
|
||||
import { UmbLitElement } from '@umbraco-cms/element';
|
||||
@@ -40,7 +40,7 @@ export class UmbExtensionSlotElement extends UmbLitElement {
|
||||
umbExtensionsRegistry
|
||||
?.extensionsOfType(this.type)
|
||||
.pipe(map((extensions) => extensions.filter(this.filter))),
|
||||
async (extensions: ManifestTypes[]) => {
|
||||
async (extensions) => {
|
||||
|
||||
const oldLength = this._extensions.length;
|
||||
this._extensions = this._extensions.filter(current => extensions.find(incoming => incoming.alias === current.alias));
|
||||
@@ -48,7 +48,7 @@ export class UmbExtensionSlotElement extends UmbLitElement {
|
||||
this.requestUpdate('_extensions');
|
||||
}
|
||||
|
||||
extensions.forEach(async (extension: ManifestTypes) => {
|
||||
extensions.forEach(async (extension) => {
|
||||
|
||||
const hasExt = this._extensions.find(x => x.alias === extension.alias);
|
||||
if(!hasExt) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { ManifestElementType } from '../models';
|
||||
import type { ManifestElement } from '../models';
|
||||
import { hasDefaultExport } from './has-default-export.function';
|
||||
import { isManifestElementNameType } from './is-manifest-element-name-type.function';
|
||||
import { loadExtension } from './load-extension.function';
|
||||
|
||||
export async function createExtensionElement(manifest: ManifestElementType): Promise<HTMLElement | undefined> {
|
||||
export async function createExtensionElement(manifest: ManifestElement): Promise<HTMLElement | undefined> {
|
||||
|
||||
//TODO: Write tests for these extension options:
|
||||
const js = await loadExtension(manifest);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ManifestElementType, ManifestElementWithElementName } from '../models';
|
||||
import type { ManifestElement, ManifestElementWithElementName } from '../models';
|
||||
|
||||
export function isManifestElementNameType(manifest: unknown): manifest is ManifestElementWithElementName {
|
||||
return (
|
||||
typeof manifest === 'object' && manifest !== null && (manifest as ManifestElementType).elementName !== undefined
|
||||
typeof manifest === 'object' && manifest !== null && (manifest as ManifestElement).elementName !== undefined
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { ManifestElementType, ManifestTypes } from "../extensions-registry/models";
|
||||
import type { ManifestElement, ManifestBase } from "../extensions-registry/models";
|
||||
import { isManifestElementNameType } from "./is-manifest-element-name-type.function";
|
||||
import { isManifestJSType } from "./is-manifest-js-type.function";
|
||||
import { isManifestLoaderType } from "./is-manifest-loader-type.function";
|
||||
|
||||
export function isManifestElementableType(manifest: ManifestTypes): manifest is ManifestElementType {
|
||||
export function isManifestElementableType(manifest: ManifestBase): manifest is ManifestElement {
|
||||
return isManifestElementNameType(manifest) || isManifestLoaderType(manifest) || isManifestJSType(manifest);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ManifestTypes } from "../extensions-registry/models";
|
||||
import type { ManifestBase } from "../extensions-registry/models";
|
||||
import { ManifestJSType } from "./load-extension.function";
|
||||
|
||||
export function isManifestJSType(manifest: ManifestTypes): manifest is ManifestJSType {
|
||||
export function isManifestJSType(manifest: ManifestBase): manifest is ManifestJSType {
|
||||
return (manifest as ManifestJSType).js !== undefined;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ManifestTypes } from "../extensions-registry/models";
|
||||
import type { ManifestBase } from "../extensions-registry/models";
|
||||
import { ManifestLoaderType } from "./load-extension.function";
|
||||
|
||||
export function isManifestLoaderType(manifest: ManifestTypes): manifest is ManifestLoaderType {
|
||||
export function isManifestLoaderType(manifest: ManifestBase): manifest is ManifestLoaderType {
|
||||
return typeof (manifest as ManifestLoaderType).loader === 'function';
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { ManifestTypes } from '../models';
|
||||
import type { ManifestElement } from '../models';
|
||||
import { isManifestJSType } from './is-manifest-js-type.function';
|
||||
import { isManifestLoaderType } from './is-manifest-loader-type.function';
|
||||
|
||||
export type ManifestLoaderType = ManifestTypes & { loader: () => Promise<object | HTMLElement> };
|
||||
export type ManifestJSType = ManifestTypes & { js: string };
|
||||
export type ManifestLoaderType = ManifestElement & { loader: () => Promise<object | HTMLElement> };
|
||||
export type ManifestJSType = ManifestElement & { js: string };
|
||||
|
||||
export async function loadExtension(manifest: ManifestTypes): Promise<object | HTMLElement | null> {
|
||||
export async function loadExtension(manifest: ManifestElement): Promise<object | HTMLElement | null> {
|
||||
try {
|
||||
if (isManifestLoaderType(manifest)) {
|
||||
return manifest.loader();
|
||||
|
||||
@@ -37,6 +37,7 @@ export * from './collection-bulk-action.models';
|
||||
export * from './collection-view.models';
|
||||
|
||||
export type ManifestTypes =
|
||||
| ManifestCustom
|
||||
| ManifestHeaderApp
|
||||
| ManifestSection
|
||||
| ManifestSectionView
|
||||
@@ -55,7 +56,6 @@ export type ManifestTypes =
|
||||
| ManifestPackageView
|
||||
| ManifestExternalLoginProvider
|
||||
| ManifestEntrypoint
|
||||
| ManifestCustom
|
||||
| ManifestCollectionBulkAction
|
||||
| ManifestCollectionView;
|
||||
|
||||
@@ -65,23 +65,6 @@ export type ManifestTypeMap = {
|
||||
[Manifest in ManifestTypes as Manifest['type']]: Manifest;
|
||||
};
|
||||
|
||||
export type ManifestElementType =
|
||||
| ManifestSection
|
||||
| ManifestSectionView
|
||||
| ManifestTree
|
||||
| ManifestTreeItemAction
|
||||
| ManifestWorkspace
|
||||
| ManifestWorkspaceView
|
||||
| ManifestPropertyAction
|
||||
| ManifestPropertyEditorUI
|
||||
| ManifestDashboard
|
||||
| ManifestUserDashboard
|
||||
| ManifestWorkspaceAction
|
||||
| ManifestPackageView
|
||||
| ManifestExternalLoginProvider
|
||||
| ManifestCollectionBulkAction
|
||||
| ManifestCollectionView;
|
||||
|
||||
|
||||
|
||||
export interface ManifestBase {
|
||||
|
||||
Reference in New Issue
Block a user