Compare commits

...
Author SHA1 Message Date
NathanWoulfe dcffbc65f4 provide document and documentType IDs to ISegmentService 2025-07-23 12:40:24 +10:00
8 changed files with 1208 additions and 417 deletions
@@ -1,5 +1,4 @@
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
@@ -9,7 +8,6 @@ using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Services.OperationStatus;
using Umbraco.Cms.Web.Common.Authorization;
namespace Umbraco.Cms.Api.Management.Controllers.Segment;
@@ -29,9 +27,9 @@ public class AllSegmentController : SegmentControllerBase
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(PagedViewModel<SegmentResponseModel>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<IActionResult> GetAll(CancellationToken cancellationToken, int skip = 0, int take = 100)
public async Task<IActionResult> GetAll(CancellationToken cancellationToken, int skip = 0, int take = 100, Guid? documentId = null, Guid? documentTypeId = null)
{
Attempt<PagedModel<Core.Models.Segment>?, SegmentOperationStatus> pagedAttempt = await _segmentService.GetPagedSegmentsAsync(skip, take);
Attempt<PagedModel<Core.Models.Segment>?, SegmentOperationStatus> pagedAttempt = await _segmentService.GetPagedSegmentsAsync(skip, take, documentId, documentTypeId);
if (pagedAttempt.Success is false)
{
File diff suppressed because it is too large Load Diff
@@ -5,5 +5,9 @@ namespace Umbraco.Cms.Core.Services;
public interface ISegmentService
{
[Obsolete("Use the version of GetPagedSegmentsAsync accepting all parameters instead. Scheduled for removal in V18")]
Task<Attempt<PagedModel<Segment>?, SegmentOperationStatus>> GetPagedSegmentsAsync(int skip = 0, int take = 100);
Task<Attempt<PagedModel<Segment>?, SegmentOperationStatus>> GetPagedSegmentsAsync(int skip = 0, int take = 100, Guid? documentId = null, Guid? documentTypeId = null)
=> GetPagedSegmentsAsync(skip, take);
}
@@ -347,8 +347,18 @@ export abstract class UmbContentDetailWorkspaceContextBase<
null,
);
this.observe(this._data.current, async (result) => {
if (!result) return;
const { data } = await this.#segmentRepository.requestCollection({
documentUnique: this.getUnique()?.toString(),
documentTypeUnique: this.getContentTypeUnique(),
});
this.#segments.setValue(data?.items ?? []);
});
this.loadLanguages();
this.#loadSegments();
}
public async loadLanguages() {
@@ -357,11 +367,6 @@ export abstract class UmbContentDetailWorkspaceContextBase<
this.#languages.setValue(data?.items ?? []);
}
async #loadSegments() {
const { data } = await this.#segmentRepository.requestCollection({});
this.#segments.setValue(data?.items ?? []);
}
protected override async _scaffoldProcessData(data: DetailModelType): Promise<DetailModelType> {
// Load the content type structure, usually this comes from the data, but in this case we are making the data, and we need this to be able to complete the data. [NL]
await this.structure.loadType((data as any)[this.#contentTypePropertyName].unique);
File diff suppressed because one or more lines are too long
@@ -3745,6 +3745,37 @@ export type GetTreeDataTypeRootResponses = {
export type GetTreeDataTypeRootResponse = GetTreeDataTypeRootResponses[keyof GetTreeDataTypeRootResponses];
export type GetTreeDataTypeSiblingsData = {
body?: never;
path?: never;
query?: {
target?: string;
before?: number;
after?: number;
};
url: '/umbraco/management/api/v1/tree/data-type/siblings';
};
export type GetTreeDataTypeSiblingsErrors = {
/**
* The resource is protected and requires an authentication token
*/
401: unknown;
/**
* The authenticated user does not have access to this resource
*/
403: unknown;
};
export type GetTreeDataTypeSiblingsResponses = {
/**
* OK
*/
200: Array<DataTypeTreeItemResponseModel>;
};
export type GetTreeDataTypeSiblingsResponse = GetTreeDataTypeSiblingsResponses[keyof GetTreeDataTypeSiblingsResponses];
export type GetDictionaryData = {
body?: never;
path?: never;
@@ -4652,6 +4683,37 @@ export type GetTreeDocumentBlueprintRootResponses = {
export type GetTreeDocumentBlueprintRootResponse = GetTreeDocumentBlueprintRootResponses[keyof GetTreeDocumentBlueprintRootResponses];
export type GetTreeDocumentBlueprintSiblingsData = {
body?: never;
path?: never;
query?: {
target?: string;
before?: number;
after?: number;
};
url: '/umbraco/management/api/v1/tree/document-blueprint/siblings';
};
export type GetTreeDocumentBlueprintSiblingsErrors = {
/**
* The resource is protected and requires an authentication token
*/
401: unknown;
/**
* The authenticated user does not have access to this resource
*/
403: unknown;
};
export type GetTreeDocumentBlueprintSiblingsResponses = {
/**
* OK
*/
200: Array<DocumentBlueprintTreeItemResponseModel>;
};
export type GetTreeDocumentBlueprintSiblingsResponse = GetTreeDocumentBlueprintSiblingsResponses[keyof GetTreeDocumentBlueprintSiblingsResponses];
export type PostDocumentTypeData = {
body?: CreateDocumentTypeRequestModel;
path?: never;
@@ -5462,6 +5524,37 @@ export type GetTreeDocumentTypeRootResponses = {
export type GetTreeDocumentTypeRootResponse = GetTreeDocumentTypeRootResponses[keyof GetTreeDocumentTypeRootResponses];
export type GetTreeDocumentTypeSiblingsData = {
body?: never;
path?: never;
query?: {
target?: string;
before?: number;
after?: number;
};
url: '/umbraco/management/api/v1/tree/document-type/siblings';
};
export type GetTreeDocumentTypeSiblingsErrors = {
/**
* The resource is protected and requires an authentication token
*/
401: unknown;
/**
* The authenticated user does not have access to this resource
*/
403: unknown;
};
export type GetTreeDocumentTypeSiblingsResponses = {
/**
* OK
*/
200: Array<DocumentTypeTreeItemResponseModel>;
};
export type GetTreeDocumentTypeSiblingsResponse = GetTreeDocumentTypeSiblingsResponses[keyof GetTreeDocumentTypeSiblingsResponses];
export type GetDocumentVersionData = {
body?: never;
path?: never;
@@ -7056,6 +7149,37 @@ export type GetTreeDocumentRootResponses = {
export type GetTreeDocumentRootResponse = GetTreeDocumentRootResponses[keyof GetTreeDocumentRootResponses];
export type GetTreeDocumentSiblingsData = {
body?: never;
path?: never;
query?: {
target?: string;
before?: number;
after?: number;
};
url: '/umbraco/management/api/v1/tree/document/siblings';
};
export type GetTreeDocumentSiblingsErrors = {
/**
* The resource is protected and requires an authentication token
*/
401: unknown;
/**
* The authenticated user does not have access to this resource
*/
403: unknown;
};
export type GetTreeDocumentSiblingsResponses = {
/**
* OK
*/
200: Array<DocumentTreeItemResponseModel>;
};
export type GetTreeDocumentSiblingsResponse = GetTreeDocumentSiblingsResponses[keyof GetTreeDocumentSiblingsResponses];
export type PostDynamicRootQueryData = {
body?: DynamicRootRequestModel;
path?: never;
@@ -8920,6 +9044,37 @@ export type GetTreeMediaTypeRootResponses = {
export type GetTreeMediaTypeRootResponse = GetTreeMediaTypeRootResponses[keyof GetTreeMediaTypeRootResponses];
export type GetTreeMediaTypeSiblingsData = {
body?: never;
path?: never;
query?: {
target?: string;
before?: number;
after?: number;
};
url: '/umbraco/management/api/v1/tree/media-type/siblings';
};
export type GetTreeMediaTypeSiblingsErrors = {
/**
* The resource is protected and requires an authentication token
*/
401: unknown;
/**
* The authenticated user does not have access to this resource
*/
403: unknown;
};
export type GetTreeMediaTypeSiblingsResponses = {
/**
* OK
*/
200: Array<MediaTypeTreeItemResponseModel>;
};
export type GetTreeMediaTypeSiblingsResponse = GetTreeMediaTypeSiblingsResponses[keyof GetTreeMediaTypeSiblingsResponses];
export type GetCollectionMediaData = {
body?: never;
path?: never;
@@ -9854,6 +10009,37 @@ export type GetTreeMediaRootResponses = {
export type GetTreeMediaRootResponse = GetTreeMediaRootResponses[keyof GetTreeMediaRootResponses];
export type GetTreeMediaSiblingsData = {
body?: never;
path?: never;
query?: {
target?: string;
before?: number;
after?: number;
};
url: '/umbraco/management/api/v1/tree/media/siblings';
};
export type GetTreeMediaSiblingsErrors = {
/**
* The resource is protected and requires an authentication token
*/
401: unknown;
/**
* The authenticated user does not have access to this resource
*/
403: unknown;
};
export type GetTreeMediaSiblingsResponses = {
/**
* OK
*/
200: Array<MediaTreeItemResponseModel>;
};
export type GetTreeMediaSiblingsResponse = GetTreeMediaSiblingsResponses[keyof GetTreeMediaSiblingsResponses];
export type GetItemMemberGroupData = {
body?: never;
path?: never;
@@ -12828,6 +13014,8 @@ export type GetSegmentData = {
query?: {
skip?: number;
take?: number;
documentId?: string;
documentTypeId?: string;
};
url: '/umbraco/management/api/v1/segment';
};
@@ -12841,10 +13029,6 @@ export type GetSegmentErrors = {
* The resource is protected and requires an authentication token
*/
401: unknown;
/**
* The authenticated user does not have access to this resource
*/
403: unknown;
};
export type GetSegmentError = GetSegmentErrors[keyof GetSegmentErrors];
@@ -13962,6 +14146,37 @@ export type GetTreeTemplateRootResponses = {
export type GetTreeTemplateRootResponse = GetTreeTemplateRootResponses[keyof GetTreeTemplateRootResponses];
export type GetTreeTemplateSiblingsData = {
body?: never;
path?: never;
query?: {
target?: string;
before?: number;
after?: number;
};
url: '/umbraco/management/api/v1/tree/template/siblings';
};
export type GetTreeTemplateSiblingsErrors = {
/**
* The resource is protected and requires an authentication token
*/
401: unknown;
/**
* The authenticated user does not have access to this resource
*/
403: unknown;
};
export type GetTreeTemplateSiblingsResponses = {
/**
* OK
*/
200: Array<NamedEntityTreeItemResponseModel>;
};
export type GetTreeTemplateSiblingsResponse = GetTreeTemplateSiblingsResponses[keyof GetTreeTemplateSiblingsResponses];
export type PostTemporaryFileData = {
body?: {
Id: string;
@@ -16081,6 +16296,10 @@ export type GetWebhookByIdLogsErrors = {
* The resource is protected and requires an authentication token
*/
401: unknown;
/**
* The authenticated user does not have access to this resource
*/
403: unknown;
};
export type GetWebhookByIdLogsResponses = {
@@ -16137,6 +16356,10 @@ export type GetWebhookLogsErrors = {
* The resource is protected and requires an authentication token
*/
401: unknown;
/**
* The authenticated user does not have access to this resource
*/
403: unknown;
};
export type GetWebhookLogsResponses = {
@@ -22,6 +22,7 @@ export class UmbSegmentCollectionServerDataSource
* @memberof UmbLanguageCollectionServerDataSource
*/
async getCollection(filter: UmbSegmentCollectionFilterModel) {
debugger;
const { data, error } = await tryExecute(this, SegmentService.getSegment({ query: filter }));
if (data) {
@@ -3,4 +3,6 @@ export type * from './repository/types.js';
export interface UmbSegmentCollectionFilterModel {
skip?: number;
take?: number;
documentTypeUnique?: string;
documentUnique?: string;
}