diff --git a/ui/packages/consul-ui/app/abilities/peer.js b/ui/packages/consul-ui/app/abilities/peer.js
index acd09956be..89d5c00401 100644
--- a/ui/packages/consul-ui/app/abilities/peer.js
+++ b/ui/packages/consul-ui/app/abilities/peer.js
@@ -1,6 +1,9 @@
import BaseAbility from 'consul-ui/abilities/base';
+import { inject as service } from '@ember/service';
export default class PeerAbility extends BaseAbility {
+ @service('env') env;
+
resource = 'operator';
segmented = false;
@@ -9,11 +12,10 @@ export default class PeerAbility extends BaseAbility {
}
get canDelete() {
// TODO: Need to confirm these states
- return ![
- 'DELETING',
- 'TERMINATED',
- 'UNDEFINED'
- ].includes(this.item.State);
+ return !['DELETING', 'TERMINATED', 'UNDEFINED'].includes(this.item.State);
}
+ get canUse() {
+ return this.env.var('CONSUL_PEERING_ENABLED');
+ }
}
diff --git a/ui/packages/consul-ui/app/adapters/node.js b/ui/packages/consul-ui/app/adapters/node.js
index 6df3b3b026..6e30108c7a 100644
--- a/ui/packages/consul-ui/app/adapters/node.js
+++ b/ui/packages/consul-ui/app/adapters/node.js
@@ -11,12 +11,12 @@ import { inject as service } from '@ember/service';
// to the node.
export default class NodeAdapter extends Adapter {
- @service features;
+ @service abilities;
get peeringQuery() {
const query = {};
- if (this.features.isEnabled('peering')) {
+ if (this.abilities.can('use peers')) {
query['with-peers'] = true;
}
diff --git a/ui/packages/consul-ui/app/adapters/service.js b/ui/packages/consul-ui/app/adapters/service.js
index d0dda48e46..7507c41b6b 100644
--- a/ui/packages/consul-ui/app/adapters/service.js
+++ b/ui/packages/consul-ui/app/adapters/service.js
@@ -2,12 +2,12 @@ import Adapter from './application';
import { inject as service } from '@ember/service';
export default class ServiceAdapter extends Adapter {
- @service features;
+ @service abilities;
get peeringQuery() {
const query = {};
- if (this.features.isEnabled('peering')) {
+ if (this.abilities.can('use peers')) {
query['with-peers'] = true;
}
diff --git a/ui/packages/consul-ui/app/components/hashicorp-consul/index.hbs b/ui/packages/consul-ui/app/components/hashicorp-consul/index.hbs
index 2a98a76853..d19eadb3a3 100644
--- a/ui/packages/consul-ui/app/components/hashicorp-consul/index.hbs
+++ b/ui/packages/consul-ui/app/components/hashicorp-consul/index.hbs
@@ -146,7 +146,7 @@
@partition={{@partition}}
@nspace={{@nspace}}
/>
- {{#if (feature-flag "peering")}}
+ {{#if (can "use peers")}}
Organization
diff --git a/ui/packages/consul-ui/app/helpers/feature-flag.js b/ui/packages/consul-ui/app/helpers/feature-flag.js
deleted file mode 100644
index bf5c273187..0000000000
--- a/ui/packages/consul-ui/app/helpers/feature-flag.js
+++ /dev/null
@@ -1,10 +0,0 @@
-import Helper from '@ember/component/helper';
-import { inject as service } from '@ember/service';
-
-export default class extends Helper {
- @service features;
-
- compute([feature]) {
- return this.features.isEnabled(feature);
- }
-}
diff --git a/ui/packages/consul-ui/app/routes/dc/peers.js b/ui/packages/consul-ui/app/routes/dc/peers.js
index 195d1e2a18..b09a9d4d0c 100644
--- a/ui/packages/consul-ui/app/routes/dc/peers.js
+++ b/ui/packages/consul-ui/app/routes/dc/peers.js
@@ -2,10 +2,10 @@ import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
export default class PeersRoute extends Route {
- @service features;
+ @service abilities;
beforeModel() {
- if (!this.features.isEnabled('peering')) {
+ if (!this.abilities.can('use peers')) {
this.transitionTo('dc.services.index');
}
}
diff --git a/ui/packages/consul-ui/app/services/features.js b/ui/packages/consul-ui/app/services/features.js
deleted file mode 100644
index bbfc53748b..0000000000
--- a/ui/packages/consul-ui/app/services/features.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import Service, { inject as service } from '@ember/service';
-
-export default class FeatureService extends Service {
- @service env;
-
- get features() {
- return this.env.var('features');
- }
-
- isEnabled(featureName) {
- return !!this.features?.[featureName];
- }
-}
diff --git a/ui/packages/consul-ui/app/utils/get-environment.js b/ui/packages/consul-ui/app/utils/get-environment.js
index 157eef2f8e..d6dc699d65 100644
--- a/ui/packages/consul-ui/app/utils/get-environment.js
+++ b/ui/packages/consul-ui/app/utils/get-environment.js
@@ -124,13 +124,17 @@ export default function(config = {}, win = window, doc = document) {
return typeof operatorConfig.PartitionsEnabled === 'undefined'
? false
: operatorConfig.PartitionsEnabled;
+ case 'CONSUL_PEERING_ENABLED':
+ return typeof operatorConfig.PeeringEnabled === 'undefined'
+ ? false
+ : operatorConfig.PeeringEnabled;
case 'CONSUL_DATACENTER_LOCAL':
return operatorConfig.LocalDatacenter;
case 'CONSUL_DATACENTER_PRIMARY':
return operatorConfig.PrimaryDatacenter;
case 'CONSUL_UI_CONFIG':
dashboards = {
- service: undefined
+ service: undefined,
};
provider = env('CONSUL_METRICS_PROVIDER');
proxy = env('CONSUL_METRICS_PROXY_ENABLED');
@@ -209,6 +213,9 @@ export default function(config = {}, win = window, doc = document) {
case 'CONSUL_METRICS_PROXY_ENABLE':
prev['CONSUL_METRICS_PROXY_ENABLED'] = !!JSON.parse(String(value).toLowerCase());
break;
+ case 'CONSUL_PEERING_ENABLE':
+ prev['CONSUL_PEERING_ENABLED'] = !!JSON.parse(String(value).toLowerCase());
+ break;
case 'CONSUL_UI_CONFIG':
prev['CONSUL_UI_CONFIG'] = JSON.parse(value);
break;
@@ -241,6 +248,7 @@ export default function(config = {}, win = window, doc = document) {
case 'CONSUL_DATACENTER_PRIMARY':
case 'CONSUL_ACLS_ENABLED':
case 'CONSUL_NSPACES_ENABLED':
+ case 'CONSUL_PEERING_ENABLED':
case 'CONSUL_SSO_ENABLED':
case 'CONSUL_PARTITIONS_ENABLED':
case 'CONSUL_METRICS_PROVIDER':
diff --git a/ui/packages/consul-ui/config/environment.js b/ui/packages/consul-ui/config/environment.js
index f62c13efcd..b4b7562711 100644
--- a/ui/packages/consul-ui/config/environment.js
+++ b/ui/packages/consul-ui/config/environment.js
@@ -82,6 +82,7 @@ module.exports = function(environment, $ = process.env) {
ACLsEnabled: false,
NamespacesEnabled: false,
SSOEnabled: false,
+ PeeringEnabled: env('CONSUL_PEERING_ENABLED', false),
PartitionsEnabled: false,
LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'),
PrimaryDatacenter: env('CONSUL_DATACENTER_PRIMARY', 'dc1'),
@@ -105,15 +106,13 @@ module.exports = function(environment, $ = process.env) {
ACLsEnabled: env('CONSUL_ACLS_ENABLED', true),
NamespacesEnabled: env('CONSUL_NSPACES_ENABLED', false),
SSOEnabled: env('CONSUL_SSO_ENABLED', false),
+ // in testing peering feature is on by default
+ PeeringEnabled: env('CONSUL_PEERING_ENABLED', true),
PartitionsEnabled: env('CONSUL_PARTITIONS_ENABLED', false),
LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'),
PrimaryDatacenter: env('CONSUL_DATACENTER_PRIMARY', 'dc1'),
},
- features: {
- peering: true,
- },
-
'@hashicorp/ember-cli-api-double': {
'auto-import': false,
enabled: true,
@@ -134,15 +133,13 @@ module.exports = function(environment, $ = process.env) {
autoboot: false,
}),
});
+
break;
case environment === 'development':
ENV = Object.assign({}, ENV, {
torii: {
disableRedirectInitializer: true,
},
- features: {
- peering: true,
- },
});
break;
case environment === 'staging':
diff --git a/ui/packages/consul-ui/docs/bookmarklets.mdx b/ui/packages/consul-ui/docs/bookmarklets.mdx
index cc19f72171..4da4cec68f 100644
--- a/ui/packages/consul-ui/docs/bookmarklets.mdx
+++ b/ui/packages/consul-ui/docs/bookmarklets.mdx
@@ -12,6 +12,7 @@ Below is a list of the most commonly used functions as bookmarklets followed by
| [Enable ACLs](javascript:Scenario('CONSUL_ACLS_ENABLE=1')) | Enable ACLs |
| [Enable TProxy](javascript:Scenario('CONSUL_TPROXY_ENABLE=1')) | Enable TProxy |
| [Enable Nspaces](javascript:Scenario('CONSUL_NSPACES_ENABLE=1')) | Enable Namespace Support |
+| [Enable Peers](javascript:Scenario('CONSUL_PEERING_ENABLE=1')) | Enable Peers Support |
| [Enable Partitions](javascript:Scenario('CONSUL_PARTITIONS_ENABLE=1')) | Enable Admin Partition Support |
| [Enable SSO](javascript:Scenario('CONSUL_SSO_ENABLE=1')) | Enable SSO Support |
| [Enable Metrics](javascript:Scenario('CONSUL_METRICS_PROXY_ENABLE=1;CONSUL_METRICS_PROVIDER=prometheus')) | Enable all configuration required for viewing the full Metrics Visualization |