Skip to content

Commit

Permalink
Merge branch 'v15/dev' into v15/bugfix/validate-emails-for-member-update
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeegaan committed Nov 15, 2024
2 parents b52b6d6 + a315aa9 commit 20f8a0b
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 35 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<!-- Package Validation -->
<PropertyGroup>
<GenerateCompatibilitySuppressionFile>false</GenerateCompatibilitySuppressionFile>
<EnablePackageValidation>false</EnablePackageValidation>
<PackageValidationBaselineVersion>14.0.0</PackageValidationBaselineVersion>
<EnablePackageValidation>true</EnablePackageValidation>
<PackageValidationBaselineVersion>15.0.0</PackageValidationBaselineVersion>
<EnableStrictModeForCompatibleFrameworksInPackage>true</EnableStrictModeForCompatibleFrameworksInPackage>
<EnableStrictModeForCompatibleTfms>true</EnableStrictModeForCompatibleTfms>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected IActionResult BackOfficeUserClientCredentialsOperationStatusResult(Bac
.Build()),
BackOfficeUserClientCredentialsOperationStatus.InvalidClientId => BadRequest(problemDetailsBuilder
.WithTitle("Invalid client ID")
.WithDetail("The specified client ID is invalid. A valid client ID can only contain [a-z], [A-Z], [0-9], and [-._~].")
.WithDetail("The specified client ID is invalid. A valid client ID can only contain [a-z], [A-Z], [0-9], and [-._~]. Furthermore, including the prefix it cannot be longer than 255 characters.")
.Build()),
_ => StatusCode(StatusCodes.Status500InternalServerError, problemDetailsBuilder
.WithTitle("Unknown client credentials operation status.")
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Core/Services/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2675,7 +2675,7 @@ private static void AddAdditionalPermissions(ISet<string> assignedPermissions, I
}
}

[GeneratedRegex(@"^[\w\d\-\._~]*$")]
[GeneratedRegex(@"^[\w\d\-\._~]{1,255}$")]
private static partial Regex ValidClientId();

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { UmbBooleanState } from '@umbraco-cms/backoffice/observable-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
import { UMB_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/property';
import type { UmbVariantId } from '@umbraco-cms/backoffice/variant';

export class UmbBlockListEntriesContext extends UmbBlockEntriesContext<
typeof UMB_BLOCK_LIST_MANAGER_CONTEXT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
UMB_BLOCK_ENTRY_CONTEXT,
} from '@umbraco-cms/backoffice/block';
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
import type { UUIModalSidebarSize } from '@umbraco-cms/backoffice/external/uui';

export type UmbBlockWorkspaceElementManagerNames = 'content' | 'settings';
export class UmbBlockWorkspaceContext<LayoutDataType extends UmbBlockLayoutBaseModel = UmbBlockLayoutBaseModel>
Expand All @@ -44,6 +45,7 @@ export class UmbBlockWorkspaceContext<LayoutDataType extends UmbBlockLayoutBaseM
setOriginData(data: UmbBlockWorkspaceOriginData) {
this.#originData = data;
}
#modalContext?: typeof UMB_MODAL_CONTEXT.TYPE;
#retrieveModalContext;

#entityType: string;
Expand Down Expand Up @@ -83,6 +85,7 @@ export class UmbBlockWorkspaceContext<LayoutDataType extends UmbBlockLayoutBaseM
this.addValidationContext(this.settings.validation);

this.#retrieveModalContext = this.consumeContext(UMB_MODAL_CONTEXT, (context) => {
this.#modalContext = context;
this.#originData = context?.data.originData;
context.onSubmit().catch(this.#modalRejected);
}).asPromise();
Expand Down Expand Up @@ -116,7 +119,7 @@ export class UmbBlockWorkspaceContext<LayoutDataType extends UmbBlockLayoutBaseM

this.#variantId.setValue(variantId);
},
'observeBlockType',
'observeVariantIds',
);

this.removeUmbControllerByAlias('observeHasExpose');
Expand Down Expand Up @@ -156,6 +159,22 @@ export class UmbBlockWorkspaceContext<LayoutDataType extends UmbBlockLayoutBaseM
},
'observeIsReadOnly',
);

