Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7c8c3ff
Created condition for workspace content type unique.
engijlr Nov 20, 2025
4d77e7e
Merge branch 'main' into v17/improvement/workspace-content-type-uniqu…
engijlr Nov 20, 2025
7872b19
Changed import.
engijlr Nov 20, 2025
356807f
Merge branch 'main' into v17/improvement/workspace-content-type-uniqu…
engijlr Nov 20, 2025
2aaf93f
Revert import.
engijlr Nov 20, 2025
e1bd529
Merge branch 'v17/improvement/workspace-content-type-unique-condition…
engijlr Nov 20, 2025
f60ec04
Updated name in the alias example and also import.
engijlr Nov 24, 2025
39cefbc
Update src/Umbraco.Web.UI.Client/examples/entity-content-type-conditi…
engijlr Nov 24, 2025
14c70f9
Update src/Umbraco.Web.UI.Client/examples/entity-content-type-conditi…
engijlr Nov 24, 2025
aa34cf5
Moved the manifest definition to the manifest file.
engijlr Nov 24, 2025
65c2dd8
Changed default export.
engijlr Nov 24, 2025
26450e9
Updated example element to render the real GUID.
engijlr Nov 24, 2025
ac668cd
Merge branch 'main' into v17/improvement/workspace-content-type-uniqu…
engijlr Nov 24, 2025
ae4a216
Fixed import.
engijlr Nov 24, 2025
09cd053
Replaced CONTENT_WORKSPACE for PROPERTY_STRUCTURE_WORKSPACE context.
engijlr Nov 24, 2025
5c0efaa
Moved content type unique condition to the content type folder.
engijlr Nov 24, 2025
7edfec1
Merge branch 'main' into v17/improvement/workspace-content-type-uniqu…
engijlr Nov 24, 2025
64f1d44
Fixed import.
engijlr Nov 24, 2025
196c25a
Merge branch 'v17/improvement/workspace-content-type-unique-condition…
engijlr Nov 24, 2025
5a5e6eb
final adjustments
madsrasmussen Nov 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { UMB_WORKSPACE_CONTENT_TYPE_ALIAS_CONDITION_ALIAS } from '@umbraco-cms/backoffice/content-type';
import { UMB_WORKSPACE_CONTENT_TYPE_UNIQUE_CONDITION_ALIAS } from 'src/packages/core/workspace/conditions/workspace-content-type-unique/constants.js';

const workspace: UmbExtensionManifest = {
const workspaceViewAlias: UmbExtensionManifest = {
type: 'workspaceView',
alias: 'Example.WorkspaceView.EntityContentTypeCondition',
name: 'Example Workspace View With Entity Content Type Condition',
Expand All @@ -13,10 +14,28 @@ const workspace: UmbExtensionManifest = {
conditions: [
{
alias: UMB_WORKSPACE_CONTENT_TYPE_ALIAS_CONDITION_ALIAS,
//match : 'blogPost'
//match: 'blogPost',
oneOf: ['blogPost', 'mediaType1'],
},
],
};

export const manifests = [workspace];
const workspaceViewUnique: UmbExtensionManifest = {
type: 'workspaceView',
alias: 'Example.WorkspaceView.EntityContentTypeConditionUnique',
name: 'Example Workspace View With Content Type Unique Condition',
element: () => import('./workspace-view-unique.element.js'),
meta: {
icon: 'icon-science',
label: 'Conditional (Unique)',
pathname: 'conditional-unique',
},
conditions: [
{
alias: UMB_WORKSPACE_CONTENT_TYPE_UNIQUE_CONDITION_ALIAS,
oneOf: ['9cf7f9ba-6bad-469a-8d8a-524546bb6c82'], // Example GUID
},
],
};

export const manifests = [workspaceViewAlias, workspaceViewUnique];
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { html, customElement } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';

@customElement('umb-example-entity-content-type-condition-unique')
export class UmbWorkspaceExampleViewUniqueElement extends UmbLitElement {
override render() {
return html`<uui-box>
<h3>Content Type Unique Condition Test</h3>
<p>It appears only on documents with GUID: <strong>42d7572e-1ba1-458d-a765-95b60040c3ac</strong></p>
</uui-box>`;
}
}

export default UmbWorkspaceExampleViewUniqueElement;

declare global {
interface HTMLElementTagNameMap {
'umb-example-entity-content-type-condition-unique': UmbWorkspaceExampleViewUniqueElement;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './workspace-alias/constants.js';
export * from './workspace-entity-is-new/constants.js';
export * from './workspace-entity-type/constants.js';
export * from './workspace-content-type-unique/constants.js';
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { manifests as workspaceAliasCondition } from './workspace-alias/manifests.js';
import { manifests as workspaceEntityIsNewCondition } from './workspace-entity-is-new/manifests.js';
import { manifests as workspaceEntityTypeCondition } from './workspace-entity-type/manifests.js';
import { manifests as workspaceViewUnique } from './workspace-content-type-unique/manifests.js';

export const manifests: Array<UmbExtensionManifest> = [
...workspaceAliasCondition,
...workspaceEntityIsNewCondition,
...workspaceEntityTypeCondition,
...workspaceViewUnique,
];
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export type * from './workspace-alias/types.js';
export type * from './workspace-entity-is-new/types.js';
export type * from './workspace-entity-type/types.js';
export type * from './workspace-content-type-unique/types.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Workspace Content Type Unique condition alias
*/
export const UMB_WORKSPACE_CONTENT_TYPE_UNIQUE_CONDITION_ALIAS = 'Umb.Condition.WorkspaceContentTypeUnique';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { manifest as workspaceContentTypeUniqueCondition } from './workspace-content-type-unique.condition.js';

export const manifests: Array<UmbExtensionManifest> = [workspaceContentTypeUniqueCondition];
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { UMB_WORKSPACE_CONTENT_TYPE_UNIQUE_CONDITION_ALIAS } from './constants.js';
import type { UmbConditionConfigBase } from '@umbraco-cms/backoffice/extension-api';

export type UmbWorkspaceContentTypeUniqueConditionConfig = UmbConditionConfigBase<
typeof UMB_WORKSPACE_CONTENT_TYPE_UNIQUE_CONDITION_ALIAS
> & {
/**
* Define a content type unique (GUID) in which workspace this extension should be available
* @example
* Depends on implementation, but i.e. "d59be02f-1df9-4228-aa1e-01917d806cda"
*/
match?: string;
/**
* Define one or more content type unique (GUIDs) in which workspace this extension should be available
* @example
* ["d59be02f-1df9-4228-aa1e-01917d806cda", "42d7572e-1ba1-458d-a765-95b60040c3ac"]
*/
oneOf?: Array<string>;
};

declare global {
interface UmbExtensionConditionConfigMap {
umbWorkspaceContentTypeUniqueConditionConfig: UmbWorkspaceContentTypeUniqueConditionConfig;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { UMB_CONTENT_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/content';
import type { UmbWorkspaceContentTypeUniqueConditionConfig } from './types.js';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import type { UmbConditionControllerArguments, UmbExtensionCondition } from '@umbraco-cms/backoffice/extension-api';
import { UmbConditionBase } from '@umbraco-cms/backoffice/extension-registry';

const ObserveSymbol = Symbol();

/**
* Condition to apply workspace extension based on a content type unique (GUID)
*/
export class UmbWorkspaceContentTypeUniqueCondition
extends UmbConditionBase<UmbWorkspaceContentTypeUniqueConditionConfig>
implements UmbExtensionCondition
{
constructor(
host: UmbControllerHost,
args: UmbConditionControllerArguments<UmbWorkspaceContentTypeUniqueConditionConfig>,
) {
super(host, args);

let permissionCheck: ((contentTypeUniques: string[]) => boolean) | undefined = undefined;
if (this.config.match) {
permissionCheck = (contentTypeUniques: string[]) => contentTypeUniques.includes(this.config.match!);
} else if (this.config.oneOf) {
permissionCheck = (contentTypeUniques: string[]) =>
contentTypeUniques.some((item) => this.config.oneOf!.includes(item));
}

if (permissionCheck !== undefined) {
this.consumeContext(UMB_CONTENT_WORKSPACE_CONTEXT, (context) => {
this.observe(
context?.structure.contentTypeUniques,
(contentTypeUniques) => {
const result = contentTypeUniques ? permissionCheck!(contentTypeUniques) : false;
this.permitted = result;
},
ObserveSymbol,
);
});
} else {
throw new Error(
'Condition `Umb.Condition.WorkspaceContentTypeUnique` could not be initialized properly. Either "match" or "oneOf" must be defined',
);
}
}
}

export const manifest: UmbExtensionManifest = {
type: 'condition',
name: 'Workspace Content Type Unique Condition',
alias: 'Umb.Condition.WorkspaceContentTypeUnique',
api: UmbWorkspaceContentTypeUniqueCondition,
};
Loading