Skip to content

Commit e8c4fb9

Browse files
Feature: Published Document Pending Changes (#17812)
* implement validation for media and prepare for member * remove import * port code from backoffice repo * move repo into publishing module * port get published methods * cleanup * wip render state * align state UI * post merge clean up * move publish modal * move schedule modal * move unpublish modal * move publish action and bulk action * move unpublish action + bulk action * lint fix * Update document-workspace.context.ts * wip move publishing methods to publishing context * move publish with descendants * fix more references * Update document-publishing.workspace-context.ts * export entity action * add return type * temp internal methods * use repository response type * expose methods for other contexts to use * use public methods * call publishing context methods * fix import * move manager into folder * organise in folders * add get method to get variants with changes * preselect variants with pending changes * observe data changes * render pending changes client state * observe unique * Update document-publishing.server.data-source.ts * use correct key * clean up * expose persisted data * rename arg * use persisted data instead of current * add reload method * reload data after publish * remove headline * handle all publish actions the same * reset state as the first thing when creating + loading * add method to get variants * only load published if document has a published variant * remove variants from observer * add public method to get the changed variants * align preselection with current logic * add deprecation util * add method deprecation warnings * remove unused publish method * move publishing workspace actions into publishing module * use publishing context * clean up * add tests for published pending changes manager * handle server the same way * process pending changes when persisted data changes * remove buggy updateDate * remove unused * lint fix * add publish method back to avoid a breaking change --------- Co-authored-by: Niels Lyngsø <[email protected]> Co-authored-by: Niels Lyngsø <[email protected]>
1 parent b6351f9 commit e8c4fb9

File tree

115 files changed

+1578
-712
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1578
-712
lines changed

src/Umbraco.Web.UI.Client/src/apps/installer/consent/installer-content.test.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Umbraco.Web.UI.Client/src/apps/installer/database/installer-database.test.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Umbraco.Web.UI.Client/src/apps/installer/error/installer-error.test.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Umbraco.Web.UI.Client/src/apps/installer/installing/installer-installing.test.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Umbraco.Web.UI.Client/src/apps/installer/shared/layout/installer-layout.test.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Umbraco.Web.UI.Client/src/apps/installer/user/installer-user.test.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ export default {
654654
indexCannotRebuild: 'This index cannot be rebuilt because it has no assigned',
655655
iIndexPopulator: 'IIndexPopulator',
656656
corruptStatus: 'Possible corrupt index detected',
657-
corruptErrorDescription: 'Error received when evaluating the index:'
657+
corruptErrorDescription: 'Error received when evaluating the index:',
658658
},
659659
placeholders: {
660660
username: 'Enter your username',

src/Umbraco.Web.UI.Client/src/packages/core/content/workspace/content-detail-workspace-base.ts

Lines changed: 90 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@ export interface UmbContentDetailWorkspaceContextArgs<
6363
saveModalToken?: UmbModalToken<UmbContentVariantPickerData<VariantOptionModelType>, UmbContentVariantPickerValue>;
6464
}
6565

66+
/**
67+
* The base class for a content detail workspace context.
68+
* @exports
69+
* @abstract
70+
* @class UmbContentDetailWorkspaceContextBase
71+
* @augments {UmbEntityDetailWorkspaceContextBase<DetailModelType, DetailRepositoryType, CreateArgsType>}
72+
* @implements {UmbContentWorkspaceContext<DetailModelType, ContentTypeDetailModelType, VariantModelType>}
73+
* @template DetailModelType
74+
* @template DetailRepositoryType
75+
* @template ContentTypeDetailModelType
76+
* @template VariantModelType
77+
* @template VariantOptionModelType
78+
* @template CreateArgsType
79+
*/
6680
export abstract class UmbContentDetailWorkspaceContextBase<
6781
DetailModelType extends UmbContentDetailModel<VariantModelType>,
6882
DetailRepositoryType extends UmbDetailRepository<DetailModelType> = UmbDetailRepository<DetailModelType>,
@@ -83,8 +97,11 @@ export abstract class UmbContentDetailWorkspaceContextBase<
8397

8498
/* Content Data */
8599
protected override readonly _data = new UmbContentWorkspaceDataManager<DetailModelType, VariantModelType>(this);
100+
101+
public override readonly data = this._data.current;
86102
public readonly values = this._data.createObservablePartOfCurrent((data) => data?.values);
87103
public readonly variants = this._data.createObservablePartOfCurrent((data) => data?.variants ?? []);
104+
public override readonly persistedData = this._data.persisted;
88105

89106
/* Content Type (Structure) Data */
90107
public readonly structure;
@@ -332,6 +349,10 @@ export abstract class UmbContentDetailWorkspaceContextBase<
332349
return this._data.getCurrent()?.variants?.find((x) => variantId.compare(x));
333350
}
334351

