diff --git a/addons/core/addon/decorators/resource-filter-param.js b/addons/core/addon/decorators/resource-filter-param.js index 61978ee06..b8395a20f 100644 --- a/addons/core/addon/decorators/resource-filter-param.js +++ b/addons/core/addon/decorators/resource-filter-param.js @@ -46,6 +46,9 @@ export function resourceFilterParam(allowedValues, defaultValue) { // If the route has no query params specified yet, declare them. if (!Object.keys(target.queryParams).length) target.queryParams = {}; + // If the route has no resource filters list specified yet, create one. + if (!target.resourceFilterParams) target.resourceFilterParams = []; + // Add the resource filter query parameter to the route. Resource filter // param changes refresh the model but do not contribute to browser history. // See https://guides.emberjs.com/release/routing/query-params/ @@ -54,6 +57,9 @@ export function resourceFilterParam(allowedValues, defaultValue) { replace: true, }; + // Note the name of this filter param. + target.resourceFilterParams.push(name); + // Store the allowed values for future lookup // (via `ResourceFilterParamHelper`). target[filterAllowedValuesKey] = allowedValues; diff --git a/addons/core/addon/helpers/has-resource-filter-param-selections.js b/addons/core/addon/helpers/has-resource-filter-param-selections.js new file mode 100644 index 000000000..6f6015078 --- /dev/null +++ b/addons/core/addon/helpers/has-resource-filter-param-selections.js @@ -0,0 +1,73 @@ +import Helper from '@ember/component/helper'; +import { inject as service } from '@ember/service'; +import { getOwner } from '@ember/application'; +import { action } from '@ember/object'; + +/** + * Use this helper to determine if a resource filter for a route has any + * currently selected value. + * + * @see resourceFilterParam (decorator) + * + * @example + * + * {{#if (has-resource-filter-param-selections 'route.name' 'field')}} + * Field has filter selections. + * {{/if}} + */ +export default class HasResourceFilterParamSelectionsHelper extends Helper { + // =services + + @service router; + + // =methods + + // =lifecycle management methods + + /** + * Recompute this helper when the route changes. + */ + constructor() { + super(...arguments); + this.router.on('routeDidChange', this.routeDidChange); + } + + /** + * Stop listening to route events when this helper is destroyed. + */ + willDestroy() { + this.router.off('routeDidChange', this.routeDidChange); + super.willDestroy(); + } + + // =compute method + + /** + * Returns true if the specified route has a value set for + * any resource filter. + * @param {string} routeName + * @return {boolean} + */ + compute([routeName]) { + const owner = getOwner(this); + const route = owner.lookup(`route:${routeName}`); + const names = route.resourceFilterParams; + const selectedValues = names.map((name) => route[name] || null).flat(); + const anyTruthy = selectedValues.reduce( + (previousValue, currentValue) => previousValue || currentValue, + false + ); + return Boolean(anyTruthy); + } + + // =actions + + /** + * Triggers a recompute (see above) when the route changes, especially when + * route query params change. + */ + @action + routeDidChange() { + this.recompute(); + } +} diff --git a/addons/core/app/helpers/has-resource-filter-param-selections.js b/addons/core/app/helpers/has-resource-filter-param-selections.js new file mode 100644 index 000000000..b6ab1bc86 --- /dev/null +++ b/addons/core/app/helpers/has-resource-filter-param-selections.js @@ -0,0 +1 @@ +export { default } from 'core/helpers/has-resource-filter-param-selections'; diff --git a/addons/core/package.json b/addons/core/package.json index b51acc24b..fd10d6d9f 100644 --- a/addons/core/package.json +++ b/addons/core/package.json @@ -37,10 +37,10 @@ "ember-intl": "^5.7.0", "ember-loading": "^0.4.0", "ember-route-action-helper": "^2.0.8", + "ember-truth-helpers": "^3.0.0", "rose": "*" }, "devDependencies": { - "js-bexpr": "hashicorp/js-bexpr#9b4a4b54d85eba67fdfc0990133d1518d890b1e1", "@ember/optional-features": "^2.0.0", "@ember/test-helpers": "^2.4.2", "@glimmer/component": "^1.0.4", @@ -73,6 +73,7 @@ "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-qunit": "^6.2.0", "faker": "^5.5.3", + "js-bexpr": "hashicorp/js-bexpr#9b4a4b54d85eba67fdfc0990133d1518d890b1e1", "loader.js": "^4.7.0", "npm-run-all": "^4.1.5", "prettier": "^2.4.0", diff --git a/addons/core/translations/en-us.yaml b/addons/core/translations/en-us.yaml index 8f98f633c..73a720d62 100644 --- a/addons/core/translations/en-us.yaml +++ b/addons/core/translations/en-us.yaml @@ -29,11 +29,13 @@ titles: welcome-to-boundary: Welcome to Boundary label: Label value: Value + no-results: No Results descriptions: empty-set: There are no items to display yet. You may be able to add items or try back later. origin-initialization: To get started, please enter your origin URL create-but-not-list: You do not have permission to list {resource}, but you can create new instances. neither-list-nor-create: You do not have permission to list or create {resource}. + no-results: We found no matching records. questions: delete-confirm: Are you sure you want to delete this resource? remove-confirm: Are you sure you want to remove this association? diff --git a/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs b/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs index c5982d1de..4c4509ede 100644 --- a/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs +++ b/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs @@ -35,8 +35,47 @@ - {{#if @model}} + {{#if + (or + @model + (has-resource-filter-param-selections 'scopes.scope.auth-methods') + ) + }} + + + {{#with + (resource-filter-param 'scopes.scope.auth-methods' 'type') + as |filter| + }} + + + + + + + + {{/with}} + + + {{/if}} + + {{#if @model}} {{#if (feature-flag 'primary-auth-method')}} {{#unless this.hasPrimaryAuthMethod}} - - {{#with - (resource-filter-param 'scopes.scope.auth-methods' 'type') - as |filter| - }} - - - - - - - - {{/with}} - - - {{/if}} - @@ -189,6 +196,18 @@ + {{else if (has-resource-filter-param-selections + 'scopes.scope.auth-methods' + )}} + + + + + {{t 'descriptions.no-results'}} + + + + {{else}} @@ -223,4 +242,4 @@ {{/if}} - + \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 3d3cb02ab..991935f89 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6993,14 +6993,14 @@ browserify-zlib@^0.2.0: pako "~1.0.5" browserslist@4.14.2, browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.14.5, browserslist@^4.16.5, browserslist@^4.16.6, browserslist@^4.16.7, browserslist@^4.17.3: - version "4.17.4" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.17.4.tgz#72e2508af2a403aec0a49847ef31bd823c57ead4" - integrity sha512-Zg7RpbZpIJRW3am9Lyckue7PLytvVxxhJj1CaJVlCWENsGEAOlnlt8X0ZxGRPp7Bt9o8tIRM5SEXy4BCPMJjLQ== + version "4.17.6" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.17.6.tgz#c76be33e7786b497f66cad25a73756c8b938985d" + integrity sha512-uPgz3vyRTlEiCv4ee9KlsKgo2V6qPk7Jsn0KAn2OBqbqKo3iNcPEC1Ti6J4dwnz+aIRfEEEuOzC9IBk8tXUomw== dependencies: - caniuse-lite "^1.0.30001265" - electron-to-chromium "^1.3.867" + caniuse-lite "^1.0.30001274" + electron-to-chromium "^1.3.886" escalade "^3.1.1" - node-releases "^2.0.0" + node-releases "^2.0.1" picocolors "^1.0.0" bser@2.1.1: @@ -7311,10 +7311,10 @@ caniuse-api@^3.0.0: lodash.memoize "^4.1.2" lodash.uniq "^4.5.0" -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001157, caniuse-lite@^1.0.30001265: - version "1.0.30001271" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001271.tgz#0dda0c9bcae2cf5407cd34cac304186616cc83e8" - integrity sha512-BBruZFWmt3HFdVPS8kceTBIguKxu4f99n5JNp06OlPD/luoAMIaIK5ieV5YjnBLH3Nysai9sxj9rpJj4ZisXOA== +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001157, caniuse-lite@^1.0.30001274: + version "1.0.30001279" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001279.tgz#eb06818da481ef5096a3b3760f43e5382ed6b0ce" + integrity sha512-VfEHpzHEXj6/CxggTwSFoZBBYGQfQv9Cf42KPlO79sWXCD1QNKWKsKzFeWL7QpZHJQYAvocqV6Rty1yJMkqWLQ== capture-exit@^2.0.0: version "2.0.0" @@ -8570,7 +8570,7 @@ debug@^3.0.0, debug@^3.0.1, debug@^3.1.0, debug@^3.1.1, debug@^3.2.6: dependencies: ms "^2.1.1" -debuglog@^1.0.1: +debuglog@*, debuglog@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= @@ -9151,10 +9151,10 @@ electron-rebuild@^2.0.3: tar "^6.0.5" yargs "^16.0.0" -electron-to-chromium@^1.3.867: - version "1.3.884" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.884.tgz#0cd8c3a80271fd84a81f284c60fb3c9ecb33c166" - integrity sha512-kOaCAa+biA98PwH5BpCkeUeTL6mCeg8p3Q3OhqzPyqhu/5QUnWAN2wr/3IK8xMQxIV76kfoQpP+Bn/wij/jXrg== +electron-to-chromium@^1.3.886: + version "1.3.895" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.895.tgz#9b0f8f2e32d8283bbb200156fd5d8dfd775f31ed" + integrity sha512-9Ww3fB8CWctjqHwkOt7DQbMZMpal2x2reod+/lU4b9axO1XJEDUpPMBxs7YnjLhhqpKXIIB5SRYN/B4K0QpvyQ== element-resize-detector@^1.2.2: version "1.2.3" @@ -10335,6 +10335,13 @@ ember-template-recast@^5.0.1, ember-template-recast@^5.0.3: tmp "^0.2.1" workerpool "^6.1.4" +ember-truth-helpers@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ember-truth-helpers/-/ember-truth-helpers-3.0.0.tgz#86766bdca4ac9b86bce3d262dff2aabc4a0ea384" + integrity sha512-hPKG9QqruAELh0li5xaiLZtr88ioWYxWCXisAWHWE0qCP4a2hgtuMzKUPpiTCkltvKjuqpzTZCU4VhQ+IlRmew== + dependencies: + ember-cli-babel "^7.22.1" + ember-try-config@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ember-try-config/-/ember-try-config-3.0.0.tgz#012d8c90cae9eb624e2b62040bf7e76a1aa58edc" @@ -13392,7 +13399,7 @@ import-lazy@^4.0.0: resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-4.0.0.tgz#e8eb627483a0a43da3c03f3e35548be5cb0cc153" integrity sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw== -imurmurhash@^0.1.4: +imurmurhash@*, imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= @@ -15194,6 +15201,11 @@ lodash._baseflatten@^3.0.0: lodash.isarguments "^3.0.0" lodash.isarray "^3.0.0" +lodash._baseindexof@*: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c" + integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw= + lodash._baseuniq@~4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8" @@ -15202,11 +15214,16 @@ lodash._baseuniq@~4.6.0: lodash._createset "~4.0.0" lodash._root "~3.0.0" -lodash._bindcallback@^3.0.0: +lodash._bindcallback@*, lodash._bindcallback@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4= +lodash._cacheindexof@*: + version "3.0.2" + resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92" + integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI= + lodash._createassigner@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz#838a5bae2fdaca63ac22dee8e19fa4e6d6970b11" @@ -15216,12 +15233,19 @@ lodash._createassigner@^3.0.0: lodash._isiterateecall "^3.0.0" lodash.restparam "^3.0.0" +lodash._createcache@*: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093" + integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM= + dependencies: + lodash._getnative "^3.0.0" + lodash._createset@~4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26" integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY= -lodash._getnative@^3.0.0: +lodash._getnative@*, lodash._getnative@^3.0.0: version "3.9.1" resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U= @@ -15439,7 +15463,7 @@ lodash.pick@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" integrity sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM= -lodash.restparam@^3.0.0: +lodash.restparam@*, lodash.restparam@^3.0.0: version "3.6.1" resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU= @@ -16669,7 +16693,7 @@ node-pre-gyp@^0.11.0: semver "^5.3.0" tar "^4" -node-releases@^2.0.0: +node-releases@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.1.tgz#3d1d395f204f1f2f29a54358b9fb678765ad2fc5" integrity sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA==