move upgrader
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import { rest } from 'msw';
|
||||
|
||||
import { umbracoPath } from '@umbraco-cms/utils';
|
||||
import type { PostInstallRequest, UmbracoUpgrader } from '@umbraco-cms/models';
|
||||
import { UpgradeSettings } from '@umbraco-cms/backend-api';
|
||||
|
||||
export const handlers = [
|
||||
rest.get(umbracoPath('/upgrade/settings'), (_req, res, ctx) => {
|
||||
return res(
|
||||
// Respond with a 200 status code
|
||||
ctx.status(200),
|
||||
ctx.json<UmbracoUpgrader>({
|
||||
ctx.json<UpgradeSettings>({
|
||||
currentState: '2b20c6e7',
|
||||
newState: '2b20c6e8',
|
||||
oldVersion: '13.0.0',
|
||||
@@ -18,7 +18,7 @@ export const handlers = [
|
||||
);
|
||||
}),
|
||||
|
||||
rest.post<PostInstallRequest>(umbracoPath('/upgrade/authorize'), async (_req, res, ctx) => {
|
||||
rest.post(umbracoPath('/upgrade/authorize'), async (_req, res, ctx) => {
|
||||
await new Promise((resolve) => setTimeout(resolve, (Math.random() + 1) * 1000)); // simulate a delay of 1-2 seconds
|
||||
|
||||
return res(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { css, CSSResultGroup, html, LitElement } from 'lit';
|
||||
import { customElement, property } from 'lit/decorators.js';
|
||||
import { ifDefined } from 'lit/directives/if-defined.js';
|
||||
|
||||
import type { UmbracoUpgrader } from '@umbraco-cms/models';
|
||||
import { UpgradeSettings } from '@umbraco-cms/backend-api';
|
||||
|
||||
/**
|
||||
* @element umb-upgrader-view
|
||||
@@ -33,7 +32,7 @@ export class UmbUpgraderView extends LitElement {
|
||||
errorMessage = '';
|
||||
|
||||
@property({ type: Object, reflect: true })
|
||||
settings?: UmbracoUpgrader;
|
||||
settings?: UpgradeSettings;
|
||||
|
||||
private _renderLayout() {
|
||||
return html`
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
import { html, LitElement } from 'lit';
|
||||
import { customElement, state } from 'lit/decorators.js';
|
||||
import { getUpgradeSettings, PostUpgradeAuthorize } from '@umbraco-cms/backend-api';
|
||||
import type { UmbracoUpgrader } from '@umbraco-cms/models';
|
||||
|
||||
import '../installer/shared/layout/installer-layout.element';
|
||||
import './upgrader-view.element';
|
||||
|
||||
import { html, LitElement } from 'lit';
|
||||
import { customElement, state } from 'lit/decorators.js';
|
||||
import { ApiError, ProblemDetails, UpgradeResource, UpgradeSettings } from '@umbraco-cms/backend-api';
|
||||
|
||||
/**
|
||||
* @element umb-upgrader
|
||||
*/
|
||||
@customElement('umb-upgrader')
|
||||
export class UmbUpgrader extends LitElement {
|
||||
@state()
|
||||
private upgradeSettings?: UmbracoUpgrader;
|
||||
private upgradeSettings?: UpgradeSettings;
|
||||
|
||||
@state()
|
||||
private fetching = true;
|
||||
@@ -43,12 +42,12 @@ export class UmbUpgrader extends LitElement {
|
||||
this.fetching = true;
|
||||
|
||||
try {
|
||||
const { data } = await getUpgradeSettings({});
|
||||
|
||||
const data = await UpgradeResource.getUmbracoManagementApiV1UpgradeSettings();
|
||||
this.upgradeSettings = data;
|
||||
} catch (e) {
|
||||
if (e instanceof getUpgradeSettings.Error) {
|
||||
this.errorMessage = e.data.detail;
|
||||
if (e instanceof ApiError) {
|
||||
const error = e.body as ProblemDetails;
|
||||
this.errorMessage = error.detail;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +60,13 @@ export class UmbUpgrader extends LitElement {
|
||||
this.upgrading = true;
|
||||
|
||||
try {
|
||||
await PostUpgradeAuthorize({});
|
||||
await UpgradeResource.postUmbracoManagementApiV1UpgradeAuthorize();
|
||||
history.pushState(null, '', '/');
|
||||
} catch (e) {
|
||||
if (e instanceof PostUpgradeAuthorize.Error) {
|
||||
const error = e.getActualType();
|
||||
if (error.status === 400) {
|
||||
this.errorMessage = error.data.detail || 'Unknown error, please try again';
|
||||
if (e instanceof ApiError) {
|
||||
const error = e.body as ProblemDetails;
|
||||
if (e.status === 400) {
|
||||
this.errorMessage = error.detail || 'Unknown error, please try again';
|
||||
}
|
||||
} else {
|
||||
this.errorMessage = 'Unknown error, please try again';
|
||||
|
||||
Reference in New Issue
Block a user