Skip to content

Updated management API endpoint and model for data type references to align with that used for documents, media etc. #18905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Apr 1, 2025

Prerequisites

  • I have added steps to test this contribution in the description below

Handles internal task (HQ link).

Description

Although we already have a method for retrieving references for data types, it's not aligned from a management API endpoint and model perspective with that returned for document, media and members. We would like it to be so the front-end can handle in a consistent way.

This PR does that - obsoleting the existing method at the API and service layer and introducing new paged endpoints and service methods that return the appropriate models.

Note that under the hood these "relations" are quite different to the document, media and member ones that rely on Umbraco relations. These are derived from the Umbraco schema itself.

I decided not to do the paging at the database level and hence have reused existing repository methods. This was certainly simpler, as we would otherwise need to combine and page two already complicated database queries. And it seems reasonable given the number of relations here are relatively small compared to relations from documents, and the previous implementation wasn't paged.

Testing

Verify via the /umbraco/management/api/v1/data-type/{id}/referenced-by?skip={skip?&take={take} management API endpoint.

You should retrieve a response like the following:

{
  "total": 24,
  "items": [
    {
      "$type": "DocumentTypePropertyReferenceResponseModel",
      "documentType": {
        "id": "ee9c4aed-156a-499e-b467-8de4e4d02b34",
        "icon": "icon-map-location color-black",
        "alias": "contact",
        "name": "Contact"
      },
      "alias": "contactFormHeader",
      "id": "f46f193d-5e40-4d6a-ac94-4f77703d7fde",
      "name": "Contact Form Header"
    }
  ]
}

@Copilot Copilot AI review requested due to automatic review settings April 1, 2025 12:37
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the management API for data type references so that the response model aligns with those used for document, media, and member references.

  • New paged endpoint for retrieving data type references.
  • Introduces consolidated relation retrieval from both property and list view usages.
  • Updates mapping definitions and controllers to support the new response models.

Reviewed Changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/DataTypeServiceTests.cs Added tests for the new GetPagedRelationsAsync functionality
tests/Umbraco.Tests.Common/Builders/MediaTypeBuilder.cs Updated media type builder to include an icon value for media types
src/Umbraco.Core/Services/IDataTypeService.cs Added new GetPagedRelationsAsync method and marked legacy methods as obsolete
src/Umbraco.Core/Services/DataTypeService.cs Introduced overloaded constructors and implemented GetPagedRelationsAsync with consolidated usages
src/Umbraco.Core/Persistence/Repositories/IDataTypeRepository.cs Minor removal of an empty line
src/Umbraco.Core/Models/RelationItemModel.cs Added property NodeAlias to support the new response model
src/Umbraco.Core/Constants-ReferenceTypes.cs Added a new class for reference types with updated properties
src/Umbraco.Cms.Api.Management/* Updated view models, mapping definitions, and controllers to accommodate refactored relation responses
src/Umbraco.Cms.Api.Management/Controllers/DataType/ReferencesDataTypeController.cs Marked outdated controller obsolete in favor of the new endpoint
src/Umbraco.Cms.Api.Management/Controllers/DataType/References/ReferencedByDataTypeController.cs Introduced new controller for retrieving paged data type relations
Files not reviewed (1)
  • src/Umbraco.Cms.Api.Management/OpenApi.json: Language not supported
Comments suppressed due to low confidence (2)

src/Umbraco.Core/Services/DataTypeService.cs:71

  • The parameter name 'memberTypeRepositor' appears to be a typo; consider renaming it to 'memberTypeRepository' for clarity.
IMemberTypeRepository memberTypeRepositor,

src/Umbraco.Cms.Api.Management/Controllers/DataType/References/ReferencedByDataTypeController.cs:11

  • The namespace contains 'DateType' which likely should be 'DataType' to stay consistent with the rest of the codebase.
namespace Umbraco.Cms.Api.Management.Controllers.DateType.References;

Copy link
Contributor

@madsrasmussen madsrasmussen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speaking from a consumer perspective 😃

It looks really good and works as expected. One minor detail is the naming of the reference. I believe the correct name is "DocumentTypePropertyType," with the extra "Type" after "Property." I think what exists on a Document Type are Property Types, and what exists on the Document are properties. The same applies to the other Content Types 🤔

@AndyButland AndyButland changed the base branch from contrib to v15/dev April 2, 2025 10:13
@AndyButland
Copy link
Contributor Author

Thanks @madsrasmussen, agreed - I've updated the model and constants to align with this naming structure.

@madsrasmussen
Copy link
Contributor

@AndyButland @nikolajlauridsen Everything looks good on the frontend. Feel free to merge when you're satisfied! 😄

I have opened a PR for the UI here #18914

Copy link
Contributor

@nikolajlauridsen nikolajlauridsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, fixed a minor multiple enumeration thing

@nielslyngsoe nielslyngsoe merged commit 1f4c19d into v15/dev Apr 4, 2025
20 of 21 checks passed
@nielslyngsoe nielslyngsoe deleted the v15/task/align-data-type-reference-endpoint-and-model branch April 4, 2025 13:10
kjac added a commit that referenced this pull request Apr 9, 2025
* Only prevent the unpublish or delete of a related item when configured to do so if it is related as a child, not as a parent (#18886)

* Only prevent the unpubkish or delete of a related item when configured to do so if it is related as a child, not as a parent.

* Fixed incorect parameter names.

* Fixed failing integration tests.

* Use using variable instead to reduce nesting

* Applied suggestions from code review.

* Used simple using statement throughout RelationService for consistency.

* Applied XML header comments consistently.

---------

Co-authored-by: mole <[email protected]>

* Feature: highlight invariant doc with variant blocks is unsupported (#18806)

* mark variant blocks in invariant docs as invalid

* implement RTE Blocks

* Fix pagination for users restricted by start nodes (#18907)

* Fix pagination for users restricted by start nodes

* Default implementation to avoid breakage

* Review comments

* Fix failing test

* Add media start node tests

* Fix issue preventing blueprint derived values from being scaffolded (#18917)

* Fix issue preventing blueprint derived values from being scaffolded.

* fix manipulating frooen array

* compare with variantId as well

---------

Co-authored-by: Niels Lyngsø <[email protected]>

* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure [email protected]

* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure [email protected]

* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure [email protected]

* Remove admin permission on user configuration, allowing users with user section access only to manaage users and groups. (#18848)

* Tiptap RTE: Style Menu extension kind (#18918)

* Adds 'styleMenu' Tiptap toolbar extension kind

* Adds icons for `<h4>` and `<p>` tags

* Adds commands to HTML Global Attributes extension

for setting the `class` and `id` attributes.

* Renamed "default-tiptap-toolbar-element.api.ts" file

The "element" part was confusing.

* Toolbar Menu: uses correct `item` value

* Cascading Menu: adds localization for the label

* Adds `label` attribute to UUI components

for accessibility.

* Toolbar Menu: uses correct `appearance` value

* Removed unrequired `api` from Style Select

* Destructs the `item.data` object

* Ensure has children reflects only items with folder children when folders only are queried. (#18790)

* Ensure has children reflects only items with folder children when folders only are queried.

* Added supression for change to integration test public code.

---------

Co-authored-by: Migaroez <[email protected]>

* Only apply validation on content update to variant cultures where the editor has permission for the culture (#18778)

* Only apply validation on content update to variant cultures where the editor has permission for the culture.

* Remove inadvertent comment updates.

* Fixed failing integration test.

* Adds ancestor ID details on document tree and collection responses (#18909)

* Populate ancestor keys on document tree response items.

* Populate ancestor keys on document collection response items.

* Update OpenApi.json

* Use array of objects rather than Ids for the ancestor collection.

* Update OpenApi.json.

* Move publish with descendants to a background task with polling (#18497)

* Use background queue for database cache rebuild and track rebuilding status.

* Updated OpenApi.json and client-side types.

* Updated client to poll for completion of database rebuild.

* Move IBackgroundTaskQueue to core and prepare publish branch to run as background task.

* Endpoints for retrieval of status and result from branch publish operations.

* Poll and retrieve result for publish with descendants.

* Handled issues from testing.

* Rework to single controller for status and result.

* Updated client side sdk.

* OpenApi post dev merge gen

---------

Co-authored-by: Migaroez <[email protected]>

* Clear roots before rebuilding navigation dictionary (#18766)

* Clear roots before rebuilding navigation dictionary.

* Added tests to verify fix.

* Correct test implementation.

* Convert integration tests with method overloads into test cases.

* Integration test compatibility supressions.

* Fixes save of empty, invariant block list on variant content. (#18932)

* remove unnecessary code (#18927)

* V15/bugfix/fix route issue from 18859 (#18931)

* unique check

* unique for workspace empty path

* more unique routes

* Bump vite from 6.2.3 to 6.2.4 in /src/Umbraco.Web.UI.Client

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.3 to 6.2.4.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.2.4/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.2.4/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 6.2.4
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>

* removes autogenerated workflows

* make getHasUnpersistedChanges public (#18929)

* Added management API endpoint, service and repository for retrieval of references from the recycle bin (#18882)

* Added management API endpoint, service and repository for retrieval of references from the recycle bin.

* Update src/Umbraco.Cms.Api.Management/Controllers/Document/RecycleBin/ReferencedByDocumentRecycleBinController.cs

Co-authored-by: Copilot <[email protected]>

* Removed unused code.

---------

Co-authored-by: Copilot <[email protected]>

* Updated management API endpoint and model for data type references to align with that used for documents, media etc. (#18905)

* Updated management API endpoint and model for data type references to align with that used for documents, media etc.

* Refactoring.

* Update src/Umbraco.Core/Constants-ReferenceTypes.cs

Co-authored-by: Copilot <[email protected]>

* Fixed typos.

* Added id to tracked reference content type response.

* Updated OpenApi.json.

* Added missing updates.

* Renamed model and constants from code review feedback.

* Fix typo

* Fix multiple enumeration

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: mole <[email protected]>

* Skip lock tests

* Look-up redirect in content finder for multi-lingual sites using path and legacy route prefixed with the integer ID of the node with domains defined (#18763)

* Look-up redirect in content finder for multi-lingual sites using path and legacy route prefixed with the integer ID of the node with domains defined.

* Added tests to verify functionality.

* Added reference to previous PR.

* Referenced second PR.

* Assemble URLs for all cultures, not just the default.

* Revert previous update.

* Display an original URL if we have one.

* Bump vite from 6.2.4 to 6.2.5 in /src/Umbraco.Web.UI.Client

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.4 to 6.2.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.2.5/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.2.5/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 6.2.5
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>

* Add raw value validation to multiple text strings property editor (#18936)

* Add raw value validation to multiple text strings property editor

* Added additional assert on unit test and comment on validation logic.

* Don't remove items to obtain a valid value

---------

Co-authored-by: Andy Butland <[email protected]>

* Integration tests for content publishing with ancestor unpublished (#18941)

* Resolved warnings in test class.

* Refactor regions into partial classes.

* Aligned test names.

* Variable name refactoring.

* Added tests for unpublished paths.

* Adjust tests to verify current behaviour.

* Cleaned up project file.

* fix circular icon import (#18952)

* remove segment toggle for elements (#18949)

* Fix modal route registration circular import (#18953)

* fix modal route registration circular import

* Update modal-route-registration.controller.ts

* V15/fix/18595 (#18925)

* fix for #18595

* updates the en.ts

* Avoid unneeded Dictionary operations (#18890)

* Avoid some heap allocations

* Remove unneeded double seek

* Avoid allocating new empty arrays, reuse existing empty array

* Avoid allocating strings for parsing comma separated int values (#18199)

* Data type References UI: Workspace + Delete (#18914)

* Updated management API endpoint and model for data type references to align with that used for documents, media etc.

* Refactoring.

* Update src/Umbraco.Core/Constants-ReferenceTypes.cs

Co-authored-by: Copilot <[email protected]>

* Fixed typos.

* generate server models

* add extension slot

* register data type reference info app

* add reference data mappers

* Added id to tracked reference content type response.

* Updated OpenApi.json.

* Added missing updates.

* generate new models

* update models

* register ref item

* remove debugger

* render types

* register member type property type ref

* register media type property type ref

* Renamed model and constants from code review feedback.

* register reference workspace info app kind

* use kind for document references

* use kind for media references

* use kind for member references

* use deleteWithRelation kind when deleting data types

* fix manifest types

* fix types

* Update types.gen.ts

* update code to fit new server models

---------

Co-authored-by: Andy Butland <[email protected]>
Co-authored-by: Copilot <[email protected]>

* Feature: discard changes for block workspace (#18930)

* make getHasUnpersistedChanges public

* Discard changes impl for Block Workspace

* fix 18367 (#18956)

* Merge commit from fork

* Prevent path traveral vulnerability with upload of temporary files.

* Used BadRequest instead of NotFound for invalid file name response.

* V15 QA Fixing the failing media acceptance tests (#18881)

* Fixed the function name due to test helper changes

* Updated assertion steps due to UI changes

* Added more waits

* Bumped version

* Increase timeout

* Reverted

---------

Co-authored-by: Andreas Zerbst <[email protected]>

* V15 QA added clipboard test for not being able to copy to root when block is not allowed at root (#18937)

* Added clipboard test

* Bumped version

* Updated to use the name

* Run all tests on the pipeline

* Reverted command

* build: adjusts circular ref number to 4

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Andy Butland <[email protected]>
Co-authored-by: mole <[email protected]>
Co-authored-by: Niels Lyngsø <[email protected]>
Co-authored-by: Niels Lyngsø <[email protected]>
Co-authored-by: Jacob Overgaard <[email protected]>
Co-authored-by: Lee Kelleher <[email protected]>
Co-authored-by: Migaroez <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Nikolaj Geisle <[email protected]>
Co-authored-by: Mads Rasmussen <[email protected]>
Co-authored-by: Jacob Welander Jensen <[email protected]>
Co-authored-by: Henrik <[email protected]>
Co-authored-by: Sebastiaan Janssen <[email protected]>
Co-authored-by: Nhu Dinh <[email protected]>
Co-authored-by: Andreas Zerbst <[email protected]>
nielslyngsoe pushed a commit that referenced this pull request Apr 9, 2025
… align with that used for documents, media etc. (#18905)

* Updated management API endpoint and model for data type references to align with that used for documents, media etc.

* Refactoring.

* Update src/Umbraco.Core/Constants-ReferenceTypes.cs

Co-authored-by: Copilot <[email protected]>

* Fixed typos.

* Added id to tracked reference content type response.

* Updated OpenApi.json.

* Added missing updates.

* Renamed model and constants from code review feedback.

* Fix typo

* Fix multiple enumeration

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: mole <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants