Skip to content

Commit 9beeaa4

Browse files
authored
Merge pull request #2293 from umbraco/v15/feature/emm-user-permission-conditions
Move User Permission Conditions
2 parents d9a9cbd + 849bb35 commit 9beeaa4

File tree

16 files changed

+65
-60
lines changed

16 files changed

+65
-60
lines changed

src/packages/core/extension-registry/conditions/types.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import type { CollectionAliasConditionConfig } from '../../collection/collection-alias.manifest.js';
22
import type { CollectionBulkActionPermissionConditionConfig } from '../../collection/collection-bulk-action-permission.manifest.js';
3-
import type { UmbSectionUserPermissionConditionConfig } from '../../section/conditions/index.js';
43
import type { SectionAliasConditionConfig } from './section-alias.condition.js';
54
import type { SwitchConditionConfig } from './switch.condition.js';
65
import type { UmbMultipleAppLanguageConditionConfig } from './multiple-app-languages.condition.js';
76
import type { UmbConditionConfigBase } from '@umbraco-cms/backoffice/extension-api';
8-
import type { UmbDocumentUserPermissionConditionConfig } from '@umbraco-cms/backoffice/document';
97

108
export type ConditionTypes =
119
| CollectionAliasConditionConfig
1210
| CollectionBulkActionPermissionConditionConfig
1311
| SectionAliasConditionConfig
1412
| SwitchConditionConfig
15-
| UmbConditionConfigBase
16-
| UmbDocumentUserPermissionConditionConfig
1713
| UmbMultipleAppLanguageConditionConfig
18-
| UmbSectionUserPermissionConditionConfig;
14+
| UmbConditionConfigBase;
1915

2016
type UnionOfProperties<T> = T extends object ? T[keyof T] : never;
2117

src/packages/core/section/conditions/section-user-permission.condition.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1+
import type { UmbSectionUserPermissionConditionConfig } from './types.js';
12
import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user';
23
import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
3-
import type {
4-
UmbConditionConfigBase,
5-
UmbConditionControllerArguments,
6-
UmbExtensionCondition,
7-
} from '@umbraco-cms/backoffice/extension-api';
4+
import type { UmbConditionControllerArguments, UmbExtensionCondition } from '@umbraco-cms/backoffice/extension-api';
85
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
96

107
export class UmbSectionUserPermissionCondition extends UmbControllerBase implements UmbExtensionCondition {
@@ -31,12 +28,9 @@ export class UmbSectionUserPermissionCondition extends UmbControllerBase impleme
3128
}
3229
}
3330

34-
export type UmbSectionUserPermissionConditionConfig = UmbConditionConfigBase<'Umb.Condition.SectionUserPermission'> & {
35-
/**
36-
*
37-
*
38-
* @example
39-
* "Umb.Section.Content"
40-
*/
41-
match: string;
31+
export const manifest = {
32+
type: 'condition',
33+
name: 'Section User Permission Condition',
34+
alias: 'Umb.Condition.SectionUserPermission',
35+
api: UmbSectionUserPermissionCondition,
4236
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { UmbConditionConfigBase } from '@umbraco-cms/backoffice/extension-api';
2+
3+
export type UmbSectionUserPermissionConditionConfig = UmbConditionConfigBase<'Umb.Condition.SectionUserPermission'> & {
4+
/**
5+
*
6+
*
7+
* @example
8+
* "Umb.Section.Content"
9+
*/
10+
match: string;
11+
};
12+
13+
declare global {
14+
interface UmbExtensionConditionMap {
15+
UmbSectionUserPermissionConditionConfig: UmbSectionUserPermissionConditionConfig;
16+
}
17+
}

src/packages/core/section/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export * from './section-sidebar-menu-with-entity-actions/index.js';
88
export * from './section-sidebar-menu/index.js';
99
export * from './section-sidebar/index.js';
1010
export * from './section.context.js';
11+
export type * from './types.js';
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
import { UmbSectionUserPermissionCondition } from './conditions/section-user-permission.condition.js';
1+
import { manifest as sectionUserPermissionConditionManifest } from './conditions/section-user-permission.condition.js';
22
import { manifests as repositoryManifests } from './repository/manifests.js';
3-
import type { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
43

5-
export const manifests: Array<ManifestTypes> = [
4+
export const manifests: Array<UmbExtensionManifest> = [
65
{
76
type: 'modal',
87
alias: 'Umb.Modal.SectionPicker',
98
name: 'Section Picker Modal',
109
element: () => import('./section-picker-modal/section-picker-modal.element.js'),
1110
},
12-
{
13-
type: 'condition',
14-
name: 'Section User Permission Condition',
15-
alias: 'Umb.Condition.SectionUserPermission',
16-
api: UmbSectionUserPermissionCondition,
17-
},
11+
sectionUserPermissionConditionManifest,
1812
...repositoryManifests,
1913
];

src/packages/core/section/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type * from './conditions/types.js';

src/packages/core/tree/tree-item/tree-item-base/tree-item-context-base.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
88
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
99
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
1010
import { UMB_SECTION_CONTEXT, UMB_SECTION_SIDEBAR_CONTEXT } from '@umbraco-cms/backoffice/section';
11-
import type { UmbSectionContext, UmbSectionSidebarContext } from '@umbraco-cms/backoffice/section';
1211
import type { ManifestTreeItem } from '@umbraco-cms/backoffice/extension-registry';
1312
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
14-
import { UMB_ACTION_EVENT_CONTEXT, type UmbActionEventContext } from '@umbraco-cms/backoffice/action';
13+
import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';
1514
import {
1615
UmbRequestReloadChildrenOfEntityEvent,
1716
UmbRequestReloadStructureForEntityEvent,
@@ -69,9 +68,9 @@ export abstract class UmbTreeItemContextBase<
6968
readonly foldersOnly = this.#foldersOnly.asObservable();
7069

7170
treeContext?: UmbDefaultTreeContext<TreeItemType, TreeRootType>;
72-
#sectionContext?: UmbSectionContext;
73-
#sectionSidebarContext?: UmbSectionSidebarContext;
74-
#actionEventContext?: UmbActionEventContext;
71+
#sectionContext?: typeof UMB_SECTION_CONTEXT.TYPE;
72+
#sectionSidebarContext?: typeof UMB_SECTION_SIDEBAR_CONTEXT.TYPE;
73+
#actionEventContext?: typeof UMB_ACTION_EVENT_CONTEXT.TYPE;
7574

7675
// TODO: get this from the tree context
7776
#paging = {

src/packages/documents/documents/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { UmbVariantModel, UmbVariantOptionModel, UmbVariantPublishModel } f
33
import type { UmbReferenceByUnique } from '@umbraco-cms/backoffice/models';
44
import { DocumentVariantStateModel as UmbDocumentVariantState } from '@umbraco-cms/backoffice/external/backend-api';
55
export { UmbDocumentVariantState };
6-
export type { UmbDocumentUserPermissionConditionConfig } from './user-permissions/condition/document-user-permission.condition.js';
76

87
export interface UmbDocumentDetailModel {
98
documentType: {

src/packages/documents/documents/user-permissions/condition/document-user-permission.condition.ts renamed to src/packages/documents/documents/user-permissions/conditions/document-user-permission.condition.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import { isDocumentUserPermission } from '../utils.js';
2+
import type { UmbDocumentUserPermissionConditionConfig } from './types.js';
23
import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user';
34
import { UMB_ENTITY_CONTEXT } from '@umbraco-cms/backoffice/entity';
45
import { observeMultiple } from '@umbraco-cms/backoffice/observable-api';
56
import { UmbConditionBase } from '@umbraco-cms/backoffice/extension-registry';
6-
import type {
7-
UmbConditionConfigBase,
8-
UmbConditionControllerArguments,
9-
UmbExtensionCondition,
10-
} from '@umbraco-cms/backoffice/extension-api';
7+
import type { UmbConditionControllerArguments, UmbExtensionCondition } from '@umbraco-cms/backoffice/extension-api';
118
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
129
import type { DocumentPermissionPresentationModel } from '@umbraco-cms/backoffice/external/backend-api';
1310

@@ -109,21 +106,4 @@ export class UmbDocumentUserPermissionCondition
109106
}
110107
}
111108

112-
export type UmbDocumentUserPermissionConditionConfig =
113-
UmbConditionConfigBase<'Umb.Condition.UserPermission.Document'> & {
114-
/**
115-
* The user must have all of the permissions in this array for the condition to be met.
116-
* @example
117-
* ["Umb.Document.Save", "Umb.Document.Publish"]
118-
*/
119-
allOf?: Array<string>;
120-
121-
/**
122-
* The user must have at least one of the permissions in this array for the condition to be met.
123-
* @example
124-
* ["Umb.Document.Save", "Umb.Document.Publish"]
125-
*/
126-
oneOf?: Array<string>;
127-
};
128-
129109
export { UmbDocumentUserPermissionCondition as api };

0 commit comments

Comments
 (0)