mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 02:28:09 +00:00 
			
		
		
		
	UI: Ember 5 deprecation stragglers (#26666)
* use router for transitions within replication engine * fix inverse value on group-alias belongsTo relationship * Always call super.willDestroy after custom hooks * fix deprecation ember-engines.deprecation-camelized-engine-names * graceful fallback on message-error if adapterError does not include errors * use router.replaceWith during tests on logout * fix more links
This commit is contained in:
		| @@ -15,7 +15,7 @@ export default class App extends Application { | |||||||
|   engines = { |   engines = { | ||||||
|     'config-ui': { |     'config-ui': { | ||||||
|       dependencies: { |       dependencies: { | ||||||
|         services: ['auth', 'flash-messages', 'namespace', 'router', 'store', 'version', 'customMessages'], |         services: ['auth', 'flash-messages', 'namespace', 'router', 'store', 'version', 'custom-messages'], | ||||||
|       }, |       }, | ||||||
|     }, |     }, | ||||||
|     'open-api-explorer': { |     'open-api-explorer': { | ||||||
|   | |||||||
| @@ -99,7 +99,7 @@ export function tabsForAuthSection([authMethodModel, sectionType = 'authSettings | |||||||
|     tabs.push({ |     tabs.push({ | ||||||
|       label: 'Method Options', |       label: 'Method Options', | ||||||
|       route: 'vault.cluster.settings.auth.configure.section', |       route: 'vault.cluster.settings.auth.configure.section', | ||||||
|       routeParams: ['options'], |       routeParams: [authMethodModel.id, 'options'], | ||||||
|     }); |     }); | ||||||
|     return tabs; |     return tabs; | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ export default IdentityModel.extend({ | |||||||
|   formFields: computed(function () { |   formFields: computed(function () { | ||||||
|     return ['name', 'mountAccessor']; |     return ['name', 'mountAccessor']; | ||||||
|   }), |   }), | ||||||
|   group: belongsTo('identity/group', { readOnly: true, async: false }), |   group: belongsTo('identity/group', { readOnly: true, async: false, inverse: 'alias' }), | ||||||
|  |  | ||||||
|   name: attr('string'), |   name: attr('string'), | ||||||
|   canonicalId: attr('string'), |   canonicalId: attr('string'), | ||||||
|   | |||||||
| @@ -45,9 +45,8 @@ export default Route.extend(ModelBoundaryRoute, { | |||||||
|       queryParams.namespace = ns; |       queryParams.namespace = ns; | ||||||
|     } |     } | ||||||
|     if (Ember.testing) { |     if (Ember.testing) { | ||||||
|       // TODO: cleanup this replaceWith instance. Using router.replaceWith causes test failures |  | ||||||
|       // Don't redirect on the test |       // Don't redirect on the test | ||||||
|       this.replaceWith('vault.cluster.auth', { queryParams }); |       this.router.replaceWith('vault.cluster.auth', { queryParams }); | ||||||
|     } else { |     } else { | ||||||
|       const { cluster_name } = this.paramsFor('vault.cluster'); |       const { cluster_name } = this.paramsFor('vault.cluster'); | ||||||
|       location.assign(this.router.urlFor('vault.cluster.auth', cluster_name, { queryParams })); |       location.assign(this.router.urlFor('vault.cluster.auth', cluster_name, { queryParams })); | ||||||
|   | |||||||
| @@ -37,12 +37,12 @@ export default class MessagesList extends Component { | |||||||
|   @tracked userConfirmation = ''; |   @tracked userConfirmation = ''; | ||||||
|  |  | ||||||
|   willDestroy() { |   willDestroy() { | ||||||
|     super.willDestroy(); |  | ||||||
|     const noTeardown = this.store && !this.store.isDestroying; |     const noTeardown = this.store && !this.store.isDestroying; | ||||||
|     const { model } = this; |     const { model } = this; | ||||||
|     if (noTeardown && model && model.isDirty && !model.isDestroyed && !model.isDestroying) { |     if (noTeardown && model && model.isDirty && !model.isDestroyed && !model.isDestroying) { | ||||||
|       model.rollbackAttributes(); |       model.rollbackAttributes(); | ||||||
|     } |     } | ||||||
|  |     super.willDestroy(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   validate() { |   validate() { | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ export default class ConfigUiEngine extends Engine { | |||||||
|   modulePrefix = modulePrefix; |   modulePrefix = modulePrefix; | ||||||
|   Resolver = Resolver; |   Resolver = Resolver; | ||||||
|   dependencies = { |   dependencies = { | ||||||
|     services: ['auth', 'store', 'flash-messages', 'namespace', 'router', 'version', 'customMessages'], |     services: ['auth', 'store', 'flash-messages', 'namespace', 'router', 'version', 'custom-messages'], | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -39,7 +39,7 @@ class MessageError extends Component { | |||||||
|       if (!adapterError) { |       if (!adapterError) { | ||||||
|         return null; |         return null; | ||||||
|       } |       } | ||||||
|       if (adapterError.errors.length > 0) { |       if (adapterError.errors?.length > 0) { | ||||||
|         return adapterError.errors.map((e) => { |         return adapterError.errors.map((e) => { | ||||||
|           if (typeof e === 'object') return e.title || e.message || JSON.stringify(e); |           if (typeof e === 'object') return e.title || e.message || JSON.stringify(e); | ||||||
|           return e; |           return e; | ||||||
|   | |||||||
| @@ -39,7 +39,7 @@ | |||||||
|         <ul> |         <ul> | ||||||
|           {{#if options.hasOverview}} |           {{#if options.hasOverview}} | ||||||
|             <li> |             <li> | ||||||
|               <LinkTo @route="vault.cluster.secrets.backend.overview" data-test-tab="overview"> |               <LinkTo @route="vault.cluster.secrets.backend.overview" @model={{@model.id}} data-test-tab="overview"> | ||||||
|                 Overview |                 Overview | ||||||
|               </LinkTo> |               </LinkTo> | ||||||
|             </li> |             </li> | ||||||
| @@ -56,7 +56,11 @@ | |||||||
|             </li> |             </li> | ||||||
|           {{/each}} |           {{/each}} | ||||||
|           <li> |           <li> | ||||||
|             <LinkTo @route="vault.cluster.secrets.backend.configuration" data-test-configuration-tab={{true}}> |             <LinkTo | ||||||
|  |               @route="vault.cluster.secrets.backend.configuration" | ||||||
|  |               @model={{@model.id}} | ||||||
|  |               data-test-configuration-tab={{true}} | ||||||
|  |             > | ||||||
|               Configuration |               Configuration | ||||||
|             </LinkTo> |             </LinkTo> | ||||||
|           </li> |           </li> | ||||||
| @@ -72,6 +76,7 @@ | |||||||
|             <li> |             <li> | ||||||
|               <LinkTo |               <LinkTo | ||||||
|                 @route="vault.cluster.secrets.backend.list-root" |                 @route="vault.cluster.secrets.backend.list-root" | ||||||
|  |                 @model={{@model.id}} | ||||||
|                 @current-when="vault.cluster.secrets.backend.list-root vault.cluster.secrets.backend.list" |                 @current-when="vault.cluster.secrets.backend.list-root vault.cluster.secrets.backend.list" | ||||||
|               > |               > | ||||||
|                 {{capitalize (pluralize options.item)}} |                 {{capitalize (pluralize options.item)}} | ||||||
| @@ -79,7 +84,11 @@ | |||||||
|             </li> |             </li> | ||||||
|           {{/if}} |           {{/if}} | ||||||
|           <li> |           <li> | ||||||
|             <LinkTo @route="vault.cluster.secrets.backend.configuration" data-test-configuration-tab={{true}}> |             <LinkTo | ||||||
|  |               @route="vault.cluster.secrets.backend.configuration" | ||||||
|  |               @model={{@model.id}} | ||||||
|  |               data-test-configuration-tab={{true}} | ||||||
|  |             > | ||||||
|               Configuration |               Configuration | ||||||
|             </LinkTo> |             </LinkTo> | ||||||
|           </li> |           </li> | ||||||
|   | |||||||
| @@ -5,8 +5,12 @@ | |||||||
|  |  | ||||||
| <KvPageHeader @breadcrumbs={{this.breadcrumbs}} @mountName={{this.mountName}}> | <KvPageHeader @breadcrumbs={{this.breadcrumbs}} @mountName={{this.mountName}}> | ||||||
|   <:tabLinks> |   <:tabLinks> | ||||||
|     <li><LinkTo @route="list" data-test-secrets-tab="Secrets">Secrets</LinkTo></li> |     <li><LinkTo @route="list" @model={{this.mountName}} data-test-secrets-tab="Secrets">Secrets</LinkTo></li> | ||||||
|     <li><LinkTo @route="configuration" data-test-secrets-tab="Configuration">Configuration</LinkTo></li> |     <li><LinkTo | ||||||
|  |         @route="configuration" | ||||||
|  |         @model={{this.mountName}} | ||||||
|  |         data-test-secrets-tab="Configuration" | ||||||
|  |       >Configuration</LinkTo></li> | ||||||
|   </:tabLinks> |   </:tabLinks> | ||||||
| </KvPageHeader> | </KvPageHeader> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,7 +19,8 @@ export default Base.extend({ | |||||||
|       .findRecord('path-filter-config', id) |       .findRecord('path-filter-config', id) | ||||||
|       .then(() => { |       .then(() => { | ||||||
|         // if we find a record, transition to the edit view |         // if we find a record, transition to the edit view | ||||||
|         return this.transitionTo('mode.secondaries.config-edit', id) |         return this.router | ||||||
|  |           .transitionTo('vault.cluster.replication.mode.secondaries.config-edit', id) | ||||||
|           .followRedirects() |           .followRedirects() | ||||||
|           .then(() => { |           .then(() => { | ||||||
|             flash.info( |             flash.info( | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ export default Base.extend({ | |||||||
|       !cluster[replicationMode].isPrimary || |       !cluster[replicationMode].isPrimary || | ||||||
|       !cluster.canAddSecondary |       !cluster.canAddSecondary | ||||||
|     ) { |     ) { | ||||||
|       return this.transitionTo('mode', replicationMode); |       return this.router.transitionTo('vault.cluster.replication.mode', replicationMode); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -31,7 +31,7 @@ export default Base.extend({ | |||||||
|       replicationMode !== 'performance' || |       replicationMode !== 'performance' || | ||||||
|       !cluster[replicationMode].isPrimary |       !cluster[replicationMode].isPrimary | ||||||
|     ) { |     ) { | ||||||
|       return this.transitionTo('mode', cluster.name, replicationMode); |       return this.router.transitionTo('vault.cluster.replication.mode', cluster.name, replicationMode); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ export default Base.extend({ | |||||||
|   redirect(model) { |   redirect(model) { | ||||||
|     const replicationMode = this.replicationMode; |     const replicationMode = this.replicationMode; | ||||||
|     if (!model[replicationMode].isPrimary || !model.canRevokeSecondary) { |     if (!model[replicationMode].isPrimary || !model.canRevokeSecondary) { | ||||||
|       return this.transitionTo('index'); |       return this.router.transitionTo('vault.cluster.replication.index'); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|  |  | ||||||
|   | |||||||
| @@ -41,8 +41,8 @@ export default class SyncSecretsDestinationsPageComponent extends Component<Args | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   willDestroy(): void { |   willDestroy(): void { | ||||||
|     super.willDestroy(); |  | ||||||
|     this.router.off('routeDidChange', this.focusNameFilter); |     this.router.off('routeDidChange', this.focusNameFilter); | ||||||
|  |     super.willDestroy(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   focusNameFilter(transition?: Transition) { |   focusNameFilter(transition?: Transition) { | ||||||
|   | |||||||
| @@ -68,6 +68,8 @@ module('Acceptance | secrets/secret/create, read, delete', function (hooks) { | |||||||
|       assert |       assert | ||||||
|         .dom(PAGE.infoRowValue('Automate secret deletion')) |         .dom(PAGE.infoRowValue('Automate secret deletion')) | ||||||
|         .hasText('1 second', 'displays the delete version after set when configuring the secret-engine'); |         .hasText('1 second', 'displays the delete version after set when configuring the secret-engine'); | ||||||
|  |       // [BANDAID] avoid error from missing param for links in SecretEdit > KeyValueHeader | ||||||
|  |       await visit('/vault/secrets'); | ||||||
|       await deleteEngine(enginePath, assert); |       await deleteEngine(enginePath, assert); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
| @@ -77,6 +79,8 @@ module('Acceptance | secrets/secret/create, read, delete', function (hooks) { | |||||||
|       await runCmd(['vault write sys/mounts/test type=kv', 'refresh', 'vault write test/a keys=a keys=b']); |       await runCmd(['vault write sys/mounts/test type=kv', 'refresh', 'vault write test/a keys=a keys=b']); | ||||||
|       await showPage.visit({ backend: 'test', id: 'a' }); |       await showPage.visit({ backend: 'test', id: 'a' }); | ||||||
|       assert.ok(showPage.editIsPresent, 'renders the page properly'); |       assert.ok(showPage.editIsPresent, 'renders the page properly'); | ||||||
|  |       // [BANDAID] avoid error from missing param for links in SecretEdit > KeyValueHeader | ||||||
|  |       await visit('/vault/secrets'); | ||||||
|       await deleteEngine('test', assert); |       await deleteEngine('test', assert); | ||||||
|     }); |     }); | ||||||
|   }); |   }); | ||||||
| @@ -246,6 +250,8 @@ module('Acceptance | secrets/secret/create, read, delete', function (hooks) { | |||||||
|           `${path}: show page renders correctly` |           `${path}: show page renders correctly` | ||||||
|         ); |         ); | ||||||
|       } |       } | ||||||
|  |       // [BANDAID] avoid error from missing param for links in SecretEdit > KeyValueHeader | ||||||
|  |       await visit('/vault/secrets'); | ||||||
|       await deleteEngine(backend, assert); |       await deleteEngine(backend, assert); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Chelsea Shaw
					Chelsea Shaw