352+
public getVariants(): Array<VariantModelType> | undefined {
353+
return this._data.getCurrent()?.variants;
354+
}
355+
335356
/**
336357
* Observe the property type
337358
* @param {string} propertyId - The id of the property
@@ -440,7 +461,19 @@ export abstract class UmbContentDetailWorkspaceContextBase<
440461
this._data.finishPropertyValueChange();
441462
};
442463

443-
protected async _determineVariantOptions() {
464+
/**
465+
* Gets the changed variant ids
466+
* @returns {Array<UmbVariantId>} - The changed variant ids
467+
* @memberof UmbContentDetailWorkspaceContextBase
468+
*/
469+
public getChangedVariants(): Array<UmbVariantId> {
470+
return this._data.getChangedVariants();
471+
}
472+
473+
protected async _determineVariantOptions(): Promise<{
474+
options: VariantOptionModelType[];
475+
selected: string[];
476+
}> {
444477
const options = await firstValueFrom(this.variantOptions);
445478

446479
const activeVariants = this.splitView.getActiveVariants();
@@ -465,7 +498,23 @@ export abstract class UmbContentDetailWorkspaceContextBase<
465498
};
466499

467500
/* validation */
501+
/**
502+
* Run the mandatory validation for the save data
503+
* @deprecated Use the public runMandatoryValidationForSaveData instead. Will be removed in v. 17.
504+
* @protected
505+
* @param {DetailModelType} saveData - The data to validate
506+
* @memberof UmbContentDetailWorkspaceContextBase
507+
*/
468508
protected async _runMandatoryValidationForSaveData(saveData: DetailModelType) {
509+
this.runMandatoryValidationForSaveData(saveData);
510+
}
511+
512+
/**
513+
* Run the mandatory validation for the save data
514+
* @param {DetailModelType} saveData - The data to validate
515+
* @memberof UmbContentDetailWorkspaceContextBase
516+
*/
517+
public async runMandatoryValidationForSaveData(saveData: DetailModelType) {
469518
// Check that the data is valid before we save it.
470519
// Check variants have a name:
471520
const variantsWithoutAName = saveData.variants.filter((x) => !x.name);
@@ -482,7 +531,13 @@ export abstract class UmbContentDetailWorkspaceContextBase<
482531
}
483532
}
484533

