feat: 🎸 Add pagination support to client daemon handler (#2016)
✅ Closes: https://hashicorp.atlassian.net/browse/ICU-11743
This commit is contained in:
1 parent
1135f88cb7
commit
3f11019ef0
4 files changed
+49
-13
No files matched your search
@@ -33,7 +33,7 @@ export default class ScopesScopeProjectsTargetsIndexController extends Controlle
|
||||
* @returns {boolean}
|
||||
*/
|
||||
get noResults() {
|
||||
return this.model.length === 0 && this.search;
|
||||
return this.model.targets.length === 0 && this.search;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ export default class ScopesScopeProjectsTargetsIndexController extends Controlle
|
||||
* @returns {boolean}
|
||||
*/
|
||||
get noTargets() {
|
||||
return this.model.length === 0 && !this.search;
|
||||
return this.model.targets.length === 0 && !this.search;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,9 +35,9 @@ export default class ScopesScopeProjectsTargetsIndexRoute extends Route {
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all targets under current scope.
|
||||
* Loads all targets and the number of targets under current scope.
|
||||
*
|
||||
* @return {Promise{[TargetModel]}}
|
||||
* @returns {Promise<{totalItems: number, targets: [TargetModel]}>}
|
||||
*/
|
||||
async model({ search = '' }) {
|
||||
// TODO: Filter targets by scope we're in manually
|
||||
@@ -45,12 +45,13 @@ export default class ScopesScopeProjectsTargetsIndexRoute extends Route {
|
||||
const queryOptions = { query: { search } };
|
||||
|
||||
let targets = await this.store.query('target', queryOptions);
|
||||
const totalItems = targets.meta?.totalItems;
|
||||
|
||||
// Filter out targets to which users do not have the connect ability
|
||||
targets = targets.filter((target) =>
|
||||
this.can.can('connect target', target),
|
||||
);
|
||||
|
||||
return targets;
|
||||
return { targets: targets, totalItems };
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
</page.header>
|
||||
|
||||
<page.body class='targets'>
|
||||
{{#if (or @model this.search)}}
|
||||
{{#if (or @model.targets this.search)}}
|
||||
<div class='target-search-filtering'>
|
||||
<Hds::SegmentedGroup as |S|>
|
||||
<S.TextInput
|
||||
@@ -54,9 +54,9 @@
|
||||
</S.Dropdown>
|
||||
</Hds::SegmentedGroup>
|
||||
</div>
|
||||
{{#if @model}}
|
||||
{{#if @model.targets}}
|
||||
<Hds::Table
|
||||
@model={{@model}}
|
||||
@model={{@model.targets}}
|
||||
@columns={{array
|
||||
(hash label=(t 'form.name.label'))
|
||||
(hash label=(t 'form.id.label'))
|
||||
|
||||
Reference in new issue
Block a user