Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Migrated RolesManager to BaseSettingsPage's newest save interface
Browse files Browse the repository at this point in the history
  • Loading branch information
artkravchenko committed Sep 28, 2016
1 parent 80525f2 commit e4a3853
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/settings/roles-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
import React, { PropTypes } from 'react';
import { uniqueId, pick } from 'lodash';

import { Command } from '../../utils/command';
import Role from './role';
import { ROLES } from '../../consts/profileConstants';


export default class RolesManager extends React.Component {
static displayName = 'RolesManager';

Expand Down Expand Up @@ -63,12 +65,16 @@ export default class RolesManager extends React.Component {

handleSave = async () => {
const roles = this.getRoles();
let success = false;

try {
await this.props.onSave({ more: { roles } });
success = true;
} catch (e) {
this.props.onError(e);
}

return { success };
};

getRoles = () => {
Expand All @@ -89,7 +95,8 @@ export default class RolesManager extends React.Component {
onChange = ({ index, name, value }) => {
this.roles[index][name] = value;

this.props.onChange('roles', this.handleSave);
const command = new Command('roles', this.handleSave);
this.props.onChange(command);
};

onAdd = () => {
Expand All @@ -100,7 +107,8 @@ export default class RolesManager extends React.Component {
});
this.setState({ rolesAmount: this.state.rolesAmount + 1 });

this.props.onChange('roles', this.handleSave);
const command = new Command('roles', this.handleSave);
this.props.onChange(command);
}

render() {
Expand Down

0 comments on commit e4a3853

Please sign in to comment.