bulks actions

This commit is contained in:
Niels Lyngsø
2023-10-09 15:45:48 +02:00
parent 93c0848839
commit 538e143909
41 changed files with 209 additions and 146 deletions

View File

@@ -69,13 +69,15 @@ export class UmbExtensionElementController<
protected async _conditionsAreGood() {
const manifest = this.manifest!; // In this case we are sure its not undefined.
console.log("---defaultElement", this._defaultElement)
if (isManifestElementableType(manifest)) {
const newComponent = await createExtensionElement(manifest);
const newComponent = await createExtensionElement(manifest, this._defaultElement);
if (!this._positive) {
// We are not positive anymore, so we will back out of this creation.
return false;
}
this._component = newComponent;
} else if (this._defaultElement) {
this._component = document.createElement(this._defaultElement);
} else {

View File

@@ -4,7 +4,7 @@ import { loadExtensionApi } from './load-extension-api.function.js';
//TODO: Write tests for this method:
export async function createExtensionApi<ApiType = unknown>(
manifest: ManifestApi | ManifestElementAndApi,
manifest: ManifestApi<ApiType> | ManifestElementAndApi<any, ApiType>,
constructorArguments: unknown[]
): Promise<ApiType | undefined> {
const js = await loadExtensionApi(manifest);

View File

@@ -3,11 +3,12 @@ import type { HTMLElementConstructor, ManifestElement } from './types.js';
import { loadExtensionElement } from './load-extension-element.function.js';
export async function createExtensionElement<ElementType extends HTMLElement>(
manifest: ManifestElement<ElementType>
manifest: ManifestElement<ElementType>, defaultElement?: string
): Promise<ElementType | undefined> {
//TODO: Write tests for these extension options:
const js = await loadExtensionElement(manifest);
console.log("defaultElement", defaultElement)
if (isManifestElementNameType(manifest)) {
// created by manifest method providing HTMLElement
return document.createElement(manifest.elementName) as ElementType;
@@ -23,18 +24,16 @@ export async function createExtensionElement<ElementType extends HTMLElement>(
// Element will be created by default class
return new js.default();
}
}
// If some JS was loaded and manifest did not have a elementName neither it the JS file contain a default export, so we will fail:
console.error(
'-- Extension did not succeed creating an element, missing a default export of the served JavaScript file',
manifest
);
return undefined;
if(defaultElement) {
return document.createElement(defaultElement) as ElementType;
}
// If some JS was loaded and manifest did not have a elementName neither it the JS file contain a default export, so we will fail:
console.error(
'-- Extension did not succeed creating an element, missing a default export or `elementName` in the manifest.',
'-- Extension did not succeed creating an element, missing a `element` or `default` export of the JavaScript file or `elementName` in the manifest.',
manifest
);
return undefined;

View File

@@ -2,6 +2,6 @@ import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api
export interface UmbAction<RepositoryType = unknown> {
host: UmbControllerHostElement;
repository: RepositoryType;
repository?: RepositoryType;
execute(): Promise<void>;
}

View File

@@ -0,0 +1,42 @@
import { UMB_COLLECTION_CONTEXT } from './collection.context.js';
import { UmbBaseController } from '@umbraco-cms/backoffice/controller-api';
import {
ManifestCondition,
UmbConditionConfigBase,
UmbConditionControllerArguments,
UmbExtensionCondition,
} from '@umbraco-cms/backoffice/extension-api';
export class UmbCollectionEntityTypeCondition extends UmbBaseController implements UmbExtensionCondition {
config: CollectionEntityTypeConditionConfig;
permitted = false;
#onChange: () => void;
constructor(args: UmbConditionControllerArguments<CollectionEntityTypeConditionConfig>) {
super(args.host);
this.config = args.config;
this.#onChange = args.onChange;
this.consumeContext(UMB_COLLECTION_CONTEXT, (context) => {
this.permitted = context.getEntityType().toLowerCase() === this.config.match.toLowerCase();
this.#onChange();
});
}
}
export type CollectionEntityTypeConditionConfig = UmbConditionConfigBase<'Umb.Condition.CollectionEntityType'> & {
/**
* Define the workspace that this extension should be available in
*
* @example
* "Document"
*/
match: string;
};
export const manifest: ManifestCondition = {
type: 'condition',
name: 'Collection Entity Type Condition',
alias: 'Umb.Condition.CollectionEntityType',
api: UmbCollectionEntityTypeCondition,
};

View File

@@ -1,14 +1,11 @@
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import { css, html, nothing, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { map } from '@umbraco-cms/backoffice/external/rxjs';
import { UMB_COLLECTION_CONTEXT_TOKEN, UmbCollectionContext } from '@umbraco-cms/backoffice/collection';
import { ManifestEntityBulkAction, umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { UMB_COLLECTION_CONTEXT, UmbCollectionContext } from '@umbraco-cms/backoffice/collection';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import { UmbExecutedEvent } from '@umbraco-cms/backoffice/events';
@customElement('umb-collection-selection-actions')
export class UmbCollectionSelectionActionsElement extends UmbLitElement {
#entityType?: string;
@state()
private _nodesLength = 0;
@@ -16,22 +13,13 @@ export class UmbCollectionSelectionActionsElement extends UmbLitElement {
@state()
private _selectionLength = 0;
@state()
private _entityBulkActions: Array<ManifestEntityBulkAction> = [];
private _collectionContext?: UmbCollectionContext<any, any>;
private _selection: Array<string> = [];
constructor() {
super();
this.consumeContext(UMB_COLLECTION_CONTEXT_TOKEN, (instance) => {
this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
this._collectionContext = instance;
this._observeCollectionContext();
if (instance.getEntityType()) {
this.#entityType = instance.getEntityType() ?? undefined;
this.#observeEntityBulkActions();
}
});
}
@@ -55,29 +43,12 @@ export class UmbCollectionSelectionActionsElement extends UmbLitElement {
this.observe(this._collectionContext.selection, (selection) => {
this._selectionLength = selection.length;
this._selection = selection;
}, 'observeSelection');
}
private _renderSelectionCount() {
return html`<div>${this._selectionLength} of ${this._nodesLength} selected</div>`;
}
// TODO: find a solution to use extension slot
#observeEntityBulkActions() {
this.observe(
umbExtensionsRegistry.extensionsOfType('entityBulkAction').pipe(
map((extensions) => {
return extensions.filter((extension) => extension.conditions.entityType === this.#entityType);
})
),
(bulkActions) => {
this._entityBulkActions = bulkActions;
}
, 'observeEntityBulkActions'
);
}
#onActionExecuted(event: UmbExecutedEvent) {
event.stopPropagation();
this._collectionContext?.clearSelection();
@@ -97,15 +68,8 @@ export class UmbCollectionSelectionActionsElement extends UmbLitElement {
${this._renderSelectionCount()}
</div>
<div id="actions">
${this._entityBulkActions?.map(
(manifest) =>
html`<umb-entity-bulk-action
@executed=${this.#onActionExecuted}
.selection=${this._selection}
.manifest=${manifest}></umb-entity-bulk-action>`
)}
</div>
<umb-extension-slot id="actions" type="entityBulkAction" default-element="umb-entity-bulk-action" @action-executed=${this.#onActionExecuted}>
</umb-extension-slot>
</div>
`;
}

View File

@@ -1,3 +1,4 @@
import { UmbCollectionRepository } from '@umbraco-cms/backoffice/repository';
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
import {
@@ -8,13 +9,12 @@ import {
} from '@umbraco-cms/backoffice/observable-api';
import { createExtensionApi } from '@umbraco-cms/backoffice/extension-api';
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { UmbCollectionRepository } from '@umbraco-cms/backoffice/repository';
import type { UmbCollectionFilterModel } from '@umbraco-cms/backoffice/collection';
// TODO: Clean up the need for store as Media has switched to use Repositories(repository).
export class UmbCollectionContext<ItemType, FilterModelType extends UmbCollectionFilterModel> {
private _host: UmbControllerHostElement;
private _entityType: string | null;
private _entityType: string;
protected _dataObserver?: UmbObserverController<ItemType[]>;
@@ -38,7 +38,7 @@ export class UmbCollectionContext<ItemType, FilterModelType extends UmbCollectio
public readonly search = this._search.asObservable();
*/
constructor(host: UmbControllerHostElement, entityType: string | null, repositoryAlias: string) {
constructor(host: UmbControllerHostElement, entityType: string, repositoryAlias: string) {
this._entityType = entityType;
this._host = host;
@@ -63,6 +63,9 @@ export class UmbCollectionContext<ItemType, FilterModelType extends UmbCollectio
if (!value) return;
this.#selection.next(value);
}
public getSelection() {
this.#selection.getValue();
}
public clearSelection() {
this.#selection.next([]);
@@ -147,4 +150,4 @@ export class UmbCollectionContext<ItemType, FilterModelType extends UmbCollectio
}
}
export const UMB_COLLECTION_CONTEXT_TOKEN = new UmbContextToken<UmbCollectionContext<any, any>>('UmbCollectionContext');
export const UMB_COLLECTION_CONTEXT = new UmbContextToken<UmbCollectionContext<any, any>>('UmbCollectionContext');

View File

@@ -1,7 +1,7 @@
import { UmbTextStyles } from "@umbraco-cms/backoffice/style";
import { css, html, nothing, customElement, state, property } from '@umbraco-cms/backoffice/external/lit';
import { map } from '@umbraco-cms/backoffice/external/rxjs';
import { UmbCollectionContext, UMB_COLLECTION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/collection';
import { UmbCollectionContext, UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection';
import { createExtensionElement } from '@umbraco-cms/backoffice/extension-api';
import { ManifestCollectionView, umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
@@ -36,7 +36,7 @@ export class UmbCollectionElement extends UmbLitElement {
constructor() {
super();
this.consumeContext(UMB_COLLECTION_CONTEXT_TOKEN, (instance) => {
this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
this._collectionContext = instance;
this._observeCollectionContext();
});

View File

@@ -1,5 +1,5 @@
import { css, html, customElement, state, ifDefined } from '@umbraco-cms/backoffice/external/lit';
import { UMB_COLLECTION_CONTEXT_TOKEN, UmbCollectionContext } from '@umbraco-cms/backoffice/collection';
import { UMB_COLLECTION_CONTEXT, UmbCollectionContext } from '@umbraco-cms/backoffice/collection';
import type { ManifestDashboardCollection } from '@umbraco-cms/backoffice/extension-registry';
import type { FolderTreeItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
@@ -23,7 +23,7 @@ export class UmbDashboardCollectionElement extends UmbLitElement {
const repositoryAlias = this.manifest.meta.repositoryAlias;
this._entityType = this.manifest.conditions.entityType;
this._collectionContext = new UmbCollectionContext(this, this._entityType, repositoryAlias);
this.provideContext(UMB_COLLECTION_CONTEXT_TOKEN, this._collectionContext);
this.provideContext(UMB_COLLECTION_CONTEXT, this._collectionContext);
}
}

View File

@@ -1,3 +1,4 @@
export * from './collection.context.js';
export * from './collection-filter-model.interface.js';
export * from './collection-selection-actions.element.js';
export { type CollectionEntityTypeConditionConfig } from './collection-entity-type.condition.js';

View File

@@ -0,0 +1,3 @@
import { manifest as collectionEntityTypeCondition } from './collection-entity-type.condition.js';
export const manifests = [collectionEntityTypeCondition];

View File

@@ -92,7 +92,7 @@ export class UmbExtensionSlotElement extends UmbLitElement {
#props?: Record<string, unknown> = {};
@property({ type: String, attribute: 'default-element' })
public defaultElement = '';
public defaultElement?:string;
@property()
public renderMethod?: (extension: UmbExtensionElementController) => TemplateResult | HTMLElement | null | undefined;

View File

@@ -40,7 +40,7 @@ export class UmbEntityActionElement extends UmbLitElement {
if (!this._manifest) return;
if (this._unique === undefined) return;
this.#api = createExtensionApi(this._manifest, [this._manifest.meta.repositoryAlias, this.unique]);
this.#api = createExtensionApi(this._manifest, [this, this._manifest.meta.repositoryAlias, this.unique]);
// TODO: Fix so when we use a HREF it does not refresh the page?
this._href = await this.#api.getHref?.();

View File

@@ -36,8 +36,9 @@ export class UmbEntityBulkActionElement extends UmbLitElement {
}
async #createApi() {
if (!this._manifest?.meta.api) return;
this.#api = await createExtensionApi(this._manifest, [this._manifest.meta.repositoryAlias, this._selection]);
if (!this._manifest) return;
this.#api = await createExtensionApi(this._manifest, [this, this._manifest.meta.repositoryAlias, this._selection]);
}
#api?: UmbEntityBulkAction;

View File

@@ -1,14 +1,19 @@
import type { SectionAliasConditionConfig } from './section-alias.condition.js';
import type { SwitchConditionConfig } from './switch.condition.js';
import type { WorkspaceAliasConditionConfig } from '@umbraco-cms/backoffice/workspace';
import type { WorkspaceAliasConditionConfig, WorkspaceEntityTypeConditionConfig } from '@umbraco-cms/backoffice/workspace';
import type { UmbConditionConfigBase } from '@umbraco-cms/backoffice/extension-api';
import type { UserPermissionConditionConfig } from '@umbraco-cms/backoffice/current-user';
import type { CollectionEntityTypeConditionConfig } from '@umbraco-cms/backoffice/collection';
/* TODO: in theory should't the core package import from other packages.
Are there any other way we can do this? */
Are there any other way we can do this?
Niels: Sadly I don't see any other solutions currently. But are very open for ideas :-) now that I think about it maybe there is some ability to extend a global type, similar to the 'declare global' trick we use on Elements.
*/
export type ConditionTypes =
| CollectionEntityTypeConditionConfig
| SectionAliasConditionConfig
| WorkspaceAliasConditionConfig
| WorkspaceEntityTypeConditionConfig
| SwitchConditionConfig
| UserPermissionConditionConfig
| UmbConditionConfigBase;

View File

@@ -1,10 +1,12 @@
import type { ManifestElementAndApi, ManifestWithConditions } from '@umbraco-cms/backoffice/extension-api';
import type { ConditionTypes } from '../conditions/types.js';
import type { UmbEntityBulkAction } from '@umbraco-cms/backoffice/entity-bulk-action';
import type { ManifestElementAndApi, ManifestWithDynamicConditions } from '@umbraco-cms/backoffice/extension-api';
/**
* An action to perform on multiple entities
* For example for content you may wish to move one or more documents in bulk
*/
export interface ManifestEntityBulkAction extends ManifestElementAndApi, ManifestWithConditions<ConditionsEntityBulkAction> {
export interface ManifestEntityBulkAction extends ManifestElementAndApi<HTMLElement, UmbEntityBulkAction>, ManifestWithDynamicConditions<ConditionTypes> {
type: 'entityBulkAction';
meta: MetaEntityBulkAction;
}
@@ -25,17 +27,3 @@ export interface MetaEntityBulkAction {
*/
repositoryAlias: string;
}
export interface ConditionsEntityBulkAction {
/**
* The entity type this action is for
*
* @examples [
* "document",
* "media",
* "user",
* "user-group"
* ]
*/
entityType: string;
}

View File

@@ -4,6 +4,7 @@ import { manifests as localizationManifests } from './localization/manifests.js'
import { manifests as propertyActionManifests } from './property-action/manifests.js';
import { manifests as propertyEditorManifests } from './property-editor/manifests.js';
import { manifests as tinyMcePluginManifests } from './property-editor/uis/tiny-mce/plugins/manifests.js';
import { manifests as collectionManifests } from './collection/manifests.js';
import { manifests as workspaceManifests } from './workspace/manifests.js';
import { manifests as modalManifests } from './modal/common/manifests.js';
import { manifests as themeManifests } from './themes/manifests.js';
@@ -22,7 +23,6 @@ import {
export * from './localization/index.js';
export * from './action/index.js';
export * from './collection/index.js';
export * from './components/index.js';
export * from './content-type/index.js';
export * from './debug/index.js';
@@ -52,6 +52,7 @@ const manifests: Array<ManifestTypes | UmbBackofficeManifestKind> = [
...propertyActionManifests,
...propertyEditorManifests,
...tinyMcePluginManifests,
...collectionManifests,
...workspaceManifests,
...modalManifests,
...themeManifests,

View File

@@ -75,7 +75,7 @@ export class UmbSectionSidebarContextMenuElement extends UmbLitElement {
? html`<div id="action-modal">
<h3>${this._headline}</h3>
<umb-entity-action-list
@executed=${this.#onActionExecuted}
@action-executed=${this.#onActionExecuted}
.entityType=${this._entityType}
.unique=${this._unique}></umb-entity-action-list>
</div>`

View File

@@ -1,7 +1,8 @@
export * from './variant-context/index.js';
export * from './workspace-action-menu/index.js';
export * from './workspace-action/index.js';
export * from './workspace-alias.condition.js';
export type { WorkspaceAliasConditionConfig } from './workspace-alias.condition.js';
export type { WorkspaceEntityTypeConditionConfig } from './workspace-entity-type.condition.js';
export * from './workspace-context/index.js';
export * from './workspace-editor/index.js';
export * from './workspace-footer/index.js';

View File

@@ -1,4 +1,5 @@
import { manifests as workspaceModals } from './workspace-modal/manifests.js';
import { manifest as workspaceCondition } from './workspace-alias.condition.js';
import { manifest as workspaceAliasCondition } from './workspace-alias.condition.js';
import { manifest as workspaceEntityTypeCondition } from './workspace-entity-type.condition.js';
export const manifests = [...workspaceModals, workspaceCondition];
export const manifests = [...workspaceModals, workspaceAliasCondition, workspaceEntityTypeCondition];

View File

@@ -56,7 +56,7 @@ export class UmbWorkspaceActionMenuElement extends UmbLitElement {
<div id="action-menu-dropdown" slot="popover">
<uui-scroll-container>
<umb-entity-action-list
@executed=${this.#onActionExecuted}
@action-executed=${this.#onActionExecuted}
.entityType=${this._entityType}
.unique=${this._entityId}>
</umb-entity-action-list>

View File

@@ -1,6 +1,6 @@
import { css, html, customElement, ifDefined } from '@umbraco-cms/backoffice/external/lit';
import { UmbTextStyles } from "@umbraco-cms/backoffice/style";
import { UmbCollectionContext, UMB_COLLECTION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/collection';
import { UmbCollectionContext, UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import type { FolderTreeItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
import type { ManifestWorkspaceViewCollection } from '@umbraco-cms/backoffice/extension-registry';
@@ -34,7 +34,7 @@ export class UmbWorkspaceViewCollectionElement extends UmbLitElement {
const manifestMeta = this.manifest.meta;
this._collectionContext = new UmbCollectionContext(this, entityType, manifestMeta.repositoryAlias);
this.provideContext(UMB_COLLECTION_CONTEXT_TOKEN, this._collectionContext);
this.provideContext(UMB_COLLECTION_CONTEXT, this._collectionContext);
}
}

View File

@@ -0,0 +1,41 @@
import { UMB_WORKSPACE_CONTEXT } from './workspace-context/index.js';
import { UmbBaseController } from '@umbraco-cms/backoffice/controller-api';
import {
ManifestCondition,
UmbConditionConfigBase,
UmbConditionControllerArguments,
UmbExtensionCondition,
} from '@umbraco-cms/backoffice/extension-api';
export class UmbWorkspaceEntityTypeCondition extends UmbBaseController implements UmbExtensionCondition {
config: WorkspaceEntityTypeConditionConfig;
permitted = false;
#onChange: () => void;
constructor(args: UmbConditionControllerArguments<WorkspaceEntityTypeConditionConfig>) {
super(args.host);
this.config = args.config;
this.#onChange = args.onChange;
this.consumeContext(UMB_WORKSPACE_CONTEXT, (context) => {
this.permitted = context.getEntityType().toLowerCase() === this.config.match.toLowerCase();
this.#onChange();
});
}
}
export type WorkspaceEntityTypeConditionConfig = UmbConditionConfigBase<'Umb.Condition.WorkspaceEntityType'> & {
/**
* Define the workspace that this extension should be available in
*
* @example
* "Document"
*/
match: string;
};
export const manifest: ManifestCondition = {
type: 'condition',
name: 'Workspace Entity Type Condition',
alias: 'Umb.Condition.WorkspaceEntityType',
api: UmbWorkspaceEntityTypeCondition,
};

View File

@@ -54,7 +54,7 @@ export class UmbDocumentTableActionColumnLayoutElement extends LitElement {
<div id="action-menu-dropdown" slot="popover">
<uui-scroll-container>
<umb-entity-action-list
@executed=${this.#onActionExecuted}
@action-executed=${this.#onActionExecuted}
entity-type=${ifDefined(this.value.entityType)}
unique=${ifDefined(this.item.id)}></umb-entity-action-list>
</uui-scroll-container>

View File

@@ -10,7 +10,7 @@ import {
UmbTableOrderedEvent,
UmbTableSelectedEvent,
} from '@umbraco-cms/backoffice/components';
import { UMB_COLLECTION_CONTEXT_TOKEN, UmbCollectionContext } from '@umbraco-cms/backoffice/collection';
import { UMB_COLLECTION_CONTEXT, UmbCollectionContext } from '@umbraco-cms/backoffice/collection';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import { DocumentTreeItemResponseModel, EntityTreeItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
@@ -54,7 +54,7 @@ export class UmbDocumentTableCollectionViewElement extends UmbLitElement {
constructor() {
super();
this.consumeContext(UMB_COLLECTION_CONTEXT_TOKEN, (instance) => {
this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
this._collectionContext = instance;
this._observeCollectionContext();
});

View File

@@ -16,9 +16,10 @@ const entityActions: Array<ManifestEntityBulkAction> = [
label: 'Move',
repositoryAlias: DOCUMENT_REPOSITORY_ALIAS,
},
conditions: {
entityType,
},
conditions: [{
alias: 'Umb.Condition.CollectionEntityType',
match: entityType,
}],
},
{
type: 'entityBulkAction',
@@ -30,9 +31,10 @@ const entityActions: Array<ManifestEntityBulkAction> = [
label: 'Copy',
repositoryAlias: DOCUMENT_REPOSITORY_ALIAS,
},
conditions: {
entityType,
},
conditions: [{
alias: 'Umb.Condition.CollectionEntityType',
match: entityType,
}],
},
];

View File

@@ -1,6 +1,6 @@
import { UmbTextStyles } from "@umbraco-cms/backoffice/style";
import { css, html, customElement, state, repeat } from '@umbraco-cms/backoffice/external/lit';
import { UmbCollectionContext, UMB_COLLECTION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/collection';
import { UmbCollectionContext, UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import { EntityTreeItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
@@ -19,7 +19,7 @@ export class UmbMediaGridCollectionViewElement extends UmbLitElement {
document.addEventListener('dragenter', this._handleDragEnter.bind(this));
document.addEventListener('dragleave', this._handleDragLeave.bind(this));
document.addEventListener('drop', this._handleDrop.bind(this));
this.consumeContext(UMB_COLLECTION_CONTEXT_TOKEN, (instance) => {
this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
this._collectionContext = instance;
this._observeCollectionContext();
});

View File

@@ -10,7 +10,7 @@ import type {
UmbTableOrderedEvent,
UmbTableSelectedEvent,
} from '@umbraco-cms/backoffice/components';
import { UmbCollectionContext, UMB_COLLECTION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/collection';
import { UmbCollectionContext, UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import { EntityTreeItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
@@ -42,7 +42,7 @@ export class UmbMediaTableCollectionViewElement extends UmbLitElement {
constructor() {
super();
this.consumeContext(UMB_COLLECTION_CONTEXT_TOKEN, (instance) => {
this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
this._collectionContext = instance;
this._observeCollectionContext();
});

View File

@@ -17,9 +17,10 @@ const entityActions: Array<ManifestEntityBulkAction> = [
label: 'Move',
repositoryAlias: MEDIA_REPOSITORY_ALIAS,
},
conditions: {
entityType,
},
conditions: [{
alias: 'Umb.Condition.CollectionEntityType',
match: entityType,
}],
},
{
type: 'entityBulkAction',
@@ -31,9 +32,10 @@ const entityActions: Array<ManifestEntityBulkAction> = [
label: 'Copy',
repositoryAlias: MEDIA_REPOSITORY_ALIAS,
},
conditions: {
entityType,
},
conditions: [{
alias: 'Umb.Condition.CollectionEntityType',
match: entityType,
}],
},
{
type: 'entityBulkAction',
@@ -45,9 +47,10 @@ const entityActions: Array<ManifestEntityBulkAction> = [
label: 'Trash',
repositoryAlias: MEDIA_REPOSITORY_ALIAS,
},
conditions: {
entityType,
},
conditions: [{
alias: 'Umb.Condition.CollectionEntityType',
match: entityType,
}],
},
];

View File

@@ -35,7 +35,7 @@ export class UmbLanguageRootTableDeleteColumnLayoutElement extends UmbLitElement
</uui-button>
<umb-entity-action-list
slot="dropdown"
@executed=${this.#onActionExecuted}
@action-executed=${this.#onActionExecuted}
entity-type="language"
unique=${ifDefined(this.value.isoCode)}></umb-entity-action-list>
</umb-dropdown>

View File

@@ -1,7 +1,7 @@
import { UmbUserGroupCollectionContext } from './user-group-collection.context.js';
import { UUIInputEvent } from '@umbraco-cms/backoffice/external/uui';
import { css, html, customElement } from '@umbraco-cms/backoffice/external/lit';
import { UMB_COLLECTION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/collection';
import { UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
@customElement('umb-user-group-collection-header')
@@ -11,7 +11,7 @@ export class UmbUserGroupCollectionHeaderElement extends UmbLitElement {
constructor() {
super();
this.consumeContext(UMB_COLLECTION_CONTEXT_TOKEN, (instance) => {
this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
this.#collectionContext = instance as UmbUserGroupCollectionContext;
});
}

View File

@@ -2,7 +2,7 @@ import { UmbUserGroupCollectionContext } from './user-group-collection.context.j
import { UmbTextStyles } from "@umbraco-cms/backoffice/style";
import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import { UMB_COLLECTION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/collection';
import { UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection';
import { UserGroupResponseModel } from '@umbraco-cms/backoffice/backend-api';
import './user-group-table-name-column-layout.element.js';
@@ -59,7 +59,7 @@ export class UmbUserGroupCollectionViewElement extends UmbLitElement {
constructor() {
super();
this.consumeContext(UMB_COLLECTION_CONTEXT_TOKEN, (instance) => {
this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
this.#collectionContext = instance;
this.observe(this.#collectionContext.selection, (selection) => (this._selection = selection));
this.observe(this.#collectionContext.items, (items) => {

View File

@@ -1,7 +1,7 @@
import { UmbUserGroupCollectionContext } from './user-group-collection.context.js';
import { css, html, customElement } from '@umbraco-cms/backoffice/external/lit';
import { UmbTextStyles } from "@umbraco-cms/backoffice/style";
import { UMB_COLLECTION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/collection';
import { UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import './user-group-collection-view.element.js';
@@ -13,7 +13,7 @@ export class UmbUserCollectionElement extends UmbLitElement {
connectedCallback(): void {
super.connectedCallback();
this.provideContext(UMB_COLLECTION_CONTEXT_TOKEN, this.#collectionContext);
this.provideContext(UMB_COLLECTION_CONTEXT, this.#collectionContext);
}
render() {

View File

@@ -15,9 +15,10 @@ const entityActions: Array<ManifestEntityBulkAction> = [
label: 'Delete',
repositoryAlias: USER_GROUP_REPOSITORY_ALIAS,
},
conditions: {
entityType,
},
conditions: [{
alias: 'Umb.Condition.CollectionEntityType',
match: entityType,
}],
},
];

View File

@@ -8,7 +8,7 @@ import {
import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import { UmbDropdownElement } from '@umbraco-cms/backoffice/components';
import { UMB_COLLECTION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/collection';
import { UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection';
import {
UMB_CREATE_USER_MODAL,
UMB_INVITE_USER_MODAL,
@@ -46,7 +46,7 @@ export class UmbUserCollectionHeaderElement extends UmbLitElement {
this.#modalContext = instance;
});
this.consumeContext(UMB_COLLECTION_CONTEXT_TOKEN, (instance) => {
this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
this.#collectionContext = instance as UmbUserCollectionContext;
});
}
@@ -124,7 +124,7 @@ export class UmbUserCollectionHeaderElement extends UmbLitElement {
<!-- TODO: we should consider using the uui-combobox. We need to add a multiple options to it first -->
<umb-dropdown margin="8">
<uui-button @click=${this.#onDropdownClick} slot="trigger" label="status">
<umb-localize key="general_status"></umb-localize>:
<umb-localize key="general_status"></umb-localize>:
<umb-localize key=${'user_state'+this._stateFilterSelection}></umb-localize>
</uui-button>
<div slot="dropdown" class="filter-dropdown">

View File

@@ -1,7 +1,7 @@
import { UmbUserCollectionContext } from './user-collection.context.js';
import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbTextStyles } from "@umbraco-cms/backoffice/style";
import { UMB_COLLECTION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/collection';
import { UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import type { UmbRoute } from '@umbraco-cms/backoffice/router';
@@ -30,7 +30,7 @@ export class UmbUserCollectionElement extends UmbLitElement {
connectedCallback(): void {
super.connectedCallback();
this.provideContext(UMB_COLLECTION_CONTEXT_TOKEN, this.#collectionContext);
this.provideContext(UMB_COLLECTION_CONTEXT, this.#collectionContext);
}
render() {

View File

@@ -3,7 +3,7 @@ import { UmbUserCollectionContext } from '../../user-collection.context.js';
import { type UmbUserDetail } from '../../../types.js';
import { css, html, nothing, customElement, state, repeat, ifDefined } from '@umbraco-cms/backoffice/external/lit';
import { UmbTextStyles } from "@umbraco-cms/backoffice/style";
import { UMB_COLLECTION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/collection';
import { UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import { UserStateModel } from '@umbraco-cms/backoffice/backend-api';
@@ -22,7 +22,7 @@ export class UmbUserCollectionGridViewElement extends UmbLitElement {
//TODO: Get user group names
this.consumeContext(UMB_COLLECTION_CONTEXT_TOKEN, (instance) => {
this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
this.#collectionContext = instance as UmbUserCollectionContext;
this.observe(this.#collectionContext.selection, (selection) => (this._selection = selection));
this.observe(this.#collectionContext.items, (items) => (this._users = items));

View File

@@ -16,7 +16,7 @@ import {
UmbTableOrderedEvent,
} from '@umbraco-cms/backoffice/components';
import type { UserGroupEntity } from '@umbraco-cms/backoffice/user-group';
import { UMB_COLLECTION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/collection';
import { UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection';
import { UmbLitElement } from '@umbraco-cms/internal/lit-element';
import './column-layouts/name/user-table-name-column-layout.element.js';
@@ -75,7 +75,7 @@ export class UmbUserCollectionTableViewElement extends UmbLitElement {
this._observeUserGroups();
});
this.consumeContext(UMB_COLLECTION_CONTEXT_TOKEN, (instance) => {
this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
this.#collectionContext = instance as UmbUserCollectionContext;
this.observe(this.#collectionContext.selection, (selection) => (this._selection = selection));
this.observe(this.#collectionContext.items, (items) => (this._users = items));

View File

@@ -18,9 +18,10 @@ const entityActions: Array<ManifestEntityBulkAction> = [
label: 'SetGroup',
repositoryAlias: USER_REPOSITORY_ALIAS,
},
conditions: {
entityType,
},
conditions: [{
alias: 'Umb.Condition.CollectionEntityType',
match: entityType,
}],
},
{
type: 'entityBulkAction',
@@ -32,9 +33,10 @@ const entityActions: Array<ManifestEntityBulkAction> = [
label: 'Enable',
repositoryAlias: USER_REPOSITORY_ALIAS,
},
conditions: {
entityType,
},
conditions: [{
alias: 'Umb.Condition.CollectionEntityType',
match: entityType,
}],
},
{
type: 'entityBulkAction',
@@ -46,9 +48,10 @@ const entityActions: Array<ManifestEntityBulkAction> = [
label: 'Unlock',
repositoryAlias: USER_REPOSITORY_ALIAS,
},
conditions: {
entityType,
},
conditions: [{
alias: 'Umb.Condition.CollectionEntityType',
match: entityType,
}],
},
{
type: 'entityBulkAction',
@@ -60,9 +63,10 @@ const entityActions: Array<ManifestEntityBulkAction> = [
label: 'Disable',
repositoryAlias: USER_REPOSITORY_ALIAS,
},
conditions: {
entityType,
},
conditions: [{
alias: 'Umb.Condition.CollectionEntityType',
match: entityType,
}],
},
];

View File

@@ -1,5 +1,5 @@
export class UmbExecutedEvent extends Event {
public constructor() {
super('executed', { bubbles: true, composed: true, cancelable: false });
super('action-executed', { bubbles: true, composed: true, cancelable: false });
}
}

View File

@@ -184,9 +184,10 @@ const manifest = {
label: 'My Entity Bulk Action',
repositoryAlias: 'My.Repository',
},
conditions: {
entityType: 'my-entity',
},
conditions: [{
alias: 'Umb.Condition.CollectionEntityType',
match: 'my-entity-type',
}],
};
extensionRegistry.register(manifest);