ICU-14870 Update Manage Dropdown for Projects form (#2457)
* refactor: 💡 HDS Manage Dropdown for Projects ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-14870 * refactor: 💡 Fixing up tests ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-14870 * refactor: 💡 Updated naming convention and consolidated ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-14870
This commit is contained in:
3 files changed
+33
-30
No files matched your search
@@ -56,23 +56,20 @@
|
||||
|
||||
{{#if (and (can 'delete model' @model) (not @model.isGlobal))}}
|
||||
<page.actions>
|
||||
<Rose::Dropdown
|
||||
@text={{t 'actions.manage'}}
|
||||
@dropdownRight={{true}}
|
||||
as |dropdown|
|
||||
>
|
||||
<dropdown.button
|
||||
@style='danger'
|
||||
@disabled={{@model.canSave}}
|
||||
<Hds::Dropdown data-test-manage-projects-dropdown as |dd|>
|
||||
<dd.ToggleButton @text={{t 'actions.manage'}} @color='secondary' />
|
||||
<dd.Interactive
|
||||
@color='critical'
|
||||
@text={{t
|
||||
(if
|
||||
@model.isOrg
|
||||
'resources.org.actions.delete'
|
||||
'resources.project.actions.delete'
|
||||
)
|
||||
}}
|
||||
{{on 'click' (fn this.scopes.delete @model)}}
|
||||
>
|
||||
{{#if @model.isOrg}}
|
||||
{{t 'resources.org.actions.delete'}}
|
||||
{{else}}
|
||||
{{t 'resources.project.actions.delete'}}
|
||||
{{/if}}
|
||||
</dropdown.button>
|
||||
</Rose::Dropdown>
|
||||
/>
|
||||
</Hds::Dropdown>
|
||||
</page.actions>
|
||||
{{/if}}
|
||||
|
||||
|
||||
@@ -22,6 +22,10 @@ module('Acceptance | scopes | delete', function (hooks) {
|
||||
setupIndexedDb(hooks);
|
||||
|
||||
let getScopeCount;
|
||||
const MANAGE_DROPDOWN_SELECTOR =
|
||||
'[data-test-manage-projects-dropdown] div:first-child button';
|
||||
const DELETE_ACTION_SELECTOR =
|
||||
'[data-test-manage-projects-dropdown] ul li button';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
@@ -64,7 +68,8 @@ module('Acceptance | scopes | delete', function (hooks) {
|
||||
await visit(urls.orgScope);
|
||||
|
||||
await click(`[href="${urls.orgScopeEdit}"]`);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
|
||||
assert.strictEqual(getScopeCount('org'), orgScopeCount - 1);
|
||||
});
|
||||
@@ -80,9 +85,7 @@ module('Acceptance | scopes | delete', function (hooks) {
|
||||
await click(`[href="${urls.orgScopeEdit}"]`);
|
||||
|
||||
assert.false(instances.scopes.org.authorized_actions.includes('delete'));
|
||||
assert
|
||||
.dom('.rose-layout-page-actions .rose-dropdown-button-danger')
|
||||
.doesNotExist();
|
||||
assert.dom(MANAGE_DROPDOWN_SELECTOR).doesNotExist();
|
||||
});
|
||||
|
||||
test('can accept delete scope via dialog', async function (assert) {
|
||||
@@ -92,7 +95,8 @@ module('Acceptance | scopes | delete', function (hooks) {
|
||||
await visit(urls.orgScope);
|
||||
|
||||
await click(`[href="${urls.orgScopeEdit}"]`);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
await click('.rose-dialog .rose-button-primary');
|
||||
|
||||
assert.strictEqual(getScopeCount('org'), orgScopeCount - 1);
|
||||
@@ -106,7 +110,8 @@ module('Acceptance | scopes | delete', function (hooks) {
|
||||
await visit(urls.orgScope);
|
||||
|
||||
await click(`[href="${urls.orgScopeEdit}"]`);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
await click('.rose-dialog .rose-button-secondary');
|
||||
|
||||
assert.strictEqual(getScopeCount('org'), orgScopeCount);
|
||||
@@ -128,7 +133,8 @@ module('Acceptance | scopes | delete', function (hooks) {
|
||||
});
|
||||
|
||||
await click(`[href="${urls.orgScopeEdit}"]`);
|
||||
await click('.rose-layout-page-actions .rose-dropdown-button-danger');
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
|
||||
assert.dom('.rose-notification-body').hasText('Oops.');
|
||||
});
|
||||
|
||||
@@ -25,9 +25,10 @@ module('Acceptance | scopes | read', function (hooks) {
|
||||
let featureEdition;
|
||||
|
||||
const FORM_SELECTOR = 'main .rose-form';
|
||||
const FORM_ACTIONS_SELECTOR = '.rose-form-actions';
|
||||
const DELETE_DROPDOWN_SELECTOR =
|
||||
'.rose-layout-page-actions .rose-dropdown-button-danger';
|
||||
const MANAGE_DROPDOWN_SELECTOR =
|
||||
'[data-test-manage-projects-dropdown] div:first-child button';
|
||||
const DELETE_ACTION_SELECTOR =
|
||||
'[data-test-manage-projects-dropdown] ul li button';
|
||||
const STORAGE_POLICY_SIDEBAR = '.policy-sidebar';
|
||||
|
||||
const instances = {
|
||||
@@ -69,8 +70,7 @@ module('Acceptance | scopes | read', function (hooks) {
|
||||
|
||||
assert.strictEqual(currentURL(), urls.orgScopeEdit);
|
||||
assert.dom(FORM_SELECTOR).exists();
|
||||
assert.dom(FORM_ACTIONS_SELECTOR).exists();
|
||||
assert.dom(DELETE_DROPDOWN_SELECTOR).exists();
|
||||
assert.dom(MANAGE_DROPDOWN_SELECTOR).exists();
|
||||
});
|
||||
|
||||
test('visiting global scope settings when feature flag is enabled', async function (assert) {
|
||||
@@ -83,8 +83,8 @@ module('Acceptance | scopes | read', function (hooks) {
|
||||
|
||||
assert.strictEqual(currentURL(), urls.globalScopeEdit);
|
||||
assert.dom(FORM_SELECTOR).exists();
|
||||
assert.dom(FORM_ACTIONS_SELECTOR).doesNotExist();
|
||||
assert.dom(DELETE_DROPDOWN_SELECTOR).doesNotExist();
|
||||
assert.dom(MANAGE_DROPDOWN_SELECTOR).doesNotExist();
|
||||
assert.dom(DELETE_ACTION_SELECTOR).doesNotExist();
|
||||
});
|
||||
|
||||
test('user cannot visit global scope settings when feature flag is not enabled', async function (assert) {
|
||||
|
||||
Reference in new issue
Block a user