From 1eb93726a063f0bc567240e5658c8505d8228db2 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Wed, 19 Jan 2022 10:14:59 +0000 Subject: [PATCH] ui: Runtime Injectable Components (#11969) - Simplifies how we 'import' our configuration files a little in order to make them more grokable. - Starts to exclude files based on explicit configuration rather than convention. - Adds the first instance of us being able to select an implementation (of multiple) of a component at runtime. --- .../consul-acls/vendor/consul-acls/routes.js | 7 +- .../vendor/consul-acls/services.js | 7 + .../vendor/consul-nspaces/routes.js | 7 +- .../vendor/consul-nspaces/services.js | 7 + .../consul/partition/selector/index.hbs | 3 - .../vendor/consul-partitions/routes.js | 7 +- .../vendor/consul-partitions/services.js | 9 + .../app/instance-initializers/container.js | 27 +- ui/packages/consul-ui/app/router.js | 442 +----------------- ui/packages/consul-ui/ember-cli-build.js | 87 +++- .../lib/startup/templates/body.html.js | 17 +- .../vendor/consul-ui/routes-debug.js | 33 +- .../consul-ui/vendor/consul-ui/routes.js | 412 ++++++++++++++++ .../vendor/consul-ui/services-debug.js | 27 +- .../consul-ui/vendor/consul-ui/services.js | 42 +- 15 files changed, 588 insertions(+), 546 deletions(-) create mode 100644 ui/packages/consul-acls/vendor/consul-acls/services.js create mode 100644 ui/packages/consul-nspaces/vendor/consul-nspaces/services.js create mode 100644 ui/packages/consul-partitions/vendor/consul-partitions/services.js create mode 100644 ui/packages/consul-ui/vendor/consul-ui/routes.js diff --git a/ui/packages/consul-acls/vendor/consul-acls/routes.js b/ui/packages/consul-acls/vendor/consul-acls/routes.js index cf4dc72d8..bfd045da7 100644 --- a/ui/packages/consul-acls/vendor/consul-acls/routes.js +++ b/ui/packages/consul-acls/vendor/consul-acls/routes.js @@ -9,10 +9,7 @@ }, }, }))( - (json, data = document.currentScript.dataset) => { - const appNameJS = data.appName.split('-') - .map((item, i) => i ? `${item.substr(0, 1).toUpperCase()}${item.substr(1)}` : item) - .join(''); - data[`${appNameJS}Routes`] = JSON.stringify(json); + (json, data = (typeof document !== 'undefined' ? document.currentScript.dataset : module.exports)) => { + data[`routes`] = JSON.stringify(json); } ); diff --git a/ui/packages/consul-acls/vendor/consul-acls/services.js b/ui/packages/consul-acls/vendor/consul-acls/services.js new file mode 100644 index 000000000..159a7a96e --- /dev/null +++ b/ui/packages/consul-acls/vendor/consul-acls/services.js @@ -0,0 +1,7 @@ +(services => services({ + +}))( + (json, data = (typeof document !== 'undefined' ? document.currentScript.dataset : module.exports)) => { + data[`services`] = JSON.stringify(json); + } +); diff --git a/ui/packages/consul-nspaces/vendor/consul-nspaces/routes.js b/ui/packages/consul-nspaces/vendor/consul-nspaces/routes.js index 2c1e882b7..a3537ac71 100644 --- a/ui/packages/consul-nspaces/vendor/consul-nspaces/routes.js +++ b/ui/packages/consul-nspaces/vendor/consul-nspaces/routes.js @@ -34,10 +34,7 @@ }, }, }))( - (json, data = document.currentScript.dataset) => { - const appNameJS = data.appName.split('-') - .map((item, i) => i ? `${item.substr(0, 1).toUpperCase()}${item.substr(1)}` : item) - .join(''); - data[`${appNameJS}Routes`] = JSON.stringify(json); + (json, data = (typeof document !== 'undefined' ? document.currentScript.dataset : module.exports)) => { + data[`routes`] = JSON.stringify(json); } ); diff --git a/ui/packages/consul-nspaces/vendor/consul-nspaces/services.js b/ui/packages/consul-nspaces/vendor/consul-nspaces/services.js new file mode 100644 index 000000000..159a7a96e --- /dev/null +++ b/ui/packages/consul-nspaces/vendor/consul-nspaces/services.js @@ -0,0 +1,7 @@ +(services => services({ + +}))( + (json, data = (typeof document !== 'undefined' ? document.currentScript.dataset : module.exports)) => { + data[`services`] = JSON.stringify(json); + } +); diff --git a/ui/packages/consul-partitions/app/components/consul/partition/selector/index.hbs b/ui/packages/consul-partitions/app/components/consul/partition/selector/index.hbs index 966b26172..91a9c8845 100644 --- a/ui/packages/consul-partitions/app/components/consul/partition/selector/index.hbs +++ b/ui/packages/consul-partitions/app/components/consul/partition/selector/index.hbs @@ -1,4 +1,3 @@ -{{#if (can "use partitions")}} {{#let (or @partition 'default') as |partition|}} @@ -62,5 +61,3 @@ as |partition|}} {{/if}} {{/let}} -{{/if}} - diff --git a/ui/packages/consul-partitions/vendor/consul-partitions/routes.js b/ui/packages/consul-partitions/vendor/consul-partitions/routes.js index dc925e985..0ecba8ef2 100644 --- a/ui/packages/consul-partitions/vendor/consul-partitions/routes.js +++ b/ui/packages/consul-partitions/vendor/consul-partitions/routes.js @@ -34,10 +34,7 @@ }, }, }))( - (json, data = document.currentScript.dataset) => { - const appNameJS = data.appName.split('-') - .map((item, i) => i ? `${item.substr(0, 1).toUpperCase()}${item.substr(1)}` : item) - .join(''); - data[`${appNameJS}Routes`] = JSON.stringify(json); + (json, data = (typeof document !== 'undefined' ? document.currentScript.dataset : module.exports)) => { + data[`routes`] = JSON.stringify(json); } ); diff --git a/ui/packages/consul-partitions/vendor/consul-partitions/services.js b/ui/packages/consul-partitions/vendor/consul-partitions/services.js new file mode 100644 index 000000000..550211f9d --- /dev/null +++ b/ui/packages/consul-partitions/vendor/consul-partitions/services.js @@ -0,0 +1,9 @@ +(services => services({ + "component:consul/partition/selector": { + "class": "consul-ui/components/consul/partition/selector" + } +}))( + (json, data = (typeof document !== 'undefined' ? document.currentScript.dataset : module.exports)) => { + data[`services`] = JSON.stringify(json); + } +); diff --git a/ui/packages/consul-ui/app/instance-initializers/container.js b/ui/packages/consul-ui/app/instance-initializers/container.js index 103038450..ee286c376 100644 --- a/ui/packages/consul-ui/app/instance-initializers/container.js +++ b/ui/packages/consul-ui/app/instance-initializers/container.js @@ -3,38 +3,33 @@ import require from 'require'; import merge from 'deepmerge'; const doc = document; -const appName = 'consul-ui'; -const appNameJS = appName - .split('-') - .map((item, i) => (i ? `${item.substr(0, 1).toUpperCase()}${item.substr(1)}` : item)) - .join(''); export const services = merge.all( - [].concat( - ...[...doc.querySelectorAll(`script[data-${appName}-services]`)].map($item => - JSON.parse($item.dataset[`${appNameJS}Services`]) - ) + [...doc.querySelectorAll(`script[data-services]`)].map($item => + JSON.parse($item.dataset[`services`]) ) ); const inject = function(container, obj) { // inject all the things Object.entries(obj).forEach(([key, value]) => { - switch(true) { - case (typeof value.class === 'string'): - if(require.has(value.class)) { - container.register(key.replace('auth-provider:', 'torii-provider:'), require(value.class).default); + switch (true) { + case typeof value.class === 'string': + if (require.has(value.class)) { + container.register( + key.replace('auth-provider:', 'torii-provider:'), + require(value.class).default + ); } else { throw new Error(`Unable to locate '${value.class}'`); } - break; + break; } }); -} +}; export default { name: 'container', initialize(application) { - inject(application, services); const container = application.lookup('service:container'); diff --git a/ui/packages/consul-ui/app/router.js b/ui/packages/consul-ui/app/router.js index fb6691f92..f89519e6f 100644 --- a/ui/packages/consul-ui/app/router.js +++ b/ui/packages/consul-ui/app/router.js @@ -8,443 +8,9 @@ import walk, { dump } from 'consul-ui/utils/routing/walk'; const doc = document; const appName = config.modulePrefix; -const appNameJS = appName - .split('-') - .map((item, i) => (i ? `${item.substr(0, 1).toUpperCase()}${item.substr(1)}` : item)) - .join(''); export const routes = merge.all( - [ - { - // Our parent datacenter resource sets the namespace - // for the entire application - dc: { - _options: { - path: '/:dc', - }, - index: { - _options: { - path: '/', - redirect: '../services', - }, - }, - // Services represent a consul service - services: { - _options: { path: '/services' }, - index: { - _options: { - path: '/', - queryParams: { - sortBy: 'sort', - status: 'status', - source: 'source', - kind: 'kind', - searchproperty: { - as: 'searchproperty', - empty: [['Name', 'Tags']], - }, - search: { - as: 'filter', - replace: true, - }, - }, - }, - }, - // Show an individual service - show: { - _options: { path: '/:name' }, - instances: { - _options: { - path: '/instances', - queryParams: { - sortBy: 'sort', - status: 'status', - source: 'source', - searchproperty: { - as: 'searchproperty', - empty: [ - [ - 'Name', - 'Node', - 'Tags', - 'ID', - 'Address', - 'Port', - 'Service.Meta', - 'Node.Meta', - ], - ], - }, - search: { - as: 'filter', - replace: true, - }, - }, - }, - }, - intentions: { - _options: { path: '/intentions' }, - index: { - _options: { - path: '', - queryParams: { - sortBy: 'sort', - access: 'access', - searchproperty: { - as: 'searchproperty', - empty: [['SourceName', 'DestinationName']], - }, - search: { - as: 'filter', - replace: true, - }, - }, - }, - }, - edit: { - _options: { path: '/:intention_id' }, - }, - create: { - _options: { - template: '../edit', - path: '/create', - }, - }, - }, - topology: { - _options: { path: '/topology' }, - }, - services: { - _options: { - path: '/services', - queryParams: { - sortBy: 'sort', - instance: 'instance', - searchproperty: { - as: 'searchproperty', - empty: [['Name', 'Tags']], - }, - search: { - as: 'filter', - replace: true, - }, - }, - }, - }, - upstreams: { - _options: { - path: '/upstreams', - queryParams: { - sortBy: 'sort', - instance: 'instance', - searchproperty: { - as: 'searchproperty', - empty: [['Name', 'Tags']], - }, - search: { - as: 'filter', - replace: true, - }, - }, - }, - }, - routing: { - _options: { path: '/routing' }, - }, - tags: { - _options: { path: '/tags' }, - }, - }, - instance: { - _options: { - path: '/:name/instances/:node/:id', - redirect: './healthchecks', - }, - healthchecks: { - _options: { - path: '/health-checks', - queryParams: { - sortBy: 'sort', - status: 'status', - check: 'check', - searchproperty: { - as: 'searchproperty', - empty: [['Name', 'Node', 'CheckID', 'Notes', 'Output', 'ServiceTags']], - }, - search: { - as: 'filter', - replace: true, - }, - }, - }, - }, - upstreams: { - _options: { - path: '/upstreams', - queryParams: { - sortBy: 'sort', - search: { - as: 'filter', - replace: true, - }, - searchproperty: { - as: 'searchproperty', - empty: [['DestinationName', 'LocalBindAddress', 'LocalBindPort']], - }, - }, - }, - }, - exposedpaths: { - _options: { path: '/exposed-paths' }, - }, - addresses: { - _options: { path: '/addresses' }, - }, - metadata: { - _options: { path: '/metadata' }, - }, - }, - notfound: { - _options: { path: '/:name/:node/:id' }, - }, - }, - // Nodes represent a consul node - nodes: { - _options: { path: '/nodes' }, - index: { - _options: { - path: '', - queryParams: { - sortBy: 'sort', - status: 'status', - searchproperty: { - as: 'searchproperty', - empty: [['Node', 'Address', 'Meta']], - }, - search: { - as: 'filter', - replace: true, - }, - }, - }, - }, - // Show an individual node - show: { - _options: { path: '/:name' }, - healthchecks: { - _options: { - path: '/health-checks', - queryParams: { - sortBy: 'sort', - status: 'status', - kind: 'kind', - check: 'check', - searchproperty: { - as: 'searchproperty', - empty: [['Name', 'Service', 'CheckID', 'Notes', 'Output', 'ServiceTags']], - }, - search: { - as: 'filter', - replace: true, - }, - }, - }, - }, - services: { - _options: { - path: '/service-instances', - queryParams: { - sortBy: 'sort', - status: 'status', - source: 'source', - searchproperty: { - as: 'searchproperty', - empty: [['Name', 'Tags', 'ID', 'Address', 'Port', 'Service.Meta']], - }, - search: { - as: 'filter', - replace: true, - }, - }, - }, - }, - rtt: { - _options: { path: '/round-trip-time' }, - }, - sessions: { - _options: { path: '/lock-sessions' }, - }, - metadata: { - _options: { path: '/metadata' }, - }, - }, - }, - // Intentions represent a consul intention - intentions: { - _options: { path: '/intentions' }, - index: { - _options: { - path: '/', - queryParams: { - sortBy: 'sort', - access: 'access', - searchproperty: { - as: 'searchproperty', - empty: [['SourceName', 'DestinationName']], - }, - search: { - as: 'filter', - replace: true, - }, - }, - }, - }, - edit: { - _options: { - path: '/:intention_id', - abilities: ['read intentions'], - }, - }, - create: { - _options: { - template: '../edit', - path: '/create', - abilities: ['create intentions'], - }, - }, - }, - // Key/Value - kv: { - _options: { path: '/kv' }, - index: { - _options: { - path: '/', - queryParams: { - sortBy: 'sort', - kind: 'kind', - search: { - as: 'filter', - replace: true, - }, - }, - }, - }, - folder: { - _options: { - template: '../index', - path: '/*key', - }, - }, - edit: { - _options: { path: '/*key/edit' }, - }, - create: { - _options: { - template: '../edit', - path: '/*key/create', - abilities: ['create kvs'], - }, - }, - 'root-create': { - _options: { - template: '../edit', - path: '/create', - abilities: ['create kvs'], - }, - }, - }, - // ACLs - acls: { - _options: { - path: '/acls', - abilities: ['access acls'], - }, - policies: { - _options: { - path: '/policies', - abilities: ['read policies'], - }, - edit: { - _options: { path: '/:id' }, - }, - create: { - _options: { - path: '/create', - abilities: ['create policies'], - }, - }, - }, - roles: { - _options: { - path: '/roles', - abilities: ['read roles'], - }, - edit: { - _options: { path: '/:id' }, - }, - create: { - _options: { - path: '/create', - abilities: ['create roles'], - }, - }, - }, - tokens: { - _options: { - path: '/tokens', - abilities: ['access acls'], - }, - edit: { - _options: { path: '/:id' }, - }, - create: { - _options: { - path: '/create', - abilities: ['create tokens'], - }, - }, - }, - 'auth-methods': { - _options: { - path: '/auth-methods', - abilities: ['read auth-methods'], - }, - show: { - _options: { path: '/:id' }, - 'auth-method': { - _options: { path: '/auth-method' }, - }, - 'binding-rules': { - _options: { path: '/binding-rules' }, - }, - 'nspace-rules': { - _options: { path: '/nspace-rules' }, - }, - }, - }, - }, - 'routing-config': { - _options: { path: '/routing-config/:name' }, - }, - }, - // Shows a datacenter picker. If you only have one - // it just redirects you through. - index: { - _options: { path: '/' }, - }, - // The settings page is global. - settings: { - _options: { path: '/setting' }, - }, - notfound: { - _options: { path: '/*notfound' }, - }, - }, - ].concat( - ...[...doc.querySelectorAll(`script[data-${appName}-routes]`)].map($item => - JSON.parse($item.dataset[`${appNameJS}Routes`]) - ) - ) + [...doc.querySelectorAll(`script[data-routes]`)].map($item => JSON.parse($item.dataset[`routes`])) ); runInDebug(() => { @@ -497,6 +63,12 @@ runInDebug(() => { }; }); +// Consul UIs routes are kept in individual configuration files Please see for +// example /ui/pacakges/consul-ui/vendor/routes.js Routing for additional +// applications/features are kept in the corresponding configuration files for +// the application/feature and optional merged at runtime depending on a +// Consul backend feature flag. Please see for example +// /ui/packages/consul-nspaces/vendor/route.js export default class Router extends EmberRouter { location = env('locationType'); rootURL = env('rootURL'); diff --git a/ui/packages/consul-ui/ember-cli-build.js b/ui/packages/consul-ui/ember-cli-build.js index b6fea5edc..7884e859b 100644 --- a/ui/packages/consul-ui/ember-cli-build.js +++ b/ui/packages/consul-ui/ember-cli-build.js @@ -27,6 +27,7 @@ module.exports = function(defaults, $ = process.env) { let excludeFiles = []; const apps = [ + 'consul-ui', 'consul-acls', 'consul-partitions', 'consul-nspaces' @@ -55,6 +56,7 @@ module.exports = function(defaults, $ = process.env) { ]) } + if(['test', 'production'].includes(env)) { // exclude our debug initializer, route and template excludeFiles = excludeFiles.concat([ @@ -66,6 +68,30 @@ module.exports = function(defaults, $ = process.env) { 'templates/debug.hbs', 'components/debug/**/*.*' ]) + // inspect *-debug configuration files for files to exclude + excludeFiles = apps.reduce( + (prev, item) => { + return ['services', 'routes'].reduce( + (prev, type) => { + const path = `${item.path}/vendor/${item.name}/${type}-debug.js`; + if(exists(path)) { + return Object.entries(JSON.parse(require(path)[type])).reduce( + (prev, [key, definition]) => { + if(typeof definition.class !== 'undefined') { + return prev.concat(`${definition.class.replace(`${item.name}/`, '')}.js`); + } + return prev; + }, + prev + ); + } + return prev; + }, + prev + ) + }, + excludeFiles + ); // exclude any debug like addons from production or test environments addons.blacklist = [ // exclude docfy @@ -88,18 +114,24 @@ module.exports = function(defaults, $ = process.env) { } // - trees.app = mergeTrees([ - new Funnel('app', { exclude: excludeFiles }) - ].concat( - apps.filter(item => exists(`${item.path}/app`)).map(item => new Funnel(`${item.path}/app`, {exclude: excludeFiles})) - ), { - overwrite: true - }); - trees.vendor = mergeTrees([ - new Funnel('vendor'), - ].concat( - apps.map(item => new Funnel(`${item.path}/vendor`)) - )); + ( + function(apps) { + trees.app = mergeTrees([ + new Funnel('app', { exclude: excludeFiles }) + ].concat( + apps.filter(item => exists(`${item.path}/app`)).map(item => new Funnel(`${item.path}/app`, {exclude: excludeFiles})) + ), { + overwrite: true + }); + trees.vendor = mergeTrees([ + new Funnel('vendor'), + ].concat( + apps.map(item => new Funnel(`${item.path}/vendor`)) + )); + } + // consul-ui will eventually be a separate app just like the others + // at which point we can remove this filter/extra scope + )(apps.filter(item => item.name !== 'consul-ui')); // const app = new EmberApp( @@ -147,20 +179,31 @@ module.exports = function(defaults, $ = process.env) { }, } ); + const build = function(path, options) { + const {root, ...rest} = options; + if(exists(`${root}/${path}`)) { + app.import(path, rest); + } + }; apps.forEach(item => { - app.import(`vendor/${item.name}/routes.js`, { + build(`vendor/${item.name}/routes.js`, { + root: item.path, outputFile: `assets/${item.name}/routes.js`, }); - }); - [ - 'consul-ui/services' - ].concat(devlike ? [ - 'consul-ui/services-debug', - 'consul-ui/routes-debug' - ] : []).forEach(item => { - app.import(`vendor/${item}.js`, { - outputFile: `assets/${item}.js`, + build(`vendor/${item.name}/services.js`, { + root: item.path, + outputFile: `assets/${item.name}/services.js`, + }); + if(devlike) { + build(`vendor/${item.name}/routes-debug.js`, { + root: item.path, + outputFile: `assets/${item.name}/routes-debug.js`, }); + build(`vendor/${item.name}/services-debug.js`, { + root: item.path, + outputFile: `assets/${item.name}/services-debug.js`, + }); + } }); // Use `app.import` to add additional libraries to the generated // output files. diff --git a/ui/packages/consul-ui/lib/startup/templates/body.html.js b/ui/packages/consul-ui/lib/startup/templates/body.html.js index 72738c9af..9a2b3fe09 100644 --- a/ui/packages/consul-ui/lib/startup/templates/body.html.js +++ b/ui/packages/consul-ui/lib/startup/templates/body.html.js @@ -42,12 +42,13 @@ ${environment === 'production' ? `{{jsonEncode .}}` : JSON.stringify(config.oper "codemirror/mode/xml/xml.js": "${rootURL}assets/codemirror/mode/xml/xml.js" } - + + ${ environment === 'development' || environment === 'staging' ? ` - - + + ` : `` } @@ -55,13 +56,14 @@ ${ environment === 'production' ? ` {{if .ACLsEnabled}} - + {{end}} {{if .PartitionsEnabled}} - + + {{end}} {{if .NamespacesEnabled}} - + {{end}} ` : ` @@ -72,7 +74,8 @@ ${ if(get(key) || (key === 'CONSUL_NSPACES_ENABLE' && ${ env('CONSUL_NSPACES_ENABLED') === '1' ? `true` : `false` })) { - document.write(\`\\x3Cscript data-app-name="${appName}" data-${appName}-routing src="${rootURL}assets/\${value}/routes.js">\\x3C/script>\`); + document.write(\`\\x3Cscript src="${rootURL}assets/\${value}/services.js">\\x3C/script>\`); + document.write(\`\\x3Cscript src="${rootURL}assets/\${value}/routes.js">\\x3C/script>\`); } }); } diff --git a/ui/packages/consul-ui/vendor/consul-ui/routes-debug.js b/ui/packages/consul-ui/vendor/consul-ui/routes-debug.js index 9e100a05f..575bef096 100644 --- a/ui/packages/consul-ui/vendor/consul-ui/routes-debug.js +++ b/ui/packages/consul-ui/vendor/consul-ui/routes-debug.js @@ -1,19 +1,20 @@ -(routes => routes({ - ['oauth-provider-debug']: { - _options: { - path: '/oauth-provider-debug', - queryParams: { - redirect_uri: 'redirect_uri', - response_type: 'response_type', - scope: 'scope', +(routes => + routes({ + ['oauth-provider-debug']: { + _options: { + path: '/oauth-provider-debug', + queryParams: { + redirect_uri: 'redirect_uri', + response_type: 'response_type', + scope: 'scope', + }, }, - } - }, -}))( - (json, data = document.currentScript.dataset) => { - const appNameJS = data.appName.split('-') - .map((item, i) => i ? `${item.substr(0, 1).toUpperCase()}${item.substr(1)}` : item) - .join(''); - data[`${appNameJS}Routes`] = JSON.stringify(json); + }, + }))( + ( + json, + data = typeof document !== 'undefined' ? document.currentScript.dataset : module.exports + ) => { + data[`routes`] = JSON.stringify(json); } ); diff --git a/ui/packages/consul-ui/vendor/consul-ui/routes.js b/ui/packages/consul-ui/vendor/consul-ui/routes.js new file mode 100644 index 000000000..151180491 --- /dev/null +++ b/ui/packages/consul-ui/vendor/consul-ui/routes.js @@ -0,0 +1,412 @@ +(routes => + routes({ + dc: { + _options: { + path: '/:dc', + }, + index: { + _options: { + path: '/', + redirect: '../services', + }, + }, + services: { + _options: { path: '/services' }, + index: { + _options: { + path: '/', + queryParams: { + sortBy: 'sort', + status: 'status', + source: 'source', + kind: 'kind', + searchproperty: { + as: 'searchproperty', + empty: [['Name', 'Tags']], + }, + search: { + as: 'filter', + replace: true, + }, + }, + }, + }, + show: { + _options: { path: '/:name' }, + instances: { + _options: { + path: '/instances', + queryParams: { + sortBy: 'sort', + status: 'status', + source: 'source', + searchproperty: { + as: 'searchproperty', + empty: [ + ['Name', 'Node', 'Tags', 'ID', 'Address', 'Port', 'Service.Meta', 'Node.Meta'], + ], + }, + search: { + as: 'filter', + replace: true, + }, + }, + }, + }, + intentions: { + _options: { path: '/intentions' }, + index: { + _options: { + path: '', + queryParams: { + sortBy: 'sort', + access: 'access', + searchproperty: { + as: 'searchproperty', + empty: [['SourceName', 'DestinationName']], + }, + search: { + as: 'filter', + replace: true, + }, + }, + }, + }, + edit: { + _options: { path: '/:intention_id' }, + }, + create: { + _options: { + template: '../edit', + path: '/create', + }, + }, + }, + topology: { + _options: { path: '/topology' }, + }, + services: { + _options: { + path: '/services', + queryParams: { + sortBy: 'sort', + instance: 'instance', + searchproperty: { + as: 'searchproperty', + empty: [['Name', 'Tags']], + }, + search: { + as: 'filter', + replace: true, + }, + }, + }, + }, + upstreams: { + _options: { + path: '/upstreams', + queryParams: { + sortBy: 'sort', + instance: 'instance', + searchproperty: { + as: 'searchproperty', + empty: [['Name', 'Tags']], + }, + search: { + as: 'filter', + replace: true, + }, + }, + }, + }, + routing: { + _options: { path: '/routing' }, + }, + tags: { + _options: { path: '/tags' }, + }, + }, + instance: { + _options: { + path: '/:name/instances/:node/:id', + redirect: './healthchecks', + }, + healthchecks: { + _options: { + path: '/health-checks', + queryParams: { + sortBy: 'sort', + status: 'status', + check: 'check', + searchproperty: { + as: 'searchproperty', + empty: [['Name', 'Node', 'CheckID', 'Notes', 'Output', 'ServiceTags']], + }, + search: { + as: 'filter', + replace: true, + }, + }, + }, + }, + upstreams: { + _options: { + path: '/upstreams', + queryParams: { + sortBy: 'sort', + search: { + as: 'filter', + replace: true, + }, + searchproperty: { + as: 'searchproperty', + empty: [['DestinationName', 'LocalBindAddress', 'LocalBindPort']], + }, + }, + }, + }, + exposedpaths: { + _options: { path: '/exposed-paths' }, + }, + addresses: { + _options: { path: '/addresses' }, + }, + metadata: { + _options: { path: '/metadata' }, + }, + }, + notfound: { + _options: { path: '/:name/:node/:id' }, + }, + }, + nodes: { + _options: { path: '/nodes' }, + index: { + _options: { + path: '', + queryParams: { + sortBy: 'sort', + status: 'status', + searchproperty: { + as: 'searchproperty', + empty: [['Node', 'Address', 'Meta']], + }, + search: { + as: 'filter', + replace: true, + }, + }, + }, + }, + show: { + _options: { path: '/:name' }, + healthchecks: { + _options: { + path: '/health-checks', + queryParams: { + sortBy: 'sort', + status: 'status', + kind: 'kind', + check: 'check', + searchproperty: { + as: 'searchproperty', + empty: [['Name', 'Service', 'CheckID', 'Notes', 'Output', 'ServiceTags']], + }, + search: { + as: 'filter', + replace: true, + }, + }, + }, + }, + services: { + _options: { + path: '/service-instances', + queryParams: { + sortBy: 'sort', + status: 'status', + source: 'source', + searchproperty: { + as: 'searchproperty', + empty: [['Name', 'Tags', 'ID', 'Address', 'Port', 'Service.Meta']], + }, + search: { + as: 'filter', + replace: true, + }, + }, + }, + }, + rtt: { + _options: { path: '/round-trip-time' }, + }, + sessions: { + _options: { path: '/lock-sessions' }, + }, + metadata: { + _options: { path: '/metadata' }, + }, + }, + }, + intentions: { + _options: { path: '/intentions' }, + index: { + _options: { + path: '/', + queryParams: { + sortBy: 'sort', + access: 'access', + searchproperty: { + as: 'searchproperty', + empty: [['SourceName', 'DestinationName']], + }, + search: { + as: 'filter', + replace: true, + }, + }, + }, + }, + edit: { + _options: { + path: '/:intention_id', + abilities: ['read intentions'], + }, + }, + create: { + _options: { + template: '../edit', + path: '/create', + abilities: ['create intentions'], + }, + }, + }, + kv: { + _options: { path: '/kv' }, + index: { + _options: { + path: '/', + queryParams: { + sortBy: 'sort', + kind: 'kind', + search: { + as: 'filter', + replace: true, + }, + }, + }, + }, + folder: { + _options: { + template: '../index', + path: '/*key', + }, + }, + edit: { + _options: { path: '/*key/edit' }, + }, + create: { + _options: { + template: '../edit', + path: '/*key/create', + abilities: ['create kvs'], + }, + }, + 'root-create': { + _options: { + template: '../edit', + path: '/create', + abilities: ['create kvs'], + }, + }, + }, + acls: { + _options: { + path: '/acls', + abilities: ['access acls'], + }, + policies: { + _options: { + path: '/policies', + abilities: ['read policies'], + }, + edit: { + _options: { path: '/:id' }, + }, + create: { + _options: { + path: '/create', + abilities: ['create policies'], + }, + }, + }, + roles: { + _options: { + path: '/roles', + abilities: ['read roles'], + }, + edit: { + _options: { path: '/:id' }, + }, + create: { + _options: { + path: '/create', + abilities: ['create roles'], + }, + }, + }, + tokens: { + _options: { + path: '/tokens', + abilities: ['access acls'], + }, + edit: { + _options: { path: '/:id' }, + }, + create: { + _options: { + path: '/create', + abilities: ['create tokens'], + }, + }, + }, + 'auth-methods': { + _options: { + path: '/auth-methods', + abilities: ['read auth-methods'], + }, + show: { + _options: { path: '/:id' }, + 'auth-method': { + _options: { path: '/auth-method' }, + }, + 'binding-rules': { + _options: { path: '/binding-rules' }, + }, + 'nspace-rules': { + _options: { path: '/nspace-rules' }, + }, + }, + }, + }, + 'routing-config': { + _options: { path: '/routing-config/:name' }, + }, + }, + index: { + _options: { path: '/' }, + }, + settings: { + _options: { path: '/setting' }, + }, + notfound: { + _options: { path: '/*notfound' }, + }, + }))( + ( + json, + data = typeof document !== 'undefined' ? document.currentScript.dataset : module.exports + ) => { + data[`routes`] = JSON.stringify(json); + } +); diff --git a/ui/packages/consul-ui/vendor/consul-ui/services-debug.js b/ui/packages/consul-ui/vendor/consul-ui/services-debug.js index dba5d8f3e..f585db5f1 100644 --- a/ui/packages/consul-ui/vendor/consul-ui/services-debug.js +++ b/ui/packages/consul-ui/vendor/consul-ui/services-debug.js @@ -1,15 +1,16 @@ -(services => services({ - "route:application": { - "class": "consul-ui/routing/application-debug" - }, - "service:intl": { - "class": "consul-ui/services/i18n-debug" - } -}))( - (json, data = document.currentScript.dataset) => { - const appNameJS = data.appName.split('-') - .map((item, i) => i ? `${item.substr(0, 1).toUpperCase()}${item.substr(1)}` : item) - .join(''); - data[`${appNameJS}Services`] = JSON.stringify(json); +(services => + services({ + 'route:application': { + class: 'consul-ui/routing/application-debug', + }, + 'service:intl': { + class: 'consul-ui/services/i18n-debug', + }, + }))( + ( + json, + data = typeof document !== 'undefined' ? document.currentScript.dataset : module.exports + ) => { + data[`services`] = JSON.stringify(json); } ); diff --git a/ui/packages/consul-ui/vendor/consul-ui/services.js b/ui/packages/consul-ui/vendor/consul-ui/services.js index 61b50b6d1..ff679e2d2 100644 --- a/ui/packages/consul-ui/vendor/consul-ui/services.js +++ b/ui/packages/consul-ui/vendor/consul-ui/services.js @@ -1,21 +1,25 @@ -(services => services({ - "route:basic": { - "class": "consul-ui/routing/route" - }, - "service:intl": { - "class": "consul-ui/services/i18n" - }, - "service:state": { - "class": "consul-ui/services/state-with-charts" - }, - "auth-provider:oidc-with-url": { - "class": "consul-ui/services/auth-providers/oauth2-code-with-url-provider" - } -}))( - (json, data = document.currentScript.dataset) => { - const appNameJS = data.appName.split('-') - .map((item, i) => i ? `${item.substr(0, 1).toUpperCase()}${item.substr(1)}` : item) - .join(''); - data[`${appNameJS}Services`] = JSON.stringify(json); +(services => + services({ + 'route:basic': { + class: 'consul-ui/routing/route', + }, + 'service:intl': { + class: 'consul-ui/services/i18n', + }, + 'service:state': { + class: 'consul-ui/services/state-with-charts', + }, + 'auth-provider:oidc-with-url': { + class: 'consul-ui/services/auth-providers/oauth2-code-with-url-provider', + }, + 'component:consul/partition/selector': { + class: '@glimmer/component', + }, + }))( + ( + json, + data = typeof document !== 'undefined' ? document.currentScript.dataset : module.exports + ) => { + data[`services`] = JSON.stringify(json); } );