Skip to content

Commit

Permalink
ui: Redesigns for the token/policy/roles listings pages (hashicorp#8144)
Browse files Browse the repository at this point in the history
  • Loading branch information
johncowen authored Jun 23, 2020
1 parent 4c58f94 commit 7a8b5e7
Show file tree
Hide file tree
Showing 45 changed files with 664 additions and 469 deletions.
3 changes: 3 additions & 0 deletions ui-v2/app/components/confirmation-alert/action/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li class="dangerous">
<button tabindex="-1" type="button" onclick={{action onclick}}>{{yield}}</button>
</li>
5 changes: 5 additions & 0 deletions ui-v2/app/components/confirmation-alert/action/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Component from '@ember/component';

export default Component.extend({
tagName: '',
});
22 changes: 22 additions & 0 deletions ui-v2/app/components/confirmation-alert/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{yield}}
<div class="confirmation-alert" ...attributes>
<div>
<header>
<YieldSlot @name="header">{{yield}}</YieldSlot>
</header>
<YieldSlot @name="body">{{yield}}</YieldSlot>
</div>
<ul>
<YieldSlot @name="confirm" @params={{
block-params (component 'confirmation-alert/action'
onclick=(action onclick)
)
}}
>
{{yield}}
</YieldSlot>
<li>
<label for={{name}}>Cancel</label>
</li>
</ul>
</div>
5 changes: 5 additions & 0 deletions ui-v2/app/components/confirmation-alert/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Component from '@ember/component';

export default Component.extend({
tagName: '',
});
24 changes: 24 additions & 0 deletions ui-v2/app/components/consul-policy-list/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## ConsulPolicyList

```
<ConsulPolicyList
@items={{items}}
@ondelete={{action 'delete'}}
/>
```

A presentational component for rendering Consul ACL policies

### Arguments

| Argument/Attribute | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `array` | | An array of ACL policies |
| `ondelete` | `function` | | An action to execute when the `Delete` action is clicked |

### See

- [Component Source Code](./index.js)
- [TemplateSource Code](./index.hbs)

---
67 changes: 67 additions & 0 deletions ui-v2/app/components/consul-policy-list/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{#if (gt items.length 0)}}
<ListCollection @items={{items}} class="consul-policy-list" as |item|>
<BlockSlot @name="header">
{{#if (eq (policy/typeof item) 'policy-management')}}
<dl class="policy-management">
<dd>
<Tooltip @position="top-start">
Global Management Policy
</Tooltip>
</dd>
</dl>
{{/if}}
<a data-test-policy={{item.Name}} href={{href-to 'dc.acls.policies.edit' item.ID}} class={{if (eq (policy/typeof item) 'policy-management') 'is-management'}}>{{item.Name}}</a>
</BlockSlot>
<BlockSlot @name="details">
<dl class="datacenter">
<dt>
<Tooltip @position="top-start">Datacenters</Tooltip>
</dt>
<dd>
{{join ', ' (policy/datacenters item)}}
</dd>
</dl>
<dl class="description">
<dt>Description</dt>
<dd data-test-description>
{{item.Description}}
</dd>
</dl>
</BlockSlot>
<BlockSlot @name="actions" as |Actions|>
<Actions as |Action|>
<Action data-test-edit-action @href={{href-to 'dc.acls.policies.edit' item.ID}}>
<BlockSlot @name="label">
{{#if (eq (policy/typeof item) 'policy-management')}}
View
{{else}}
Edit
{{/if}}
</BlockSlot>
</Action>
{{#if (not-eq (policy/typeof item) 'policy-management')}}
<Action data-test-delete-action @onclick={{action ondelete item}} class="dangerous">
<BlockSlot @name="label">
Delete
</BlockSlot>
<BlockSlot @name="confirmation" as |Confirmation|>
<Confirmation class="warning">
<BlockSlot @name="header">
Confirm delete
</BlockSlot>
<BlockSlot @name="body">
<p>
Are you sure you want to delete this policy?
</p>
</BlockSlot>
<BlockSlot @name="confirm" as |Confirm|>
<Confirm>Delete</Confirm>
</BlockSlot>
</Confirmation>
</BlockSlot>
</Action>
{{/if}}
</Actions>
</BlockSlot>
</ListCollection>
{{/if}}
5 changes: 5 additions & 0 deletions ui-v2/app/components/consul-policy-list/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Component from '@ember/component';

export default Component.extend({
tagName: '',
});
8 changes: 8 additions & 0 deletions ui-v2/app/components/consul-policy-list/pageobject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default (collection, clickable, attribute, text, actions) => () => {
return collection('.consul-policy-list li:not(:first-child)', {
name: attribute('data-test-policy', '[data-test-policy]'),
description: text('[data-test-description]'),
policy: clickable('a'),
...actions(['edit', 'delete']),
});
};
24 changes: 24 additions & 0 deletions ui-v2/app/components/consul-role-list/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## ConsulRoleList

```
<ConsulRoleList
@items={{items}}
@ondelete={{action 'delete'}}
/>
```

A presentational component for rendering Consul ACL roles

### Arguments

| Argument/Attribute | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `array` | | An array of ACL roles |
| `ondelete` | `function` | | An action to execute when the `Delete` action is clicked |

### See

- [Component Source Code](./index.js)
- [TemplateSource Code](./index.hbs)

---
45 changes: 45 additions & 0 deletions ui-v2/app/components/consul-role-list/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{#if (gt items.length 0)}}
<ListCollection @items={{items}} class="consul-role-list" as |item|>
<BlockSlot @name="header">
<a data-test-role={{item.Name}} href={{href-to 'dc.acls.roles.edit' item.ID}}>{{item.Name}}</a>
</BlockSlot>
<BlockSlot @name="details">
<ConsulTokenRulesetList @item={{item}} />
<dl>
<dt>Description</dt>
<dd data-test-description>
{{item.Description}}
</dd>
</dl>
</BlockSlot>
<BlockSlot @name="actions" as |Actions|>
<Actions as |Action|>
<Action data-test-edit-action @href={{href-to 'dc.acls.roles.edit' item.ID}}>
<BlockSlot @name="label">
Edit
</BlockSlot>
</Action>
<Action data-test-delete-action @onclick={{action ondelete item}} class="dangerous">
<BlockSlot @name="label">
Delete
</BlockSlot>
<BlockSlot @name="confirmation" as |Confirmation|>
<Confirmation class="warning">
<BlockSlot @name="header">
Confirm delete
</BlockSlot>
<BlockSlot @name="body">
<p>
Are you sure you want to delete this role?
</p>
</BlockSlot>
<BlockSlot @name="confirm" as |Confirm|>
<Confirm>Delete</Confirm>
</BlockSlot>
</Confirmation>
</BlockSlot>
</Action>
</Actions>
</BlockSlot>
</ListCollection>
{{/if}}
5 changes: 5 additions & 0 deletions ui-v2/app/components/consul-role-list/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Component from '@ember/component';

export default Component.extend({
tagName: '',
});
9 changes: 9 additions & 0 deletions ui-v2/app/components/consul-role-list/pageobject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default (collection, clickable, attribute, text, actions) => () => {
return collection('.consul-role-list li:not(:first-child)', {
name: attribute('data-test-role', '[data-test-role]'),
description: text('[data-test-description]'),
policy: text('[data-test-policy].policy', { multiple: true }),
serviceIdentity: text('[data-test-policy].policy-service-identity', { multiple: true }),
...actions(['edit', 'delete']),
});
};
Loading

0 comments on commit 7a8b5e7

Please sign in to comment.