Page MenuHomePhorge

D1954.1775225995.diff
No OneTemporary

Authored By
Unknown
Size
15 KB
Referenced Files
None
Subscribers
None

D1954.1775225995.diff

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 @@
<div class="card" id="user-info">
<div class="card-body">
- <div class="card-title" v-if="user_id !== 'new'">User account</div>
+ <div class="card-title" v-if="user_id !== 'new'">User account
+ <button
+ class="btn btn-outline-danger button-delete float-right"
+ v-on:click="showDeleteConfirmation()" tag="button"
+ >
+ <svg-icon icon="trash-alt"></svg-icon> Delete user
+ </button>
+ </div>
<div class="card-title" v-if="user_id === 'new'">New user account</div>
<div class="card-text">
<form @submit.prevent="submit">
@@ -155,6 +162,29 @@
</div>
</div>
</div>
+ <div id="delete-warning" class="modal" tabindex="-1" role="dialog">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h5 class="modal-title"></h5>
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <p>Do you really want to delete this user permanently?
+ This will delete all account data and withdraw the permission to access the email account.
+ Please note that this action cannot be undone.</p>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-secondary modal-cancel" data-dismiss="modal">Cancel</button>
+ <button type="button" class="btn btn-danger modal-action" @click="deleteUser()">
+ <svg-icon icon="trash-alt"></svg-icon> Delete
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
</div>
</template>
@@ -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 @@
<div class="card-body">
<div class="card-title">
User Accounts
- <router-link class="btn btn-primary float-right create-user" :to="{ path: 'user/new' }" tag="button">
+ <router-link class="btn btn-success float-right create-user" :to="{ path: 'user/new' }" tag="button">
<svg-icon icon="user"></svg-icon> Create user
</router-link>
</div>
@@ -13,7 +13,6 @@
<thead class="thead-light">
<tr>
<th scope="col">Primary Email</th>
- <th scope="col"></th>
</tr>
</thead>
<tbody>
@@ -22,50 +21,17 @@
<svg-icon icon="user" :class="$root.userStatusClass(user)" :title="$root.userStatusText(user)"></svg-icon>
<router-link :to="{ path: 'user/' + user.id }">{{ user.email }}</router-link>
</td>
- <td class="buttons">
- <button v-if="$root.isController(user.wallet_id)"
- title="Delete"
- class="btn btn-link text-danger button-delete p-0"
- @click="deleteUser(user.id)"
- >
- <svg-icon icon="trash-alt"></svg-icon><span class="sr-only">Delete</span>
- </button>
- </td>
</tr>
</tbody>
<tfoot class="table-fake-body">
<tr>
- <td colspan="2">There are no users in this account.</td>
+ <td>There are no users in this account.</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
-
- <div id="delete-warning" class="modal" tabindex="-1" role="dialog">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title"></h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">&times;</span>
- </button>
- </div>
- <div class="modal-body">
- <p>Do you really want to delete this user permanently?
- This will delete all account data and withdraw the permission to access the email account.
- Please note that this action cannot be undone.</p>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary modal-cancel" data-dismiss="modal">Cancel</button>
- <button type="button" class="btn btn-danger modal-action" @click="deleteUser()">
- <svg-icon icon="trash-alt"></svg-icon> Delete
- </button>
- </div>
- </div>
- </div>
- </div>
</div>
</template>
@@ -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]
- }
- }
- }
}
}
</script>
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 @@
<div class="container">
<div class="card" id="user-profile">
<div class="card-body">
- <div class="card-title">Your profile</div>
+ <div class="card-title">
+ Your profile
+ <router-link
+ v-if="$root.isController(wallet_id)"
+ class="btn btn-outline-danger button-delete float-right"
+ to="/profile/delete" tag="button"
+ >
+ <svg-icon icon="trash-alt"></svg-icon> Delete account
+ </router-link>
+ </div>
<div class="card-text">
<form @submit.prevent="submit">
<div class="form-group row plaintext">
@@ -69,11 +78,6 @@
</div>
</div>
<button class="btn btn-primary button-submit" type="submit"><svg-icon icon="check"></svg-icon> Submit</button>
- <router-link
- v-if="$root.isController(wallet_id)"
- class="btn btn-danger button-delete"
- to="/profile/delete" tag="button"
- ><svg-icon icon="trash-alt"></svg-icon> Delete account</router-link>
</form>
</div>
</div>
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

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 3, 2:19 PM (15 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18824292
Default Alt Text
D1954.1775225995.diff (15 KB)

Event Timeline