Skip to content

Commit 73028e3

Browse files
authored
Merge pull request #1732 from umbraco/feature/trashed-context
Feature: Entity Is trashed condition + filter document/media entity actions
2 parents 9513c92 + a4365a2 commit 73028e3

40 files changed

+401
-20
lines changed

src/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class UmbEntityActionsBundleElement extends UmbLitElement {
3131

3232
#sectionSidebarContext?: UmbSectionSidebarContext;
3333

34+
// TODO: provide the entity context on a higher level, like the root element of this entity, tree-item/workspace/... [NL]
3435
#entityContext = new UmbEntityContext(this);
3536

3637
constructor() {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const UMB_ENTITY_IS_NOT_TRASHED_CONDITION_ALIAS = 'Umb.Condition.EntityIsNotTrashed';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { UMB_ENTITY_IS_NOT_TRASHED_CONDITION_ALIAS } from './constants.js';
2+
import type { ManifestCondition } from '@umbraco-cms/backoffice/extension-api';
3+
4+
export const manifest: ManifestCondition = {
5+
type: 'condition',
6+
name: 'Entity Is not trashed Condition',
7+
alias: UMB_ENTITY_IS_NOT_TRASHED_CONDITION_ALIAS,
8+
api: () => import('./entity-is-not-trashed.condition.js'),
9+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { UMB_IS_TRASHED_ENTITY_CONTEXT } from '../../contexts/is-trashed/index.js';
2+
import { UmbConditionBase } from '@umbraco-cms/backoffice/extension-registry';
3+
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
4+
import type {
5+
UmbConditionConfigBase,
6+
UmbConditionControllerArguments,
7+
UmbExtensionCondition,
8+
} from '@umbraco-cms/backoffice/extension-api';
9+
10+
export class UmbEntityIsNotTrashedCondition
11+
extends UmbConditionBase<UmbConditionConfigBase>
12+
implements UmbExtensionCondition
13+
{
14+
constructor(host: UmbControllerHost, args: UmbConditionControllerArguments<UmbConditionConfigBase>) {
15+
super(host, args);
16+
17+
// this is a "negative/not" condition, so we assume the default value is that the context is not trashed
18+
// and therefore the condition is permitted
19+
this.permitted = true;
20+
21+
this.consumeContext(UMB_IS_TRASHED_ENTITY_CONTEXT, (context) => {
22+
this.observe(context.isTrashed, (isTrashed) => {
23+
this.permitted = isTrashed === false;
24+
});
25+
});
26+
}
27+
}
28+
29+
export { UmbEntityIsNotTrashedCondition as api };
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const UMB_ENTITY_IS_TRASHED_CONDITION_ALIAS = 'Umb.Condition.EntityIsTrashed';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { UMB_ENTITY_IS_TRASHED_CONDITION_ALIAS } from './constants.js';
2+
import type { ManifestCondition } from '@umbraco-cms/backoffice/extension-api';
3+
4+
export const manifest: ManifestCondition = {
5+
type: 'condition',
6+
name: 'Entity Is trashed Condition',
7+
alias: UMB_ENTITY_IS_TRASHED_CONDITION_ALIAS,
8+
api: () => import('./entity-is-trashed.condition.js'),
9+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { UMB_IS_TRASHED_ENTITY_CONTEXT } from '../../contexts/is-trashed/index.js';
2+
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
3+
import type {
4+
UmbConditionConfigBase,
5+
UmbConditionControllerArguments,
6+
UmbExtensionCondition,
7+
} from '@umbraco-cms/backoffice/extension-api';
8+
import { UmbConditionBase } from '@umbraco-cms/backoffice/extension-registry';
9+
10+
export class UmbIsTrashedCondition extends UmbConditionBase<UmbConditionConfigBase> implements UmbExtensionCondition {
11+
constructor(host: UmbControllerHost, args: UmbConditionControllerArguments<UmbConditionConfigBase>) {
12+
super(host, args);
13+
14+
this.consumeContext(UMB_IS_TRASHED_ENTITY_CONTEXT, (context) => {
15+
this.observe(context.isTrashed, (isTrashed) => {
16+
this.permitted = isTrashed === true;
17+
});
18+
});
19+
}
20+
}
21+
22+
export { UmbIsTrashedCondition as api };
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { manifest as isTrashedManifest } from './is-trashed/entity-is-trashed.condition.manifest.js';
2+
import { manifest as isNotTrashedManifest } from './is-not-trashed/entity-is-not-trashed.condition.manifest.js';
3+
4+
export const manifests = [isTrashedManifest, isNotTrashedManifest];
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { UmbIsTrashedEntityContext } from './is-trashed.entity-context.js';
2+
export { UMB_IS_TRASHED_ENTITY_CONTEXT } from './is-trashed.entity-context-token.js';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { UmbIsTrashedEntityContext } from './is-trashed.entity-context.js';
2+
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
3+
4+
export const UMB_IS_TRASHED_ENTITY_CONTEXT = new UmbContextToken<UmbIsTrashedEntityContext>(
5+
'UmbEntityIsTrashedContext',
6+
);

0 commit comments

Comments
 (0)