Skip to content

Commit

Permalink
Merge pull request #9966 from nextcloud/resend-welcome-email
Browse files Browse the repository at this point in the history
Resend activation email for new users as admin
  • Loading branch information
MorrisJobke authored Jun 26, 2018
2 parents f569891 + d3d357f commit a97cc29
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 21 deletions.
37 changes: 26 additions & 11 deletions settings/css/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,8 @@ doesnotexist:-o-prefocus, .strengthify-wrapper {
&.disabled {
opacity: .5;
}

/* grid col width */
.name,
.displayName,
.password {
Expand All @@ -1407,14 +1409,15 @@ doesnotexist:-o-prefocus, .strengthify-wrapper {
width: 250px;
}
.userBackend,
.lastLogin,
.userActions {
.lastLogin {
width: 100px;
}
.obfuscated {
width: 400px;
opacity: .7;
}

/* various */
&#grid-header,
&#new-user {
position: sticky;
Expand Down Expand Up @@ -1521,15 +1524,27 @@ doesnotexist:-o-prefocus, .strengthify-wrapper {
display: block;
}
}
.toggleUserActions {
position: relative;
.icon-more {
width: 44px;
height: 44px;
opacity: .5;
cursor: pointer;
:hover {
opacity: .7;
&.userActions {
.toggleUserActions {
position: relative;
.icon-more {
width: 44px;
height: 44px;
opacity: .5;
cursor: pointer;
&:hover {
opacity: .7;
}
}
}
.feedback {
display: flex;
align-items: center;
white-space: nowrap;
transition: opacity 200ms ease-in-out;
.icon-checkmark {
opacity: .5;
margin-right: 5px;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions settings/js/settings-vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion settings/js/settings-vue.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion settings/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion settings/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "settings",
"description": "Nextcloud settings",
"version": "1.1.1",
"version": "1.2.0",
"author": "John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>",
"license": "AGPL3",
"private": true,
Expand Down
37 changes: 34 additions & 3 deletions settings/src/components/userList/userRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@
<popover-menu :menu="userActions" />
</div>
</div>
<div class="feedback" :style="{opacity: feedbackMessage !== '' ? 1 : 0}">
<div class="icon-checkmark"></div>
{{feedbackMessage}}
</div>
</div>
</div>
</template>
Expand Down Expand Up @@ -146,6 +150,7 @@ export default {
return {
rand: parseInt(Math.random() * 1000),
openedMenu: false,
feedbackMessage: '',
loading: {
all: false,
displayName: false,
Expand All @@ -163,15 +168,23 @@ export default {
computed: {
/* USER POPOVERMENU ACTIONS */
userActions() {
return [{
let actions = [{
icon: 'icon-delete',
text: t('settings','Delete user'),
action: this.deleteUser
},{
icon: this.user.enabled ? 'icon-close' : 'icon-add',
text: this.user.enabled ? t('settings','Disable user') : t('settings','Enable user'),
action: this.enableDisableUser
}]
}];
if (this.user.email !== null && this.user.email !== '') {
actions.push({
icon: 'icon-mail',
text: t('settings','Resend welcome email'),
action: this.sendWelcomeMail
})
}
return actions;
},

/* GROUPS MANAGEMENT */
Expand Down Expand Up @@ -289,7 +302,7 @@ export default {
this.loading.delete = true;
this.loading.all = true;
let userid = this.user.id;
return this.$store.dispatch('deleteUser', {userid})
return this.$store.dispatch('deleteUser', userid)
.then(() => {
this.loading.delete = false
this.loading.all = false
Expand Down Expand Up @@ -506,6 +519,24 @@ export default {
value: lang.code
}).then(() => this.loading.languages = false);
return lang;
},

/**
* Dispatch new welcome mail request
*/
sendWelcomeMail() {
this.loading.all = true;
this.$store.dispatch('sendWelcomeMail', this.user.id)
.then(success => {
if (success) {
// Show feedback to indicate the success
this.feedbackMessage = t('setting', 'Welcome mail sent!');
setTimeout(() => {
this.feedbackMessage = '';
}, 2000);
}
this.loading.all = false;
});
}
}
}
Expand Down
19 changes: 17 additions & 2 deletions settings/src/store/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const defaults = {
usercount: 0,
disabled: 0
}
}
};

const state = {
users: [],
Expand Down Expand Up @@ -395,7 +395,7 @@ const actions = {
* @param {string} userid User id
* @returns {Promise}
*/
deleteUser(context, { userid }) {
deleteUser(context, userid) {
return api.requireAdmin().then((response) => {
return api.delete(OC.linkToOCS(`cloud/users/${userid}`, 2))
.then((response) => context.commit('deleteUser', userid))
Expand Down Expand Up @@ -484,6 +484,21 @@ const actions = {
}
}
return Promise.reject(new Error('Invalid request data'));
},

/**
* Send welcome mail
*
* @param {Object} context
* @param {string} userid User id
* @returns {Promise}
*/
sendWelcomeMail(context, userid) {
return api.requireAdmin().then((response) => {
return api.post(OC.linkToOCS(`cloud/users/${userid}/welcome`, 2))
.then(response => true)
.catch((error) => {throw error;});
}).catch((error) => context.commit('API_FAILURE', { userid, error }));
}
};

Expand Down

0 comments on commit a97cc29

Please sign in to comment.