consul/ui/packages/consul-ui
Kenia 1507dd8ab3
ui: Auth Methods List view (#9617)
* Create mock-api endpoints for auth-methods

* Implement auth-method endpoints and model with tests

* Create route and tab for auth-methods

* Create auth-method list and type components with styles

* Add JWT and OIDC svg logos to codebase

* Add brand translations

* Add SearchBar to Auth Methods

* Add acceptance test for Auth Methods UI

* Skip auth method repo test

* Changes from review notes

* Fixup auth-method modela and mock-data

* Update SearhBar with rebased changes

* Add filterBy source and sortBy max token ttl

* Update to SortBy MethodName

* Update UI acceptance tests

* Update mock data DisplayNames

* Skip repo test

* Fix to breaking serializer test

* Implement auth-method endpoints and model with tests

* Add acceptance test for Auth Methods UI

* Update SearhBar with rebased changes

* Add filterBy source and sortBy max token ttl

* Update to SortBy MethodName

* Update UI acceptance tests

* Update mock data DisplayNames

* Fix to breaking serializer test

* Update class for search

* Add auth-methods link to sidebar

* Fixup PR review notes

* Fixup review notes

* Only show OIDC filter with enterprise

* Update conditionals for MaxTokenTTL & TokenLocality

* Refactor
2021-02-17 13:56:56 -05:00
..
.storybook ui: Move linting to the `node:test` script (#9385) 2020-12-14 15:28:35 +00:00
app ui: Auth Methods List view (#9617) 2021-02-17 13:56:56 -05:00
blueprints ui: Move linting to the `node:test` script (#9385) 2020-12-14 15:28:35 +00:00
config ui: Update browser targets to ~2016 browsers (#9729) 2021-02-11 10:03:13 +00:00
lib Fix -ui-content-path without regex (#9569) 2021-01-20 18:40:46 +00:00
mock-api ui: Auth Methods List view (#9617) 2021-02-17 13:56:56 -05:00
node-tests/config Fix -ui-content-path without regex (#9569) 2021-01-20 18:40:46 +00:00
public ui: Move to Workspaced Structure (#8994) 2020-10-21 15:23:16 +01:00
server ui: Move linting to the `node:test` script (#9385) 2020-12-14 15:28:35 +00:00
tests ui: Auth Methods List view (#9617) 2021-02-17 13:56:56 -05:00
translations ui: Auth Methods List view (#9617) 2021-02-17 13:56:56 -05:00
vendor Fix -ui-content-path without regex (#9569) 2021-01-20 18:40:46 +00:00
.dev.eslintrc.js ui: Move to Workspaced Structure (#8994) 2020-10-21 15:23:16 +01:00
.editorconfig ui: Move to Workspaced Structure (#8994) 2020-10-21 15:23:16 +01:00
.ember-cli ui: Default to glimmer components (#9121) 2020-11-06 14:54:44 +00:00
.eslintignore ui: Move linting to the `node:test` script (#9385) 2020-12-14 15:28:35 +00:00
.eslintrc.js ui: Add vendor directory as a target for JS linting and lint (#9157) 2020-11-11 16:59:15 +00:00
.istanbul.yml ui: Move to Workspaced Structure (#8994) 2020-10-21 15:23:16 +01:00
.nvmrc ui: Move to Workspaced Structure (#8994) 2020-10-21 15:23:16 +01:00
.prettierrc ui: Move to Workspaced Structure (#8994) 2020-10-21 15:23:16 +01:00
.template-lintrc.js ui: Search/filtering 'Filtered by:' search status (#9442) 2021-01-25 18:13:54 +00:00
.watchmanconfig ui: Move to Workspaced Structure (#8994) 2020-10-21 15:23:16 +01:00
GNUmakefile ui: Move linting to the `node:test` script (#9385) 2020-12-14 15:28:35 +00:00
README.md ui: Add 'Scenario' debug function for easy saving debug scenarios (#9675) 2021-02-01 17:50:11 +00:00
ember-cli-build.js ui: Update browser targets to ~2016 browsers (#9729) 2021-02-11 10:03:13 +00:00
package.json ui: Update browser targets to ~2016 browsers (#9729) 2021-02-11 10:03:13 +00:00
testem.js ui: Add vendor directory as a target for JS linting and lint (#9157) 2020-11-11 16:59:15 +00:00

README.md

consul-ui

Prerequisites

You will need the following things properly installed on your computer.

Installation

  • git clone https://github.com/hashicorp/consul.git this repository
  • cd ui/packages/consul-ui
  • make start or yarn && yarn start

Yarn Commands

Most used tooling scripts below primarily use make which will yarn install and in turn call node package scripts.

List of available project commands. yarn run <command-name>

Command Description
build:staging Builds the UI in staging mode (ready for PR preview site).
build:ci Builds the UI for CI.
build Builds the UI for production.
lint Runs all lint commands.
lint:hbs Lints hbs template files.
lint:js Lints js files.
format Runs all auto-formatters.
format:js Auto-formats js files using Prettier.
format:sass Auto-formats scss files using Prettier.
start Runs the development app on a local server using the mock API.
start:consul Runs the development app local server using a real consul instance as the backend.
start:staging Runs the staging app local server.
test Runs the ember tests in a headless browser.
test:view Runs the ember tests in a non-headless browser.
test:oss Runs only the OSS ember tests in a headless browser.
test:oss:view Runs only the OSS ember tests in a non-headless browser.
test:coverage:view Runs only the test specified for coverage in a non-headless browser.
test:node Runs tests that can't be run in ember using node.
doc:toc Automatically generates a table of contents for this README file.

Running / Development

The source code comes with a small development mode that runs enough of the consul API as a set of mocks/fixtures to be able to run the UI without having to run consul.

You can also run the UI against a normal Consul installation.

  • consul server -dev to start consul listening on http://localhost:8500
  • make start-consul to start the ember app proxying to consul (this will respect the CONSUL_HTTP_ADDR environment variable to locate the Consul installation.
  • Visit your app at http://localhost:4200.

Example:

CONSUL_HTTP_ADDR=http://10.0.0.1:8500 make start-consul

Browser 'Environment' Variables

In order to configure different configurations of Consul you can use Web Inspector in your browser to set various cookie which to emulate different configurations whislt using the mock API.

For example: to enable ACLs, use Web Inspector to set a cookie as follows:

CONSUL_ACLS_ENABLE=1

This will enable the ACLs login page, to which you can login with any ACL token/secret.

Variable Default Value Description
CONSUL_ACLS_ENABLE false Enable/disable ACLs support.
CONSUL_ACLS_LEGACY false Enable/disable legacy ACLs support.
CONSUL_NSPACES_ENABLE false Enable/disable Namespace support.
CONSUL_SSO_ENABLE false Enable/disable SSO support.
CONSUL_OIDC_PROVIDER_URL undefined Provide a OIDC provider URL for SSO.
CONSUL_LATENCY 0 Add a latency to network requests (milliseconds)
CONSUL_METRICS_POLL_INTERVAL 10000 Change the interval between requests to the metrics provider (milliseconds)
CONSUL_METRICS_PROXY_ENABLE false Enable/disable the metrics proxy
CONSUL_METRICS_PROVIDER Set the metrics provider to use for the Topology Tab
CONSUL_SERVICE_DASHBOARD_URL Set the template URL to use for Service Dashboard links
CONSUL_UI_CONFIG Set the entire ui_config for the UI as JSON if you don't want to use the above singular variables
CONSUL_SERVICE_COUNT (random) Configure the number of services that the API returns.
CONSUL_NODE_COUNT (random) Configure the number of nodes that the API returns.
CONSUL_KV_COUNT (random) Configure the number of KV entires that the API returns.
CONSUL_INTENTION_COUNT (random) Configure the number of intentions that the API returns.
CONSUL_POLICY_COUNT (random) Configure the number of policies that the API returns.
CONSUL_ROLE_COUNT (random) Configure the number of roles that the API returns.
CONSUL_NSPACE_COUNT (random) Configure the number of namespaces that the API returns.
CONSUL_UPSTREAM_COUNT (random) Configure the number of upstreams that the API returns.
CONSUL_EXPOSED_COUNT (random) Configure the number of exposed paths that the API returns.
CONSUL_CHECK_COUNT (random) Configure the number of health checks that the API returns.
CONSUL_OIDC_PROVIDER_COUNT (random) Configure the number of OIDC providers that the API returns.
DEBUG_ROUTES_ENDPOINT undefined When using the window.Routes() debug utility (see utility functions), use a URL to pass the route DSL to. %s in the URL will be replaced with the route DSL - http://url.com?routes=%s

See ./mock-api for more details.

Browser 'Debug Utility' Functions

We currently have one 'debug utility', that only exists during development (they are removed from the production build using Embers runInDebug). You can call these either straight from the console in WebInspector, or by using javascript URLs i.e. javascript:Routes()

Variable Arguments Description
Routes(url) url: The url to pass the DSL to, if left undefined just use a blank tab Provides a way to easily print out Embers Route DSL for the application or to pass it straight to any third party utility such as ember-diagonal
Scenario(str) str: 'Cookie formatted' string, if left undefined open a new tab with a link/bookmarklet to the current Scenario Provides a way to easily save and reload scenarios of configurations via URLs or bookmarklets

Code Generators

Many classes used in the UI can be generated with ember generators, try ember help generate for more details

Running Tests

Tests use the mock api (see ./mock-api for details)

  • make test or yarn run test
  • make test-view or yarn run test:view to view the tests running in Chrome

OSS only tests can also be run using:

  • make test-oss or yarn run test:oss
  • make test-oss-view or yarn run test:oss:view to view the tests running in Chrome

Linting

make lint currently runs linting on the majority of js files and hbs files (using ember-template-lint).

See .eslintrc.js and .eslintignore for specific configuration.

Building

  • make build builds the UI for production usage (env=production)
  • make build-ci builds the UI for CI/test usage (env=test)

Static files are built into ./dist

Running Tests in Parallel

Alternatively, ember-exam can be used to split the tests across multiple browser instances for faster results. Most options are the same as ember test. To see a full list of options, run ember exam --help.

Note: The EMBER_EXAM_PARALLEL environment variable must be set to override the default parallel value of 1 browser instance in testem.js.

To quickly run the tests across 4 parallel browser instances:

make test-parallel

To run manually:

$ EMBER_EXAM_PARALLEL=true ./node_modules/.bin/ember exam --split <num> --parallel

More ways to split tests can be found in the ember-exam README.md.