Skip to content

Commit 6d4ecea

Browse files
author
Vikas Agarwal
committed
Github issue#1133, Chatbot: "Save changes" button is enabled, but not working when validation is triggered
— Fixed toaster message to show correct state of the project being updated.
1 parent d05c08e commit 6d4ecea

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/reducers/alerts.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
CREATE_PROJECT_SUCCESS, CREATE_PROJECT_FAILURE,
77
UPDATE_PROJECT_SUCCESS, UPDATE_PROJECT_FAILURE,
88
DELETE_PROJECT_SUCCESS, DELETE_PROJECT_FAILURE,
9+
LOAD_PROJECT_SUCCESS,
910
// Attachments
1011
ADD_PROJECT_ATTACHMENT_SUCCESS, ADD_PROJECT_ATTACHMENT_FAILURE,
1112
UPDATE_PROJECT_ATTACHMENT_SUCCESS, UPDATE_PROJECT_ATTACHMENT_FAILURE,
@@ -20,7 +21,9 @@ import {
2021
SAVE_PROJECT_FEED_FAILURE,
2122
SAVE_PROJECT_FEED_COMMENT_FAILURE,
2223
DELETE_PROJECT_FEED_FAILURE,
23-
DELETE_PROJECT_FEED_COMMENT_FAILURE
24+
DELETE_PROJECT_FEED_COMMENT_FAILURE,
25+
// Project status
26+
PROJECT_STATUS_IN_REVIEW
2427
} from '../config/constants'
2528
/* eslint-enable no-unused-vars */
2629

@@ -36,13 +39,21 @@ export default function(state = {}, action) {
3639
Alert.success('Project deleted.')
3740
return state
3841

42+
case LOAD_PROJECT_SUCCESS:
43+
return Object.assign({}, state, {
44+
project: action.payload
45+
})
3946
case UPDATE_PROJECT_SUCCESS:
40-
if (action.payload.status === 'in_review') {
47+
const prevStatus = _.get(state, 'project.status', '')
48+
if (action.payload.status === PROJECT_STATUS_IN_REVIEW
49+
&& prevStatus && prevStatus !== PROJECT_STATUS_IN_REVIEW) {
4150
Alert.success('Project submitted.')
4251
} else {
4352
Alert.success('Project updated.')
4453
}
45-
return state
54+
return Object.assign({}, state, {
55+
project: action.payload
56+
})
4657
case REMOVE_PROJECT_MEMBER_SUCCESS:
4758
// show notification message if user leaving a project
4859
if (action.meta.isUserLeaving) {

0 commit comments

Comments
 (0)