open-consul/ui/packages/consul-ui/config/environment.js
Michael Klein 272c878559
ui: feature-flagged peering mvp (#13425)
* add peers route

* add peers to nav

* use regular app ui patterns peers template

* use empty state in peers UI

* mock `v1/peerings` request

* implement custom adapter/serializer for `peers`-model

* index request for peerings on peers route

* update peers list to show as proper list

* Use tailwind for easier styling

* Unique ids in peerings response mock-api

* Add styling peerings list

* Allow creating empty tooltip

To make it easier to iterate over a set of items where some items
should not display a tooltip and others should.

* Add tooltip Peerings:Badge

* Add undefined peering state badge

* Remove imported/exported services count peering

This won't be included in the initial version of the API response

* Implement Peerings::Search

* Make it possible to filter peerings by name

* Install ember-keyboard

For idiomatic handling of key-presses.

* Clear peering search input when pressing `Escape`

* use peers.index instead of peers for peerings listing

* Allow to include peered services in services-query

* update services mock to add peerName

* add Consul::Peer component

To surface peering information on a resource

* add PeerName as attribute to service model

* surface peering information in service list

* Add tooltip to Consul::Peer

* Make services searchable by peer-name

* Allow passing optional query-params to href-to

* Add peer query-param to dc.services.show

* Pass peer as query-param services listing

* support option peer route-param

* set peer-name undefined in services serializer when empty

* update peer route-param when navigating to peered service

* request sercice with peer-name if need be

* make sure to reset peer route-param when leaving service.show

* componentize services.peer-info

* surface peer info services.show

* make sure to reset peer route-param in main nav

* fix services breadcrumb services.intentions

we need to reset peer route-param here to not break the app

* surface peer when querying for it on service api call

* query for peer info service-instance api calls

* surface peer info service-instance.show

* Camelize peer attributes to match rest of app

* Refactor peers.index to reflect camelized attributes for peer

* Remove unused query-params services.show

* make logo href reset peer route-param

* Cleanup optional peer param query service-instance

* Use replace decorator instead of serializer for empty peerName

* make sure to only send peer info when correct qp is passed

* Always send qp for querying peers services request

* rename with-imports to with-peers

* Use css for peer-icon

* Refactor bucket-list component to surface peer-info

* Remove Consul::Peer component

This info is now displayed via the bucket-list component

* Fix bucket-list component to surface service again

* Update bucket-list docs to reflect peer-info addition

* Remove tailwind related styles

* Remove consul-tailwind package

We won't be using tailwind for now

* Fix typo badge scss

* Add with-import handling mock-api nodes

* Add peerName to node attributes

* include peers when querying nodes

* reflect api updates node list mock

* Create consul::node::peer-info component

* Surface peer-info in nodes list

* Mock peer response for node request

* Make it possible to add peer-name to node request

* Update peer route-param when linking to node

* Reset peers route-param when leaving nodes.show

We need to reset the route-param to not introduce a bug - otherwise
subsequent node show request would request with the old peer query-param

* Add sourcePeer intentions api mock

* add SourcePeer attr to intentions model

* Surface peering info on intentions list

* Request peered intentions differently intentions.edit

* Handle peer info in intentions/exact mock

* Surface peering info intention view

* Add randomized peer data topology mock

* Surface peer info topology view

* fix service/peer-info styling

We aren't using tailwind anymore - we need to create a custom scss file

* Update peerings api mocks

* Update peerings::badge with updated styling

* cleanup intentions/exact mock

* Create watcher component to declaratively register polling

* Poll peers in background when on peers route

* use existing colors for peering-badge

* Add test for requesting service with `with-peers`-query

* add imported/exported count to peers model

* update mock-api to surface exported/imported count on peers

* Show exported/imported peers count on peers list

* Use translations for service import/export UI peers

* Make sure to ask for nodes with peers

* Add match-url step for easier url testing of service urls

* Add test for peer-name on peered services

* Add test for service navigation peered service

* Implement feature-flag handling

* Enable peering feature in test and development

* Redirect peers to services.index when feature-flag is disabled

* Only query for peers when feature is enabled

* Only show peers in nav when feature is enabled

* Componentize peering service count detail

* Handle non-state Peerings::Badge

* Use Peerings::ServiceCount in peerings list

* Only send peer query for peered service-instances.

* Add step to visit url directly

* add test for accessing peered service directly

* Remove unused service import peers.index

* Only query for peer when peer provided node-adapter

* fix tests
2022-06-23 14:16:26 +01:00

187 lines
6.7 KiB
JavaScript

// All of the configuration here is shared between buildtime and runtime and
// is therefore added to ember's <meta> tag in the actual app, if the
// configuration is for buildtime only you should probably just use
// ember-cli-build to prevent values being outputted in the meta tag
'use strict';
const path = require('path');
const utils = require('./utils');
const repositoryRoot = path.resolve(__dirname, '../../../../');
const repositoryYear = utils.repositoryYear;
const repositorySHA = utils.repositorySHA;
const binaryVersion = utils.binaryVersion(repositoryRoot);
module.exports = function(environment, $ = process.env) {
// available environments
// ['production', 'development', 'staging', 'test'];
const env = utils.env($);
// basic 'get env var with fallback' accessor
let ENV = {
modulePrefix: 'consul-ui',
environment,
rootURL: '/ui/',
locationType: 'fsm-with-optional',
historySupportMiddleware: true,
torii: {
disableRedirectInitializer: false,
},
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false,
},
},
APP: {
// Here you can pass flags/options to your application instance
// when it is created
},
resizeServiceDefaults: {
injectionFactories: ['view', 'controller', 'component'],
},
};
// The following 'environment variables' are set at build-time and compiled
// into a meta tag in generated index.html file.
// They can be accessed in the UI by using either:
//
// 1. The 'env' service from within javascript: `@service('env') env;` (../app/services/env.js)
// 2. The 'env' helper from within hbs: `{{env 'VARIABLE_NAME'}}` (../app/helpers/env.js)
//
// These variables can be overwritten depending on certain environments.
// For example for a production release the binary will overwrite some
// variables at runtime, during development some variables can be
// overwritten by adding cookie values using the browsers' Web Inspector
// TODO: These should probably go onto APP
ENV = Object.assign({}, ENV, {
// The following variables are compile-time variables that are set during
// the consul build process and baked into the generated assetsfs file that
// is later added to the consul binary itself. Some values, if not set,
// will automatically pull information from the git repository which means
// these values are guaranteed to be set/correct during development.
CONSUL_COPYRIGHT_YEAR: env('CONSUL_COPYRIGHT_YEAR', repositoryYear),
CONSUL_GIT_SHA: env('CONSUL_GIT_SHA', repositorySHA),
CONSUL_VERSION: env('CONSUL_VERSION', binaryVersion),
CONSUL_BINARY_TYPE: env('CONSUL_BINARY_TYPE', 'oss'),
// These can be overwritten by the UI user at runtime by setting localStorage values
CONSUL_UI_DISABLE_REALTIME: env('CONSUL_UI_DISABLE_REALTIME', false),
CONSUL_UI_DISABLE_ANCHOR_SELECTION: env('CONSUL_UI_DISABLE_ANCHOR_SELECTION', false),
// The following variables are runtime variables that are overwritten when
// the go binary serves the index.html page
operatorConfig: {
ACLsEnabled: false,
NamespacesEnabled: false,
SSOEnabled: false,
PartitionsEnabled: false,
LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'),
PrimaryDatacenter: env('CONSUL_DATACENTER_PRIMARY', 'dc1'),
},
// Static variables used in multiple places throughout the UI
CONSUL_HOME_URL: 'https://www.consul.io',
CONSUL_REPO_ISSUES_URL: 'https://github.com/hashicorp/consul/issues/new/choose',
CONSUL_DOCS_URL: 'https://www.consul.io/docs',
CONSUL_DOCS_LEARN_URL: 'https://learn.hashicorp.com',
CONSUL_DOCS_API_URL: 'https://www.consul.io/api',
CONSUL_COPYRIGHT_URL: 'https://www.hashicorp.com',
});
switch (true) {
case environment === 'test':
ENV = Object.assign({}, ENV, {
locationType: 'fsm-with-optional-test',
// During testing ACLs default to being turned on
operatorConfig: {
ACLsEnabled: env('CONSUL_ACLS_ENABLED', true),
NamespacesEnabled: env('CONSUL_NSPACES_ENABLED', false),
SSOEnabled: env('CONSUL_SSO_ENABLED', false),
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,
endpoints: {
'/v1': '/mock-api/v1',
},
},
APP: Object.assign({}, ENV.APP, {
LOG_ACTIVE_GENERATION: false,
LOG_VIEW_LOOKUPS: false,
// LOG_RESOLVER: true,
// LOG_ACTIVE_GENERATION: true,
// LOG_TRANSITIONS: true,
// LOG_TRANSITIONS_INTERNAL: true,
rootElement: '#ember-testing',
autoboot: false,
}),
});
break;
case environment === 'development':
ENV = Object.assign({}, ENV, {
torii: {
disableRedirectInitializer: true,
},
features: {
peering: true,
},
});
break;
case environment === 'staging':
ENV = Object.assign({}, ENV, {
torii: {
disableRedirectInitializer: true,
},
// On staging sites everything defaults to being turned on by
// different staging sites can be built with certain features disabled
// by setting an environment variable to 0 during building (e.g.
// CONSUL_NSPACES_ENABLED=0 make build)
// TODO: We should be able to remove this now we can link to different
// scenarios in staging
operatorConfig: {
ACLsEnabled: env('CONSUL_ACLS_ENABLED', true),
NamespacesEnabled: env('CONSUL_NSPACES_ENABLED', true),
SSOEnabled: env('CONSUL_SSO_ENABLED', true),
PartitionsEnabled: env('CONSUL_PARTITIONS_ENABLED', true),
LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'),
PrimaryDatacenter: env('CONSUL_DATACENTER_PRIMARY', 'dc1'),
},
'@hashicorp/ember-cli-api-double': {
enabled: true,
endpoints: {
'/v1': '/mock-api/v1',
},
},
});
break;
case environment === 'production':
ENV = Object.assign({}, ENV, {
// in production operatorConfig is populated at consul runtime from
// operator configuration
operatorConfig: {},
});
break;
}
return ENV;
};