diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-actions/unpublish.action.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-actions/unpublish.action.ts index ff9d645a17..d0f47c9878 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-actions/unpublish.action.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-actions/unpublish.action.ts @@ -11,6 +11,7 @@ import { UmbVariantId } from '@umbraco-cms/backoffice/variant'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal'; import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action'; +import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'; export class UmbUnpublishDocumentEntityAction extends UmbEntityActionBase { constructor(host: UmbControllerHost, args: UmbEntityActionArgs) { @@ -28,8 +29,16 @@ export class UmbUnpublishDocumentEntityAction extends UmbEntityActionBase if (!documentData) throw new Error('The document was not found'); - const context = await this.getContext(UMB_APP_LANGUAGE_CONTEXT); - const appCulture = context.getAppCulture(); + const appLanguageContext = await this.getContext(UMB_APP_LANGUAGE_CONTEXT); + const appCulture = appLanguageContext.getAppCulture(); + + const currentUserContext = await this.getContext(UMB_CURRENT_USER_CONTEXT); + const currentUserAllowedLanguages = currentUserContext.getLanguages(); + const currentUserHasAccessToAllLanguages = currentUserContext.getHasAccessToAllLanguages(); + + if (currentUserAllowedLanguages === undefined) throw new Error('The current user languages are missing'); + if (currentUserHasAccessToAllLanguages === undefined) + throw new Error('The current user access to all languages is missing'); const options: Array = documentData.variants.map( (variant) => ({ @@ -65,6 +74,11 @@ export class UmbUnpublishDocumentEntityAction extends UmbEntityActionBase data: { documentUnique: this.args.unique, options, + pickableFilter: (option) => { + if (!option.culture) return false; + if (currentUserHasAccessToAllLanguages) return true; + return currentUserAllowedLanguages.includes(option.culture); + }, }, value: { selection }, }) @@ -89,4 +103,5 @@ export class UmbUnpublishDocumentEntityAction extends UmbEntityActionBase } } } + export default UmbUnpublishDocumentEntityAction;