Merge pull request #10592 from nextcloud/allow-external-actions-userslist

Allow external actions to users list
This commit is contained in:
Roeland Jago Douma 2018-08-13 15:39:22 +02:00 committed by GitHub
commit 7ba57233bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -119,7 +119,8 @@
</form> </form>
<user-row v-for="(user, key) in filteredUsers" :user="user" :key="key" :settings="settings" :showConfig="showConfig" <user-row v-for="(user, key) in filteredUsers" :user="user" :key="key" :settings="settings" :showConfig="showConfig"
:groups="groups" :subAdminsGroups="subAdminsGroups" :quotaOptions="quotaOptions" :languages="languages" /> :groups="groups" :subAdminsGroups="subAdminsGroups" :quotaOptions="quotaOptions" :languages="languages"
:externalActions="externalActions" />
<infinite-loading @infinite="infiniteHandler" ref="infiniteLoading"> <infinite-loading @infinite="infiniteHandler" ref="infiniteLoading">
<div slot="spinner"><div class="users-icon-loading icon-loading"></div></div> <div slot="spinner"><div class="users-icon-loading icon-loading"></div></div>
<div slot="no-more"><div class="users-list-end"></div></div> <div slot="no-more"><div class="users-list-end"></div></div>
@ -141,7 +142,7 @@ import Vue from 'vue';
export default { export default {
name: 'userList', name: 'userList',
props: ['users', 'showConfig', 'selectedGroup'], props: ['users', 'showConfig', 'selectedGroup', 'externalActions'],
components: { components: {
userRow, userRow,
Multiselect, Multiselect,

View File

@ -22,7 +22,7 @@
<template> <template>
<!-- Obfuscated user: Logged in user does not have permissions to see all of the data --> <!-- Obfuscated user: Logged in user does not have permissions to see all of the data -->
<div class="row" v-if="Object.keys(user).length ===1"> <div class="row" v-if="Object.keys(user).length ===1" :data-id="user.id">
<div class="avatar" :class="{'icon-loading-small': loading.delete || loading.disable}"> <div class="avatar" :class="{'icon-loading-small': loading.delete || loading.disable}">
<img alt="" width="32" height="32" :src="generateAvatar(user.id, 32)" <img alt="" width="32" height="32" :src="generateAvatar(user.id, 32)"
:srcset="generateAvatar(user.id, 64)+' 2x, '+generateAvatar(user.id, 128)+' 4x'" :srcset="generateAvatar(user.id, 64)+' 2x, '+generateAvatar(user.id, 128)+' 4x'"
@ -33,7 +33,7 @@
</div> </div>
<!-- User full data --> <!-- User full data -->
<div class="row" v-else :class="{'disabled': loading.delete || loading.disable}"> <div class="row" v-else :class="{'disabled': loading.delete || loading.disable}" :data-id="user.id">
<div class="avatar" :class="{'icon-loading-small': loading.delete || loading.disable}"> <div class="avatar" :class="{'icon-loading-small': loading.delete || loading.disable}">
<img alt="" width="32" height="32" :src="generateAvatar(user.id, 32)" <img alt="" width="32" height="32" :src="generateAvatar(user.id, 32)"
:srcset="generateAvatar(user.id, 64)+' 2x, '+generateAvatar(user.id, 128)+' 4x'" :srcset="generateAvatar(user.id, 64)+' 2x, '+generateAvatar(user.id, 128)+' 4x'"
@ -133,7 +133,7 @@ Vue.use(VTooltip)
export default { export default {
name: 'userRow', name: 'userRow',
props: ['user', 'settings', 'groups', 'subAdminsGroups', 'quotaOptions', 'showConfig', 'languages'], props: ['user', 'settings', 'groups', 'subAdminsGroups', 'quotaOptions', 'showConfig', 'languages', 'externalActions'],
components: { components: {
popoverMenu, popoverMenu,
Multiselect Multiselect
@ -184,7 +184,7 @@ export default {
action: this.sendWelcomeMail action: this.sendWelcomeMail
}) })
} }
return actions; return actions.concat(this.externalActions);
}, },
/* GROUPS MANAGEMENT */ /* GROUPS MANAGEMENT */
@ -538,6 +538,7 @@ export default {
this.loading.all = false; this.loading.all = false;
}); });
} }
} }
} }
</script> </script>

View File

@ -52,7 +52,7 @@
</div> </div>
</template> </template>
</app-navigation> </app-navigation>
<user-list :users="users" :showConfig="showConfig" :selectedGroup="selectedGroup" /> <user-list :users="users" :showConfig="showConfig" :selectedGroup="selectedGroup" :externalActions="externalActions" />
</div> </div>
</template> </template>
@ -83,12 +83,24 @@ export default {
}); });
this.$store.dispatch('getPasswordPolicyMinLength'); this.$store.dispatch('getPasswordPolicyMinLength');
}, },
created() {
// init the OCA.Settings.UserList object
// and add the registerAction method
Object.assign(OCA, {
Settings: {
UserList: {
registerAction: this.registerAction
}
}
});
},
data() { data() {
return { return {
// default quota is set to unlimited // default quota is set to unlimited
unlimitedQuota: {id: 'none', label: t('settings', 'Unlimited')}, unlimitedQuota: {id: 'none', label: t('settings', 'Unlimited')},
// temporary value used for multiselect change // temporary value used for multiselect change
selectedQuota: false, selectedQuota: false,
externalActions: [],
showConfig: { showConfig: {
showStoragePath: false, showStoragePath: false,
showUserBackend: false, showUserBackend: false,
@ -171,6 +183,22 @@ export default {
// if no valid do not change // if no valid do not change
return false; return false;
}, },
/**
* Register a new action for the user menu
*
* @param {string} icon the icon class
* @param {string} text the text to display
* @param {function} action the function to run
*/
registerAction(icon, text, action) {
this.externalActions.push({
icon: icon,
text: text,
action: action
});
return this.externalActions;
}
}, },
computed: { computed: {
users() { users() {