mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +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 = { | ||||
|     'config-ui': { | ||||
|       dependencies: { | ||||
|         services: ['auth', 'flash-messages', 'namespace', 'router', 'store', 'version', 'customMessages'], | ||||
|         services: ['auth', 'flash-messages', 'namespace', 'router', 'store', 'version', 'custom-messages'], | ||||
|       }, | ||||
|     }, | ||||
|     'open-api-explorer': { | ||||
|   | ||||
| @@ -99,7 +99,7 @@ export function tabsForAuthSection([authMethodModel, sectionType = 'authSettings | ||||
|     tabs.push({ | ||||
|       label: 'Method Options', | ||||
|       route: 'vault.cluster.settings.auth.configure.section', | ||||
|       routeParams: ['options'], | ||||
|       routeParams: [authMethodModel.id, 'options'], | ||||
|     }); | ||||
|     return tabs; | ||||
|   } | ||||
|   | ||||
| @@ -14,7 +14,7 @@ export default IdentityModel.extend({ | ||||
|   formFields: computed(function () { | ||||
|     return ['name', 'mountAccessor']; | ||||
|   }), | ||||
|   group: belongsTo('identity/group', { readOnly: true, async: false }), | ||||
|   group: belongsTo('identity/group', { readOnly: true, async: false, inverse: 'alias' }), | ||||
|  | ||||
|   name: attr('string'), | ||||
|   canonicalId: attr('string'), | ||||
|   | ||||
| @@ -45,9 +45,8 @@ export default Route.extend(ModelBoundaryRoute, { | ||||
|       queryParams.namespace = ns; | ||||
|     } | ||||
|     if (Ember.testing) { | ||||
|       // TODO: cleanup this replaceWith instance. Using router.replaceWith causes test failures | ||||
|       // Don't redirect on the test | ||||
|       this.replaceWith('vault.cluster.auth', { queryParams }); | ||||
|       this.router.replaceWith('vault.cluster.auth', { queryParams }); | ||||
|     } else { | ||||
|       const { cluster_name } = this.paramsFor('vault.cluster'); | ||||
|       location.assign(this.router.urlFor('vault.cluster.auth', cluster_name, { queryParams })); | ||||
|   | ||||
| @@ -37,12 +37,12 @@ export default class MessagesList extends Component { | ||||
|   @tracked userConfirmation = ''; | ||||
|  | ||||
|   willDestroy() { | ||||
|     super.willDestroy(); | ||||
|     const noTeardown = this.store && !this.store.isDestroying; | ||||
|     const { model } = this; | ||||
|     if (noTeardown && model && model.isDirty && !model.isDestroyed && !model.isDestroying) { | ||||
|       model.rollbackAttributes(); | ||||
|     } | ||||
|     super.willDestroy(); | ||||
|   } | ||||
|  | ||||
|   validate() { | ||||
|   | ||||
| @@ -16,7 +16,7 @@ export default class ConfigUiEngine extends Engine { | ||||
|   modulePrefix = modulePrefix; | ||||
|   Resolver = Resolver; | ||||
|   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) { | ||||
|         return null; | ||||
|       } | ||||
|       if (adapterError.errors.length > 0) { | ||||
|       if (adapterError.errors?.length > 0) { | ||||
|         return adapterError.errors.map((e) => { | ||||
|           if (typeof e === 'object') return e.title || e.message || JSON.stringify(e); | ||||
|           return e; | ||||
|   | ||||
| @@ -39,7 +39,7 @@ | ||||
|         <ul> | ||||
|           {{#if options.hasOverview}} | ||||
|             <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 | ||||
|               </LinkTo> | ||||
|             </li> | ||||
| @@ -56,7 +56,11 @@ | ||||
|             </li> | ||||
|           {{/each}} | ||||
|           <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 | ||||
|             </LinkTo> | ||||
|           </li> | ||||
| @@ -72,6 +76,7 @@ | ||||
|             <li> | ||||
|               <LinkTo | ||||
|                 @route="vault.cluster.secrets.backend.list-root" | ||||
|                 @model={{@model.id}} | ||||
|                 @current-when="vault.cluster.secrets.backend.list-root vault.cluster.secrets.backend.list" | ||||
|               > | ||||
|                 {{capitalize (pluralize options.item)}} | ||||
| @@ -79,7 +84,11 @@ | ||||
|             </li> | ||||
|           {{/if}} | ||||
|           <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 | ||||
|             </LinkTo> | ||||
|           </li> | ||||
|   | ||||
| @@ -5,8 +5,12 @@ | ||||
|  | ||||
| <KvPageHeader @breadcrumbs={{this.breadcrumbs}} @mountName={{this.mountName}}> | ||||
|   <:tabLinks> | ||||
|     <li><LinkTo @route="list" data-test-secrets-tab="Secrets">Secrets</LinkTo></li> | ||||
|     <li><LinkTo @route="configuration" data-test-secrets-tab="Configuration">Configuration</LinkTo></li> | ||||
|     <li><LinkTo @route="list" @model={{this.mountName}} data-test-secrets-tab="Secrets">Secrets</LinkTo></li> | ||||
|     <li><LinkTo | ||||
|         @route="configuration" | ||||
|         @model={{this.mountName}} | ||||
|         data-test-secrets-tab="Configuration" | ||||
|       >Configuration</LinkTo></li> | ||||
|   </:tabLinks> | ||||
| </KvPageHeader> | ||||
|  | ||||
|   | ||||
| @@ -19,7 +19,8 @@ export default Base.extend({ | ||||
|       .findRecord('path-filter-config', id) | ||||
|       .then(() => { | ||||
|         // 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() | ||||
|           .then(() => { | ||||
|             flash.info( | ||||
|   | ||||
| @@ -25,7 +25,7 @@ export default Base.extend({ | ||||
|       !cluster[replicationMode].isPrimary || | ||||
|       !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' || | ||||
|       !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) { | ||||
|     const replicationMode = this.replicationMode; | ||||
|     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 { | ||||
|     super.willDestroy(); | ||||
|     this.router.off('routeDidChange', this.focusNameFilter); | ||||
|     super.willDestroy(); | ||||
|   } | ||||
|  | ||||
|   focusNameFilter(transition?: Transition) { | ||||
|   | ||||
| @@ -68,6 +68,8 @@ module('Acceptance | secrets/secret/create, read, delete', function (hooks) { | ||||
|       assert | ||||
|         .dom(PAGE.infoRowValue('Automate secret deletion')) | ||||
|         .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); | ||||
|     }); | ||||
|  | ||||
| @@ -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 showPage.visit({ backend: 'test', id: 'a' }); | ||||
|       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); | ||||
|     }); | ||||
|   }); | ||||
| @@ -246,6 +250,8 @@ module('Acceptance | secrets/secret/create, read, delete', function (hooks) { | ||||
|           `${path}: show page renders correctly` | ||||
|         ); | ||||
|       } | ||||
|       // [BANDAID] avoid error from missing param for links in SecretEdit > KeyValueHeader | ||||
|       await visit('/vault/secrets'); | ||||
|       await deleteEngine(backend, assert); | ||||
|     }); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Chelsea Shaw
					Chelsea Shaw