this.observe(
this.content.contentTypeId,
(contentTypeId) => {
this.observe(
contentTypeId ? manager.blockTypeOf(contentTypeId) : undefined,
(blockType) => {
if (blockType?.editorSize) {
this.setEditorSize(blockType.editorSize);
}
},
'observeBlockType',
);
},
'observeContentTypeId',
);
});

this.#retrieveBlockEntries = this.consumeContext(UMB_BLOCK_ENTRIES_CONTEXT, (context) => {
Expand Down Expand Up @@ -197,6 +216,10 @@ export class UmbBlockWorkspaceContext<LayoutDataType extends UmbBlockLayoutBaseM
]);
}

setEditorSize(editorSize: UUIModalSidebarSize) {
this.#modalContext?.setModalSize(editorSize);
}

protected override resetState() {
super.resetState();
this.#name.setValue(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
type UUIDialogElement,
type UUIModalDialogElement,
type UUIModalSidebarElement,
type UUIModalSidebarSize,
} from '@umbraco-cms/backoffice/external/uui';
import { UMB_ROUTE_CONTEXT, type UmbRouterSlotElement } from '@umbraco-cms/backoffice/router';
import { createExtensionElement, loadManifestElement } from '@umbraco-cms/backoffice/extension-api';
Expand Down Expand Up @@ -117,7 +118,13 @@ export class UmbModalElement extends UmbLitElement {

#createSidebarElement() {
const sidebarElement = document.createElement('uui-modal-sidebar');
sidebarElement.size = this.#modalContext!.size;
this.observe(
this.#modalContext!.size,
(size) => {
sidebarElement.size = size as UUIModalSidebarSize;
},
'observeSize',
);
return sidebarElement;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
import type { UmbModalToken } from '../token/modal-token.js';
import { UmbModalContext, type UmbModalContextClassArgs } from './modal.context.js';
import type { UUIModalElement, UUIModalSidebarSize } from '@umbraco-cms/backoffice/external/uui';
import { UmbBasicState, appendToFrozenArray } from '@umbraco-cms/backoffice/observable-api';
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import type { ElementLoaderProperty } from '@umbraco-cms/backoffice/extension-api';

export type UmbModalType = 'dialog' | 'sidebar' | 'custom';

export interface UmbModalConfig {
key?: string;
type?: UmbModalType;
size?: UUIModalSidebarSize;

/**
* Used to provide a custom modal element to replace the default uui-modal-dialog or uui-modal-sidebar
*/
element?: ElementLoaderProperty<UUIModalElement>;

/**
* Set the background property of the modal backdrop
*/
backdropBackground?: string;
}

export class UmbModalManagerContext extends UmbContextBase<UmbModalManagerContext> {
// TODO: Investigate if we can get rid of HTML elements in our store, so we can use one of our states.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { UmbModalToken } from '../token/modal-token.js';
import type { UmbModalConfig, UmbModalType } from './modal-manager.context.js';
import type { UmbModalConfig, UmbModalType } from '../types.js';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import type { IRouterSlot } from '@umbraco-cms/backoffice/external/router-slot';
import type { UUIModalElement, UUIModalSidebarSize } from '@umbraco-cms/backoffice/external/uui';
import { UmbId } from '@umbraco-cms/backoffice/id';
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
import { UmbObjectState, UmbStringState } from '@umbraco-cms/backoffice/observable-api';
import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
import { type UmbDeepPartialObject, umbDeepMerge } from '@umbraco-cms/backoffice/utils';
import type { ElementLoaderProperty } from '@umbraco-cms/backoffice/extension-api';
Expand Down Expand Up @@ -38,15 +38,17 @@ export class UmbModalContext<
public readonly key: string;
public readonly data: ModalData;
public readonly type: UmbModalType = 'dialog';
public readonly size: UUIModalSidebarSize = 'small';
public element?: ElementLoaderProperty<UUIModalElement>;
public readonly element?: ElementLoaderProperty<UUIModalElement>;
public readonly backdropBackground?: string;
public readonly router: IRouterSlot | null = null;
public readonly alias: string | UmbModalToken<ModalData, ModalValue>;

#value;
public readonly value;

#size = new UmbStringState<UUIModalSidebarSize>('small');
public readonly size = this.#size.asObservable();

constructor(
host: UmbControllerHost,
modalAlias: string | UmbModalToken<ModalData, ModalValue>,
Expand All @@ -57,18 +59,24 @@ export class UmbModalContext<
this.router = args.router ?? null;
this.alias = modalAlias;

let size = 'small';

if (this.alias instanceof UmbModalToken) {
this.type = this.alias.getDefaultModal()?.type || this.type;
this.size = this.alias.getDefaultModal()?.size || this.size;
size = this.alias.getDefaultModal()?.size ?? size;
this.element = this.alias.getDefaultModal()?.element || this.element;
this.backdropBackground = this.alias.getDefaultModal()?.backdropBackground || this.backdropBackground;
}

this.type = args.modal?.type || this.type;
this.size = args.modal?.size || this.size;
size = args.modal?.size ?? size;
this.element = args.modal?.element || this.element;
this.backdropBackground = args.modal?.backdropBackground || this.backdropBackground;

console.log('size', size);

this.#size.setValue(size);

const defaultData = this.alias instanceof UmbModalToken ? this.alias.getDefaultData() : undefined;
this.data = Object.freeze(
// If we have both data and defaultData perform a deep merge
Expand Down Expand Up @@ -153,6 +161,16 @@ export class UmbModalContext<
this.#value.update(partialValue);
}

/**
* Updates the size this modal.
* @param size
* @public
* @memberof UmbModalContext
*/
setModalSize(size: UUIModalSidebarSize) {
this.#size.setValue(size);
}

public override destroy(): void {
this.dispatchEvent(new CustomEvent('umb:destroy'));
this.#value.destroy();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UmbModalConfig } from '../context/modal-manager.context.js';
import type { UmbModalConfig } from '../types.js';

export interface UmbModalTokenDefaults<
ModalDataType extends { [key: string]: any } = { [key: string]: any },
Expand Down
21 changes: 21 additions & 0 deletions src/Umbraco.Web.UI.Client/src/packages/core/modal/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import type { UUIModalElement, UUIModalSidebarSize } from '@umbraco-cms/backoffice/external/uui';
import type { ElementLoaderProperty } from '@umbraco-cms/backoffice/extension-api';

export type * from './extensions/index.js';

export interface UmbPickerModalData<ItemType> {
Expand All @@ -15,3 +18,21 @@ export interface UmbPickerModalSearchConfig {
export interface UmbPickerModalValue {
selection: Array<string | null>;
}

export type UmbModalType = 'dialog' | 'sidebar' | 'custom';

export interface UmbModalConfig {
key?: string;
type?: UmbModalType;
size?: UUIModalSidebarSize;

/**
* Used to provide a custom modal element to replace the default uui-modal-dialog or uui-modal-sidebar
*/
element?: ElementLoaderProperty<UUIModalElement>;

/**
* Set the background property of the modal backdrop
*/
backdropBackground?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ export class UmbPropertyEditorUIOverlaySizeElement extends UmbLitElement impleme
@property()
value: UUIModalSidebarSize | string = '';

// TODO: Stop having global type of the UUI-SELECT element. And make it possible to have undefined as an option.
@state()
private _list: Array<Option> = [
{ value: 'small', name: 'Small', selected: true },
{ value: undefined as any, name: 'Default', selected: true },
{ value: 'small', name: 'Small' },
{ value: 'medium', name: 'Medium' },
{ value: 'large', name: 'Large' },
{ value: 'full', name: 'Full' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,7 @@ public async Task Can_Assign_ClientId_To_Api_User(UserKind userKind, UserClientC
[TestCase("@", UserClientCredentialsOperationStatus.InvalidClientId)]
[TestCase("[", UserClientCredentialsOperationStatus.InvalidClientId)]
[TestCase("]", UserClientCredentialsOperationStatus.InvalidClientId)]
[TestCase("More_Than_255_characters_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", UserClientCredentialsOperationStatus.InvalidClientId)]
public async Task Can_Use_Only_Unreserved_Characters_For_ClientId(string clientId, UserClientCredentialsOperationStatus expectedResult)
{
// Arrange
Expand Down

0 comments on commit 20f8a0b

Please sign in to comment.