open-vault/ui/app/components/secret-link.js
Hamid Ghaf 27bb03bbc0
adding copyright header (#19555)
* adding copyright header

* fix fmt and a test
2023-03-15 09:00:52 -07:00

32 lines
812 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { encodePath } from 'vault/utils/path-encoding-helpers';
export default class SecretLink extends Component {
get link() {
const { mode, secret } = this.args;
const route = `vault.cluster.secrets.backend.${mode}`;
if ((mode !== 'versions' && !secret) || secret === ' ') {
return { route: `${route}-root`, models: [] };
} else {
return { route, models: [encodePath(secret)] };
}
}
get query() {
const qp = this.args.queryParams || {};
return qp.isQueryParams ? qp.values : qp;
}
@action
onLinkClick() {
if (this.args.onLinkClick) {
this.args.onLinkClick(...arguments);
}
}
}