Bug: switching between namespaces using the namespace-link caused the model not to refresh (#10572)

* fix issue with model not reloading on href-to previously tried to fix after upgrade.

* replace with normalizednamepsace and setup for testing

* add the same functionality to the switch namespace link

* meep, wrong branch

* wow it's friday, correct branch

* add changelog for upgrade, didn't do earlier.

* another friday move

* correct change to changelog for ember upgrade

* remove and make another pr

* remove href-to dep and add comment
This commit is contained in:
Angel Garbarino 2021-01-04 14:26:26 -07:00 committed by GitHub
parent 2a8f9632d3
commit 4c71055329
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 11 deletions

View file

@ -1,3 +1,4 @@
import Ember from 'ember';
import { inject as service } from '@ember/service';
import { alias } from '@ember/object/computed';
import Component from '@ember/component';
@ -30,4 +31,23 @@ export default Component.extend({
isCurrentNamespace: computed('targetNamespace', 'currentNamespace', function() {
return this.currentNamespace === this.targetNamespace;
}),
get namespaceLink() {
if (Ember.testing) {
if (this.normalizedNamespace) {
return `/ui/vault/secrets?namespace=${this.normalizedNamespace}`;
}
return `/ui/vault/secrets`;
}
let origin =
window.location.protocol +
'//' +
window.location.hostname +
(window.location.port ? ':' + window.location.port : '');
if (!this.normalizedNamespace) return `${origin}/ui/vault/secrets`;
// The full URL/origin is required so that the page is reloaded.
return `${origin}/ui/vault/secrets?namespace=${encodeURIComponent(this.normalizedNamespace)}`;
},
});

View file

@ -1,5 +1,5 @@
<a
href="{{href-to 'vault.cluster.secrets' (query-params namespace=this.normalizedNamespace)}}"
href={{this.namespaceLink}}
class={{concat "is-block " class}}
data-test-namespace-link={{this.normalizedNamespace}}
>

View file

@ -38,9 +38,9 @@
{{#with (concat currentNamespace (if currentNamespace "/") list.item.id) as |targetNamespace|}}
{{#if (contains targetNamespace accessibleNamespaces)}}
<li class="action">
<LinkTo @route="vault.cluster.secrets" @query={{hash namespace=targetNamespace}} class="is-block">
<NamespaceLink @targetNamespace={{targetNamespace}} @class="is-block">
Switch to Namespace
</LinkTo>
</NamespaceLink>
</li>
{{/if}}
{{/with}}

View file

@ -99,7 +99,6 @@
"ember-engines": "^0.8.3",
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^8.0.2",
"ember-href-to": "^4.1.0",
"ember-inflector": "^3.0.0",
"ember-link-action": "^1.0.0",
"ember-load-initializers": "^2.1.2",

View file

@ -8716,13 +8716,6 @@ ember-get-config@^0.2.2:
broccoli-file-creator "^1.1.1"
ember-cli-babel "^6.3.0"
ember-href-to@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/ember-href-to/-/ember-href-to-4.1.0.tgz#daa8b398bc5a51ba3ba5ff736e099f0a0d010b7b"
integrity sha512-h8xSzt9lQAUzk4JvXNnZjRj29hOWKo92VIHzH68io13UurDBaMmJ4WtXa0iy/awlSFs6h8BwpEWQeaCYIZDRuQ==
dependencies:
ember-cli-babel "^7.13.2"
"ember-inflector@^2.0.0 || ^3.0.0", ember-inflector@^3.0.0, ember-inflector@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/ember-inflector/-/ember-inflector-3.0.1.tgz#04be6df4d7e4000f6d6bd70787cdc995f77be4ab"