mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 02:57:59 +00:00
* Update browserslist * Add browserslistrc * ember-cli-update --to 3.26, fix conflicts * Run codemodes that start with ember-* * More codemods - before cp* * More codemods (curly data-test-*) * WIP ember-basic-dropdown template errors * updates ember-basic-dropdown and related deps to fix build issues * updates basic dropdown instances to new version API * updates more deps -- ember-template-lint is working again * runs no-implicit-this codemod * creates and runs no-quoteless-attributes codemod * runs angle brackets codemod * updates lint:hbs globs to only touch hbs files * removes yield only templates * creates and runs deprecated args transform * supresses lint error for invokeAction on LinkTo component * resolves remaining ambiguous path lint errors * resolves simple-unless lint errors * adds warnings for deprecated tagName arg on LinkTo components * adds warnings for remaining curly component invocation * updates global template lint rules * resolves remaining template lint errors * disables some ember specfic lint rules that target pre octane patterns * js lint fix run * resolves remaining js lint errors * fixes test run * adds npm-run-all dep * fixes test attribute issues * fixes console acceptance tests * fixes tests * adds yield only wizard/tutorial-active template * fixes more tests * attempts to fix more flaky tests * removes commented out settled in transit test * updates deprecations workflow and adds initializer to filter by version * updates flaky policies acl old test * updates to flaky transit test * bumps ember deps down to LTS version * runs linters after main merge * fixes client count tests after bad merge conflict fixes * fixes client count history test * more updates to lint config * another round of hbs lint fixes after extending stylistic rule * updates lint-staged commands * removes indent eslint rule since it seems to break things * fixes bad attribute in transform-edit-form template * test fixes * fixes enterprise tests * adds changelog * removes deprecated ember-concurrency-test-waiters dep and adds @ember/test-waiters * flaky test fix Co-authored-by: hashishaw <cshaw@hashicorp.com>
73 lines
2.1 KiB
JavaScript
73 lines
2.1 KiB
JavaScript
import { inject as service } from '@ember/service';
|
|
import Component from '@ember/component';
|
|
import { encodePath } from 'vault/utils/path-encoding-helpers';
|
|
|
|
/**
|
|
* @module LinkedBlock
|
|
* LinkedBlock components are linkable divs that yield any content nested within them. They are often used in list views such as when listing the secret engines.
|
|
*
|
|
* @example
|
|
* ```js
|
|
* <LinkedBlock
|
|
* @params={{array 'vault.cluster.secrets.backend.show 'my-secret-path'}}
|
|
* @queryParams={{hash version=1}}
|
|
* @class="list-item-row"
|
|
* data-test-list-item-link
|
|
* >
|
|
* // Use any wrapped content here
|
|
* </LinkedBlock>
|
|
* ```
|
|
*
|
|
* @param {Array} params=null - These are values sent to the router's transitionTo method. First item is route, second is the optional path.
|
|
* @param {Object} [queryParams=null] - queryParams can be passed via this property. It needs to be an object.
|
|
* @param {String} [linkPrefix=null] - Overwrite the params with custom route. See KMIP.
|
|
* @param {Boolean} [encode=false] - Encode the path.
|
|
*/
|
|
|
|
let LinkedBlockComponent = Component.extend({
|
|
router: service(),
|
|
|
|
classNames: 'linked-block',
|
|
|
|
queryParams: null,
|
|
linkPrefix: null,
|
|
|
|
encode: false,
|
|
|
|
click(event) {
|
|
const $target = event.target;
|
|
const isAnchorOrButton =
|
|
$target.tagName === 'A' ||
|
|
$target.tagName === 'BUTTON' ||
|
|
$target.closest('button') ||
|
|
$target.closest('a');
|
|
if (!isAnchorOrButton) {
|
|
let params = this.params;
|
|
if (this.encode) {
|
|
params = params.map((param, index) => {
|
|
if (index === 0 || typeof param !== 'string') {
|
|
return param;
|
|
}
|
|
return encodePath(param);
|
|
});
|
|
}
|
|
const queryParams = this.queryParams;
|
|
if (queryParams) {
|
|
params.push({ queryParams });
|
|
}
|
|
if (this.linkPrefix) {
|
|
let targetRoute = this.params[0];
|
|
targetRoute = `${this.linkPrefix}.${targetRoute}`;
|
|
this.params[0] = targetRoute;
|
|
}
|
|
this.router.transitionTo(...params);
|
|
}
|
|
},
|
|
});
|
|
|
|
LinkedBlockComponent.reopenClass({
|
|
positionalParams: 'params',
|
|
});
|
|
|
|
export default LinkedBlockComponent;
|