mirror of https://github.com/status-im/consul.git
Use reject-by composable helper instead of provider
This commit is contained in:
parent
344ebaa962
commit
4218124b10
|
@ -1 +0,0 @@
|
||||||
{{yield (hash data=this.data)}}
|
|
|
@ -1,36 +0,0 @@
|
||||||
import Component from '@glimmer/component';
|
|
||||||
import { isArray } from '@ember/array';
|
|
||||||
import { get } from '@ember/object';
|
|
||||||
import { isEmpty, isEqual, isPresent } from '@ember/utils';
|
|
||||||
|
|
||||||
export default class RejectByProvider extends Component {
|
|
||||||
get items() {
|
|
||||||
const { items, path, value } = this.args;
|
|
||||||
|
|
||||||
if (!isArray) {
|
|
||||||
return [];
|
|
||||||
} else if (isEmpty(path)) {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
let filterFn;
|
|
||||||
if (isPresent(value)) {
|
|
||||||
if (typeof value === 'function') {
|
|
||||||
filterFn = (item) => !value(get(item, path));
|
|
||||||
} else {
|
|
||||||
filterFn = (item) => !isEqual(get(item, path), value);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
filterFn = (item) => !get(item, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return items.filter(filterFn);
|
|
||||||
}
|
|
||||||
|
|
||||||
get data() {
|
|
||||||
const { items } = this;
|
|
||||||
return {
|
|
||||||
items,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,133 +1,121 @@
|
||||||
<Route
|
<Route @name={{routeName}} as |route|>
|
||||||
@name={{routeName}}
|
|
||||||
as |route|>
|
|
||||||
|
|
||||||
<DataSource @src={{
|
<DataSource
|
||||||
uri '/${partition}/${nspace}/${dc}/leader'
|
@src={{uri
|
||||||
(hash
|
'/${partition}/${nspace}/${dc}/leader'
|
||||||
partition=route.params.partition
|
(hash partition=route.params.partition nspace=route.params.nspace dc=route.params.dc)
|
||||||
nspace=route.params.nspace
|
}}
|
||||||
dc=route.params.dc
|
as |leader|
|
||||||
)
|
>
|
||||||
}} as |leader|>
|
|
||||||
|
|
||||||
<DataLoader
|
<DataLoader
|
||||||
@src={{uri '/${partition}/${nspace}/${dc}/nodes'
|
@src={{uri
|
||||||
(hash
|
'/${partition}/${nspace}/${dc}/nodes'
|
||||||
partition=route.params.partition
|
(hash partition=route.params.partition nspace=route.params.nspace dc=route.params.dc)
|
||||||
nspace=route.params.nspace
|
|
||||||
dc=route.params.dc
|
|
||||||
)
|
|
||||||
}}
|
}}
|
||||||
as |api|>
|
as |api|
|
||||||
|
>
|
||||||
|
|
||||||
<BlockSlot @name="error">
|
<BlockSlot @name='error'>
|
||||||
<AppError
|
<AppError @error={{api.error}} @login={{route.model.app.login.open}} />
|
||||||
@error={{api.error}}
|
|
||||||
@login={{route.model.app.login.open}}
|
|
||||||
/>
|
|
||||||
</BlockSlot>
|
|
||||||
|
|
||||||
<BlockSlot @name="loaded">
|
|
||||||
{{#let
|
|
||||||
|
|
||||||
(hash
|
|
||||||
value=(or sortBy "Status:asc")
|
|
||||||
change=(action (mut sortBy) value="target.selected")
|
|
||||||
)
|
|
||||||
|
|
||||||
(hash
|
|
||||||
status=(hash
|
|
||||||
value=(if status (split status ',') undefined)
|
|
||||||
change=(action (mut status) value="target.selectedItems")
|
|
||||||
)
|
|
||||||
searchproperty=(hash
|
|
||||||
value=(if (not-eq searchproperty undefined)
|
|
||||||
(split searchproperty ',')
|
|
||||||
this._searchProperties
|
|
||||||
)
|
|
||||||
change=(action (mut searchproperty) value="target.selectedItems")
|
|
||||||
default=this._searchProperties
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
api.data
|
|
||||||
|
|
||||||
leader.data
|
|
||||||
|
|
||||||
as |sort filters items leader|}}
|
|
||||||
<AppView>
|
|
||||||
<BlockSlot @name="header">
|
|
||||||
<h1>
|
|
||||||
<route.Title @title="Nodes" /> <em>{{format-number items.length}} total</em>
|
|
||||||
</h1>
|
|
||||||
<label for="toolbar-toggle"></label>
|
|
||||||
</BlockSlot>
|
</BlockSlot>
|
||||||
<BlockSlot @name="toolbar">
|
|
||||||
{{#if (gt items.length 0) }}
|
|
||||||
<Consul::Node::SearchBar
|
|
||||||
@search={{search}}
|
|
||||||
@onsearch={{action (mut search) value="target.value"}}
|
|
||||||
|
|
||||||
@sort={{sort}}
|
<BlockSlot @name='loaded'>
|
||||||
|
{{#let
|
||||||
@filter={{filters}}
|
(hash value=(or sortBy 'Status:asc') change=(action (mut sortBy) value='target.selected'))
|
||||||
/>
|
(hash
|
||||||
{{/if}}
|
status=(hash
|
||||||
|
value=(if status (split status ',') undefined)
|
||||||
|
change=(action (mut status) value='target.selectedItems')
|
||||||
|
)
|
||||||
|
searchproperty=(hash
|
||||||
|
value=(if
|
||||||
|
(not-eq searchproperty undefined) (split searchproperty ',') this._searchProperties
|
||||||
|
)
|
||||||
|
change=(action (mut searchproperty) value='target.selectedItems')
|
||||||
|
default=this._searchProperties
|
||||||
|
)
|
||||||
|
)
|
||||||
|
api.data
|
||||||
|
leader.data
|
||||||
|
as |sort filters items leader|
|
||||||
|
}}
|
||||||
|
{{#let (reject-by 'Meta.synthetic-node' 'true' items) as |filtered|}}
|
||||||
|
<AppView>
|
||||||
|
<BlockSlot @name='header'>
|
||||||
|
<h1>
|
||||||
|
<route.Title @title='Nodes' />
|
||||||
|
<em>{{format-number items.length}} total</em>
|
||||||
|
</h1>
|
||||||
|
<label for='toolbar-toggle'></label>
|
||||||
|
</BlockSlot>
|
||||||
|
<BlockSlot @name='toolbar'>
|
||||||
|
{{#if (gt filtered.length 0)}}
|
||||||
|
<Consul::Node::SearchBar
|
||||||
|
@search={{search}}
|
||||||
|
@onsearch={{action (mut search) value='target.value'}}
|
||||||
|
@sort={{sort}}
|
||||||
|
@filter={{filters}}
|
||||||
|
/>
|
||||||
|
{{/if}}
|
||||||
|
</BlockSlot>
|
||||||
|
<BlockSlot @name='content'>
|
||||||
|
<DataCollection
|
||||||
|
@type='node'
|
||||||
|
@sort={{sort.value}}
|
||||||
|
@filters={{filters}}
|
||||||
|
@search={{search}}
|
||||||
|
@items={{filtered}}
|
||||||
|
as |collection|
|
||||||
|
>
|
||||||
|
<collection.Collection>
|
||||||
|
<Consul::Node::List @items={{collection.items}} @leader={{leader}} />
|
||||||
|
</collection.Collection>
|
||||||
|
<collection.Empty>
|
||||||
|
<EmptyState @login={{route.model.app.login.open}}>
|
||||||
|
<BlockSlot @name='header'>
|
||||||
|
<h2>
|
||||||
|
{{t 'routes.dc.nodes.index.empty.header' items=items.length}}
|
||||||
|
</h2>
|
||||||
|
</BlockSlot>
|
||||||
|
<BlockSlot @name='body'>
|
||||||
|
{{t
|
||||||
|
'routes.dc.nodes.index.empty.body'
|
||||||
|
items=items.length
|
||||||
|
canUseACLs=(can 'use acls')
|
||||||
|
htmlSafe=true
|
||||||
|
}}
|
||||||
|
</BlockSlot>
|
||||||
|
<BlockSlot @name='actions'>
|
||||||
|
<li class='docs-link'>
|
||||||
|
<a
|
||||||
|
href='{{env "CONSUL_DOCS_DEVELOPER_URL"}}/agent'
|
||||||
|
rel='noopener noreferrer'
|
||||||
|
target='_blank'
|
||||||
|
>
|
||||||
|
{{t 'routes.dc.nodes.index.empty.documentation'}}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class='learn-link'>
|
||||||
|
<a
|
||||||
|
href='{{env
|
||||||
|
"CONSUL_DOCS_LEARN_URL"
|
||||||
|
}}/tutorials/consul/deployment-guide?in=consul/production-deploy#configure-consul-agents'
|
||||||
|
rel='noopener noreferrer'
|
||||||
|
target='_blank'
|
||||||
|
>
|
||||||
|
{{t 'routes.dc.nodes.index.empty.learn'}}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</BlockSlot>
|
||||||
|
</EmptyState>
|
||||||
|
</collection.Empty>
|
||||||
|
</DataCollection>
|
||||||
|
</BlockSlot>
|
||||||
|
</AppView>
|
||||||
|
{{/let}}
|
||||||
|
{{/let}}
|
||||||
</BlockSlot>
|
</BlockSlot>
|
||||||
<BlockSlot @name="content">
|
|
||||||
<Providers::RejectBy @items={{items}} @path="Meta.synthetic-node" @value="true" as |filtered|>
|
|
||||||
<DataCollection
|
|
||||||
@type="node"
|
|
||||||
@sort={{sort.value}}
|
|
||||||
@filters={{filters}}
|
|
||||||
@search={{search}}
|
|
||||||
@items={{filtered.data.items}}
|
|
||||||
as |collection|>
|
|
||||||
<collection.Collection>
|
|
||||||
<Consul::Node::List
|
|
||||||
@items={{collection.items}}
|
|
||||||
@leader={{leader}}
|
|
||||||
/>
|
|
||||||
</collection.Collection>
|
|
||||||
<collection.Empty>
|
|
||||||
<EmptyState
|
|
||||||
@login={{route.model.app.login.open}}
|
|
||||||
>
|
|
||||||
<BlockSlot @name="header">
|
|
||||||
<h2>
|
|
||||||
{{t 'routes.dc.nodes.index.empty.header'
|
|
||||||
items=items.length
|
|
||||||
}}
|
|
||||||
</h2>
|
|
||||||
</BlockSlot>
|
|
||||||
<BlockSlot @name="body">
|
|
||||||
{{t 'routes.dc.nodes.index.empty.body'
|
|
||||||
items=items.length
|
|
||||||
canUseACLs=(can 'use acls')
|
|
||||||
htmlSafe=true
|
|
||||||
}}
|
|
||||||
</BlockSlot>
|
|
||||||
<BlockSlot @name="actions">
|
|
||||||
<li class="docs-link">
|
|
||||||
<a href="{{env 'CONSUL_DOCS_DEVELOPER_URL'}}/agent" rel="noopener noreferrer" target="_blank">
|
|
||||||
{{t 'routes.dc.nodes.index.empty.documentation'}}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="learn-link">
|
|
||||||
<a href="{{env "CONSUL_DOCS_LEARN_URL"}}/tutorials/consul/deployment-guide?in=consul/production-deploy#configure-consul-agents" rel="noopener noreferrer" target="_blank">
|
|
||||||
{{t 'routes.dc.nodes.index.empty.learn'}}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</BlockSlot>
|
|
||||||
</EmptyState>
|
|
||||||
</collection.Empty>
|
|
||||||
</DataCollection>
|
|
||||||
</Providers::RejectBy>
|
|
||||||
</BlockSlot>
|
|
||||||
</AppView>
|
|
||||||
{{/let}}
|
|
||||||
</BlockSlot>
|
|
||||||
</DataLoader>
|
</DataLoader>
|
||||||
</DataSource>
|
</DataSource>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
Loading…
Reference in New Issue