-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Segmentation: The Backoffice should use the enhanced endpoint to fetch segment options for documents based on GUID #20340
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
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8100911
feat: adds new repository for document by id segment options
iOvergaard f1f3109
chore: mocks up the new endpoint
iOvergaard b8c2273
feat: all 'null' segments should appear on all languages
iOvergaard d1f2fdc
feat: uses new endpoint in content detail workspace base
iOvergaard 1ad62fe
feat: maps up the name of the segment
iOvergaard d231c6a
chore: mock segment data
iOvergaard 8dec40d
feat: adds filter on available segments
iOvergaard 166f116
Merge remote-tracking branch 'origin/v17/dev' into v16/feature/docume…
iOvergaard cf27515
feat: do not alter behavior depending on "undefined" and "null"
iOvergaard 9687810
chore: updates mock handler
iOvergaard 6173a36
Merge branch 'v17/dev' into v16/feature/document-segment-options
iOvergaard b13a46a
Merge branch 'v17/dev' into v16/feature/document-segment-options
iOvergaard 99b995d
feat: ensures that the segments are loaded based on an override metho…
iOvergaard 98104fc
feat: refines the segment filter
iOvergaard 37a06ed
Merge branch 'v17/dev' into v16/feature/document-segment-options
iOvergaard 03c60ce
chore: updates deprecated model
iOvergaard 975f0c4
feat: treats all culture-less segments as applying to everything
iOvergaard 45bbae5
Merge remote-tracking branch 'origin/v17/dev' into v16/feature/docume…
iOvergaard 48a254b
docs: updates console warn for developers
iOvergaard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { UmbDocumentDetailRepository } from './detail/index.js'; | ||
export { UmbDocumentPreviewRepository } from './preview/index.js'; | ||
export { UmbDocumentSegmentRepository } from './segment/index.js'; | ||
|
||
export * from './constants.js'; |
41 changes: 41 additions & 0 deletions
41
...Client/src/packages/documents/documents/repository/segment/document-segment.repository.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import type { UmbDocumentSegmentFilterModel } from './types.js'; | ||
import { UmbRepositoryBase, type UmbRepositoryResponse } from '@umbraco-cms/backoffice/repository'; | ||
import { DocumentService } from '@umbraco-cms/backoffice/external/backend-api'; | ||
import { tryExecute } from '@umbraco-cms/backoffice/resources'; | ||
import type { UmbSegmentModel, UmbSegmentResponseModel } from '@umbraco-cms/backoffice/segment'; | ||
|
||
export class UmbDocumentSegmentRepository extends UmbRepositoryBase { | ||
/** | ||
* Get available segment options for a document by its ID. | ||
* @param {string} unique The unique identifier of the document. | ||
* @param {UmbDocumentSegmentFilterModel} filter The filter options to apply. | ||
* @returns A promise that resolves with the available segment options. | ||
*/ | ||
async getDocumentByIdSegmentOptions( | ||
unique: string, | ||
filter: UmbDocumentSegmentFilterModel, | ||
): Promise<UmbRepositoryResponse<UmbSegmentResponseModel>> { | ||
const { data, error } = await tryExecute( | ||
this, | ||
// eslint-disable-next-line @typescript-eslint/no-deprecated | ||
DocumentService.getDocumentByIdAvailableSegmentOptions({ path: { id: unique }, query: filter }), | ||
iOvergaard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
|
||
if (data) { | ||
const items = data.items.map((item) => { | ||
const model: UmbSegmentModel = { | ||
alias: item.alias, | ||
name: item.name, | ||
// eslint-disable-next-line @typescript-eslint/no-deprecated | ||
cultures: item.cultures, | ||
iOvergaard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
return model; | ||
}); | ||
|
||
return { data: { items, total: data.total } }; | ||
} | ||
|
||
return { error }; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/segment/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './document-segment.repository.js'; |
4 changes: 4 additions & 0 deletions
4
src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/segment/types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface UmbDocumentSegmentFilterModel { | ||
skip?: number; | ||
take?: number; | ||
} |
1 change: 1 addition & 0 deletions
1
src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type * from './segment/types.js'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
export type * from './entity.js'; | ||
export type * from './collection/types.js'; | ||
|
||
export interface UmbSegmentModel { | ||
/** | ||
* The unique alias of the segment. | ||
*/ | ||
alias: string; | ||
|
||
/** | ||
* The name of the segment used for display purposes. | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* An optional list of culture codes that the segment applies to. | ||
* If null, the segment applies to the invariant culture. | ||
* If undefined, the segment is considered generic and applies to all cultures. | ||
*/ | ||
cultures?: Array<string> | null; | ||
} | ||
|
||
export interface UmbSegmentResponseModel { | ||
items: Array<UmbSegmentModel>; | ||
total: number; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.