diff --git a/src/packages/core/extension-registry/conditions/types.ts b/src/packages/core/extension-registry/conditions/types.ts index 0939e4845c..b4c2119fdc 100644 --- a/src/packages/core/extension-registry/conditions/types.ts +++ b/src/packages/core/extension-registry/conditions/types.ts @@ -1,11 +1,9 @@ import type { CollectionAliasConditionConfig } from '../../collection/collection-alias.manifest.js'; import type { CollectionBulkActionPermissionConditionConfig } from '../../collection/collection-bulk-action-permission.manifest.js'; -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 { UmbConditionConfigBase } from '@umbraco-cms/backoffice/extension-api'; -import type { UmbDocumentUserPermissionConditionConfig } from '@umbraco-cms/backoffice/document'; // temp location to avoid circular dependencies export type BlockWorkspaceHasSettingsConditionConfig = @@ -21,10 +19,8 @@ export type ConditionTypes = | CollectionBulkActionPermissionConditionConfig | SectionAliasConditionConfig | SwitchConditionConfig - | UmbConditionConfigBase - | UmbDocumentUserPermissionConditionConfig | UmbMultipleAppLanguageConditionConfig - | UmbSectionUserPermissionConditionConfig; + | UmbConditionConfigBase; type UnionOfProperties = T extends object ? T[keyof T] : never; diff --git a/src/packages/core/section/conditions/section-user-permission.condition.ts b/src/packages/core/section/conditions/section-user-permission.condition.ts index f57d742553..0fefc682ad 100644 --- a/src/packages/core/section/conditions/section-user-permission.condition.ts +++ b/src/packages/core/section/conditions/section-user-permission.condition.ts @@ -1,10 +1,7 @@ +import type { UmbSectionUserPermissionConditionConfig } from './types.js'; import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'; import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; -import type { - UmbConditionConfigBase, - UmbConditionControllerArguments, - UmbExtensionCondition, -} from '@umbraco-cms/backoffice/extension-api'; +import type { UmbConditionControllerArguments, UmbExtensionCondition } from '@umbraco-cms/backoffice/extension-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; export class UmbSectionUserPermissionCondition extends UmbControllerBase implements UmbExtensionCondition { @@ -31,12 +28,9 @@ export class UmbSectionUserPermissionCondition extends UmbControllerBase impleme } } -export type UmbSectionUserPermissionConditionConfig = UmbConditionConfigBase<'Umb.Condition.SectionUserPermission'> & { - /** - * - * - * @example - * "Umb.Section.Content" - */ - match: string; +export const manifest = { + type: 'condition', + name: 'Section User Permission Condition', + alias: 'Umb.Condition.SectionUserPermission', + api: UmbSectionUserPermissionCondition, }; diff --git a/src/packages/core/section/conditions/types.ts b/src/packages/core/section/conditions/types.ts new file mode 100644 index 0000000000..d4f1331089 --- /dev/null +++ b/src/packages/core/section/conditions/types.ts @@ -0,0 +1,17 @@ +import type { UmbConditionConfigBase } from '@umbraco-cms/backoffice/extension-api'; + +export type UmbSectionUserPermissionConditionConfig = UmbConditionConfigBase<'Umb.Condition.SectionUserPermission'> & { + /** + * + * + * @example + * "Umb.Section.Content" + */ + match: string; +}; + +declare global { + interface UmbExtensionConditionMap { + UmbSectionUserPermissionConditionConfig: UmbSectionUserPermissionConditionConfig; + } +} diff --git a/src/packages/core/section/index.ts b/src/packages/core/section/index.ts index 51e427cbb7..1da6d056ac 100644 --- a/src/packages/core/section/index.ts +++ b/src/packages/core/section/index.ts @@ -8,3 +8,4 @@ export * from './section-sidebar-menu-with-entity-actions/index.js'; export * from './section-sidebar-menu/index.js'; export * from './section-sidebar/index.js'; export * from './section.context.js'; +export type * from './types.js'; diff --git a/src/packages/core/section/manifests.ts b/src/packages/core/section/manifests.ts index 8442b3fd05..4d21c4412b 100644 --- a/src/packages/core/section/manifests.ts +++ b/src/packages/core/section/manifests.ts @@ -1,19 +1,13 @@ -import { UmbSectionUserPermissionCondition } from './conditions/section-user-permission.condition.js'; +import { manifest as sectionUserPermissionConditionManifest } from './conditions/section-user-permission.condition.js'; import { manifests as repositoryManifests } from './repository/manifests.js'; -import type { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry'; -export const manifests: Array = [ +export const manifests: Array = [ { type: 'modal', alias: 'Umb.Modal.SectionPicker', name: 'Section Picker Modal', element: () => import('./section-picker-modal/section-picker-modal.element.js'), }, - { - type: 'condition', - name: 'Section User Permission Condition', - alias: 'Umb.Condition.SectionUserPermission', - api: UmbSectionUserPermissionCondition, - }, + sectionUserPermissionConditionManifest, ...repositoryManifests, ]; diff --git a/src/packages/core/section/types.ts b/src/packages/core/section/types.ts new file mode 100644 index 0000000000..f28780c132 --- /dev/null +++ b/src/packages/core/section/types.ts @@ -0,0 +1 @@ +export type * from './conditions/types.js'; diff --git a/src/packages/core/tree/tree-item/tree-item-base/tree-item-context-base.ts b/src/packages/core/tree/tree-item/tree-item-base/tree-item-context-base.ts index 7c64a54380..7f0a1e83e5 100644 --- a/src/packages/core/tree/tree-item/tree-item-base/tree-item-context-base.ts +++ b/src/packages/core/tree/tree-item/tree-item-base/tree-item-context-base.ts @@ -8,10 +8,9 @@ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'; import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; import { UMB_SECTION_CONTEXT, UMB_SECTION_SIDEBAR_CONTEXT } from '@umbraco-cms/backoffice/section'; -import type { UmbSectionContext, UmbSectionSidebarContext } from '@umbraco-cms/backoffice/section'; import type { ManifestTreeItem } from '@umbraco-cms/backoffice/extension-registry'; import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'; -import { UMB_ACTION_EVENT_CONTEXT, type UmbActionEventContext } from '@umbraco-cms/backoffice/action'; +import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action'; import { UmbRequestReloadChildrenOfEntityEvent, UmbRequestReloadStructureForEntityEvent, @@ -69,9 +68,9 @@ export abstract class UmbTreeItemContextBase< readonly foldersOnly = this.#foldersOnly.asObservable(); treeContext?: UmbDefaultTreeContext; - #sectionContext?: UmbSectionContext; - #sectionSidebarContext?: UmbSectionSidebarContext; - #actionEventContext?: UmbActionEventContext; + #sectionContext?: typeof UMB_SECTION_CONTEXT.TYPE; + #sectionSidebarContext?: typeof UMB_SECTION_SIDEBAR_CONTEXT.TYPE; + #actionEventContext?: typeof UMB_ACTION_EVENT_CONTEXT.TYPE; // TODO: get this from the tree context #paging = { diff --git a/src/packages/documents/documents/types.ts b/src/packages/documents/documents/types.ts index 2d2d184e6e..d0a52f2798 100644 --- a/src/packages/documents/documents/types.ts +++ b/src/packages/documents/documents/types.ts @@ -3,7 +3,6 @@ import type { UmbVariantModel, UmbVariantOptionModel, UmbVariantPublishModel } f import type { UmbReferenceByUnique } from '@umbraco-cms/backoffice/models'; import { DocumentVariantStateModel as UmbDocumentVariantState } from '@umbraco-cms/backoffice/external/backend-api'; export { UmbDocumentVariantState }; -export type { UmbDocumentUserPermissionConditionConfig } from './user-permissions/condition/document-user-permission.condition.js'; export interface UmbDocumentDetailModel { documentType: { diff --git a/src/packages/documents/documents/user-permissions/condition/document-user-permission.condition.ts b/src/packages/documents/documents/user-permissions/conditions/document-user-permission.condition.ts similarity index 84% rename from src/packages/documents/documents/user-permissions/condition/document-user-permission.condition.ts rename to src/packages/documents/documents/user-permissions/conditions/document-user-permission.condition.ts index d04b0e646e..64d5836673 100644 --- a/src/packages/documents/documents/user-permissions/condition/document-user-permission.condition.ts +++ b/src/packages/documents/documents/user-permissions/conditions/document-user-permission.condition.ts @@ -1,13 +1,10 @@ import { isDocumentUserPermission } from '../utils.js'; +import type { UmbDocumentUserPermissionConditionConfig } from './types.js'; import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'; import { UMB_ENTITY_CONTEXT } from '@umbraco-cms/backoffice/entity'; import { observeMultiple } from '@umbraco-cms/backoffice/observable-api'; import { UmbConditionBase } from '@umbraco-cms/backoffice/extension-registry'; -import type { - UmbConditionConfigBase, - UmbConditionControllerArguments, - UmbExtensionCondition, -} from '@umbraco-cms/backoffice/extension-api'; +import type { UmbConditionControllerArguments, UmbExtensionCondition } from '@umbraco-cms/backoffice/extension-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import type { DocumentPermissionPresentationModel } from '@umbraco-cms/backoffice/external/backend-api'; @@ -109,21 +106,4 @@ export class UmbDocumentUserPermissionCondition } } -export type UmbDocumentUserPermissionConditionConfig = - UmbConditionConfigBase<'Umb.Condition.UserPermission.Document'> & { - /** - * The user must have all of the permissions in this array for the condition to be met. - * @example - * ["Umb.Document.Save", "Umb.Document.Publish"] - */ - allOf?: Array; - - /** - * The user must have at least one of the permissions in this array for the condition to be met. - * @example - * ["Umb.Document.Save", "Umb.Document.Publish"] - */ - oneOf?: Array; - }; - export { UmbDocumentUserPermissionCondition as api }; diff --git a/src/packages/documents/documents/user-permissions/condition/manifests.ts b/src/packages/documents/documents/user-permissions/conditions/manifests.ts similarity index 100% rename from src/packages/documents/documents/user-permissions/condition/manifests.ts rename to src/packages/documents/documents/user-permissions/conditions/manifests.ts diff --git a/src/packages/documents/documents/user-permissions/conditions/types.ts b/src/packages/documents/documents/user-permissions/conditions/types.ts new file mode 100644 index 0000000000..1eb4412fe4 --- /dev/null +++ b/src/packages/documents/documents/user-permissions/conditions/types.ts @@ -0,0 +1,24 @@ +import type { UmbConditionConfigBase } from '@umbraco-cms/backoffice/extension-api'; + +export type UmbDocumentUserPermissionConditionConfig = + UmbConditionConfigBase<'Umb.Condition.UserPermission.Document'> & { + /** + * The user must have all of the permissions in this array for the condition to be met. + * @example + * ["Umb.Document.Save", "Umb.Document.Publish"] + */ + allOf?: Array; + + /** + * The user must have at least one of the permissions in this array for the condition to be met. + * @example + * ["Umb.Document.Save", "Umb.Document.Publish"] + */ + oneOf?: Array; + }; + +declare global { + interface UmbExtensionConditionMap { + UmbDocumentUserPermissionConditionConfig: UmbDocumentUserPermissionConditionConfig; + } +} diff --git a/src/packages/documents/documents/user-permissions/manifests.ts b/src/packages/documents/documents/user-permissions/manifests.ts index 9ea0a40611..1d76f7fa4e 100644 --- a/src/packages/documents/documents/user-permissions/manifests.ts +++ b/src/packages/documents/documents/user-permissions/manifests.ts @@ -17,7 +17,7 @@ import { UMB_USER_PERMISSION_DOCUMENT_ROLLBACK, } from './constants.js'; import { manifests as repositoryManifests } from './repository/manifests.js'; -import { manifests as conditionManifests } from './condition/manifests.js'; +import { manifests as conditionManifests } from './conditions/manifests.js'; import type { ManifestGranularUserPermission, ManifestEntityUserPermission, diff --git a/src/packages/documents/documents/user-permissions/types.ts b/src/packages/documents/documents/user-permissions/types.ts index 14feb94a9e..0028a6bf35 100644 --- a/src/packages/documents/documents/user-permissions/types.ts +++ b/src/packages/documents/documents/user-permissions/types.ts @@ -1,5 +1,5 @@ import type { UmbUserPermissionModel } from '@umbraco-cms/backoffice/user-permission'; - +export type * from './conditions/types.js'; export interface UmbDocumentUserPermissionModel extends UmbUserPermissionModel { // TODO: this should be unique instead of an id, but we currently have now way to map a mixed server response. document: { id: string }; diff --git a/src/packages/documents/documents/workspace/actions/save-and-preview.action.ts b/src/packages/documents/documents/workspace/actions/save-and-preview.action.ts index 085065f0cb..ff4d773188 100644 --- a/src/packages/documents/documents/workspace/actions/save-and-preview.action.ts +++ b/src/packages/documents/documents/workspace/actions/save-and-preview.action.ts @@ -1,4 +1,4 @@ -import { UmbDocumentUserPermissionCondition } from '../../user-permissions/condition/document-user-permission.condition.js'; +import { UmbDocumentUserPermissionCondition } from '../../user-permissions/conditions/document-user-permission.condition.js'; import { UMB_DOCUMENT_WORKSPACE_CONTEXT } from '../document-workspace.context-token.js'; import { UMB_USER_PERMISSION_DOCUMENT_UPDATE } from '../../user-permissions/index.js'; import { UmbWorkspaceActionBase } from '@umbraco-cms/backoffice/workspace'; diff --git a/src/packages/documents/documents/workspace/actions/save-and-publish.action.ts b/src/packages/documents/documents/workspace/actions/save-and-publish.action.ts index ee8f35ed94..a040d57fbc 100644 --- a/src/packages/documents/documents/workspace/actions/save-and-publish.action.ts +++ b/src/packages/documents/documents/workspace/actions/save-and-publish.action.ts @@ -3,7 +3,7 @@ import { UMB_USER_PERMISSION_DOCUMENT_PUBLISH, UMB_USER_PERMISSION_DOCUMENT_UPDATE, } from '../../user-permissions/constants.js'; -import { UmbDocumentUserPermissionCondition } from '../../user-permissions/condition/document-user-permission.condition.js'; +import { UmbDocumentUserPermissionCondition } from '../../user-permissions/conditions/document-user-permission.condition.js'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UmbWorkspaceActionBase } from '@umbraco-cms/backoffice/workspace'; diff --git a/src/packages/documents/documents/workspace/actions/save.action.ts b/src/packages/documents/documents/workspace/actions/save.action.ts index 8b9d866f0a..f848baf0b7 100644 --- a/src/packages/documents/documents/workspace/actions/save.action.ts +++ b/src/packages/documents/documents/workspace/actions/save.action.ts @@ -2,7 +2,7 @@ import { UMB_USER_PERMISSION_DOCUMENT_CREATE, UMB_USER_PERMISSION_DOCUMENT_UPDATE, } from '../../user-permissions/constants.js'; -import { UmbDocumentUserPermissionCondition } from '../../user-permissions/condition/document-user-permission.condition.js'; +import { UmbDocumentUserPermissionCondition } from '../../user-permissions/conditions/document-user-permission.condition.js'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UmbSubmitWorkspaceAction } from '@umbraco-cms/backoffice/workspace';