diff --git a/src/Umbraco.Web.UI.Client/src/installer/installer.context.ts b/src/Umbraco.Web.UI.Client/src/installer/installer.context.ts index e37289f8f0..1db94fb17e 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/installer.context.ts +++ b/src/Umbraco.Web.UI.Client/src/installer/installer.context.ts @@ -1,8 +1,13 @@ -import { BehaviorSubject, ReplaySubject } from 'rxjs'; +import { BehaviorSubject, Observable, ReplaySubject } from 'rxjs'; import { getInstallSettings, postInstallSetup } from '../core/api/fetcher'; import type { PostInstallRequest, ProblemDetails, UmbracoInstaller } from '../core/models'; +/** + * Context API for the installer + * @export + * @class UmbInstallerContext + */ export class UmbInstallerContext { private _data = new BehaviorSubject({ user: { name: '', email: '', password: '', subscribeToNewsletter: false }, @@ -23,44 +28,100 @@ export class UmbInstallerContext { this._loadInstallerSettings(); } - public currentStepChanges() { - return this._currentStep; + /** + * Observable method to get the current step in the installation process + * @public + * @return {*} {Observable} + * @memberof UmbInstallerContext + */ + public currentStepChanges(): Observable { + return this.currentStep; } - public installStatusChanges() { - return this._installStatus; + /** + * Observable method to get the install status in the installation process + * @public + * @return {*} {(Observable)} + * @memberof UmbInstallerContext + */ + public installStatusChanges(): Observable { + return this.installStatus; } - public nextStep() { + /** + * Increment the current step in the installation process + * @public + * @memberof UmbInstallerContext + */ + public nextStep(): void { this._currentStep.next(this._currentStep.getValue() + 1); } - public prevStep() { + /** + * Decrements the current step in the installation process + * @public + * @memberof UmbInstallerContext + */ + public prevStep(): void { this._currentStep.next(this._currentStep.getValue() - 1); } - public reset() { + /** + * Reset the installation process + * @public + * @memberof UmbInstallerContext + */ + public reset(): void { this._currentStep.next(1); this._installStatus.next(null); } - public appendData(data: any) { + /** + * Set the data for the installation process + * @public + * @param {Partial} data + * @memberof UmbInstallerContext + */ + public appendData(data: Partial): void { this._data.next({ ...this.getData(), ...data }); } - public getData() { + /** + * Get the data for the installation process + * @public + * @return {*} {PostInstallRequest} + * @memberof UmbInstallerContext + */ + public getData(): PostInstallRequest { return this._data.getValue(); } + /** + * Post the installation data to the API + * @public + * @return {*} + * @memberof UmbInstallerContext + */ public requestInstall() { // TODO: The post install will probably return a user in the future, so we have to set that context somewhere to let the client know that it is authenticated return postInstallSetup(this.getData()); } - public setInstallStatus(status: ProblemDetails | null) { + /** + * Set the install status + * @public + * @param {(ProblemDetails | null)} status + * @memberof UmbInstallerContext + */ + public setInstallStatus(status: ProblemDetails | null): void { this._installStatus.next(status); } + /** + * Load installer settings from the API + * @private + * @memberof UmbInstallerContext + */ private _loadInstallerSettings() { getInstallSettings({}).then(({ data }) => { this._settings.next(data);