Skip to content

Commit cb539a6

Browse files
authored
Changed add collaborator flow (#257)
* changed add collaborator flow * showing the footer as well but no need to click on save changes button
1 parent 8ab39a2 commit cb539a6

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

src/components/FlowView/FlowView.react.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default class FlowView extends React.Component {
2020
saveState: SaveButton.States.WAITING,
2121
saveError: '',
2222
};
23+
this.handleClickSaveButton = this.handleClickSaveButton.bind(this);
2324
}
2425

2526
componentWillReceiveProps(props) {
@@ -58,6 +59,9 @@ export default class FlowView extends React.Component {
5859
saveError: '',
5960
changes: newChanges,
6061
});
62+
if(key === 'collaborators'){
63+
this.handleClickSaveButton();
64+
}
6165
}
6266
}
6367

@@ -71,6 +75,20 @@ export default class FlowView extends React.Component {
7175
}
7276
}
7377

78+
handleClickSaveButton() {
79+
let fields = this.currentFields();
80+
this.setState({ saveState: SaveButton.States.SAVING });
81+
this.props.onSubmit({ changes: this.state.changes, fields, setField: this.setField, resetFields: this.resetFields }).then(() => {
82+
this.setState({ saveState: SaveButton.States.SUCCEEDED });
83+
this.props.afterSave({ fields, setField: this.setField, resetFields: this.resetFields });
84+
}).catch(({ message, error, notice, errors = [] }) => {
85+
this.setState({
86+
saveState: SaveButton.States.FAILED,
87+
saveError: errors.join(' ') || message || error || notice || 'An error occurred',
88+
});
89+
});
90+
}
91+
7492
render() {
7593
let {
7694
inProgressText,
@@ -125,18 +143,7 @@ export default class FlowView extends React.Component {
125143
waitingText={submitText}
126144
savingText={inProgressText}
127145
disabled={!!hasFormValidationError}
128-
onClick={() => {
129-
this.setState({ saveState: SaveButton.States.SAVING });
130-
onSubmit({ changes, fields, setField, resetFields }).then(() => {
131-
this.setState({ saveState: SaveButton.States.SUCCEEDED });
132-
afterSave({ fields, setField, resetFields });
133-
}).catch(({ message, error, notice, errors = [] }) => {
134-
this.setState({
135-
saveState: SaveButton.States.FAILED,
136-
saveError: errors.join(' ') || message || error || notice || 'An error occurred',
137-
});
138-
});
139-
}}
146+
onClick={this.handleClickSaveButton.bind(this)}
140147
/>;
141148

142149
let footer = shouldShowFooter ? <FlowFooter
@@ -164,3 +171,7 @@ FlowView.propTypes = {
164171
secondaryButton: PropTypes.func.describe('Overrride the cancel button by passing a function that returns your custom node. By default, the cancel button says "Cancel" and calls resetFields().'),
165172
defaultFooterMessage: PropTypes.node.describe('A message for the footer when the validate message is "use default"'),
166173
};
174+
175+
FlowView.defaultProps = {
176+
afterSave: () => {}
177+
};

src/dashboard/Settings/GeneralSettings.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ export default class GeneralSettings extends DashboardView {
484484
textModal={true}>
485485
<span>We have removed <strong>{joinWithFinal('', this.state.removedCollaborators.map(c => c.userName || c.userEmail), ', ', ' and ')}</strong> from this app. If they had saved the master key, they may still have access via an SDK or the API. To be sure, you can reset your master key in the Keys section of app settings.</span>
486486
</Modal> : null;
487-
let setCollaborators = (setField, unused, allCollabs) => {
487+
let setCollaborators = (setField, _, allCollabs) => {
488488
let addedCollaborators = setDifference(allCollabs, initialFields.collaborators, compareCollaborators);
489489
let removedCollaborators = setDifference(initialFields.collaborators, allCollabs, compareCollaborators);
490490
if (addedCollaborators.length === 0 && removedCollaborators.length === 0) {
@@ -513,7 +513,7 @@ export default class GeneralSettings extends DashboardView {
513513
if (changes.inProduction !== undefined) {
514514
promiseList.push(this.context.currentApp.setInProduction(changes.inProduction));
515515
}
516-
516+
517517
let removedCollaborators;
518518
if (changes.collaborators !== undefined) {
519519
let addedCollaborators = setDifference(changes.collaborators, initialFields.collaborators, compareCollaborators);

0 commit comments

Comments
 (0)