UI/fix identity model (#11641)

This commit is contained in:
Chelsea Shaw 2021-05-17 16:41:39 -05:00 committed by GitHub
parent 549f1c7917
commit 19c5f27434
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 73 additions and 50 deletions

3
changelog/11641.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: Fix entity group membership and metadata not showing
```

View File

@ -64,8 +64,8 @@ export default IdentityModel.extend({
'memberGroupIds.[]', 'memberGroupIds.[]',
function() { function() {
let { memberEntityIds, memberGroupIds } = this; let { memberEntityIds, memberGroupIds } = this;
let numEntities = (memberEntityIds && memberEntityIds.get('length')) || 0; let numEntities = (memberEntityIds && memberEntityIds.length) || 0;
let numGroups = (memberGroupIds && memberGroupIds.get('length')) || 0; let numGroups = (memberGroupIds && memberGroupIds.length) || 0;
return numEntities + numGroups > 0; return numEntities + numGroups > 0;
} }
), ),

View File

@ -148,7 +148,6 @@
/> />
{{else}} {{else}}
{{#each @model.statementFields as |attr|}} {{#each @model.statementFields as |attr|}}
{{log attr}}
{{form-field data-test-field attr=attr model=@model}} {{form-field data-test-field attr=attr model=@model}}
{{/each}} {{/each}}
{{/if}} {{/if}}

View File

@ -1,32 +1,32 @@
<div class="box is-shadowless is-marginless is-fullwidth"> <div class="box is-shadowless is-marginless is-fullwidth">
{{#if model.disabled}} {{#if @model.disabled}}
<AlertBanner <AlertBanner
@type="warning" @type="warning"
@title="Attention" @title="Attention"
@message="This {{model.identityType}} is disabled. All associated tokens cannot be used, but are not revoked." @message="This {{@model.identityType}} is disabled. All associated tokens cannot be used, but are not revoked."
data-test-disabled-warning> data-test-disabled-warning>
{{#if model.canEdit}} {{#if @model.canEdit}}
<button onclick={{action 'enable' model}} type="button" class="link" data-test-enable=true> <button onclick={{action 'enable' @model}} type="button" class="link" data-test-enable=true>
Enable Enable
</button> </button>
{{/if}} {{/if}}
</AlertBanner> </AlertBanner>
{{/if}} {{/if}}
<InfoTableRow @label="Name" @value={{model.name}} @data-test-identity-item-name={{true}} /> <InfoTableRow @label="Name" @value={{@model.name}} @data-test-identity-item-name={{true}} />
<InfoTableRow @label="Type" @value={{model.type}} /> <InfoTableRow @label="Type" @value={{@model.type}} />
<InfoTableRow @label="ID" @value={{model.id}} /> <InfoTableRow @label="ID" @value={{@model.id}} />
<InfoTableRow @label="Merged Ids" @value={{model.mergedEntityIds}}> <InfoTableRow @label="Merged Ids" @value={{@model.mergedEntityIds}}>
<div> <div>
{{#each model.mergedEntityIds as |id|}} {{#each @model.mergedEntityIds as |id|}}
<div> <div>
<code class="has-text-black">{{id}}</code> <code class="has-text-black">{{id}}</code>
</div> </div>
{{/each}} {{/each}}
</div> </div>
</InfoTableRow> </InfoTableRow>
<InfoTableRow @label="Created" @value={{model.creationTime}}> <InfoTableRow @label="Created" @value={{@model.creationTime}}>
<time datetime={{model.creationTime}} title={{model.creationTime}}> <time datetime={{@model.creationTime}} title={{@model.creationTime}}>
{{date-format model.creationTime 'MMM dd, yyyy [at] h:mm a'}} {{date-format @model.creationTime 'MMM dd, yyyy [at] h:mm a'}}
</time> </time>
</InfoTableRow> </InfoTableRow>
<InfoTableRow @label="Last Updated" @value={{model.lastUpdateTime}}> <InfoTableRow @label="Last Updated" @value={{model.lastUpdateTime}}>

View File

@ -1,17 +1,19 @@
{{#if model.groupIds}} {{#if @model.groupIds}}
{{#each model.directGroupIds as |gid|}} {{#each @model.directGroupIds as |gid|}}
<LinkTo @route="vault.cluster.access.identity.show" @models={{array "groups" gid "details"}} class="list-item-row"><Icon <LinkTo @route="vault.cluster.access.identity.show" @models={{array "groups" gid "details"}} class="list-item-row">
<Icon
@glyph="folder-outline" @glyph="folder-outline"
class="has-text-grey-light" class="has-text-grey-light"
/>{{gid}} />{{gid}}
</LinkTo> </LinkTo>
{{/each}} {{/each}}
{{#each model.inheritedGroupIds as |gid|}} {{#each @model.inheritedGroupIds as |gid|}}
{{#linked-block {{#linked-block
"vault.cluster.access.identity.show" "groups" gid "details" "vault.cluster.access.identity.show" "groups" gid "details"
class="list-item-row" class="list-item-row"
}} }}
<LinkTo @route="vault.cluster.access.identity.show" @models={{array "groups" gid "details"}} class="has-text-black"><Icon <LinkTo @route="vault.cluster.access.identity.show" @models={{array "groups" gid "details"}} class="has-text-black">
<Icon
@glyph="folder-outline" @glyph="folder-outline"
class="has-text-grey-light" class="has-text-grey-light"
/>{{gid}} />{{gid}}
@ -21,6 +23,6 @@
{{/each}} {{/each}}
{{else}} {{else}}
<EmptyState <EmptyState
@title="{{model.name}} is not a member of any groups." @title="{{@model.name}} is not a member of any groups."
/> />
{{/if}} {{/if}}

View File

@ -1,5 +1,5 @@
{{#if model.hasMembers}} {{#if @model.hasMembers}}
{{#each model.memberGroupIds as |gid|}} {{#each @model.memberGroupIds as |gid|}}
{{#linked-block {{#linked-block
"vault.cluster.access.identity.show" "vault.cluster.access.identity.show"
"groups" "groups"
@ -15,14 +15,14 @@
/>{{gid}}</LinkTo> />{{gid}}</LinkTo>
</div> </div>
<div class="column has-text-right"> <div class="column has-text-right">
{{#if model.canEdit}} {{#if @model.canEdit}}
<Identity::PopupMembers @params={{array model "memberGroupIds" gid}} /> <Identity::PopupMembers @params={{array @model "memberGroupIds" gid}} />
{{/if}} {{/if}}
</div> </div>
</div> </div>
{{/linked-block}} {{/linked-block}}
{{/each}} {{/each}}
{{#each model.memberEntityIds as |gid|}} {{#each @model.memberEntityIds as |gid|}}
{{#linked-block {{#linked-block
"vault.cluster.access.identity.show" "vault.cluster.access.identity.show"
"groups" "groups"
@ -32,14 +32,19 @@
}} }}
<div class="columns"> <div class="columns">
<div class="column is-10"> <div class="column is-10">
<LinkTo @route="vault.cluster.access.identity.show" @models={{array "entities" gid "details"}} class="is-block has-text-black has-text-weight-semibold"><Icon <LinkTo
@route="vault.cluster.access.identity.show"
@models={{array "entities" gid "details"}}
class="is-block has-text-black has-text-weight-semibold">
<Icon
@glyph="user-square-outline" @glyph="user-square-outline"
class="has-text-grey-light" class="has-text-grey-light"
/>{{gid}}</LinkTo> />{{gid}}
</LinkTo>
</div> </div>
<div class="column has-text-right"> <div class="column has-text-right">
{{#if model.canEdit}} {{#if @model.canEdit}}
<Identity::PopupMembers @params={{array model "memberEntityIds" gid}} /> <Identity::PopupMembers @params={{array @model "memberEntityIds" gid}} />
{{/if}} {{/if}}
</div> </div>
</div> </div>

View File

@ -1,4 +1,4 @@
{{#each-in model.metadata as |key value|}} {{#each-in @model.metadata as |key value|}}
<div class="info-table-row is-mobile"> <div class="info-table-row is-mobile">
<div class="is-flex is-fullwidth"> <div class="is-flex is-fullwidth">
<div class="column is-one-quarter"> <div class="column is-one-quarter">
@ -10,19 +10,19 @@
{{value}} {{value}}
</div> </div>
<div class="column has-text-right"> <div class="column has-text-right">
{{#if model.canEdit}} {{#if @model.canEdit}}
<Identity::PopupMetadata @params={{array model key}} /> <Identity::PopupMetadata @params={{array @model key}} />
{{/if}} {{/if}}
</div> </div>
</div> </div>
</div> </div>
{{else}} {{else}}
<EmptyState <EmptyState
@title="No metadata for {{model.name}}" @title="No metadata for {{@model.name}}"
@message="You can store custom data that you want to associate with a {{lowercase (humanize model.identityType)}}. Edit this {{lowercase (humanize model.identityType)}} to get started." @message="You can store custom data that you want to associate with a {{lowercase (humanize @model.identityType)}}. Edit this {{lowercase (humanize @model.identityType)}} to get started."
> >
<LinkTo @route="vault.cluster.access.identity.edit" @model={{model.id}} @tagName="button" class="link"> <LinkTo @route="vault.cluster.access.identity.edit" @model={{@model.id}} @tagName="button" class="link">
Edit {{lowercase (humanize model.identityType)}} Edit {{lowercase (humanize @model.identityType)}}
</LinkTo> </LinkTo>
<LearnLink @path="/vault/identity-access-management/iam-identity"> <LearnLink @path="/vault/identity-access-management/iam-identity">
Learn more Learn more

View File

@ -1,5 +1,5 @@
{{#if model.parentGroupIds.length}} {{#if @model.parentGroupIds.length}}
{{#each model.parentGroupIds as |gid|}} {{#each @model.parentGroupIds as |gid|}}
{{#linked-block {{#linked-block
"vault.cluster.access.identity.show" "vault.cluster.access.identity.show"
"groups" "groups"
@ -9,7 +9,8 @@
}} }}
<div class="columns is-mobile"> <div class="columns is-mobile">
<div class="column is-10"> <div class="column is-10">
<LinkTo @route="vault.cluster.access.identity.show" @models={{array "groups" gid "details"}} class="is-block has-text-black has-text-weight-semibold"><Icon <LinkTo @route="vault.cluster.access.identity.show" @models={{array "groups" gid "details"}} class="is-block has-text-black has-text-weight-semibold">
<Icon
@glyph="folder-outline" @glyph="folder-outline"
class="has-text-grey-light" class="has-text-grey-light"
/>{{gid}} />{{gid}}

View File

@ -7,12 +7,13 @@
}} }}
<div class="columns is-mobile"> <div class="columns is-mobile">
<div class="column is-10"> <div class="column is-10">
<LinkTo @route="vault.cluster.policy.show" @models={{array "acl" policyName}} class="is-block has-text-black has-text-weight-semibold"><span class="is-underline">{{policyName}}</span> <LinkTo @route="vault.cluster.policy.show" @models={{array "acl" policyName}} class="is-block has-text-black has-text-weight-semibold">
<span class="is-underline">{{policyName}}</span>
</LinkTo> </LinkTo>
</div> </div>
<div class="column has-text-right"> <div class="column has-text-right">
{{#if model.canEdit}} {{#if @model.canEdit}}
<Identity::PopupPolicy @params={{array model policyName}} /> <Identity::PopupPolicy @params={{array @model policyName}} />
{{/if}} {{/if}}
</div> </div>
</div> </div>

View File

@ -21,7 +21,7 @@
<nav class="tabs sub-nav"> <nav class="tabs sub-nav">
<ul> <ul>
{{#each (tabs-for-identity-show model.identityType model.type) as |tab|}} {{#each (tabs-for-identity-show model.identityType model.type) as |tab|}}
<LinkTo @route="vault.cluster.access.identity.show" @models={{array (pluralize model.identityType) model.id tab}} @tagName="li"> <LinkTo @route="vault.cluster.access.identity.show" @models={{array (pluralize model.identityType) model.id tab}} @tagName="li" data-test-tab-subnav={{tab}}>
<LinkTo @route="vault.cluster.access.identity.show" @models={{array (pluralize model.identityType) model.id tab}}> <LinkTo @route="vault.cluster.access.identity.show" @models={{array (pluralize model.identityType) model.id tab}}>
{{capitalize (humanize tab)}} {{capitalize (humanize tab)}}
</LinkTo> </LinkTo>

View File

@ -1,4 +1,5 @@
import { settled, currentRouteName } from '@ember/test-helpers'; import { settled, currentRouteName, click, findAll } from '@ember/test-helpers';
import { selectChoose, clickTrigger } from 'ember-power-select/test-support/helpers';
import page from 'vault/tests/pages/access/identity/create'; import page from 'vault/tests/pages/access/identity/create';
import showPage from 'vault/tests/pages/access/identity/show'; import showPage from 'vault/tests/pages/access/identity/show';
import indexPage from 'vault/tests/pages/access/identity/index'; import indexPage from 'vault/tests/pages/access/identity/index';
@ -42,8 +43,17 @@ export const testCRUD = async (name, itemType, assert) => {
export const testDeleteFromForm = async (name, itemType, assert) => { export const testDeleteFromForm = async (name, itemType, assert) => {
await page.visit({ item_type: itemType }); await page.visit({ item_type: itemType });
await settled(); await settled();
await page.editForm.name(name).submit(); await page.editForm.name(name);
await settled(); await page.editForm.metadataKey('hello');
await page.editForm.metadataValue('goodbye');
await clickTrigger('#policies');
// first option should be "default"
await selectChoose('#policies', '.ember-power-select-option', 0);
await page.editForm.submit();
await click('[data-test-tab-subnav="policies"]');
assert.equal(findAll('.list-item-row').length, 1, 'One item is under policies');
await click('[data-test-tab-subnav="metadata"]');
assert.dom('.info-table-row').hasText('hello goodbye', 'Metadata shows on tab');
await showPage.edit(); await showPage.edit();
assert.equal( assert.equal(
currentRouteName(), currentRouteName(),

View File

@ -7,6 +7,8 @@ export default {
cancelLink: clickable('[data-test-cancel-link]'), cancelLink: clickable('[data-test-cancel-link]'),
name: fillable('[data-test-input="name"]'), name: fillable('[data-test-input="name"]'),
disabled: clickable('[data-test-input="disabled"]'), disabled: clickable('[data-test-input="disabled"]'),
metadataKey: fillable('[data-test-kv-key]'),
metadataValue: fillable('[data-test-kv-value]'),
type: fillable('[data-test-input="type"]'), type: fillable('[data-test-input="type"]'),
submit: clickable('[data-test-identity-submit]'), submit: clickable('[data-test-identity-submit]'),
delete: clickable('[data-test-confirm-action-trigger]'), delete: clickable('[data-test-confirm-action-trigger]'),