Member Index View Actions: "Assign Role" (#17866)
* Adds the Assign Role modal to the Member Index View * Adds e2e tests for the Assign role modal * WIP: Conditionally redirects to the correct view upon assigning a role * Conditionally renders the redirect in the correct method :| * Adjusts the conditional redirect to account for ID * Adds an even more explicit check for the correct refferer
This commit is contained in:
parent
27c6f07686
commit
8e4b6581e2
5 changed files with 94 additions and 2 deletions
|
|
@ -103,7 +103,12 @@ module Admin
|
|||
rescue StandardError => e
|
||||
flash[:danger] = e.message
|
||||
end
|
||||
redirect_to admin_user_path(params[:id])
|
||||
|
||||
if request.referer&.include?(admin_user_path(params[:id]))
|
||||
redirect_to admin_user_path(params[:id])
|
||||
else
|
||||
redirect_to admin_users_path
|
||||
end
|
||||
end
|
||||
|
||||
def export_data
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { showUserModal } from './editUserModals';
|
||||
import { openDropdown, closeDropdown } from '@utilities/dropdownUtils';
|
||||
import { copyToClipboard } from '@utilities/runtime';
|
||||
import { showWindowModal, closeWindowModal } from '@utilities/showModal';
|
||||
|
|
@ -123,3 +124,5 @@ document.querySelectorAll('.js-export-csv-modal-trigger').forEach((item) => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
document.body.addEventListener('click', showUserModal);
|
||||
|
|
|
|||
|
|
@ -133,4 +133,5 @@
|
|||
</div>
|
||||
<% if FeatureFlag.enabled?(:member_index_view) %>
|
||||
<%= render "admin/users/index/filters_modal" %>
|
||||
<%= render "admin/users/modals/add_role_modal" %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,16 @@
|
|||
<div id="<%= id %>-action-dropdown" class="crayons-dropdown right-0">
|
||||
<ul class="list-none">
|
||||
<% if FeatureFlag.enabled?(:member_index_view) %>
|
||||
<li><button class="c-btn align-left w-100 c-btn--icon-left"><%= crayons_icon_tag("badge", aria_hidden: true, class: "c-btn__icon") %>Assign role</button></li>
|
||||
<li>
|
||||
<button class="c-btn align-left w-100 c-btn--icon-left"
|
||||
data-modal-title="Add role"
|
||||
data-modal-size="small"
|
||||
data-modal-content-selector="#add-role-modal"
|
||||
data-form-action="<%= user_status_admin_user_path(user) %>">
|
||||
<%= crayons_icon_tag("badge", aria_hidden: true, class: "c-btn__icon") %>
|
||||
Assign role
|
||||
</button>
|
||||
</li>
|
||||
<li><button class="c-btn align-left w-100 c-btn--icon-left"><%= crayons_icon_tag("team", aria_hidden: true, class: "c-btn__icon") %>Add organization</button></li>
|
||||
<li><button class="c-btn align-left w-100 c-btn--icon-left"><%= crayons_icon_tag("wallet", aria_hidden: true, class: "c-btn__icon") %>Adjust credit balance</button><hr /></li>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -340,4 +340,78 @@ describe('User index view', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('User index view with the member_index_view feature flag enabled', () => {
|
||||
describe('small screens', () => {
|
||||
beforeEach(() => {
|
||||
cy.testSetup();
|
||||
cy.fixture('users/adminUser.json').as('user');
|
||||
cy.enableFeatureFlag('member_index_view')
|
||||
.then(() => cy.get('@user'))
|
||||
.then((user) =>
|
||||
cy.loginAndVisit(user, '/admin/member_manager/users'),
|
||||
);
|
||||
cy.viewport('iphone-x');
|
||||
});
|
||||
|
||||
describe('User actions', () => {
|
||||
it('Opens the assign role modal', () => {
|
||||
cy.enableFeatureFlag('member_index_view');
|
||||
// Helper function for cypress-pipe
|
||||
const click = (el) => el.click();
|
||||
|
||||
cy.findByRole('button', { name: 'User actions: Admin McAdmin' })
|
||||
.as('userActionsButton')
|
||||
.pipe(click)
|
||||
.should('have.attr', 'aria-expanded', 'true');
|
||||
|
||||
cy.findByRole('button', { name: 'Assign role' }).click();
|
||||
|
||||
cy.getModal().within(() => {
|
||||
cy.findByText('Add role').should('be.visible');
|
||||
cy.findByText('Add a note to this action:').should('be.visible');
|
||||
cy.findByRole('button', {
|
||||
name: 'Add',
|
||||
}).should('exist');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('large screens', () => {
|
||||
beforeEach(() => {
|
||||
cy.testSetup();
|
||||
cy.fixture('users/adminUser.json').as('user');
|
||||
cy.enableFeatureFlag('member_index_view')
|
||||
.then(() => cy.get('@user'))
|
||||
.then((user) =>
|
||||
cy.loginAndVisit(user, '/admin/member_manager/users'),
|
||||
);
|
||||
cy.viewport('macbook-16');
|
||||
});
|
||||
|
||||
describe('User actions', () => {
|
||||
it('Opens the assign role modal', () => {
|
||||
cy.enableFeatureFlag('member_index_view');
|
||||
// Helper function for cypress-pipe
|
||||
const click = (el) => el.click();
|
||||
|
||||
cy.findByRole('button', { name: 'User actions: Admin McAdmin' })
|
||||
.as('userActionsButton')
|
||||
.pipe(click)
|
||||
.should('have.attr', 'aria-expanded', 'true');
|
||||
|
||||
cy.findByRole('button', { name: 'Assign role' }).click();
|
||||
|
||||
cy.getModal().within(() => {
|
||||
cy.findByText('Add role').should('be.visible');
|
||||
cy.findByText('Add a note to this action:').should('be.visible');
|
||||
cy.findByRole('button', {
|
||||
name: 'Add',
|
||||
}).should('exist');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue