Merge branch 'main' into v14/feature/readonly-properties
This commit is contained in:
@@ -7,6 +7,11 @@ import { UmbPropertyValueChangeEvent } from '@umbraco-cms/backoffice/property-ed
|
||||
import { UMB_DATA_TYPE_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/data-type';
|
||||
import type { UmbBlockTypeWithGroupKey } from '@umbraco-cms/backoffice/block-type';
|
||||
import type { UUIComboboxElement, UUIComboboxEvent, UUIInputEvent } from '@umbraco-cms/backoffice/external/uui';
|
||||
import { UmbRepositoryItemsManager } from '@umbraco-cms/backoffice/repository';
|
||||
import {
|
||||
UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
type UmbDocumentTypeItemModel,
|
||||
} from '@umbraco-cms/backoffice/document-type';
|
||||
|
||||
@customElement('umb-property-editor-ui-block-grid-area-type-permission')
|
||||
export class UmbPropertyEditorUIBlockGridAreaTypePermissionElement
|
||||
@@ -24,20 +29,41 @@ export class UmbPropertyEditorUIBlockGridAreaTypePermissionElement
|
||||
@state()
|
||||
private _value: Array<UmbBlockGridTypeAreaTypePermission> = [];
|
||||
|
||||
_blockTypes: Array<UmbBlockTypeWithGroupKey> = [];
|
||||
|
||||
@state()
|
||||
private _blockTypes: Array<UmbBlockTypeWithGroupKey> = [];
|
||||
private _blockTypesWithElementName: Array<{ type: UmbBlockTypeWithGroupKey; name: string }> = [];
|
||||
|
||||
@state()
|
||||
private _blockGroups: Array<UmbBlockGridTypeGroupType> = [];
|
||||
|
||||
#itemsManager = new UmbRepositoryItemsManager<UmbDocumentTypeItemModel>(
|
||||
this,
|
||||
UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
|
||||
(x) => x.unique,
|
||||
);
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.observe(this.#itemsManager.items, (items) => {
|
||||
this._blockTypesWithElementName = items
|
||||
.map((item) => {
|
||||
const blockType = this._blockTypes.find((block) => block.contentElementTypeKey === item.unique);
|
||||
if (blockType) {
|
||||
return { type: blockType, name: item.name };
|
||||
}
|
||||
return undefined;
|
||||
})
|
||||
.filter((x) => x !== undefined) as Array<{ type: UmbBlockTypeWithGroupKey; name: string }>;
|
||||
});
|
||||
|
||||
this.consumeContext(UMB_DATA_TYPE_WORKSPACE_CONTEXT, async (context) => {
|
||||
this.observe(
|
||||
await context.propertyValueByAlias<Array<UmbBlockTypeWithGroupKey>>('blocks'),
|
||||
(blockTypes) => {
|
||||
this._blockTypes = blockTypes ?? [];
|
||||
this.#itemsManager.setUniques(blockTypes.map((block) => block.contentElementTypeKey));
|
||||
},
|
||||
'observeBlockType',
|
||||
);
|
||||
@@ -103,7 +129,7 @@ export class UmbPropertyEditorUIBlockGridAreaTypePermissionElement
|
||||
this._value,
|
||||
(permission) => permission,
|
||||
(permission, index) => {
|
||||
const showCategoryHeader = this._blockGroups.length && this._blockTypes.length;
|
||||
const showCategoryHeader = this._blockGroups.length > 0 && this._blockTypesWithElementName.length > 0;
|
||||
|
||||
return html`<div class="permission-setting">
|
||||
<uui-combobox
|
||||
@@ -169,13 +195,13 @@ export class UmbPropertyEditorUIBlockGridAreaTypePermissionElement
|
||||
|
||||
#renderBlockTypes(area: UmbBlockGridTypeAreaTypePermission) {
|
||||
return repeat(
|
||||
this._blockTypes,
|
||||
(block) => block.contentElementTypeKey,
|
||||
this._blockTypesWithElementName,
|
||||
(block) => block.type.contentElementTypeKey,
|
||||
(block) =>
|
||||
html`<uui-combobox-list-option
|
||||
.value=${block.contentElementTypeKey}
|
||||
?selected=${area.elementTypeKey === block.contentElementTypeKey}>
|
||||
${block.label}
|
||||
.value=${block.type.contentElementTypeKey}
|
||||
?selected=${area.elementTypeKey === block.type.contentElementTypeKey}>
|
||||
${block.name}
|
||||
</uui-combobox-list-option>`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import type { ManifestTypes } from '../models/index.js';
|
||||
import { manifest as menuAliasConditionManifest } from './menu-alias.condition.js';
|
||||
import { manifest as multipleAppLanguagesConditionManifest } from './multiple-app-languages.condition.js';
|
||||
import { manifest as sectionAliasConditionManifest } from './section-alias.condition.js';
|
||||
import { manifest as switchConditionManifest } from './switch.condition.js';
|
||||
|
||||
export const manifests: Array<ManifestTypes> = [
|
||||
menuAliasConditionManifest,
|
||||
multipleAppLanguagesConditionManifest,
|
||||
sectionAliasConditionManifest,
|
||||
switchConditionManifest,
|
||||
];
|
||||
|
||||
@@ -17,9 +17,13 @@ export class UmbMenuAliasCondition extends UmbConditionBase<MenuAliasConditionCo
|
||||
super(host, args);
|
||||
|
||||
this.consumeContext(UMB_MENU_CONTEXT, (context) => {
|
||||
this.observe(context.alias, (MenuAlias) => {
|
||||
this.permitted = MenuAlias === this.config.match;
|
||||
});
|
||||
this.observe(
|
||||
context.alias,
|
||||
(MenuAlias) => {
|
||||
this.permitted = MenuAlias === this.config.match;
|
||||
},
|
||||
'observeAlias',
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { UmbConditionBase } from './condition-base.controller.js';
|
||||
import { UMB_APP_LANGUAGE_CONTEXT } from '@umbraco-cms/backoffice/language';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import type {
|
||||
ManifestCondition,
|
||||
UmbConditionConfigBase,
|
||||
UmbConditionControllerArguments,
|
||||
UmbExtensionCondition,
|
||||
} from '@umbraco-cms/backoffice/extension-api';
|
||||
|
||||
export type UmbMultipleAppLanguageConditionConfig = UmbConditionConfigBase;
|
||||
|
||||
export class UmbMultipleAppLanguageCondition
|
||||
extends UmbConditionBase<UmbMultipleAppLanguageConditionConfig>
|
||||
implements UmbExtensionCondition
|
||||
{
|
||||
constructor(host: UmbControllerHost, args: UmbConditionControllerArguments<UmbMultipleAppLanguageConditionConfig>) {
|
||||
super(host, args);
|
||||
|
||||
this.consumeContext(UMB_APP_LANGUAGE_CONTEXT, (context) => {
|
||||
this.observe(
|
||||
context.moreThanOneLanguage,
|
||||
(moreThanOneLanguage) => {
|
||||
this.permitted = moreThanOneLanguage;
|
||||
},
|
||||
'observeLanguages',
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const manifest: ManifestCondition = {
|
||||
type: 'condition',
|
||||
name: 'Multiple App Languages Condition',
|
||||
alias: 'Umb.Condition.MultipleAppLanguages',
|
||||
api: UmbMultipleAppLanguageCondition,
|
||||
};
|
||||
@@ -24,9 +24,13 @@ export class UmbSectionAliasCondition
|
||||
|
||||
if (permissionCheck !== undefined) {
|
||||
this.consumeContext(UMB_SECTION_CONTEXT, (context) => {
|
||||
this.observe(context.alias, (sectionAlias) => {
|
||||
this.permitted = sectionAlias ? permissionCheck!(sectionAlias) : false;
|
||||
});
|
||||
this.observe(
|
||||
context.alias,
|
||||
(sectionAlias) => {
|
||||
this.permitted = sectionAlias ? permissionCheck!(sectionAlias) : false;
|
||||
},
|
||||
'observeAlias',
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { CollectionBulkActionPermissionConditionConfig } from '../../collec
|
||||
import type { UmbSectionUserPermissionConditionConfig } from '../../section/conditions/index.js';
|
||||
import type { SectionAliasConditionConfig } from './section-alias.condition.js';
|
||||
import type { SwitchConditionConfig } from './switch.condition.js';
|
||||
import type { UmbMultipleAppLanguageConditionConfig } from './multiple-app-languages.condition.js';
|
||||
import type {
|
||||
WorkspaceAliasConditionConfig,
|
||||
WorkspaceEntityTypeConditionConfig,
|
||||
@@ -29,8 +30,9 @@ export type ConditionTypes =
|
||||
| CollectionBulkActionPermissionConditionConfig
|
||||
| SectionAliasConditionConfig
|
||||
| SwitchConditionConfig
|
||||
| UmbConditionConfigBase
|
||||
| UmbDocumentUserPermissionConditionConfig
|
||||
| UmbMultipleAppLanguageConditionConfig
|
||||
| UmbSectionUserPermissionConditionConfig
|
||||
| WorkspaceAliasConditionConfig
|
||||
| WorkspaceEntityTypeConditionConfig
|
||||
| UmbConditionConfigBase;
|
||||
| WorkspaceEntityTypeConditionConfig;
|
||||
|
||||
@@ -45,7 +45,7 @@ export class UmbPropertyEditorUIDocumentTypePickerElement extends UmbLitElement
|
||||
.min=${this.min}
|
||||
.max=${this.max}
|
||||
.value=${this.value}
|
||||
?elementTypesOnly=${this.onlyElementTypes}
|
||||
.elementTypesOnly=${this.onlyElementTypes ?? false}
|
||||
?showOpenButton=${this.showOpenButton}
|
||||
@change=${this.#onChange}>
|
||||
</umb-input-document-type>
|
||||
|
||||
@@ -12,6 +12,9 @@ const entityActions: Array<ManifestSectionSidebarApp> = [
|
||||
alias: 'Umb.Condition.SectionAlias',
|
||||
match: 'Umb.Section.Content',
|
||||
},
|
||||
{
|
||||
alias: 'Umb.Condition.MultipleAppLanguages',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -12,6 +12,7 @@ import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth';
|
||||
export class UmbAppLanguageContext extends UmbContextBase<UmbAppLanguageContext> implements UmbApi {
|
||||
#languageCollectionRepository: UmbLanguageCollectionRepository;
|
||||
#languages = new UmbArrayState<UmbLanguageDetailModel>([], (x) => x.unique);
|
||||
moreThanOneLanguage = this.#languages.asObservablePart((x) => x.length > 1);
|
||||
|
||||
#appLanguage = new UmbObjectState<UmbLanguageDetailModel | undefined>(undefined);
|
||||
appLanguage = this.#appLanguage.asObservable();
|
||||
|
||||
@@ -90,7 +90,7 @@ export class UmbWebhookDetailsWorkspaceViewElement extends UmbLitElement impleme
|
||||
slot="editor"
|
||||
@change=${this.#onTypesChange}
|
||||
.selection=${this._webhook?.contentTypes ?? []}
|
||||
?documentTypesOnly=${true}></umb-input-document-type>
|
||||
.documentTypesOnly=${true}></umb-input-document-type>
|
||||
`;
|
||||
case 'Media':
|
||||
return html`
|
||||
|
||||
Reference in New Issue
Block a user