marketplace url in server.update

This commit is contained in:
Drew Ansbacher
2022-02-10 10:28:21 -07:00
committed by Aiden McClelland
parent 1d8512e1dd
commit b66720dfd0
4 changed files with 138 additions and 92 deletions

View File

@@ -3,15 +3,21 @@ import { PackageDataEntry } from 'src/app/services/patch-db/data-model'
import { Breakages } from 'src/app/services/api/api.types'
import { exists } from 'src/app/util/misc.util'
import { ApiService } from '../../services/api/embassy-api.service'
import { InstallWizardComponent, SlideDefinition, TopbarParams } from './install-wizard.component'
import {
InstallWizardComponent,
SlideDefinition,
TopbarParams,
} from './install-wizard.component'
import { ConfigService } from 'src/app/services/config.service'
@Injectable({ providedIn: 'root' })
export class WizardBaker {
constructor (
constructor(
private readonly embassyApi: ApiService,
) { }
private readonly config: ConfigService,
) {}
update (values: {
update(values: {
id: string
title: string
version: string
@@ -20,25 +26,27 @@ export class WizardBaker {
const { id, title, version, installAlert } = values
const action = 'update'
const toolbar: TopbarParams = { action, title, version }
const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [
installAlert ? {
slide: {
selector: 'alert',
params: {
title: 'Warning',
message: installAlert,
titleColor: 'warning',
},
},
bottomBar: {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Next',
},
} : undefined,
installAlert
? {
slide: {
selector: 'alert',
params: {
title: 'Warning',
message: installAlert,
titleColor: 'warning',
},
},
bottomBar: {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Next',
},
}
: undefined,
{
slide: {
selector: 'dependents',
@@ -46,7 +54,10 @@ export class WizardBaker {
action,
verb: 'updating',
title,
fetchBreakages: () => this.embassyApi.dryUpdatePackage({ id, version }).then(breakages => breakages),
fetchBreakages: () =>
this.embassyApi
.dryUpdatePackage({ id, version })
.then(breakages => breakages),
},
},
bottomBar: {
@@ -63,11 +74,15 @@ export class WizardBaker {
action,
verb: 'beginning update for',
title,
executeAction: () => this.embassyApi.installPackage({ id, 'version-spec': version ? `=${version}` : undefined }),
executeAction: () =>
this.embassyApi.installPackage({
id,
'version-spec': version ? `=${version}` : undefined,
}),
},
},
bottomBar: {
cancel: { whileLoading: { } },
cancel: { whileLoading: {} },
finish: 'Dismiss',
},
},
@@ -75,7 +90,7 @@ export class WizardBaker {
return { toolbar, slideDefinitions: slideDefinitions.filter(exists) }
}
updateOS (values: {
updateOS(values: {
version: string
releaseNotes: { [version: string]: string }
headline: string
@@ -84,11 +99,11 @@ export class WizardBaker {
const action = 'update'
const title = 'EmbassyOS'
const toolbar: TopbarParams = { action, title, version }
const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [
{
slide : {
slide: {
selector: 'notes',
params: {
notes: releaseNotes,
@@ -111,11 +126,14 @@ export class WizardBaker {
action,
verb: 'beginning update for',
title,
executeAction: () => this.embassyApi.updateServer({ }),
executeAction: () =>
this.embassyApi.updateServer({
'marketplace-url': this.config.marketplace.url,
}),
},
},
bottomBar: {
cancel: { whileLoading: { }},
cancel: { whileLoading: {} },
finish: 'Dismiss',
},
},
@@ -123,7 +141,7 @@ export class WizardBaker {
return { toolbar, slideDefinitions: slideDefinitions.filter(exists) }
}
downgrade (values: {
downgrade(values: {
id: string
title: string
version: string
@@ -132,53 +150,64 @@ export class WizardBaker {
const { id, title, version, installAlert } = values
const action = 'downgrade'
const toolbar: TopbarParams = { action, title, version }
const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [
installAlert ? {
installAlert
? {
slide: {
selector: 'alert',
params: {
title: 'Warning',
message: installAlert,
titleColor: 'warning',
},
},
bottomBar: {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Next',
},
}
: undefined,
{
slide: {
selector: 'alert',
params: {
title: 'Warning',
message: installAlert,
titleColor: 'warning',
},
},
bottomBar: {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Next',
},
} : undefined,
{ slide: {
selector: 'dependents',
params: {
action,
verb: 'downgrading',
title,
fetchBreakages: () => this.embassyApi.dryUpdatePackage({ id, version }).then(breakages => breakages),
fetchBreakages: () =>
this.embassyApi
.dryUpdatePackage({ id, version })
.then(breakages => breakages),
},
},
bottomBar: {
cancel: {
whileLoading: { },
whileLoading: {},
afterLoading: { text: 'Cancel' },
},
next: 'Downgrade Anyway',
},
},
{ slide: {
{
slide: {
selector: 'complete',
params: {
action,
verb: 'beginning downgrade for',
title,
executeAction: () => this.embassyApi.installPackage({ id, 'version-spec': version ? `=${version}` : undefined }),
executeAction: () =>
this.embassyApi.installPackage({
id,
'version-spec': version ? `=${version}` : undefined,
}),
},
},
bottomBar: {
cancel: { whileLoading: { } },
cancel: { whileLoading: {} },
finish: 'Dismiss',
},
},
@@ -186,7 +215,7 @@ export class WizardBaker {
return { toolbar, slideDefinitions: slideDefinitions.filter(exists) }
}
uninstall (values: {
uninstall(values: {
id: string
title: string
version: string
@@ -195,7 +224,7 @@ export class WizardBaker {
const { id, title, version, uninstallAlert } = values
const action = 'uninstall'
const toolbar: TopbarParams = { action, title, version }
const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [
{
@@ -211,7 +240,8 @@ export class WizardBaker {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Continue' },
next: 'Continue',
},
},
{
slide: {
@@ -220,15 +250,19 @@ export class WizardBaker {
action,
verb: 'uninstalling',
title,
fetchBreakages: () => this.embassyApi.dryUninstallPackage({ id }).then(breakages => breakages),
fetchBreakages: () =>
this.embassyApi
.dryUninstallPackage({ id })
.then(breakages => breakages),
},
},
bottomBar: {
cancel: {
whileLoading: { },
whileLoading: {},
afterLoading: { text: 'Cancel' },
},
next: 'Uninstall' },
next: 'Uninstall',
},
},
{
slide: {
@@ -243,7 +277,7 @@ export class WizardBaker {
bottomBar: {
finish: 'Dismiss',
cancel: {
whileLoading: { },
whileLoading: {},
},
},
},
@@ -251,7 +285,7 @@ export class WizardBaker {
return { toolbar, slideDefinitions: slideDefinitions.filter(exists) }
}
stop (values: {
stop(values: {
id: string
title: string
version: string
@@ -259,7 +293,7 @@ export class WizardBaker {
const { title, version, id } = values
const action = 'stop'
const toolbar: TopbarParams = { action, title, version }
const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [
{
@@ -269,12 +303,15 @@ export class WizardBaker {
action,
verb: 'stopping',
title,
fetchBreakages: () => this.embassyApi.dryStopPackage({ id }).then(breakages => breakages),
fetchBreakages: () =>
this.embassyApi
.dryStopPackage({ id })
.then(breakages => breakages),
},
},
bottomBar: {
cancel: {
whileLoading: { },
whileLoading: {},
afterLoading: { text: 'Cancel' },
},
next: 'Stop Service',
@@ -293,7 +330,7 @@ export class WizardBaker {
bottomBar: {
finish: 'Dismiss',
cancel: {
whileLoading: { },
whileLoading: {},
},
},
},
@@ -301,14 +338,14 @@ export class WizardBaker {
return { toolbar, slideDefinitions }
}
configure (values: {
configure(values: {
pkg: PackageDataEntry
breakages: Breakages
}): InstallWizardComponent['params'] {
const { breakages, pkg } = values
const { title, version } = pkg.manifest
const action = 'configure'
const toolbar: TopbarParams = { action, title, version }
const toolbar: TopbarParams = { action, title, version }
const slideDefinitions: SlideDefinition[] = [
{
@@ -317,18 +354,21 @@ export class WizardBaker {
params: {
action,
verb: 'saving config for',
title, fetchBreakages: () => Promise.resolve(breakages),
title,
fetchBreakages: () => Promise.resolve(breakages),
},
},
bottomBar: {
cancel: {
afterLoading: { text: 'Cancel' },
},
next: 'Save Config Anyway' },
next: 'Save Config Anyway',
},
},
]
return { toolbar, slideDefinitions }
}
}
const defaultUninstallWarning = (serviceName: string) => `Uninstalling ${ serviceName } will result in the deletion of its data.`
const defaultUninstallWarning = (serviceName: string) =>
`Uninstalling ${serviceName} will result in the deletion of its data.`