From ef5132861b3f85f956f6a6e26475fb407df7541a Mon Sep 17 00:00:00 2001 From: bergice Date: Wed, 7 Nov 2018 11:07:00 +1300 Subject: [PATCH] Fix discard confirmation for buttons Fix tests and add check for discard confirmation --- client/src/components/Toolbar/Toolbar.scss | 8 +++++--- client/src/legacy/LeftAndMain.js | 10 +++++++++- tests/behat/features/manage-users.feature | 22 ++++++++++++++++------ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/client/src/components/Toolbar/Toolbar.scss b/client/src/components/Toolbar/Toolbar.scss index 7d9a2e22b..174cbbc3c 100644 --- a/client/src/components/Toolbar/Toolbar.scss +++ b/client/src/components/Toolbar/Toolbar.scss @@ -25,11 +25,12 @@ .rounded { - &.btn, >.btn { + &.btn, + >.btn { width: 32px; padding-left: 7px; - &:last-child{ + &:last-child { border-top-right-radius: 100px !important; border-bottom-right-radius: 100px !important; } @@ -43,7 +44,8 @@ border-radius: 100px !important; - &::before, .btn::before { + &::before, + .btn::before { margin-right: 0; } } diff --git a/client/src/legacy/LeftAndMain.js b/client/src/legacy/LeftAndMain.js index 16b6312d0..2aea5cbfa 100644 --- a/client/src/legacy/LeftAndMain.js +++ b/client/src/legacy/LeftAndMain.js @@ -1069,7 +1069,7 @@ $.entwine('ss', function($) { * "opt in" to panel loading, while by default links still exhibit their default behaviour. * The PJAX target can be specified via a 'data-pjax-target' attribute. */ - $('.cms .cms-panel-link').entwine({ + $('.cms a.cms-panel-link').entwine({ onclick: function(e) { if($(this).hasClass('external-link')) { e.stopPropagation(); @@ -1086,6 +1086,14 @@ $.entwine('ss', function($) { } }); + $('.cms button.cms-panel-link').entwine({ + onclick: function(e) { + if (!$('.cms-container').checkCanNavigate()) { + e.preventDefault(); + } + } + }); + /** * Does an ajax loads of the link's 'href' attribute via ajax and displays any FormResponse messages from the CMS. * Little helper to avoid repetition, and make it easy to trigger actions via a link, diff --git a/tests/behat/features/manage-users.feature b/tests/behat/features/manage-users.feature index 81dbaaa4a..4e3e2c776 100644 --- a/tests/behat/features/manage-users.feature +++ b/tests/behat/features/manage-users.feature @@ -8,6 +8,7 @@ Feature: Manage users Given a "member" "ADMIN" belonging to "ADMIN group" with "Email"="admin@example.org" And the "member" "ADMIN" belonging to "ADMIN group2" And a "member" "Staff" belonging to "Staff group" with "Email"="staffmember@example.org" + And a "member" "Other Staff" belonging to "Staff group" with "Email"="otherstaffmember@example.org" And the "group" "ADMIN group" has permissions "Full administrative rights" And the "group" "ADMIN group2" has permissions "Full administrative rights" And I am logged in with "ADMIN" permissions @@ -79,7 +80,7 @@ Feature: Manage users When I click the "Users" CMS tab And I press the "Add Member" button And I fill in the following: - | First Name | Other Staff | + | First Name | John | | Surname | Doe | | Email | john.doe@example.org | And I press the "Create" button @@ -88,20 +89,29 @@ Feature: Manage users When I go to "admin/security/" Then I should see "john.doe@example.org" in the "#Root_Users" element + @modal Scenario: I can navigate users from the edit form and retain my search query When I press the "Open search and filter" button And I press the "Advanced" button And I fill in "Search__FirstName" with "Staff" And I press the "Search" button Then I should see "staffmember@example.org" in the "#Root_Users" element - And I should see "john.doe@example.org" in the "#Root_Users" element + And I should see "otherstaffmember@example.org" in the "#Root_Users" element But I should not see "admin@example.org" in the "#Root_Users" element - When I click "john.doe@example.org" in the "#Root_Users" element - And I press the "Next" button + When I click "otherstaffmember@example.org" in the "#Root_Users" element + And I press the "Form_ItemEditForm_action_doNext" button Then the "Email" field should contain "staffmember@example.org" - When I press the "Previous" button - Then the "Email" field should contain "john.doe@example.org" + When I press the "Form_ItemEditForm_action_doPrevious" button + Then the "Email" field should contain "otherstaffmember@example.org" + + When I fill in "FirstName" with "Staff Renamed" + And I press the "Form_ItemEditForm_action_doNew" button + Then I see the text "Are you sure you want to navigate away from this page?" in the alert + And I dismiss the dialog + + When I go to "admin/security/" + Then I confirm the dialog Scenario: I can edit an existing user and add him to an existing group When I go to "admin/security/"