-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: media server validation (#17591)
* implement validation for media and prepare for member * remove import * use repository response type --------- Co-authored-by: Mads Rasmussen <[email protected]>
- Loading branch information
1 parent
e87d1fc
commit 419a8e1
Showing
17 changed files
with
235 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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
8 changes: 8 additions & 0 deletions
8
...UI.Client/src/packages/core/content/repository/content-validation-repository.interface.ts
This file contains 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,8 @@ | ||
import type { UmbContentDetailModel } from '../types.js'; | ||
import type { UmbVariantId } from '@umbraco-cms/backoffice/variant'; | ||
import type { UmbRepositoryResponse } from '@umbraco-cms/backoffice/repository'; | ||
|
||
export interface UmbContentValidationRepository<DetailModelType extends UmbContentDetailModel> { | ||
validateCreate(model: DetailModelType, parentUnique: string | null): Promise<UmbRepositoryResponse<string>>; | ||
validateSave(model: DetailModelType, variantIds: Array<UmbVariantId>): Promise<UmbRepositoryResponse<string>>; | ||
} |
1 change: 1 addition & 0 deletions
1
src/Umbraco.Web.UI.Client/src/packages/core/content/repository/index.ts
This file contains 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 './content-validation-repository.interface.js'; |
This file contains 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 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 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 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 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 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 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/members/member/repository/index.ts
This file contains 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,3 @@ | ||
export { UmbMemberDetailRepository } from './detail/index.js'; | ||
export { UmbMemberItemRepository, type UmbMemberItemModel } from './item/index.js'; | ||
export * from './validation/index.js'; |
3 changes: 2 additions & 1 deletion
3
src/Umbraco.Web.UI.Client/src/packages/members/member/repository/manifests.ts
This file contains 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 @@ | ||
import { manifests as detailManifests } from './detail/manifests.js'; | ||
import { manifests as itemManifests } from './item/manifests.js'; | ||
import { manifests as validationManifests } from './validation/manifests.js'; | ||
|
||
export const manifests: Array<UmbExtensionManifest> = [...detailManifests, ...itemManifests]; | ||
export const manifests: Array<UmbExtensionManifest> = [...detailManifests, ...itemManifests, ...validationManifests]; |
2 changes: 2 additions & 0 deletions
2
src/Umbraco.Web.UI.Client/src/packages/members/member/repository/validation/index.ts
This file contains 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,2 @@ | ||
export { UmbMemberValidationRepository } from './member-validation.repository.js'; | ||
export { UMB_MEMBER_VALIDATION_REPOSITORY_ALIAS } from './manifests.js'; |
10 changes: 10 additions & 0 deletions
10
src/Umbraco.Web.UI.Client/src/packages/members/member/repository/validation/manifests.ts
This file contains 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,10 @@ | ||
export const UMB_MEMBER_VALIDATION_REPOSITORY_ALIAS = 'Umb.Repository.Member.Validation'; | ||
|
||
export const manifests: Array<UmbExtensionManifest> = [ | ||
{ | ||
type: 'repository', | ||
alias: UMB_MEMBER_VALIDATION_REPOSITORY_ALIAS, | ||
name: 'Member Validation Repository', | ||
api: () => import('./member-validation.repository.js'), | ||
}, | ||
]; |
48 changes: 48 additions & 0 deletions
48
....Client/src/packages/members/member/repository/validation/member-validation.repository.ts
This file contains 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,48 @@ | ||
import type { UmbMemberDetailModel } from '../../types.js'; | ||
import { UmbMemberValidationServerDataSource } from './member-validation.server.data-source.js'; | ||
import type { UmbVariantId } from '@umbraco-cms/backoffice/variant'; | ||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; | ||
import { UmbRepositoryBase } from '@umbraco-cms/backoffice/repository'; | ||
import type { UmbContentValidationRepository } from '@umbraco-cms/backoffice/content'; | ||
|
||
type DetailModelType = UmbMemberDetailModel; | ||
|
||
export class UmbMemberValidationRepository | ||
extends UmbRepositoryBase | ||
implements UmbContentValidationRepository<DetailModelType> | ||
{ | ||
#validationDataSource: UmbMemberValidationServerDataSource; | ||
|
||
constructor(host: UmbControllerHost) { | ||
super(host); | ||
|
||
this.#validationDataSource = new UmbMemberValidationServerDataSource(this); | ||
} | ||
|
||
/** | ||
* Returns a promise with an observable of the detail for the given unique | ||
* @param {DetailModelType} model - The model to validate | ||
* @param {string | null} [parentUnique] - The parent unique | ||
* @returns {*} | ||
*/ | ||
async validateCreate(model: DetailModelType, parentUnique: string | null) { | ||
if (!model) throw new Error('Data is missing'); | ||
|
||
return this.#validationDataSource.validateCreate(model, parentUnique); | ||
} | ||
|
||
/** | ||
* Saves the given data | ||
* @param {DetailModelType} model - The model to save | ||
* @param {Array<UmbVariantId>} variantIds - The variant ids to save | ||
* @returns {*} | ||
*/ | ||
async validateSave(model: DetailModelType, variantIds: Array<UmbVariantId>) { | ||
if (!model) throw new Error('Data is missing'); | ||
if (!model.unique) throw new Error('Unique is missing'); | ||
|
||
return this.#validationDataSource.validateUpdate(model, variantIds); | ||
} | ||
} | ||
|
||
export { UmbMemberValidationRepository as api }; |
Oops, something went wrong.