Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix - ui context menu #6018

Merged
merged 4 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ui/app/helpers/dot-to-dash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { helper as buildHelper } from '@ember/component/helper';

export function dotToDash([string]) {
return string.replace(/\./gi, '-');
}

export default buildHelper(dotToDash);
4 changes: 2 additions & 2 deletions ui/app/templates/components/identity/popup-alias.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
buttonClasses="link is-destroy"
onConfirmAction=(action "performTransaction" item)
confirmMessage=(concat "Are you sure you want to delete " item.id "?")
showConfirm=(get this (concat "shouldDelete-" item.id))
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
containerClasses="message-body is-block"
messageClasses="is-block"
}}
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/components/identity/popup-members.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
buttonClasses="link is-destroy"
onConfirmAction=(action "performTransaction" model groupArray memberId)
confirmMessage=(concat "Are you sure you want to remove " memberId "?")
showConfirm=(get this (concat "shouldDelete-" memberId))
class=(if (get this (concat "shouldDelete-" memberId)) "message is-block is-warning is-outline")
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash memberId)))
class=(if (get this (concat "shouldDelete-" (dot-to-dash memberId))) "message is-block is-warning is-outline")
containerClasses="message-body is-block"
messageClasses="is-block"
}}
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/components/identity/popup-policy.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
buttonClasses="link is-destroy"
onConfirmAction=(action "performTransaction" model policyName)
confirmMessage=(concat "Are you sure you want to remove " policyName "?")
showConfirm=(get this (concat "shouldDelete-" policyName))
class=(if (get this (concat "shouldDelete-" policyName)) "message is-block is-warning is-outline")
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash policyName)))
class=(if (get this (concat "shouldDelete-" (dot-to-dash policyName))) "message is-block is-warning is-outline")
containerClasses="message-body is-block"
messageClasses="is-block"
}}
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/components/pki-cert-popup.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
buttonClasses="link is-destroy"
onConfirmAction=(action "delete" item)
confirmMessage=(concat "Are you sure you want to revoke " item.id "?")
showConfirm=(get this (concat "shouldDelete-" item.id))
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
containerClasses="message-body is-block"
messageClasses="is-block"
confirmButtonText="Revoke"
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/partials/role-aws/popup-menu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
buttonClasses="link is-destroy"
onConfirmAction=(action "delete" item)
confirmMessage=(concat "Are you sure you want to delete " item.id "?")
showConfirm=(get this (concat "shouldDelete-" item.id))
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
containerClasses="message-body is-block"
messageClasses="is-block"
data-test-aws-role-delete=item.id
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/partials/role-pki/popup-menu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
buttonClasses="link is-destroy"
onConfirmAction=(action "delete" item)
confirmMessage=(concat "Are you sure you want to delete " item.id "?")
showConfirm=(get this (concat "shouldDelete-" item.id))
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
containerClasses="message-body is-block"
messageClasses="is-block"
data-test-aws-role-delete=item.id
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/partials/role-ssh/popup-menu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
buttonClasses="link is-destroy"
onConfirmAction=(action "delete" item)
confirmMessage=(concat "Are you sure you want to delete " item.id "?")
showConfirm=(get this (concat "shouldDelete-" item.id))
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
containerClasses="message-body is-block"
messageClasses="is-block"
data-test-ssh-role-delete=item.id
Expand Down
14 changes: 7 additions & 7 deletions ui/app/templates/partials/secret-list/item.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@mode={{if item.isFolder "list" "show" }}
@secret={{item.id}}
@class="has-text-black has-text-weight-semibold"
>
>
<ICon
@glyph={{if item.isFolder 'folder' 'file' }}
@size="14"
Expand All @@ -31,7 +31,7 @@
@mode="list"
@secret={{item.id}}
@class="has-text-black has-text-weight-semibold"
>
>
Contents
</SecretLink>
{{else}}
Expand All @@ -48,7 +48,7 @@
@mode="show"
@secret={{item.id}}
@class="has-text-black has-text-weight-semibold"
>
>
Details
</SecretLink>
</li>
Expand All @@ -58,7 +58,7 @@
@mode="versions"
@secret={{item.id}}
@class="has-text-black has-text-weight-semibold"
>
>
View version history
</SecretLink>
</li>
Expand All @@ -70,7 +70,7 @@
@mode="edit"
@secret={{item.id}}
@class="has-text-black has-text-weight-semibold"
>
>
{{if backendModel.isV2KV
"Create New Version"
"Edit"
Expand All @@ -85,8 +85,8 @@
buttonClasses="link is-destroy"
onConfirmAction=(action "delete" item "secret")
confirmMessage=(concat "Are you sure you want to permanently delete " item.id " and all its versions?")
showConfirm=(get this (concat "shouldDelete-" item.id))
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
containerClasses="message-body is-block"
messageClasses="is-block"
data-test-v2-kv-delete=item.id
Expand Down
8 changes: 4 additions & 4 deletions ui/app/templates/vault/cluster/access/identity/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
buttonClasses="link"
onConfirmAction=(action "toggleDisabled" item)
confirmMessage=(concat "Are you sure you want to disable " item.id "?")
showConfirm=(get this (concat "shouldDisable-" item.id))
class=(if (get this (concat "shouldDisable-" item.id)) "message is-block is-warning is-outline")
showConfirm=(get this (concat "shouldDisable-" (dot-to-dash item.id)))
class=(if (get this (concat "shouldDisable-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
containerClasses="message-body is-block"
messageClasses="is-block"
}}
Expand All @@ -89,8 +89,8 @@
buttonClasses="link"
onConfirmAction=(action "delete" item)
confirmMessage=(concat "Are you sure you want to delete " item.id "?")
showConfirm=(get this (concat "shouldDelete-" item.id))
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
containerClasses="message-body is-block"
messageClasses="is-block"
}}
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/vault/cluster/access/methods.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
buttonClasses="link is-destroy"
onConfirmAction=(perform disableMethod method)
confirmMessage=(concat "Are you sure you want to disable the " method.id " auth method at " method.path "?")
showConfirm=(get this (concat "shouldDelete-" method.id))
class=(if (get this (concat "shouldDelete-" method.id)) "message is-block is-warning is-outline")
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash method.id)))
class=(if (get this (concat "shouldDelete-" (dot-to-dash method.id))) "message is-block is-warning is-outline")
containerClasses="message-body is-block"
messageClasses="is-block"
confirmButtonText="Disable"
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/vault/cluster/access/namespaces/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
)
}}
@confirmMessage={{concat "Are you sure you want to delete " list.item.id "?"}}
@showConfirm={{get this (concat "shouldDelete-" list.item.id)}}
@class={{if (get this (concat "shouldDelete-" list.item.id)) "message is-block is-warning is-outline"}}
@showConfirm={{get this (concat "shouldDelete-" (dot-to-dash list.item.id))}}
@class={{if (get this (concat "shouldDelete-" (dot-to-dash list.item.id))) "message is-block is-warning is-outline"}}
@containerClasses="message-body is-block"
@messageClasses="is-block"
>
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/vault/cluster/policies/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
buttonClasses="link is-destroy"
onConfirmAction=(action "deletePolicy" item)
confirmMessage=(concat "Are you sure you want to delete " item.id "?")
showConfirm=(get this (concat "shouldDelete-" item.id))
class=(if (get this (concat "shouldDelete-" item.id)) "message is-block is-warning is-outline")
showConfirm=(get this (concat "shouldDelete-" (dot-to-dash item.id)))
class=(if (get this (concat "shouldDelete-" (dot-to-dash item.id))) "message is-block is-warning is-outline")
containerClasses="message-body is-block"
messageClasses="is-block"
data-test-policy-delete=item.id
Expand Down
8 changes: 4 additions & 4 deletions ui/app/templates/vault/cluster/secrets/backends.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
@buttonClasses="link is-destroy"
@onConfirmAction={{perform disableEngine backend}}
@confirmMessage={{concat "Are you sure you want to disable the " backend.engineType " secrets engine at " backend.path "?"}}
@showConfirm={{get this (concat "shouldDelete-" backend.id)}}
@class={{if (get this (concat "shouldDelete-" backend.id)) "message is-block is-warning is-outline"}}
@showConfirm={{get this (concat "shouldDelete-" (dot-to-dash backend.id))}}
@class={{if (get this (concat "shouldDelete-" (dot-to-dash backend.id))) "message is-block is-warning is-outline"}}
@containerClasses="message-body is-block"
@messageClasses="is-block"
@confirmButtonText="Disable"
Expand Down Expand Up @@ -128,8 +128,8 @@
@buttonClasses="link is-destroy"
@onConfirmAction={{perform disableEngine backend}}
@confirmMessage={{concat "Are you sure you want to disable the " backend.engineType " secrets engine at " backend.path "?"}}
@showConfirm={{get this (concat "shouldDelete-" backend.id)}}
@class={{if (get this (concat "shouldDelete-" backend.id)) "message is-block is-warning is-outline"}}
@showConfirm={{get this (concat "shouldDelete-" (dot-to-dash backend.id))}}
@class={{if (get this (concat "shouldDelete-" (dot-to-dash backend.id))) "message is-block is-warning is-outline"}}
@containerClasses="message-body is-block"
@messageClasses="is-block"
@confirmButtonText="Disable"
Expand Down
17 changes: 17 additions & 0 deletions ui/tests/acceptance/policies/index-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { currentURL, currentRouteName } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { create } from 'ember-cli-page-object';

