mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-29 06:31:10 +01:00
updates link-to usages to remove deprecated patterns (#14571)
This commit is contained in:
parent
990cd8b929
commit
3fdb221aa6
@ -2,23 +2,6 @@ import { computed } from '@ember/object';
|
|||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import { encodePath } from 'vault/utils/path-encoding-helpers';
|
import { encodePath } from 'vault/utils/path-encoding-helpers';
|
||||||
|
|
||||||
export function linkParams({ mode, secret, queryParams }) {
|
|
||||||
let params;
|
|
||||||
const route = `vault.cluster.secrets.backend.${mode}`;
|
|
||||||
|
|
||||||
if ((mode !== 'versions' && !secret) || secret === ' ') {
|
|
||||||
params = [route + '-root'];
|
|
||||||
} else {
|
|
||||||
params = [route, encodePath(secret)];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (queryParams) {
|
|
||||||
params.push(queryParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
onLinkClick() {},
|
onLinkClick() {},
|
||||||
tagName: '',
|
tagName: '',
|
||||||
@ -30,8 +13,16 @@ export default Component.extend({
|
|||||||
queryParams: null,
|
queryParams: null,
|
||||||
ariaLabel: null,
|
ariaLabel: null,
|
||||||
|
|
||||||
linkParams: computed('mode', 'secret', 'queryParams', function () {
|
link: computed('mode', 'secret', function () {
|
||||||
let data = { mode: this.mode, secret: this.secret, queryParams: this.queryParams };
|
const route = `vault.cluster.secrets.backend.${this.mode}`;
|
||||||
return linkParams(data);
|
if ((this.mode !== 'versions' && !this.secret) || this.secret === ' ') {
|
||||||
|
return { route: `${route}-root`, models: [] };
|
||||||
|
} else {
|
||||||
|
return { route, models: [encodePath(this.secret)] };
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
query: computed('queryParams', function () {
|
||||||
|
const qp = this.queryParams || {};
|
||||||
|
return qp.isQueryParams ? qp.values : qp;
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -36,12 +36,12 @@ const API_PATHS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const API_PATHS_TO_ROUTE_PARAMS = {
|
const API_PATHS_TO_ROUTE_PARAMS = {
|
||||||
'sys/auth': ['vault.cluster.access.methods'],
|
'sys/auth': { route: 'vault.cluster.access.methods', models: [] },
|
||||||
'identity/entity/id': ['vault.cluster.access.identity', 'entities'],
|
'identity/entity/id': { route: 'vault.cluster.access.identity', models: ['entities'] },
|
||||||
'identity/group/id': ['vault.cluster.access.identity', 'groups'],
|
'identity/group/id': { route: 'vault.cluster.access.identity', models: ['groups'] },
|
||||||
'sys/leases/lookup': ['vault.cluster.access.leases'],
|
'sys/leases/lookup': { route: 'vault.cluster.access.leases', models: [] },
|
||||||
'sys/namespaces': ['vault.cluster.access.namespaces'],
|
'sys/namespaces': { route: 'vault.cluster.access.namespaces', models: [] },
|
||||||
'sys/control-group/': ['vault.cluster.access.control-groups'],
|
'sys/control-group/': { route: 'vault.cluster.access.control-groups', models: [] },
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -99,7 +99,7 @@ export default Service.extend({
|
|||||||
navPathParams(navItem) {
|
navPathParams(navItem) {
|
||||||
const path = Object.values(API_PATHS[navItem]).find((path) => this.hasPermission(path));
|
const path = Object.values(API_PATHS[navItem]).find((path) => this.hasPermission(path));
|
||||||
if (['policies', 'tools'].includes(navItem)) {
|
if (['policies', 'tools'].includes(navItem)) {
|
||||||
return path.split('/').lastObject;
|
return { models: [path.split('/').lastObject] };
|
||||||
}
|
}
|
||||||
|
|
||||||
return API_PATHS_TO_ROUTE_PARAMS[path];
|
return API_PATHS_TO_ROUTE_PARAMS[path];
|
||||||
|
|||||||
@ -23,13 +23,11 @@
|
|||||||
<nav class="tabs">
|
<nav class="tabs">
|
||||||
<ul>
|
<ul>
|
||||||
{{#each tabs as |tab|}}
|
{{#each tabs as |tab|}}
|
||||||
{{! template-lint-configure no-curly-component-invocation "warn" }}
|
<li>
|
||||||
{{#link-to params=tab.routeParams tagName="li" data-test-auth-section-tab=true}}
|
<LinkTo @route={{get tab.routeParams 0}} @model={{get tab.routeParams 1}} data-test-auth-section-tab={{true}}>
|
||||||
{{#link-to params=tab.routeParams}}
|
|
||||||
{{tab.label}}
|
{{tab.label}}
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
{{/link-to}}
|
</li>
|
||||||
{{! template-lint-configure no-curly-component-invocation "on" }}
|
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
@ -61,14 +59,10 @@
|
|||||||
this.itemType
|
this.itemType
|
||||||
}} will be listed here. Create your first {{this.itemType}} to get started."
|
}} will be listed here. Create your first {{this.itemType}} to get started."
|
||||||
>
|
>
|
||||||
{{! template-lint-configure no-curly-component-invocation "warn" }}
|
<LinkTo @route="vault.cluster.access.method.item.create" @model={{this.itemType}} class="link">
|
||||||
{{! template-lint-configure no-link-to-positional-params "warn" }}
|
|
||||||
{{#link-to "vault.cluster.access.method.item.create" this.itemType class="link"}}
|
|
||||||
Create
|
Create
|
||||||
{{singularize this.itemType}}
|
{{singularize this.itemType}}
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
{{! template-lint-configure no-curly-component-invocation "on" }}
|
|
||||||
{{! template-lint-configure no-link-to-positional-params "on" }}
|
|
||||||
</list.empty>
|
</list.empty>
|
||||||
{{else if list.item}}
|
{{else if list.item}}
|
||||||
<ListItem @linkParams={{array "vault.cluster.access.method.item.show" this.itemType list.item.id}} as |Item|>
|
<ListItem @linkParams={{array "vault.cluster.access.method.item.show" this.itemType list.item.id}} as |Item|>
|
||||||
@ -77,20 +71,16 @@
|
|||||||
</Item.content>
|
</Item.content>
|
||||||
<Item.menu as |Menu|>
|
<Item.menu as |Menu|>
|
||||||
<li class="action">
|
<li class="action">
|
||||||
{{! template-lint-configure no-curly-component-invocation "warn" }}
|
<LinkTo @route="vault.cluster.access.method.item.show" @model={{list.item.id}} class="is-block">
|
||||||
{{! template-lint-configure no-link-to-positional-params "warn" }}
|
|
||||||
{{#link-to "vault.cluster.access.method.item.show" list.item.id class="is-block"}}
|
|
||||||
View
|
View
|
||||||
{{singularize this.itemType}}
|
{{singularize this.itemType}}
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
</li>
|
</li>
|
||||||
<li class="action">
|
<li class="action">
|
||||||
{{#link-to "vault.cluster.access.method.item.edit" list.item.id class="is-block"}}
|
<LinkTo @route="vault.cluster.access.method.item.edit" @model={{list.item.id}} class="is-block">
|
||||||
Edit
|
Edit
|
||||||
{{singularize this.itemType}}
|
{{singularize this.itemType}}
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
{{! template-lint-configure no-curly-component-invocation "on" }}
|
|
||||||
{{! template-lint-configure no-link-to-positional-params "on" }}
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<Menu.Message
|
<Menu.Message
|
||||||
|
|||||||
@ -1,18 +1,19 @@
|
|||||||
{{! template-lint-configure no-curly-component-invocation "warn" }}
|
<LinkTo
|
||||||
{{#link-to
|
@route={{this.link.route}}
|
||||||
params=this.linkParams
|
@models={{this.link.models}}
|
||||||
class=this.class
|
@query={{this.query}}
|
||||||
data-test-secret-create=this.data-test-secret-create
|
class={{this.class}}
|
||||||
data-test-credentials-link=this.data-test-credentials-link
|
data-test-secret-create={{this.data-test-secret-create}}
|
||||||
data-test-backend-credentials=this.data-test-backend-credentials
|
data-test-credentials-link={{this.data-test-credentials-link}}
|
||||||
data-test-edit-link=this.data-test-edit-link
|
data-test-backend-credentials={{this.data-test-backend-credentials}}
|
||||||
data-test-sign-link=this.data-test-sign-link
|
data-test-edit-link={{this.data-test-edit-link}}
|
||||||
data-test-transit-link=this.data-test-transit-link
|
data-test-sign-link={{this.data-test-sign-link}}
|
||||||
data-test-transit-key-actions-link=this.data-test-transit-key-actions-link
|
data-test-transit-link={{this.data-test-transit-link}}
|
||||||
data-test-transit-action-link=this.data-test-transit-action-link
|
data-test-transit-key-actions-link={{this.data-test-transit-key-actions-link}}
|
||||||
data-test-version-history=this.data-test-version-history
|
data-test-transit-action-link={{this.data-test-transit-action-link}}
|
||||||
data-test-version=this.data-test-version
|
data-test-version-history={{this.data-test-version-history}}
|
||||||
invokeAction=(action this.onLinkClick)
|
data-test-version={{this.data-test-version}}
|
||||||
}}
|
{{on "click" this.onLinkClick}}
|
||||||
|
>
|
||||||
{{yield}}
|
{{yield}}
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
@ -46,7 +46,7 @@
|
|||||||
@mode="versions"
|
@mode="versions"
|
||||||
@secret={{@model.id}}
|
@secret={{@model.id}}
|
||||||
@class="has-text-black has-text-weight-semibold has-bottom-shadow"
|
@class="has-text-black has-text-weight-semibold has-bottom-shadow"
|
||||||
@onLinkClick={{action D.actions.close}}
|
@onLinkClick={{D.actions.close}}
|
||||||
>
|
>
|
||||||
View version history
|
View version history
|
||||||
</SecretLink>
|
</SecretLink>
|
||||||
|
|||||||
@ -4,13 +4,11 @@
|
|||||||
<nav class="tabs">
|
<nav class="tabs">
|
||||||
<ul>
|
<ul>
|
||||||
{{#each tabs as |tab|}}
|
{{#each tabs as |tab|}}
|
||||||
{{! template-lint-configure no-curly-component-invocation "warn" }}
|
<li>
|
||||||
{{#link-to params=tab.routeParams tagName="li" data-test-auth-section-tab=true}}
|
<LinkTo @route={{get tab.routeParams 0}} @model={{get tab.routeParams 1}} data-test-auth-section-tab={{true}}>
|
||||||
{{#link-to params=tab.routeParams}}
|
|
||||||
{{tab.label}}
|
{{tab.label}}
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
{{/link-to}}
|
</li>
|
||||||
{{! template-lint-configure no-curly-component-invocation "on" }}
|
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@ -13,51 +13,52 @@
|
|||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<li class={{if (is-active-route "vault.cluster.secrets") "is-active"}}>
|
<li class={{if (is-active-route "vault.cluster.secrets") "is-active"}}>
|
||||||
{{! template-lint-configure no-curly-component-invocation "warn" }}
|
<LinkTo
|
||||||
{{! template-lint-configure no-link-to-positional-params "warn" }}
|
@route="vault.cluster.secrets"
|
||||||
{{#link-to
|
@current-when="vault.cluster.secrets vault.cluster.settings.mount-secret-backend vault.cluster.settings.configure-secret-backend"
|
||||||
"vault.cluster.secrets"
|
{{on "click" Nav.closeDrawer}}
|
||||||
current-when="vault.cluster.secrets vault.cluster.settings.mount-secret-backend vault.cluster.settings.configure-secret-backend"
|
|
||||||
invokeAction=(action Nav.closeDrawer)
|
|
||||||
data-test-navbar-item="secrets"
|
data-test-navbar-item="secrets"
|
||||||
}}
|
>
|
||||||
Secrets
|
Secrets
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
</li>
|
</li>
|
||||||
{{#if (has-permission "access")}}
|
{{#if (has-permission "access")}}
|
||||||
<li class={{if (is-active-route "vault.cluster.access") "is-active"}}>
|
<li class={{if (is-active-route "vault.cluster.access") "is-active"}}>
|
||||||
{{#link-to
|
<LinkTo
|
||||||
params=(route-params-for "access")
|
@route={{get (route-params-for "access") "route"}}
|
||||||
current-when="vault.cluster.access vault.cluster.settings.auth"
|
@models={{get (route-params-for "access") "models"}}
|
||||||
invokeAction=(action Nav.closeDrawer)
|
@current-when="vault.cluster.access vault.cluster.settings.auth"
|
||||||
|
{{on "click" Nav.closeDrawer}}
|
||||||
data-test-navbar-item="access"
|
data-test-navbar-item="access"
|
||||||
}}
|
>
|
||||||
Access
|
Access
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if (has-permission "policies")}}
|
{{#if (has-permission "policies")}}
|
||||||
<li class={{if (is-active-route (array "vault.cluster.policies" "vault.cluster.policy")) "is-active"}}>
|
<li class={{if (is-active-route (array "vault.cluster.policies" "vault.cluster.policy")) "is-active"}}>
|
||||||
{{#link-to
|
<LinkTo
|
||||||
"vault.cluster.policies"
|
@route="vault.cluster.policies"
|
||||||
(route-params-for "policies")
|
@models={{get (route-params-for "policies") "models"}}
|
||||||
current-when="vault.cluster.policies vault.cluster.policy"
|
@current-when="vault.cluster.policies vault.cluster.policy"
|
||||||
invokeAction=(action Nav.closeDrawer)
|
{{on "click" Nav.closeDrawer}}
|
||||||
data-test-navbar-item="policies"
|
data-test-navbar-item="policies"
|
||||||
}}
|
>
|
||||||
Policies
|
Policies
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if (has-permission "tools")}}
|
{{#if (has-permission "tools")}}
|
||||||
<li class={{if (is-active-route "vault.cluster.tools") "is-active"}}>
|
<li class={{if (is-active-route "vault.cluster.tools") "is-active"}}>
|
||||||
{{#link-to "vault.cluster.tools.tool" (route-params-for "tools") invokeAction=(action Nav.closeDrawer)}}
|
<LinkTo
|
||||||
|
@route="vault.cluster.tools.tool"
|
||||||
|
@models={{get (route-params-for "tools") "models"}}
|
||||||
|
{{on "click" Nav.closeDrawer}}
|
||||||
|
>
|
||||||
Tools
|
Tools
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{! template-lint-configure no-curly-component-invocation "on" }}
|
|
||||||
{{! template-lint-configure no-link-to-positional-params "on" }}
|
|
||||||
</ul>
|
</ul>
|
||||||
</Nav.main>
|
</Nav.main>
|
||||||
<Nav.items>
|
<Nav.items>
|
||||||
@ -73,17 +74,13 @@
|
|||||||
)}}
|
)}}
|
||||||
<div class="navbar-sections">
|
<div class="navbar-sections">
|
||||||
<div class={{if (is-active-route "vault.cluster.clients") "is-active"}}>
|
<div class={{if (is-active-route "vault.cluster.clients") "is-active"}}>
|
||||||
{{! template-lint-configure no-curly-component-invocation "warn" }}
|
<LinkTo
|
||||||
{{! template-lint-configure no-link-to-positional-params "warn" }}
|
@route="vault.cluster.clients.history"
|
||||||
{{#link-to
|
@current-when="vault.cluster.clients.history"
|
||||||
"vault.cluster.clients.history"
|
|
||||||
current-when="vault.cluster.clients.history"
|
|
||||||
data-test-navbar-item="metrics"
|
data-test-navbar-item="metrics"
|
||||||
}}
|
>
|
||||||
Client count
|
Client count
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
{{! template-lint-configure no-curly-component-invocation "on" }}
|
|
||||||
{{! template-lint-configure no-link-to-positional-params "on" }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
@ -105,6 +105,6 @@
|
|||||||
@page={{this.model.meta.currentPage}}
|
@page={{this.model.meta.currentPage}}
|
||||||
@lastPage={{this.model.meta.lastPage}}
|
@lastPage={{this.model.meta.lastPage}}
|
||||||
@link={{concat "vault.cluster.access.leases.list" (unless this.baseKey.id "-root")}}
|
@link={{concat "vault.cluster.access.leases.list" (unless this.baseKey.id "-root")}}
|
||||||
@model={{compact (array (if this.baseKey.id this.baseKey.id))}}
|
@models={{compact (array (if this.baseKey.id this.baseKey.id))}}
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
@ -3,16 +3,10 @@
|
|||||||
<p.top>
|
<p.top>
|
||||||
<nav class="breadcrumb">
|
<nav class="breadcrumb">
|
||||||
<li>
|
<li>
|
||||||
{{! template-lint-configure no-curly-component-invocation "warn" }}
|
<LinkTo @route={{if this.model.backend "vault.cluster.secrets.backend.list-root" "vault.cluster.secrets"}}>
|
||||||
{{! template-lint-configure no-link-to-positional-params "warn" }}
|
|
||||||
{{#link-to
|
|
||||||
params=(if this.model.backend (array "vault.cluster.secrets.backend.list-root") (array "vault.cluster.secrets"))
|
|
||||||
}}
|
|
||||||
<span class="sep">/</span>
|
<span class="sep">/</span>
|
||||||
{{if this.model.backend this.model.backend "secrets"}}
|
{{if this.model.backend this.model.backend "secrets"}}
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
{{! template-lint-configure no-curly-component-invocation "on" }}
|
|
||||||
{{! template-lint-configure no-link-to-positional-params "on" }}
|
|
||||||
</li>
|
</li>
|
||||||
</nav>
|
</nav>
|
||||||
</p.top>
|
</p.top>
|
||||||
@ -33,16 +27,10 @@
|
|||||||
<p data-test-secret-not-found>
|
<p data-test-secret-not-found>
|
||||||
Unable to find secret at
|
Unable to find secret at
|
||||||
<code>{{concat this.model.backend "/" this.model.secret}}</code>. Try going back to the
|
<code>{{concat this.model.backend "/" this.model.secret}}</code>. Try going back to the
|
||||||
{{! template-lint-configure no-curly-component-invocation "warn" }}
|
<LinkTo @route={{if this.model.backend "vault.cluster.secrets.backend.list-root" "vault.cluster.secrets"}}>
|
||||||
{{! template-lint-configure no-link-to-positional-params "warn" }}
|
|
||||||
{{#link-to
|
|
||||||
params=(if this.model.backend (array "vault.cluster.secrets.backend.list-root") (array "vault.cluster.secrets"))
|
|
||||||
}}
|
|
||||||
root
|
root
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
and navigating from there.
|
and navigating from there.
|
||||||
{{! template-lint-configure no-curly-component-invocation "on" }}
|
|
||||||
{{! template-lint-configure no-link-to-positional-params "on" }}
|
|
||||||
</p>
|
</p>
|
||||||
{{else if (eq this.model.httpStatus 403)}}
|
{{else if (eq this.model.httpStatus 403)}}
|
||||||
{{#if (eq this.model.policyPath "sys/capabilities-self")}}
|
{{#if (eq this.model.policyPath "sys/capabilities-self")}}
|
||||||
|
|||||||
@ -124,7 +124,7 @@
|
|||||||
@page={{this.model.meta.currentPage}}
|
@page={{this.model.meta.currentPage}}
|
||||||
@lastPage={{this.model.meta.lastPage}}
|
@lastPage={{this.model.meta.lastPage}}
|
||||||
@link={{concat "vault.cluster.secrets.backend.list" (unless this.baseKey.id "-root")}}
|
@link={{concat "vault.cluster.secrets.backend.list" (unless this.baseKey.id "-root")}}
|
||||||
@model={{compact (array this.backend (if this.baseKey.id this.baseKey.id))}}
|
@models={{compact (array this.backend (if this.baseKey.id this.baseKey.id))}}
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
|
import { computed } from '@ember/object';
|
||||||
import layout from '../templates/components/form-save-buttons';
|
import layout from '../templates/components/form-save-buttons';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,4 +24,10 @@ import layout from '../templates/components/form-save-buttons';
|
|||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layout,
|
layout,
|
||||||
tagName: '',
|
tagName: '',
|
||||||
|
|
||||||
|
cancelLink: computed('cancelLinkParams.[]', function () {
|
||||||
|
if (!Array.isArray(this.cancelLinkParams) || !this.cancelLinkParams.length) return;
|
||||||
|
const [route, ...models] = this.cancelLinkParams;
|
||||||
|
return { route, models };
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import { task } from 'ember-concurrency';
|
import { task } from 'ember-concurrency';
|
||||||
|
import { computed } from '@ember/object';
|
||||||
import layout from '../templates/components/list-item';
|
import layout from '../templates/components/list-item';
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
@ -24,4 +25,9 @@ export default Component.extend({
|
|||||||
model.rollbackAttributes();
|
model.rollbackAttributes();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
link: computed('linkParams.[]', function () {
|
||||||
|
if (!Array.isArray(this.linkParams) || !this.linkParams.length) return {};
|
||||||
|
const [route, ...models] = this.linkParams;
|
||||||
|
return { route, models };
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { gt } from '@ember/object/computed';
|
|||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import { computed } from '@ember/object';
|
import { computed } from '@ember/object';
|
||||||
import { range } from 'ember-composable-helpers/helpers/range';
|
import { range } from 'ember-composable-helpers/helpers/range';
|
||||||
|
import { A } from '@ember/array';
|
||||||
import layout from '../templates/components/list-pagination';
|
import layout from '../templates/components/list-pagination';
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
@ -10,7 +11,7 @@ export default Component.extend({
|
|||||||
page: null,
|
page: null,
|
||||||
lastPage: null,
|
lastPage: null,
|
||||||
link: null,
|
link: null,
|
||||||
model: null,
|
models: A(),
|
||||||
// number of links to show on each side of page
|
// number of links to show on each side of page
|
||||||
spread: 2,
|
spread: 2,
|
||||||
hasNext: computed('page', 'lastPage', function () {
|
hasNext: computed('page', 'lastPage', function () {
|
||||||
|
|||||||
@ -10,13 +10,11 @@
|
|||||||
{{or @saveButtonText "Save"}}
|
{{or @saveButtonText "Save"}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{{#if @cancelLinkParams}}
|
{{#if this.cancelLink}}
|
||||||
<div class="control">
|
<div class="control">
|
||||||
{{! refactor to use @route and @model args and convert to angle brackets }}
|
<LinkTo @route={{this.cancelLink.route}} @models={{this.cancelLink.models}} class="button">
|
||||||
{{! template-lint-configure no-curly-component-invocation "warn" }}
|
|
||||||
{{#link-to params=@cancelLinkParams class="button"}}
|
|
||||||
{{or @cancelButtonText "Cancel"}}
|
{{or @cancelButtonText "Cancel"}}
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if @onCancel}}
|
{{#if @onCancel}}
|
||||||
|
|||||||
@ -10,14 +10,13 @@
|
|||||||
>
|
>
|
||||||
<div class="level is-mobile">
|
<div class="level is-mobile">
|
||||||
<div class="level-left is-flex-1" data-test-list-item-content>
|
<div class="level-left is-flex-1" data-test-list-item-content>
|
||||||
{{! refactor to use @route and @model args and convert to angle brackets }}
|
<LinkTo
|
||||||
{{! template-lint-configure no-curly-component-invocation "warn" }}
|
@route={{this.link.route}}
|
||||||
{{#link-to
|
@models={{this.link.models}}
|
||||||
params=this.linkParams
|
|
||||||
class="has-text-weight-semibold has-text-black is-display-flex is-flex-1 is-no-underline"
|
class="has-text-weight-semibold has-text-black is-display-flex is-flex-1 is-no-underline"
|
||||||
}}
|
>
|
||||||
{{yield (hash content=(component "list-item/content"))}}
|
{{yield (hash content=(component "list-item/content"))}}
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
</div>
|
</div>
|
||||||
<div class="level-right">
|
<div class="level-right">
|
||||||
<div class="level-item" data-test-list-item-popup>
|
<div class="level-item" data-test-list-item-popup>
|
||||||
|
|||||||
@ -1,86 +1,89 @@
|
|||||||
{{! warn is not working! }}
|
<nav class="pagination is-centered" aria-label="pagination">
|
||||||
{{! template-lint-disable no-curly-component-invocation }}
|
{{#if this.hasPrevious}}
|
||||||
{{#with (compact (flatten (array this.link this.model))) as |params|}}
|
<LinkTo @route={{this.link}} @models={{this.models}} @query={{hash page=(dec this.page)}} class="pagination-previous">
|
||||||
<nav class="pagination is-centered" aria-label="pagination">
|
<Chevron @direction="left" />
|
||||||
{{#if this.hasPrevious}}
|
<span class="pagination-previous-label">
|
||||||
|
Previous
|
||||||
{{#link-to params=(append params (query-params page=(dec this.page))) class="pagination-previous"}}
|
</span>
|
||||||
<Chevron @direction="left" />
|
</LinkTo>
|
||||||
<span class="pagination-previous-label">
|
{{else}}
|
||||||
Previous
|
<button type="button" disabled={{true}} class="pagination-previous is-invisible" aria-hidden={{true}}>
|
||||||
</span>
|
<Chevron @direction="left" />
|
||||||
{{/link-to}}
|
<span class="pagination-previous-label">
|
||||||
{{else}}
|
Previous
|
||||||
<button type="button" disabled={{true}} class="pagination-previous is-invisible" aria-hidden={{true}}>
|
</span>
|
||||||
<Chevron @direction="left" />
|
</button>
|
||||||
<span class="pagination-previous-label">
|
{{/if}}
|
||||||
Previous
|
{{#if this.hasNext}}
|
||||||
</span>
|
<LinkTo @route={{this.link}} @models={{this.models}} @query={{hash page=(inc this.page)}} class="pagination-next">
|
||||||
</button>
|
<span class="pagination-next-label">
|
||||||
{{/if}}
|
Next
|
||||||
{{#if this.hasNext}}
|
</span>
|
||||||
{{#link-to params=(append params (query-params page=(inc this.page))) class="pagination-next"}}
|
<Chevron />
|
||||||
<span class="pagination-next-label">
|
</LinkTo>
|
||||||
Next
|
{{else}}
|
||||||
</span>
|
<button type="button" disabled={{true}} class="pagination-next is-invisible" aria-hidden={{true}}>
|
||||||
<Chevron />
|
<span class="pagination-next-label">
|
||||||
{{/link-to}}
|
Next
|
||||||
{{else}}
|
</span>
|
||||||
<button type="button" disabled={{true}} class="pagination-next is-invisible" aria-hidden={{true}}>
|
<Chevron />
|
||||||
<span class="pagination-next-label">
|
</button>
|
||||||
Next
|
{{/if}}
|
||||||
</span>
|
{{#if this.segmentLinks}}
|
||||||
<Chevron />
|
<ul class="pagination-list">
|
||||||
</button>
|
<li>
|
||||||
{{/if}}
|
<LinkTo
|
||||||
{{#if this.segmentLinks}}
|
@route={{this.link}}
|
||||||
<ul class="pagination-list">
|
@models={{this.models}}
|
||||||
|
@query={{hash page=1}}
|
||||||
|
class={{concat (if (eq this.page 1) "is-current ") "pagination-link"}}
|
||||||
|
aria-label="Go to page 1"
|
||||||
|
>
|
||||||
|
1
|
||||||
|
</LinkTo>
|
||||||
|
</li>
|
||||||
|
<li><span class="pagination-ellipsis">…</span></li>
|
||||||
|
{{#each this.pageRange as |p|}}
|
||||||
<li>
|
<li>
|
||||||
{{#link-to
|
<LinkTo
|
||||||
params=(append params (query-params page=1))
|
@route={{this.link}}
|
||||||
class=(concat (if (eq this.page 1) "is-current ") "pagination-link")
|
@models={{this.models}}
|
||||||
aria-label=(concat "Go to page " 1)
|
@query={{hash page=p}}
|
||||||
}}
|
class={{concat (if (eq this.page 1) "is-current ") "pagination-link"}}
|
||||||
1
|
aria-label={{concat "Go to page " p}}
|
||||||
{{/link-to}}
|
>
|
||||||
|
{{p}}
|
||||||
|
</LinkTo>
|
||||||
</li>
|
</li>
|
||||||
<li><span class="pagination-ellipsis">…</span></li>
|
{{/each}}
|
||||||
{{#each this.pageRange as |p|}}
|
<li><span class="pagination-ellipsis">…</span></li>
|
||||||
<li>
|
<li>
|
||||||
{{#link-to
|
<LinkTo
|
||||||
params=(append params (query-params page=p))
|
@route={{this.link}}
|
||||||
class=(concat (if (eq this.page p) "is-current ") "pagination-link")
|
@models={{this.models}}
|
||||||
aria-label=(concat "Go to page " p)
|
@query={{hash page=this.lastPage}}
|
||||||
}}
|
class={{concat (if (eq this.page this.lastPage) "is-current ") "pagination-link"}}
|
||||||
{{p}}
|
aria-label={{concat "Go to page " this.lastPage}}
|
||||||
{{/link-to}}
|
>
|
||||||
</li>
|
{{this.lastPage}}
|
||||||
{{/each}}
|
</LinkTo>
|
||||||
<li><span class="pagination-ellipsis">…</span></li>
|
</li>
|
||||||
|
</ul>
|
||||||
|
{{else}}
|
||||||
|
<ul class="pagination-list">
|
||||||
|
{{#each this.pageRange as |p|}}
|
||||||
<li>
|
<li>
|
||||||
{{#link-to
|
<LinkTo
|
||||||
params=(append params (query-params page=this.lastPage))
|
@route={{this.link}}
|
||||||
class=(concat (if (eq this.page this.lastPage) "is-current ") "pagination-link")
|
@models={{this.models}}
|
||||||
aria-label=(concat "Go to page " this.lastPage)
|
@query={{hash page=p}}
|
||||||
}}
|
class={{concat (if (eq this.page p) "is-current ") "pagination-link"}}
|
||||||
{{this.lastPage}}
|
aria-label={{concat "Go to page " p}}
|
||||||
{{/link-to}}
|
>
|
||||||
|
{{p}}
|
||||||
|
</LinkTo>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
{{/each}}
|
||||||
{{else}}
|
</ul>
|
||||||
<ul class="pagination-list">
|
{{/if}}
|
||||||
{{#each this.pageRange as |p|}}
|
</nav>
|
||||||
<li>
|
|
||||||
{{#link-to
|
|
||||||
params=(append params (query-params page=p))
|
|
||||||
class=(concat (if (eq this.page p) "is-current ") "pagination-link")
|
|
||||||
aria-label=(concat "Go to page " p)
|
|
||||||
}}
|
|
||||||
{{p}}
|
|
||||||
{{/link-to}}
|
|
||||||
</li>
|
|
||||||
{{/each}}
|
|
||||||
</ul>
|
|
||||||
{{/if}}
|
|
||||||
</nav>
|
|
||||||
{{/with}}
|
|
||||||
@ -1,10 +1,17 @@
|
|||||||
import EditForm from 'core/components/edit-form';
|
import EditForm from 'core/components/edit-form';
|
||||||
|
import { computed } from '@ember/object';
|
||||||
import layout from '../templates/components/edit-form-kmip-role';
|
import layout from '../templates/components/edit-form-kmip-role';
|
||||||
|
|
||||||
export default EditForm.extend({
|
export default EditForm.extend({
|
||||||
layout,
|
layout,
|
||||||
model: null,
|
model: null,
|
||||||
|
|
||||||
|
cancelLink: computed('cancelLinkParams.[]', function () {
|
||||||
|
if (!Array.isArray(this.cancelLinkParams) || !this.cancelLinkParams.length) return;
|
||||||
|
const [route, ...models] = this.cancelLinkParams;
|
||||||
|
return { route, models };
|
||||||
|
}),
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
|
|||||||
@ -90,13 +90,16 @@
|
|||||||
{{this.saveButtonText}}
|
{{this.saveButtonText}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{{#if this.cancelLinkParams}}
|
{{#if this.cancelLink}}
|
||||||
<div class="control">
|
<div class="control">
|
||||||
{{! refactor to use @route and @model args and convert to angle brackets }}
|
<LinkTo
|
||||||
{{! template-lint-configure no-curly-component-invocation "warn" }}
|
@route={{this.cancelLink.route}}
|
||||||
{{#link-to params=this.cancelLinkParams class="button" data-test-edit-form-cancel="true"}}
|
@models={{this.cancelLink.models}}
|
||||||
|
class="button"
|
||||||
|
data-test-edit-form-cancel={{true}}
|
||||||
|
>
|
||||||
Cancel
|
Cancel
|
||||||
{{/link-to}}
|
</LinkTo>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -139,7 +139,7 @@ module('Unit | Service | permissions', function (hooks) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
service.set('exactPaths', policyPaths);
|
service.set('exactPaths', policyPaths);
|
||||||
assert.equal(service.navPathParams('policies'), 'rgp');
|
assert.equal(service.navPathParams('policies').models[0], 'rgp');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns the first allowed nav route for access', function (assert) {
|
test('returns the first allowed nav route for access', function (assert) {
|
||||||
@ -152,7 +152,7 @@ module('Unit | Service | permissions', function (hooks) {
|
|||||||
capabilities: ['read'],
|
capabilities: ['read'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const expected = ['vault.cluster.access.identity', 'entities'];
|
const expected = { route: 'vault.cluster.access.identity', models: ['entities'] };
|
||||||
service.set('exactPaths', accessPaths);
|
service.set('exactPaths', accessPaths);
|
||||||
assert.deepEqual(service.navPathParams('access'), expected);
|
assert.deepEqual(service.navPathParams('access'), expected);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user