Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Ability } from 'ember-can';
import { ability } from 'ember-can/computed';
import { get, computed } from '@ember/object';
const hasPermission = permission => (
computed('membership.permissions.@each.hasDirtyAttributes', function() {
return this._isGroupMember() && get(this, 'membership').hasPermission(permission);
}).readOnly()
);
export default Ability.extend({
membership: null,
postAbility: ability('post', 'post'),
commentAbility: ability('comment', 'comment'),
canViewDashboard: computed('membership', function() {
const isMember = this._isGroupMember();
return isMember && (get(get(this, 'membership'), 'permissions.length') > 0);
}).readOnly(),
canManageEverything: hasPermission('owner'),
canManageMembers: hasPermission('members'),
canManageLeaders: hasPermission('leaders'),
canManageSettings: hasPermission('community'),
canManageReports: hasPermission('content'),
canManageTickets: hasPermission('tickets'),
canWritePost: computed('model', 'membership', function() {
// If this is a restricted group, then posting is limited to leaders
import { Ability } from 'ember-can';
import { ability } from 'ember-can/computed';
import { get, computed } from '@ember/object';
const hasPermission = permission => (
computed('membership.permissions.@each.hasDirtyAttributes', function() {
return this._isGroupMember() && get(this, 'membership').hasPermission(permission);
}).readOnly()
);
export default Ability.extend({
membership: null,
postAbility: ability('post', 'post'),
commentAbility: ability('comment', 'comment'),
canViewDashboard: computed('membership', function() {
const isMember = this._isGroupMember();
return isMember && (get(get(this, 'membership'), 'permissions.length') > 0);
}).readOnly(),
canManageEverything: hasPermission('owner'),
canManageMembers: hasPermission('members'),
canManageLeaders: hasPermission('leaders'),
canManageSettings: hasPermission('community'),
canManageReports: hasPermission('content'),
canManageTickets: hasPermission('tickets'),
canWritePost: computed('model', 'membership', function() {
// If this is a restricted group, then posting is limited to leaders
const group = get(this, 'model');
import { alias, and } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import { ability } from 'ember-can/computed';
export default Component.extend({
classNames: ['project-user-role-modal-container'],
tagName: 'span',
currentUser: service(),
projectUser: null,
save: null,
selectedRole: null,
showModal: false,
ability: ability('project'),
canManage: alias('ability.canManage'),
demotionDisabled: and('canManage', 'isSelf'),
user: alias('currentUser.user'),
isSelf: computed('projectUser', 'user', function() {
return get(this, 'projectUser.user.id') === get(this, 'user.id');
}),
init() {
this._super(...arguments);
let role = get(this, 'projectUser.role');
set(this, 'selectedRole', role);
}
});