ui: refactor out the taglist component to use a recursive pattern (#7837)
* ui: refactor out the taglist component to use a recursive pattern * Make sure simple rendering tests pass
This commit is contained in:
parent
4c46d2ed6f
commit
7d6f5ef92a
|
@ -37,11 +37,11 @@
|
||||||
{{item.Node.Address}}:{{item.Service.Port}}
|
{{item.Node.Address}}:{{item.Service.Port}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</li>
|
</li>
|
||||||
{{#if (gt item.Service.Tags.length 0)}}
|
<TagList @item={{item.Service}} as |Tags|>
|
||||||
<li>
|
<li>
|
||||||
<TagList @items={{item.Service.Tags}}/>
|
<Tags />
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
</TagList>
|
||||||
</ul>
|
</ul>
|
||||||
</ListCollection>
|
</ListCollection>
|
||||||
{{/if}}
|
{{/if}}
|
|
@ -25,11 +25,11 @@
|
||||||
connected with proxy
|
connected with proxy
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if (gt items.Tags.length 0)}}
|
<TagList @item={{item}} as |Tags|>
|
||||||
<li>
|
<li>
|
||||||
<TagList @items={{item.Tags}}/>
|
<Tags />
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
</TagList>
|
||||||
</ul>
|
</ul>
|
||||||
</ListCollection>
|
</ListCollection>
|
||||||
{{/if}}
|
{{/if}}
|
|
@ -1,8 +1,16 @@
|
||||||
{{#if (gt items.length 0)}}
|
{{#if (gt item.Tags.length 0)}}
|
||||||
<dt class="tags">Tags</dt>
|
{{#if (has-block)}}
|
||||||
<dd data-test-tags class="tags">
|
{{yield
|
||||||
{{#each items as |item|}}
|
(component 'tag-list' item=item)
|
||||||
<span>{{item}}</span>
|
}}
|
||||||
{{/each}}
|
{{else}}
|
||||||
</dd>
|
<dl class="tag-list">
|
||||||
|
<dt>Tags</dt>
|
||||||
|
<dd data-test-tags>
|
||||||
|
{{#each item.Tags as |item|}}
|
||||||
|
<span>{{item}}</span>
|
||||||
|
{{/each}}
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
tagName: 'dl',
|
tagName: '',
|
||||||
classNames: ['tag-list'],
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
{{item.Port}}
|
{{item.Port}}
|
||||||
</td>
|
</td>
|
||||||
<td data-test-service-tags>
|
<td data-test-service-tags>
|
||||||
<TagList @items={{item.Tags}} />
|
<TagList @item={{item}} />
|
||||||
</td>
|
</td>
|
||||||
</BlockSlot>
|
</BlockSlot>
|
||||||
</TabularCollection>
|
</TabularCollection>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div id="tags" class="tab-section">
|
<div id="tags" class="tab-section">
|
||||||
<div role="tabpanel">
|
<div role="tabpanel">
|
||||||
{{#if (gt item.Tags.length 0) }}
|
{{#if (gt item.Tags.length 0) }}
|
||||||
<TagList @items={{item.Tags}} />
|
<TagList @item={{item}} />
|
||||||
{{else}}
|
{{else}}
|
||||||
<p>
|
<p>
|
||||||
There are no tags.
|
There are no tags.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div id="tags" class="tab-section">
|
<div id="tags" class="tab-section">
|
||||||
<div role="tabpanel">
|
<div role="tabpanel">
|
||||||
{{#if (gt item.Tags.length 0) }}
|
{{#if (gt item.Tags.length 0) }}
|
||||||
<TagList @items={{item.Tags}} />
|
<TagList @item={{item}} />
|
||||||
{{else}}
|
{{else}}
|
||||||
<p>
|
<p>
|
||||||
There are no tags.
|
There are no tags.
|
||||||
|
|
|
@ -10,16 +10,17 @@ module('Integration | Component | tag list', function(hooks) {
|
||||||
// Set any properties with this.set('myProperty', 'value');
|
// Set any properties with this.set('myProperty', 'value');
|
||||||
// Handle any actions with this.on('myAction', function(val) { ... });
|
// Handle any actions with this.on('myAction', function(val) { ... });
|
||||||
|
|
||||||
await render(hbs`{{tag-list}}`);
|
await render(hbs`<TagList @item={{hash Tags=(array 'tag')}} />`);
|
||||||
|
|
||||||
assert.dom('*').hasText('');
|
assert.dom('dd').hasText('tag');
|
||||||
|
|
||||||
// Template block usage:
|
// Template block usage:
|
||||||
await render(hbs`
|
await render(hbs`
|
||||||
{{#tag-list}}
|
<TagList @item={{hash Tags=(array 'tag')}} as |Tags|>
|
||||||
{{/tag-list}}
|
<Tags />
|
||||||
|
</TagList>
|
||||||
`);
|
`);
|
||||||
|
|
||||||
assert.dom('*').hasText('');
|
assert.dom('dd').hasText('tag');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue