diff --git a/src/resources/themes/default/_variables.scss b/src/resources/themes/default/_variables.scss --- a/src/resources/themes/default/_variables.scss +++ b/src/resources/themes/default/_variables.scss @@ -15,3 +15,6 @@ $menu-gray: #575656; $main-color: $orange; $warning: $orange; + +$table-hover-bg: $menu-bg-color; +$table-head-bg: $menu-bg-color; \ No newline at end of file diff --git a/src/resources/vue/User/Info.vue b/src/resources/vue/User/Info.vue --- a/src/resources/vue/User/Info.vue +++ b/src/resources/vue/User/Info.vue @@ -4,7 +4,14 @@
-
User account
+
User account + +
New user account
@@ -155,6 +162,29 @@
+ @@ -367,6 +397,29 @@ }, statusUpdate(user) { this.user = Object.assign({}, this.user, user) + }, + deleteUser() { + // Delete the user from the confirm dialog + axios.delete('/api/v4/users/' + this.user_id) + .then(response => { + if (response.data.status == 'success') { + this.$toast.success(response.data.message) + this.$router.push({ name: 'users' }) + } + }) + }, + showDeleteConfirmation() { + // Deleting self, redirect to /profile/delete page + if (this.user_id == this.$store.state.authInfo.id) { + this.$router.push({ name: 'profile-delete' }) + } else { + // Display the warning + let dialog = $('#delete-warning') + dialog.find('.modal-title').text('Delete ' + this.user.email) + dialog.on('shown.bs.modal', () => { + dialog.find('button.modal-cancel').focus() + }).modal() + } } } } diff --git a/src/resources/vue/User/List.vue b/src/resources/vue/User/List.vue --- a/src/resources/vue/User/List.vue +++ b/src/resources/vue/User/List.vue @@ -4,7 +4,7 @@
User Accounts - + Create user
@@ -13,7 +13,6 @@ Primary Email - @@ -22,50 +21,17 @@ {{ user.email }} - - - - There are no users in this account. + There are no users in this account.
- - @@ -86,46 +52,6 @@ this.users = response.data }) .catch(this.$root.errorHandler) - }, - methods: { - deleteUser(id) { - let dialog = $('#delete-warning').modal('hide') - - // Delete the user from the confirm dialog - if (!id && this.current_user) { - id = this.current_user.id - axios.delete('/api/v4/users/' + id) - .then(response => { - if (response.data.status == 'success') { - this.$toast.success(response.data.message) - $('#user' + id).remove() - } - }) - - return - } - - // Deleting self, redirect to /profile/delete page - if (id == this.$store.state.authInfo.id) { - this.$router.push({ name: 'profile-delete' }) - return - } - - // Display the warning - if (this.current_user = this.getUser(id)) { - dialog.find('.modal-title').text('Delete ' + this.current_user.email) - dialog.on('shown.bs.modal', () => { - dialog.find('button.modal-cancel').focus() - }).modal() - } - }, - getUser(id) { - for (let i = 0; i < this.users.length; i++) { - if (this.users[i].id == id) { - return this.users[i] - } - } - } } } diff --git a/src/resources/vue/User/Profile.vue b/src/resources/vue/User/Profile.vue --- a/src/resources/vue/User/Profile.vue +++ b/src/resources/vue/User/Profile.vue @@ -2,7 +2,16 @@
-
Your profile
+
+ Your profile + + Delete account + +
@@ -69,11 +78,6 @@
- Delete account
diff --git a/src/tests/Browser/UsersTest.php b/src/tests/Browser/UsersTest.php --- a/src/tests/Browser/UsersTest.php +++ b/src/tests/Browser/UsersTest.php @@ -119,10 +119,6 @@ ->assertSeeIn('tbody tr:nth-child(2) a', 'joe@kolab.org') ->assertSeeIn('tbody tr:nth-child(3) a', 'john@kolab.org') ->assertSeeIn('tbody tr:nth-child(4) a', 'ned@kolab.org') - ->assertVisible('tbody tr:nth-child(1) button.button-delete') - ->assertVisible('tbody tr:nth-child(2) button.button-delete') - ->assertVisible('tbody tr:nth-child(3) button.button-delete') - ->assertVisible('tbody tr:nth-child(4) button.button-delete') ->assertMissing('tfoot'); }); }); @@ -473,13 +469,11 @@ $john->assignPackage($package_kolab, $julia); // Test deleting non-controller user - $this->browse(function (Browser $browser) { - $browser->visit(new UserList()) - ->whenAvailable('@table', function (Browser $browser) { - $browser->assertElementsCount('tbody tr', 5) - ->assertSeeIn('tbody tr:nth-child(4) a', 'julia.roberts@kolab.org') - ->click('tbody tr:nth-child(4) button.button-delete'); - }) + $this->browse(function (Browser $browser) use ($julia) { + $browser->visit('/user/' . $julia->id) + ->on(new UserInfo()) + ->assertSeeIn('button.button-delete', 'Delete user') + ->click('button.button-delete') ->with(new Dialog('#delete-warning'), function (Browser $browser) { $browser->assertSeeIn('@title', 'Delete julia.roberts@kolab.org') ->assertFocused('@button-cancel') @@ -487,13 +481,14 @@ ->assertSeeIn('@button-action', 'Delete') ->click('@button-cancel'); }) - ->whenAvailable('@table', function (Browser $browser) { - $browser->click('tbody tr:nth-child(4) button.button-delete'); - }) + ->waitUntilMissing('#delete-warning') + ->click('button.button-delete') ->with(new Dialog('#delete-warning'), function (Browser $browser) { $browser->click('@button-action'); }) + ->waitUntilMissing('#delete-warning') ->assertToast(Toast::TYPE_SUCCESS, 'User deleted successfully.') + ->on(new UserList()) ->with('@table', function (Browser $browser) { $browser->assertElementsCount('tbody tr', 4) ->assertSeeIn('tbody tr:nth-child(1) a', 'jack@kolab.org') @@ -504,17 +499,9 @@ $julia = User::where('email', 'julia.roberts@kolab.org')->first(); $this->assertTrue(empty($julia)); - - // Test clicking Delete on the controller record redirects to /profile/delete - $browser - ->with('@table', function (Browser $browser) { - $browser->click('tbody tr:nth-child(3) button.button-delete'); - }) - ->waitForLocation('/profile/delete'); }); // Test that non-controller user cannot see/delete himself on the users list - // Note: Access to /profile/delete page is tested in UserProfileTest.php $this->browse(function (Browser $browser) { $browser->visit('/logout') ->on(new Home()) @@ -526,15 +513,14 @@ }); }); - // Test that controller user (Ned) can see/delete all the users ??? + // Test that controller user (Ned) can see all the users $this->browse(function (Browser $browser) { $browser->visit('/logout') ->on(new Home()) ->submitLogon('ned@kolab.org', 'simple123', true) ->visit(new UserList()) ->whenAvailable('@table', function (Browser $browser) { - $browser->assertElementsCount('tbody tr', 4) - ->assertElementsCount('tbody button.button-delete', 4); + $browser->assertElementsCount('tbody tr', 4); }); // TODO: Test the delete action in details