import page from 'vault/tests/pages/policies/index';
import authPage from 'vault/tests/pages/auth';
import consoleClass from 'vault/tests/pages/components/console/ui-panel';

const consoleComponent = create(consoleClass);

module('Acceptance | policies/acl', function(hooks) {
setupApplicationTest(hooks);
Expand All @@ -24,4 +29,16 @@ module('Acceptance | policies/acl', function(hooks) {
assert.equal(currentRouteName(), 'vault.cluster.policy.show');
assert.equal(currentURL(), '/vault/policy/acl/default');
});

test('it allows deletion of policies with dots in names', async function(assert) {
const POLICY = 'path "*" { capabilities = ["list"]}';
let policyName = 'list.policy';
await consoleComponent.runCommands([`write sys/policies/acl/${policyName} policy='${POLICY}'`]);
await page.visit({ type: 'acl' });
let policy = page.row.filterBy('name', policyName)[0];
assert.ok(policy, 'policy is shown in the list');
await policy.menu();
await page.delete().confirmDelete();
assert.notOk(page.findPolicyByName(policyName), 'policy is deleted successfully');
});
});
12 changes: 11 additions & 1 deletion ui/tests/pages/policies/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { text, create, collection, visitable } from 'ember-cli-page-object';
import { text, create, collection, clickable, visitable } from 'ember-cli-page-object';
export default create({
visit: visitable('/vault/policies/:type'),
policies: collection('[data-test-policy-item]', {
name: text('[data-test-policy-name]'),
}),
row: collection('[data-test-policy-link]', {
name: text(),
menu: clickable('[data-test-popup-menu-trigger]'),
}),
findPolicyByName(name) {
return this.policies.filterBy('name', name)[0];
},
delete: clickable('[data-test-confirm-action-trigger]', {
testContainer: '#ember-testing',
}),
confirmDelete: clickable('[data-test-confirm-button]', {
testContainer: '#ember-testing',
}),
});
22 changes: 22 additions & 0 deletions ui/tests/unit/helpers/dot-to-dash-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { dotToDash } from 'vault/helpers/dot-to-dash';
import { module, test } from 'qunit';

module('Unit | Helpers | dot-to-dash', function() {
test('it returns a string unchanged if there are not .s', function(assert) {
let string = 'foo';
let result = dotToDash([string]);
assert.equal(string, result);
});

test('it replaces a single . with -', function(assert) {
let string = 'foo.bar';
let result = dotToDash([string]);
assert.equal(result, 'foo-bar');
});

test('it replaces multiple . with -', function(assert) {
let string = 'foo.bar.baz';
let result = dotToDash([string]);
assert.equal(result, 'foo-bar-baz');
});
});