Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix run loop issues for role item and user dropdown integration tests #1246

Merged
merged 1 commit into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions app/components/role-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const {
computed,
computed: { notEmpty },
get,
inject: { service }
getProperties,
inject: { service },
set
} = Ember;

export default Component.extend({
Expand All @@ -19,31 +21,30 @@ export default Component.extend({
selected: notEmpty('userRole'),

userRole: computed('role', 'userRoles.userRoles', function() {
let role = this.get('role');
let userRoles = this.get('userRoles');
let { role, userRoles } = getProperties(this, 'role', 'userRoles');
return userRoles.findUserRole(role);
}),

actions: {
addRole(role) {
this.set('isLoading', true);
set(this, 'isLoading', true);
let userRoles = this.get('userRoles');
return userRoles.addRole(role).catch(() => {
let message = `An error occurred trying to add ${role.get('name')}.`;
this._flashError(message);
}).finally(() => {
this.set('isLoading', false);
set(this, 'isLoading', false);
});
},

removeRole(role) {
this.set('isLoading', true);
set(this, 'isLoading', true);
let userRoles = this.get('userRoles');
return userRoles.removeRole(role).catch(() => {
let message = `An error occurred trying to remove ${role.get('name')}.`;
this._flashError(message);
}).finally(() => {
this.set('isLoading', false);
set(this, 'isLoading', false);
});
}
},
Expand Down