485-
protected async _askServerToValidate(saveData: DetailModelType, variantIds: Array<UmbVariantId>) {
534+
/**
535+
* Ask the server to validate the save data
536+
* @param {DetailModelType} saveData - The data to validate
537+
* @param {Array<UmbVariantId>} variantIds - The variant ids to validate
538+
* @memberof UmbContentDetailWorkspaceContextBase
539+
*/
540+
public async askServerToValidate(saveData: DetailModelType, variantIds: Array<UmbVariantId>) {
486541
if (this.#validationRepositoryClass) {
487542
// Create the validation repository if it does not exist. (we first create this here when we need it) [NL]
488543
this.#validationRepository ??= new this.#validationRepositoryClass(this);
@@ -516,6 +571,16 @@ export abstract class UmbContentDetailWorkspaceContextBase<
516571
return this._handleSubmit();
517572
}
518573

574+
/**
575+
* Get the data to save
576+
* @param {Array<UmbVariantId>} variantIds - The variant ids to save
577+
* @returns {Promise<DetailModelType>} {Promise<DetailModelType>}
578+
* @memberof UmbContentDetailWorkspaceContextBase
579+
*/
580+
public constructSaveData(variantIds: Array<UmbVariantId>): Promise<DetailModelType> {
581+
return this._data.constructData(variantIds);
582+
}
583+
519584
protected async _handleSubmit() {
520585
const data = this.getData();
521586
if (!data) {
@@ -553,24 +618,42 @@ export abstract class UmbContentDetailWorkspaceContextBase<
553618
throw new Error('No variant picker modal token is set. There are multiple variants to save. Cannot proceed.');
554619
}
555620

556-
const saveData = await this._data.constructData(variantIds);
557-
await this._runMandatoryValidationForSaveData(saveData);
621+
const saveData = await this.constructSaveData(variantIds);
622+
await this.runMandatoryValidationForSaveData(saveData);
558623
if (this.#validateOnSubmit) {
559-
await this._askServerToValidate(saveData, variantIds);
624+
await this.askServerToValidate(saveData, variantIds);
560625
return this.validateAndSubmit(
561626
async () => {
562-
return this._performCreateOrUpdate(variantIds, saveData);
627+
return this.performCreateOrUpdate(variantIds, saveData);
563628
},
564629
async () => {
565630
return this.invalidSubmit();
566631
},
567632
);
568633
} else {
569-
await this._performCreateOrUpdate(variantIds, saveData);
634+
await this.performCreateOrUpdate(variantIds, saveData);
570635
}
571636
}
572637

638+
/**
639+
* Perform the create or update of the content
640+
* @deprecated Use the public performCreateOrUpdate instead. Will be removed in v. 17.
641+
* @protected
642+
* @param {Array<UmbVariantId>} variantIds
643+
* @param {DetailModelType} saveData
644+
* @memberof UmbContentDetailWorkspaceContextBase
645+
*/
573646
protected async _performCreateOrUpdate(variantIds: Array<UmbVariantId>, saveData: DetailModelType) {
647+
await this.performCreateOrUpdate(variantIds, saveData);
648+
}
649+
650+
/**
651+
* Perform the create or update of the content
652+
* @param {Array<UmbVariantId>} variantIds - The variant ids to save
653+
* @param {DetailModelType} saveData - The data to save
654+
* @memberof UmbContentDetailWorkspaceContextBase
655+
*/
656+
public async performCreateOrUpdate(variantIds: Array<UmbVariantId>, saveData: DetailModelType) {
574657
if (this.getIsNew()) {
575658
await this.#create(variantIds, saveData);
576659
} else {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import type { UmbDeprecationArgs } from './types.js';
2+
3+
/**
4+
* Helper class for deprecation warnings.
5+
* @exports
6+
* @class UmbDeprecation
7+
*/
8+
export class UmbDeprecation {
9+
#messagePrefix: string = 'Umbraco Backoffice:';
10+
#deprecated: string;
11+
#removeInVersion: string;
12+
#solution: string;
13+
14+
constructor(args: UmbDeprecationArgs) {
15+
this.#deprecated = args.deprecated;
16+
this.#removeInVersion = args.removeInVersion;
17+
this.#solution = args.solution;
18+
}
19+
20+
/**
21+
* Logs a warning message to the console.
22+
* @memberof UmbDeprecation
23+
*/
24+
warn() {
25+
console.warn(
26+
`${this.#messagePrefix} ${this.#deprecated} The feature will be removed in version ${this.#removeInVersion}. ${this.#solution}`,
27+
);
28+
}
29+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './deprecation.js';
2+
3+
export type * from './types.js';

0 commit comments

Comments
 (0)