Skip to content

Commit

Permalink
Merge pull request #2385 from umbraco/v15/bugfix/document-blueprint-a…
Browse files Browse the repository at this point in the history
…lignment

Bug: Content Workspace Alignment
  • Loading branch information
nielslyngsoe authored Oct 1, 2024
2 parents c5e1de4 + bb1c5db commit 776a414
Show file tree
Hide file tree
Showing 79 changed files with 653 additions and 417 deletions.
2 changes: 1 addition & 1 deletion src/assets/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2633,5 +2633,5 @@ export default {
extGroup_interactive: 'Interactive elements',
extGroup_media: 'Embeds and media',
extGroup_structure: 'Content structure',
}
},
} as UmbLocalizationDictionary;
2 changes: 1 addition & 1 deletion src/mocks/handlers/document/tree.handlers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { rest } = window.MockServiceWorker;
import { umbDocumentMockDb } from '../../data/document/document.db.js';
import type { GetTreeDocumentAncestorsResponse } from '@umbraco-cms/backoffice/external/backend-api';
import { UMB_SLUG } from './slug.js';
import type { GetTreeDocumentAncestorsResponse } from '@umbraco-cms/backoffice/external/backend-api';
import { umbracoPath } from '@umbraco-cms/backoffice/utils';

export const treeHandlers = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import type { UmbBlockGridTypeAreaType } from '../../index.js';
import { UmbBlockGridAreaTypeEntriesContext } from './block-grid-area-type-entries.context.js';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { html, customElement, property, state, repeat } from '@umbraco-cms/backoffice/external/lit';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import type {
UmbPropertyEditorUiElement,
UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
import { UMB_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/property';
import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
import { incrementString } from '@umbraco-cms/backoffice/utils';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { UmbBlockGridTypeColumnSpanOption } from '../../types.js';
import { html, customElement, property, css, state, repeat } from '@umbraco-cms/backoffice/external/lit';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import {
type UmbPropertyEditorUiElement,
UmbPropertyValueChangeEvent,
type UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';

@customElement('umb-property-editor-ui-block-grid-column-span')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import {
ref,
} from '@umbraco-cms/backoffice/external/lit';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
import type {
UmbPropertyEditorUiElement,
UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
import '../../components/block-grid-entries/index.js';
import { observeMultiple } from '@umbraco-cms/backoffice/observable-api';
import { UMB_PROPERTY_CONTEXT, UMB_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/property';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { html, customElement, property, css } from '@umbraco-cms/backoffice/external/lit';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import {
type UmbPropertyEditorUiElement,
UmbPropertyValueChangeEvent,
type UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import { UmbId } from '@umbraco-cms/backoffice/id';
import type { UmbBlockGridTypeGroupType } from '@umbraco-cms/backoffice/block-grid';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import type { UmbInputStaticFileElement } from '@umbraco-cms/backoffice/static-f

import '@umbraco-cms/backoffice/static-file';
import { html, customElement, property, state } from '@umbraco-cms/backoffice/external/lit';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import {
type UmbPropertyEditorUiElement,
UmbPropertyValueChangeEvent,
type UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import { UmbServerFilePathUniqueSerializer } from '@umbraco-cms/backoffice/server-file-system';
import type { UmbNumberRangeValueType } from '@umbraco-cms/backoffice/models';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { UmbBlockTypeWithGroupKey, UmbInputBlockTypeElement } from '../../../block-type/index.js';
import '../../../block-type/components/input-block-type/index.js';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import {
type UmbPropertyEditorUiElement,
UmbPropertyValueChangeEvent,
type UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
import {
html,
customElement,
Expand All @@ -11,10 +15,6 @@ import {
css,
ifDefined,
} from '@umbraco-cms/backoffice/external/lit';
import {
UmbPropertyValueChangeEvent,
type UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import { UMB_BLOCK_LIST_PROPERTY_EDITOR_SCHEMA_ALIAS } from './manifests.js';
import { UmbLitElement, umbDestroyOnDisconnect } from '@umbraco-cms/backoffice/lit-element';
import { html, customElement, property, state, repeat, css, nothing } from '@umbraco-cms/backoffice/external/lit';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import type {
UmbPropertyEditorConfigCollection,
UmbPropertyEditorUiElement,
} from '@umbraco-cms/backoffice/property-editor';
import type { UmbNumberRangeValueType } from '@umbraco-cms/backoffice/models';
import type { UmbModalRouteBuilder } from '@umbraco-cms/backoffice/router';
import type { UmbSorterConfig } from '@umbraco-cms/backoffice/sorter';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import '../../../block-type/components/input-block-type/index.js';
import { UMB_BLOCK_LIST_TYPE } from '../../types.js';
import type { UmbBlockTypeBaseModel, UmbInputBlockTypeElement } from '@umbraco-cms/backoffice/block-type';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import { html, customElement, property, state } from '@umbraco-cms/backoffice/external/lit';
import {
type UmbPropertyEditorUiElement,
UmbPropertyValueChangeEvent,
type UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
import { html, customElement, property, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UMB_WORKSPACE_MODAL } from '@umbraco-cms/backoffice/workspace';
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
UmbSubmittableWorkspaceContextBase,
UmbInvariantWorkspacePropertyDatasetContext,
UmbWorkspaceIsNewRedirectController,
UmbWorkspaceIsNewRedirectControllerAlias,
} from '@umbraco-cms/backoffice/workspace';
import { UmbObjectState, appendToFrozenArray } from '@umbraco-cms/backoffice/observable-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
Expand Down Expand Up @@ -70,7 +71,7 @@ export class UmbBlockTypeWorkspaceContext<BlockTypeData extends UmbBlockTypeWith
protected override resetState() {
super.resetState();
this.#data.setValue(undefined);
this.removeUmbControllerByAlias('isNewRedirectController');
this.removeUmbControllerByAlias(UmbWorkspaceIsNewRedirectControllerAlias);
}

createPropertyDatasetContext(host: UmbControllerHost): UmbPropertyDatasetContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type UmbRoutableWorkspaceContext,
UmbWorkspaceIsNewRedirectController,
type ManifestWorkspace,
UmbWorkspaceIsNewRedirectControllerAlias,
} from '@umbraco-cms/backoffice/workspace';
import {
UmbBooleanState,
Expand Down Expand Up @@ -205,7 +206,7 @@ export class UmbBlockWorkspaceContext<LayoutDataType extends UmbBlockLayoutBaseM
this.#initialSettings = undefined;
this.content.reset();
this.settings.reset();
this.removeUmbControllerByAlias('isNewRedirectController');
this.removeUmbControllerByAlias(UmbWorkspaceIsNewRedirectControllerAlias);
}

async load(unique: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { css, customElement, html, property, state, styleMap } from '@umbraco-cm
import { UmbInputEvent } from '@umbraco-cms/backoffice/event';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UmbPropertyValueChangeEvent } from '@umbraco-cms/backoffice/property-editor';
import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import type {
UmbPropertyEditorConfigCollection,
UmbPropertyEditorUiElement,
} from '@umbraco-cms/backoffice/property-editor';

import '../components/code-editor.element.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
UmbSubmittableWorkspaceContextBase,
UmbInvariantWorkspacePropertyDatasetContext,
UmbWorkspaceIsNewRedirectController,
UmbWorkspaceIsNewRedirectControllerAlias,
} from '@umbraco-cms/backoffice/workspace';
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
Expand Down Expand Up @@ -87,7 +88,7 @@ export class UmbPropertyTypeWorkspaceContext<PropertyTypeData extends UmbPropert
protected override resetState() {
super.resetState();
this.#data.setValue(undefined);
this.removeUmbControllerByAlias('isNewRedirectController');
this.removeUmbControllerByAlias(UmbWorkspaceIsNewRedirectControllerAlias);
this.removeUmbControllerByAlias('observePropertyTypeData');
}

Expand Down
6 changes: 4 additions & 2 deletions src/packages/core/property/property/property.context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import {
} from '@umbraco-cms/backoffice/observable-api';
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
import type { UmbVariantId } from '@umbraco-cms/backoffice/variant';
import type { UmbPropertyEditorConfigProperty } from '@umbraco-cms/backoffice/property-editor';
import type {
UmbPropertyEditorConfigProperty,
UmbPropertyEditorUiElement,
} from '@umbraco-cms/backoffice/property-editor';
import { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import type {
UmbPropertyTypeAppearanceModel,
UmbPropertyTypeValidationModel,
Expand Down
2 changes: 1 addition & 1 deletion src/packages/core/property/property/property.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
UmbFormControlValidator,
UmbObserveValidationStateController,
} from '@umbraco-cms/backoffice/validation';
import type { ManifestPropertyEditorUi } from '@umbraco-cms/backoffice/property-editor';
import type {
ManifestPropertyEditorUi,
UmbPropertyEditorConfigCollection,
UmbPropertyEditorConfig,
} from '@umbraco-cms/backoffice/property-editor';
Expand Down
13 changes: 9 additions & 4 deletions src/packages/core/repository/detail/detail-repository-base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { UmbRepositoryBase } from '../repository-base.js';
import type { UmbRepositoryResponse, UmbRepositoryResponseWithAsObservable } from '../types.js';
import type { UmbDetailDataSource, UmbDetailDataSourceConstructor } from './detail-data-source.interface.js';
import type { UmbDetailRepository } from './detail-repository.interface.js';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
Expand Down Expand Up @@ -51,7 +52,7 @@ export abstract class UmbDetailRepositoryBase<
* @returns {*}
* @memberof UmbDetailRepositoryBase
*/
async createScaffold(preset?: Partial<DetailModelType>) {
async createScaffold(preset?: Partial<DetailModelType>): Promise<UmbRepositoryResponse<DetailModelType>> {
return this.detailDataSource.createScaffold(preset);
}

Expand All @@ -61,7 +62,7 @@ export abstract class UmbDetailRepositoryBase<
* @returns {*}
* @memberof UmbDetailRepositoryBase
*/
async requestByUnique(unique: string) {
async requestByUnique(unique: string): Promise<UmbRepositoryResponseWithAsObservable<DetailModelType>> {
if (!unique) throw new Error('Unique is missing');
await this.#init;

Expand All @@ -71,7 +72,11 @@ export abstract class UmbDetailRepositoryBase<
this.#detailStore!.append(data);
}

return { data, error, asObservable: () => this.#detailStore!.byUnique(unique) };
return {
data,
error,
asObservable: () => this.#detailStore!.byUnique(unique),
};
}

/**
Expand All @@ -81,7 +86,7 @@ export abstract class UmbDetailRepositoryBase<
* @returns {*}
* @memberof UmbDetailRepositoryBase
*/
async create(model: DetailModelType, parentUnique: string | null) {
async create(model: DetailModelType, parentUnique: string | null): Promise<UmbRepositoryResponse<DetailModelType>> {
if (!model) throw new Error('Data is missing');
await this.#init;

Expand Down
2 changes: 1 addition & 1 deletion src/packages/core/repository/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export * from './item/index.js';
export * from './detail/index.js';

export type { UmbDataSourceResponse, UmbDataSourceErrorResponse } from './data-source-response.interface.js';
export type { UmbPagedModel, UmbRepositoryResponse, UmbRepositoryErrorResponse } from './types.js';
export type * from './types.js';
2 changes: 1 addition & 1 deletion src/packages/core/repository/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export interface UmbRepositoryResponse<T> extends UmbDataSourceResponse<T> {}
export interface UmbRepositoryErrorResponse extends UmbDataSourceErrorResponse {}

export interface UmbRepositoryResponseWithAsObservable<T> extends UmbRepositoryResponse<T> {
asObservable?: () => Observable<T | undefined>;
asObservable: () => Observable<T | undefined>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
import type { UmbRouterSlotElement } from '@umbraco-cms/backoffice/router';
import { ensurePathEndsWithSlash, umbUrlPatternToString } from '@umbraco-cms/backoffice/utils';

export const UmbWorkspaceIsNewRedirectControllerAlias = Symbol('IsNewRedirectControllerAlias');

/**
* Observe the workspace context to see if the entity is new or not.
* If that changes redirect to the edit url.
Expand All @@ -19,7 +21,7 @@ export class UmbWorkspaceIsNewRedirectController extends UmbControllerBase {
workspaceContext: UmbSubmittableWorkspaceContextBase<unknown>,
router: UmbRouterSlotElement,
) {
super(host, 'isNewRedirectController');
super(host, UmbWorkspaceIsNewRedirectControllerAlias);

// Navigate to edit route when language is created:
this.observe(workspaceContext.isNew, (isNew) => {
Expand All @@ -37,5 +39,7 @@ export class UmbWorkspaceIsNewRedirectController extends UmbControllerBase {
}
}
});

// TODO: If workspace route changes cause of other reasons then this controller should be destroyed.
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';
import { UMB_CREATE_DICTIONARY_WORKSPACE_PATH_PATTERN } from '../../workspace/index.js';
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';

export class UmbCreateDictionaryEntityAction extends UmbEntityActionBase<never> {
override async execute() {
Expand Down
5 changes: 5 additions & 0 deletions src/packages/documents/document-blueprints/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ export const UMB_DOCUMENT_BLUEPRINT_FOLDER_ENTITY_TYPE = 'document-blueprint-fol
export type UmbDocumentBlueprintRootEntityType = typeof UMB_DOCUMENT_BLUEPRINT_ROOT_ENTITY_TYPE;
export type UmbDocumentBlueprintEntityType = typeof UMB_DOCUMENT_BLUEPRINT_ENTITY_TYPE;
export type UmbDocumentBlueprintFolderEntityType = typeof UMB_DOCUMENT_BLUEPRINT_FOLDER_ENTITY_TYPE;

export type UmbDocumentBlueprintEntityTypeUnion =
| UmbDocumentBlueprintRootEntityType
| UmbDocumentBlueprintEntityType
| UmbDocumentBlueprintFolderEntityType;
21 changes: 21 additions & 0 deletions src/packages/documents/document-blueprints/paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { UMB_DOCUMENTS_SECTION_PATHNAME } from '../section/paths.js';
import { UMB_DOCUMENT_BLUEPRINT_ENTITY_TYPE, type UmbDocumentBlueprintEntityTypeUnion } from './entity.js';
import type { UmbEntityUnique } from '@umbraco-cms/backoffice/entity';
import { UmbPathPattern } from '@umbraco-cms/backoffice/router';
import { UMB_WORKSPACE_PATH_PATTERN } from '@umbraco-cms/backoffice/workspace';

export const UMB_DOCUMENT_BLUEPRINT_WORKSPACE_PATH = UMB_WORKSPACE_PATH_PATTERN.generateAbsolute({
sectionName: UMB_DOCUMENTS_SECTION_PATHNAME,
entityType: UMB_DOCUMENT_BLUEPRINT_ENTITY_TYPE,
});

export const UMB_CREATE_DOCUMENT_BLUEPRINT_WORKSPACE_PATH_PATTERN = new UmbPathPattern<{
parentEntityType: UmbDocumentBlueprintEntityTypeUnion;
parentUnique?: UmbEntityUnique;
documentTypeUnique: string;
}>('create/parent/:parentEntityType/:parentUnique/:documentTypeUnique', UMB_DOCUMENT_BLUEPRINT_WORKSPACE_PATH);

export const UMB_EDIT_BLUEPRINT_DOCUMENT_WORKSPACE_PATH_PATTERN = new UmbPathPattern<{ unique: string }>(
'edit/:unique',
UMB_DOCUMENT_BLUEPRINT_WORKSPACE_PATH,
);
16 changes: 16 additions & 0 deletions src/packages/documents/document-blueprints/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { UmbDocumentBlueprintVariantOptionModel } from './types.js';

type VariantType = UmbDocumentBlueprintVariantOptionModel;

export const sortVariants = (a: VariantType, b: VariantType) => {
const compareDefault = (a: VariantType, b: VariantType) =>
(a.language?.isDefault ? -1 : 1) - (b.language?.isDefault ? -1 : 1);

// Make sure mandatory variants goes on top.
const compareMandatory = (a: VariantType, b: VariantType) =>
(a.language?.isMandatory ? -1 : 1) - (b.language?.isMandatory ? -1 : 1);

const compareName = (a: VariantType, b: VariantType) => a.variant?.name.localeCompare(b.variant?.name || '') || 99;

return compareDefault(a, b) || compareMandatory(a, b) || compareName(a, b);
};
Loading

0 comments on commit 776a414

Please sign in to comment.