Kevin Jump
05/03/2024, 2:21 PMUmb.Condition.WorkspaceAlias
condition works. and i have a 'whats going on here question'
in the code: the constructor ( https://github.com/umbraco/Umbraco.CMS.Backoffice/blob/main/src/packages/core/workspace/conditions/workspace-alias.condition.ts#L15-L35)
does this :
ts
constructor(host: UmbControllerHost, args: UmbConditionControllerArguments<WorkspaceAliasConditionConfig>) {
super(host, args);
let permissionCheck: ((context: UmbWorkspaceContext) => boolean) | undefined = undefined;
if (this.config.match) {
permissionCheck = (context: UmbWorkspaceContext) => context.workspaceAlias === this.config.match;
} else if (this.config.oneOf) {
permissionCheck = (context: UmbWorkspaceContext) => this.config.oneOf!.indexOf(context.workspaceAlias) !== -1;
}
what is this line doing !! 🤯
ts
permissionCheck = (context: UmbWorkspaceContext) => context.workspaceAlias === this.config.match
specifically where has (context: UmbWorkspaceContext)
come from, i can't see anything injected into the class (or its base classes?) its like this code just 'magics' up the context.
what is this - and is it something i should know more about ?Mark Drake
05/03/2024, 2:33 PMKevin Jump
05/03/2024, 2:33 PMKevin Jump
05/03/2024, 2:33 PMts
this.consumeContext(UMB_WORKSPACE_CONTEXT, (context) => {
this.permitted = permissionCheck!(context);
});
Mark Drake
05/03/2024, 2:33 PMKevin Jump
05/03/2024, 2:34 PMMark Drake
05/03/2024, 2:34 PMKevin Jump
05/03/2024, 2:34 PMKevin Jump
05/03/2024, 2:35 PM