From ded4c6a597d62e5be18b91b70951e02cce621e82 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 20 Oct 2021 14:51:52 -0600 Subject: [PATCH] new return type for dry configure dependency --- .../app/modals/app-config/app-config.page.ts | 19 +++++--- ui/src/app/services/api/api.types.ts | 6 ++- .../services/api/embassy-mock-api.service.ts | 44 ++++++++++--------- 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/ui/src/app/modals/app-config/app-config.page.ts b/ui/src/app/modals/app-config/app-config.page.ts index ca8269d52..d8c06aab7 100644 --- a/ui/src/app/modals/app-config/app-config.page.ts +++ b/ui/src/app/modals/app-config/app-config.page.ts @@ -49,14 +49,23 @@ export class AppConfigPage { if (!this.hasConfig) return try { - this.loadingText = 'Loading Config' - const { spec, config } = await this.embassyApi.getPackageConfig({ id: this.pkgId }) - let depConfig: object + + let oldConfig: object + let newConfig: object + let spec: ConfigSpec if (this.rec) { this.loadingText = `Setting properties to accommodate ${this.rec.dependentTitle}` - depConfig = await this.embassyApi.dryConfigureDependency({ 'dependency-id': this.pkgId, 'dependent-id': this.rec.dependentId }) + const { 'old-config': oc, 'new-config': nc, spec: s } = await this.embassyApi.dryConfigureDependency({ 'dependency-id': this.pkgId, 'dependent-id': this.rec.dependentId }) + oldConfig = oc + newConfig = nc + spec = s + } else { + this.loadingText = 'Loading Config' + const { config: oc, spec: s } = await this.embassyApi.getPackageConfig({ id: this.pkgId }) + oldConfig = oc + spec = s } - this.setConfig(spec, config, depConfig) + this.setConfig(spec, oldConfig, newConfig) } catch (e) { this.loadingError = getErrorMessage(e) } finally { diff --git a/ui/src/app/services/api/api.types.ts b/ui/src/app/services/api/api.types.ts index 83b9f8683..30f0a0c22 100644 --- a/ui/src/app/services/api/api.types.ts +++ b/ui/src/app/services/api/api.types.ts @@ -182,7 +182,11 @@ export module RR { export type DeleteRecoveredPackageRes = WithRevision export type DryConfigureDependencyReq = { 'dependency-id': string, 'dependent-id': string } // package.dependency.configure.dry - export type DryConfigureDependencyRes = object + export type DryConfigureDependencyRes = { + 'old-config': object + 'new-config': object + spec: ConfigSpec + } // marketplace diff --git a/ui/src/app/services/api/embassy-mock-api.service.ts b/ui/src/app/services/api/embassy-mock-api.service.ts index c1ed0435d..52dbb2e10 100644 --- a/ui/src/app/services/api/embassy-mock-api.service.ts +++ b/ui/src/app/services/api/embassy-mock-api.service.ts @@ -542,28 +542,32 @@ export class MockApiService extends ApiService { async dryConfigureDependency (params: RR.DryConfigureDependencyReq): Promise { await pauseFor(2000) return { - testnet: true, - // objectList: [], - // unionList: [], - randomEnum: 'option2', - favoriteNumber: 9, - secondaryNumbers: [2, 3, 5, 6], - rpcsettings: { - laws: { - law1: 'The 1st law', - law2: 'The 2nd law', + 'old-config': Mock.PackageConfig.config, + spec: Mock.PackageConfig.spec, + 'new-config': { + testnet: true, + // objectList: [], + // unionList: [], + randomEnum: 'option2', + favoriteNumber: 9, + secondaryNumbers: [2, 3, 5, 6], + rpcsettings: { + laws: { + law1: 'The 1st law', + law2: 'The 2nd law', + }, + rpcpass: null, + rpcuser: '123', + rulemakers: [], }, - rpcpass: null, - rpcuser: '123', - rulemakers: [], + advanced: { + notifications: ['call', 'text'], + }, + // bitcoinNode: undefined, + port: 22, + // rpcallowip: undefined, + // rpcauth: ['matt: 8273gr8qwoidm1uid91jeh8y23gdio1kskmwejkdnm'], }, - advanced: { - notifications: ['call', 'text'], - }, - // bitcoinNode: undefined, - port: 22, - // rpcallowip: undefined, - // rpcauth: ['matt: 8273gr8qwoidm1uid91jeh8y23gdio1kskmwejkdnm'], } }