From 9291aa66a44cf25bdc256c866de49aa9a7abefe7 Mon Sep 17 00:00:00 2001 From: LautaroCesso <59095036+LautaroCesso@users.noreply.github.com> Date: Tue, 28 Dec 2021 14:03:53 -0300 Subject: [PATCH] [DEV-197] Message bug (#1113) * Fix message bug * Add controlled pattern to message component * Fix bug in admin panel custom fields form message * Fix bug in dashboard ticket page message * Fix bug in staff editor messages * Fix bug in ticket viewer messages * Fix bug in admin login page messages * Fix bug in password recovery messages * Fix bug in main home page login widget messages * Fix bug in main signup widget messages * Fix bug in admin panel custom responses message * Fix bug in admin panel email settings message * Fix bug in admin panel ban users message * Fix bug in admin panel ban users message * Fix bug in main recover password page messages * Fix bug in dashboard list tickets page message * Fix bug in dashboard edit profile page messages * Fix bug in create ticket form messages * Fix bug in invite user widget messages * Fix bug in create ticket form messages * Fix bug in admin panel list users messages * Fix bug in admin panel system preferences messages * Fix bug in admin panel advanced settings messages * Fix bug in install step 3 database message * Fix bug in install step 5 settings message * Fix bug in install step 6 admin message * Fix bug in install completed message * Fix bug in ticket query list message * Fix bug in articles list message * Fix bug in admin pane search tickets message * Fix bug in admin panel my tickets message * Fix bug in admin panel new tickets messages * Fix bug in ticket list messages * Fix bug in main home page portal message * Fix bug in dashboard create ticket page message * Fix bug in main home page messages --- client/src/app-components/articles-list.js | 2 +- .../src/app-components/password-recovery.js | 47 +++++++----- client/src/app-components/ticket-list.js | 23 +++++- .../src/app-components/ticket-query-list.js | 10 +-- client/src/app-components/ticket-viewer.js | 27 +++++-- client/src/app/admin/admin-login-page.js | 64 +++++++++------- .../settings/admin-panel-advanced-settings.js | 50 +++++++++---- .../settings/admin-panel-email-settings.js | 2 +- .../admin-panel-system-preferences.js | 41 ++++++++-- .../panel/staff/admin-panel-departments.js | 39 +++++++--- .../src/app/admin/panel/staff/staff-editor.js | 51 +++++++++---- .../tickets/admin-panel-custom-responses.js | 21 +++++- .../panel/tickets/admin-panel-my-tickets.js | 2 +- .../panel/tickets/admin-panel-new-tickets.js | 4 +- .../tickets/admin-panel-search-tickets.js | 10 +-- .../panel/users/admin-panel-ban-users.js | 50 +++++++++++-- .../users/admin-panel-custom-field-form.js | 21 ++++-- .../panel/users/admin-panel-list-users.js | 28 ++++++- .../panel/users/admin-panel-view-user.js | 44 +++++++---- .../admin/panel/users/invite-user-widget.js | 41 ++++++++-- client/src/app/install/install-completed.js | 2 +- .../app/install/install-step-3-database.js | 30 +++++--- .../app/install/install-step-5-settings.js | 30 +++++--- .../src/app/install/install-step-6-admin.js | 32 +++++--- .../create-ticket-form.js | 41 ++++++++-- .../dashboard-create-ticket-page.js | 20 ++++- .../dashboard-edit-profile-page.js | 75 +++++++++++++++---- .../dashboard-list-tickets-page.js | 23 +++++- .../dashboard-ticket/dashboard-ticket-page.js | 15 +++- .../main-home/main-home-page-login-widget.js | 69 +++++++++++------ .../main/main-home/main-home-page-portal.js | 29 ++++--- .../src/app/main/main-home/main-home-page.js | 41 +++++++--- .../main-recover-password-page.js | 33 +++++++- .../main/main-signup/main-signup-widget.js | 38 ++++++++-- client/src/core-components/message.js | 32 ++++---- server/controllers/system/edit-settings.php | 1 - 36 files changed, 800 insertions(+), 288 deletions(-) diff --git a/client/src/app-components/articles-list.js b/client/src/app-components/articles-list.js index 776e6e42..c6bc1e43 100644 --- a/client/src/app-components/articles-list.js +++ b/client/src/app-components/articles-list.js @@ -39,7 +39,7 @@ class ArticlesList extends React.Component { const { errored, loading } = this.props; if(errored) { - return {i18n('ERROR_RETRIEVING_ARTICLES')}; + return {i18n('ERROR_RETRIEVING_ARTICLES')}; } return loading ? : this.renderContent(); diff --git a/client/src/app-components/password-recovery.js b/client/src/app-components/password-recovery.js index d7bf80d0..00ad56b3 100644 --- a/client/src/app-components/password-recovery.js +++ b/client/src/app-components/password-recovery.js @@ -24,13 +24,19 @@ class PasswordRecovery extends React.Component { renderLogo: false }; + state = { + showRecoverSentMessage: true + } + + componentDidUpdate(prevProps) { + if (!prevProps.recoverSent && this.props.recoverSent) { + this.setState({showRecoverSentMessage : true}); + } + } + render() { - const { - renderLogo, - formProps, - onBackToLoginClick, - style - } = this.props; + const { renderLogo, formProps, onBackToLoginClick, style } = this.props; + return ( {this.renderLogo()} @@ -68,22 +74,29 @@ class PasswordRecovery extends React.Component { } renderRecoverStatus() { - let status = null; - - if (this.props.recoverSent) { - status = ( - - {i18n('RECOVER_SENT')} - - ); - } - - return status; + return ( + this.props.recoverSent ? + + {i18n('RECOVER_SENT')} + : + null + ); } focusEmail() { this.refs.email.focus(); } + + onCloseMessage(showMessage) { + this.setState({ + [showMessage]: false + }); + } } export default PasswordRecovery; diff --git a/client/src/app-components/ticket-list.js b/client/src/app-components/ticket-list.js index 8722685b..26d4c581 100644 --- a/client/src/app-components/ticket-list.js +++ b/client/src/app-components/ticket-list.js @@ -15,6 +15,7 @@ import Checkbox from 'core-components/checkbox'; import Tag from 'core-components/tag'; import Icon from 'core-components/icon'; import Message from 'core-components/message'; +import history from 'lib-app/history'; class TicketList extends React.Component { static propTypes = { @@ -90,9 +91,23 @@ class TicketList extends React.Component { renderMessage() { switch (queryString.parse(window.location.search)["message"]) { case 'success': - return {i18n('TICKET_SENT')} + return ( + + {i18n('TICKET_SENT')} + + ); case 'fail': - return {i18n('TICKET_SENT_ERROR')}; + return ( + + {i18n('TICKET_SENT_ERROR')} + + ); default: return null; } @@ -293,6 +308,10 @@ class TicketList extends React.Component { } } } + + onCloseMessage() { + history.push(window.location.pathname); + } } export default connect((store) => { diff --git a/client/src/app-components/ticket-query-list.js b/client/src/app-components/ticket-query-list.js index 79c1e207..26fee229 100644 --- a/client/src/app-components/ticket-query-list.js +++ b/client/src/app-components/ticket-query-list.js @@ -21,13 +21,9 @@ class TicketQueryList extends React.Component { render() { return ( -
- { - (this.state.error) ? - {i18n('ERROR_RETRIEVING_TICKETS')} : - - } -
+ this.state.error ? + {i18n('ERROR_RETRIEVING_TICKETS')} : + ); } diff --git a/client/src/app-components/ticket-viewer.js b/client/src/app-components/ticket-viewer.js index 987640a5..97522c3b 100644 --- a/client/src/app-components/ticket-viewer.js +++ b/client/src/app-components/ticket-viewer.js @@ -71,6 +71,7 @@ class TicketViewer extends React.Component { editTags: false, editOwner: false, editDepartment: false, + showTicketCommentErrorMessage: true }; componentDidMount() { @@ -529,8 +530,16 @@ class TicketViewer extends React.Component { } renderCommentError() { + const { showTicketCommentErrorMessage } = this.state; + return ( - {i18n('TICKET_COMMENT_ERROR')} + + {i18n('TICKET_COMMENT_ERROR')} + ); } @@ -775,7 +784,7 @@ class TicketViewer extends React.Component { data, TextEditor.getContentFormData(content) ) - }).then(this.onEditCommentSuccess.bind(this), this.onFailCommentFail.bind(this)); + }).then(this.onEditCommentSuccess.bind(this), this.onEditCommentFail.bind(this)); } onEditCommentSuccess() { @@ -789,10 +798,11 @@ class TicketViewer extends React.Component { this.onTicketModification(); } - onFailCommentFail() { + onEditCommentFail() { this.setState({ loading: false, - commentError: true + commentError: true, + showTicketCommentErrorMessage: true }); } @@ -824,7 +834,8 @@ class TicketViewer extends React.Component { onCommentFail() { this.setState({ loading: false, - commentError: true + commentError: true, + showTicketCommentErrorMessage: true }); } @@ -890,6 +901,12 @@ class TicketViewer extends React.Component { return false; } + + onCloseMessage(showMessage) { + this.setState({ + [showMessage]: false + }); + } } export default connect((store) => { diff --git a/client/src/app/admin/admin-login-page.js b/client/src/app/admin/admin-login-page.js index 4d5a24f1..a843d3f6 100644 --- a/client/src/app/admin/admin-login-page.js +++ b/client/src/app/admin/admin-login-page.js @@ -27,11 +27,14 @@ class AdminLoginPage extends React.Component { recoverFormErrors: {}, recoverSent: false, loadingLogin: false, - loadingRecover: false + loadingRecover: false, + showRecoverSentMessage: true, + showEmailOrPassordErrorMessage: true }; componentDidUpdate(prevProps) { if (!prevProps.session.failed && this.props.session.failed) { + this.setState({showEmailOrPassordErrorMessage : true}); this.refs.loginForm.refs.password.focus(); } } @@ -108,31 +111,34 @@ class AdminLoginPage extends React.Component { } renderRecoverStatus() { - let status = null; + const { showRecoverSentMessage, recoverSent } = this.state; - if (this.state.recoverSent) { - status = ( - - {i18n('RECOVER_SENT')} - - ); - } - - return status; + return ( + recoverSent ? + + {i18n('RECOVER_SENT')} + : + null + ); } renderErrorStatus() { - let status = null; - - if (this.props.session.failed) { - status = ( - - {i18n('EMAIL_OR_PASSWORD')} - - ); - } - - return status; + return ( + this.props.session.failed ? + + {i18n('EMAIL_OR_PASSWORD')} + : + null + ); } getLoginFormProps() { @@ -147,10 +153,7 @@ class AdminLoginPage extends React.Component { } getRecoverFormProps() { - const { - loadingRecover, - recoverFormErrors - } = this.state; + const { loadingRecover, recoverFormErrors } = this.state; return { loading: loadingRecover, @@ -222,7 +225,8 @@ class AdminLoginPage extends React.Component { onRecoverPasswordSent() { this.setState({ loadingRecover: false, - recoverSent: true + recoverSent: true, + showRecoverSentMessage: true }); } @@ -236,6 +240,12 @@ class AdminLoginPage extends React.Component { this.refs.recoverForm.refs.email.focus(); }.bind(this)); } + + onCloseMessage(showMessage) { + this.setState({ + [showMessage]: false + }); + } } export default connect((store) => { diff --git a/client/src/app/admin/panel/settings/admin-panel-advanced-settings.js b/client/src/app/admin/panel/settings/admin-panel-advanced-settings.js index 114d1ceb..c8b794ec 100644 --- a/client/src/app/admin/panel/settings/admin-panel-advanced-settings.js +++ b/client/src/app/admin/panel/settings/admin-panel-advanced-settings.js @@ -27,7 +27,9 @@ class AdminPanelAdvancedSettings extends React.Component { messageContent: '', selectedAPIKey: -1, APIKeys: [], - error: '' + error: '', + showMessage: true, + showAPIKeyMessage: true }; componentDidMount() { @@ -36,7 +38,7 @@ class AdminPanelAdvancedSettings extends React.Component { render() { const { config } = this.props; - const { messageType, error, selectedAPIKey } = this.state; + const { messageType, error, selectedAPIKey, showAPIKeyMessage } = this.state; return (
@@ -93,7 +95,16 @@ class AdminPanelAdvancedSettings extends React.Component {
- {error ? {i18n(error)} : ((selectedAPIKey === -1) ? this.renderNoKey() : this.renderKey())} + { + error ? + + {i18n(error)} + : + ((selectedAPIKey === -1) ? this.renderNoKey() : this.renderKey()) + }
@@ -102,11 +113,16 @@ class AdminPanelAdvancedSettings extends React.Component { } renderMessage() { - const { messageType, messageTitle, messageContent } = this.state; + const { messageType, messageTitle, messageContent, showMessage } = this.state; return ( - - {messageContent} + + {messageContent} ); } @@ -270,10 +286,11 @@ class AdminPanelAdvancedSettings extends React.Component { this.setState({ messageType: 'success', messageTitle: null, + showMessage: true, messageContent: config['mandatory-login'] ? i18n('MANDATORY_LOGIN_DISABLED') : i18n('MANDATORY_LOGIN_ENABLED') }); dispatch(ConfigActions.updateData()); - }).catch(() => this.setState({messageType: 'error', messageTitle: null, messageContent: i18n('ERROR_UPDATING_SETTINGS')})); + }).catch(() => this.setState({messageType: 'error', showMessage: true, messageTitle: null, messageContent: i18n('ERROR_UPDATING_SETTINGS')})); } onAreYouSureRegistrationOk(password) { @@ -287,11 +304,12 @@ class AdminPanelAdvancedSettings extends React.Component { }).then(() => { this.setState({ messageType: 'success', + showMessage: true, messageTitle: null, messageContent: config['registration'] ? i18n('REGISTRATION_DISABLED') : i18n('REGISTRATION_ENABLED') }); dispatch(ConfigActions.updateData()); - }).catch(() => this.setState({messageType: 'error', messageTitle: null, messageContent: i18n('ERROR_UPDATING_SETTINGS')})); + }).catch(() => this.setState({messageType: 'error', showMessage: true, messageTitle: null, messageContent: i18n('ERROR_UPDATING_SETTINGS')})); } onImportCSV(event) { @@ -308,7 +326,8 @@ class AdminPanelAdvancedSettings extends React.Component { } }) .then((result) => this.setState({ - messageType: 'success', + messageType: 'success', + showMessage: true, messageTitle: i18n('SUCCESS_IMPORTING_CSV_DESCRIPTION'), messageContent: (result.data.length) ? (
@@ -319,7 +338,7 @@ class AdminPanelAdvancedSettings extends React.Component {
) : null })) - .catch(() => this.setState({messageType: 'error', messageTitle: null, messageContent: i18n('INVALID_FILE')})); + .catch(() => this.setState({messageType: 'error', showMessage: true, messageTitle: null, messageContent: i18n('INVALID_FILE')})); } onBackupDatabase() { @@ -347,12 +366,17 @@ class AdminPanelAdvancedSettings extends React.Component { data: { password: password } - }).then(() => this.setState({messageType: 'success', messageTitle: null, messageContent: i18n('SUCCESS_DELETING_ALL_USERS')} - )).catch(() => this.setState({messageType: 'error', messageTitle: null, messageContent: i18n('ERROR_DELETING_ALL_USERS')})); + }).then(() => this.setState({messageType: 'success', showMessage: true, messageTitle: null, messageContent: i18n('SUCCESS_DELETING_ALL_USERS')} + )).catch(() => this.setState({messageType: 'error', showMessage: true, messageTitle: null, messageContent: i18n('ERROR_DELETING_ALL_USERS')})); + } + + onCloseMessage(showMessage) { + this.setState({ + [showMessage]: false + }); } } - export default connect((store) => { return { config: store.config diff --git a/client/src/app/admin/panel/settings/admin-panel-email-settings.js b/client/src/app/admin/panel/settings/admin-panel-email-settings.js index d47578cc..408d1146 100644 --- a/client/src/app/admin/panel/settings/admin-panel-email-settings.js +++ b/client/src/app/admin/panel/settings/admin-panel-email-settings.js @@ -169,7 +169,7 @@ class AdminPanelEmailSettings extends React.Component { - + {i18n('IMAP_POLLING_DESCRIPTION', {url: `${apiRoot}/system/email-polling`})} diff --git a/client/src/app/admin/panel/settings/admin-panel-system-preferences.js b/client/src/app/admin/panel/settings/admin-panel-system-preferences.js index db8875ab..71a85814 100755 --- a/client/src/app/admin/panel/settings/admin-panel-system-preferences.js +++ b/client/src/app/admin/panel/settings/admin-panel-system-preferences.js @@ -26,7 +26,8 @@ class AdminPanelSystemPreferences extends React.Component { message: null, values: { maintenance: false, - } + }, + showMessage: true }; componentDidMount() { @@ -113,11 +114,29 @@ class AdminPanelSystemPreferences extends React.Component { } renderMessage() { - switch (this.state.message) { + const { message, showMessage } = this.state; + + switch (message) { case 'success': - return {i18n('SETTINGS_UPDATED')}; + return ( + + {i18n('SETTINGS_UPDATED')} + + ); case 'fail': - return {i18n('ERROR_UPDATING_SETTINGS')}; + return ( + + {i18n('ERROR_UPDATING_SETTINGS')} + + ); default: return null; } @@ -155,14 +174,15 @@ class AdminPanelSystemPreferences extends React.Component { 'allowedLanguages': JSON.stringify(form.allowedLanguages.map(index => languageKeys[index])), 'supportedLanguages': JSON.stringify(form.supportedLanguages.map(index => languageKeys[index])) } - }).then(this.onSubmitSuccess.bind(this)).catch(() => this.setState({loading: false, message: 'fail'})); + }).then(this.onSubmitSuccess.bind(this)).catch(() => this.setState({loading: false, message: 'fail', showMessage: true})); } onSubmitSuccess() { this.recoverSettings(); this.setState({ message: 'success', - loading: false + loading: false, + showMessage: true }); } @@ -202,7 +222,8 @@ class AdminPanelSystemPreferences extends React.Component { onRecoverSettingsFail() { this.setState({ - message: 'error' + message: 'error', + showMessage: true }); } @@ -211,6 +232,12 @@ class AdminPanelSystemPreferences extends React.Component { this.setState({loading: true}); this.recoverSettings(); } + + onCloseMessage(showMessage) { + this.setState({ + [showMessage]: false + }); + } } export default AdminPanelSystemPreferences; diff --git a/client/src/app/admin/panel/staff/admin-panel-departments.js b/client/src/app/admin/panel/staff/admin-panel-departments.js index d6a0cde6..97183088 100644 --- a/client/src/app/admin/panel/staff/admin-panel-departments.js +++ b/client/src/app/admin/panel/staff/admin-panel-departments.js @@ -43,6 +43,9 @@ class AdminPanelDepartments extends React.Component { editedAddDepartmentForm: false, editedDefaultDepartmentForm: false, errorMessage: null, + showErrorMessage: true, + showSuccessMessage: true, + showDefaultDepartmentErrorMessage: true, errors: {}, defaultDepartmentError: null, form: { @@ -55,7 +58,7 @@ class AdminPanelDepartments extends React.Component { }; render() { - const { errorMessage, formLoading, selectedIndex } = this.state; + const { errorMessage, formLoading, selectedIndex, showErrorMessage } = this.state; return (
@@ -65,7 +68,13 @@ class AdminPanelDepartments extends React.Component {
- {errorMessage ? {i18n(errorMessage)} : null} + { + errorMessage ? + + {i18n(errorMessage)} + : + null + }
@@ -98,15 +107,19 @@ class AdminPanelDepartments extends React.Component { } renderDefaultDepartmentForm() { - const { defaultDepartmentError, formLoading } = this.state; + const { defaultDepartmentError, formLoading, showSuccessMessage, showDefaultDepartmentErrorMessage } = this.state; return (
{(defaultDepartmentError !== null) ? ((!defaultDepartmentError) ? - {i18n('SETTINGS_UPDATED')} : - {i18n(defaultDepartmentError)}) : + + {i18n('SETTINGS_UPDATED')} + : + + {i18n(defaultDepartmentError)} + ) : null}
@@ -234,6 +247,12 @@ class AdminPanelDepartments extends React.Component { }; } + onCloseMessage(showMessage) { + this.setState({ + [showMessage]: false + }); + } + onItemChange(index) { if(this.state.editedAddDepartmentForm) { AreYouSure.openModal(i18n('WILL_LOSE_CHANGES'), this.updateForm.bind(this, index)); @@ -255,8 +274,8 @@ class AdminPanelDepartments extends React.Component { } }).then(() => { this.retrieveDepartments(true); - this.setState({formLoading: false, errorMessage: false, defaultDepartmentError: false}); - }).catch(result => this.setState({formLoading: false, defaultDepartmentError: result.message})); + this.setState({formLoading: false, errorMessage: false, defaultDepartmentError: false, showSuccessMessage: true}); + }).catch(result => this.setState({formLoading: false, defaultDepartmentError: result.message, showDefaultDepartmentErrorMessage: true})); } onFormSubmit(form) { @@ -273,7 +292,7 @@ class AdminPanelDepartments extends React.Component { }).then(() => { this.setState({formLoading: false, errorMessage: false, defaultDepartmentError: null}); this.retrieveDepartments(); - }).catch(result => this.setState({formLoading: false, errorMessage: result.message, defaultDepartmentError: null})); + }).catch(result => this.setState({formLoading: false, errorMessage: result.message, showErrorMessage: true, defaultDepartmentError: null})); } else { API.call({ path: '/system/add-department', @@ -287,7 +306,7 @@ class AdminPanelDepartments extends React.Component { this.onItemChange(-1); }).catch(result => { this.onItemChange.bind(this, -1); - this.setState({formLoading: false, errorMessage: result.message, defaultDepartmentError: null}); + this.setState({formLoading: false, errorMessage: result.message, showErrorMessage: true, defaultDepartmentError: null}); }); } } @@ -316,7 +335,7 @@ class AdminPanelDepartments extends React.Component { this.onItemChange(-1); this.setState({defaultDepartmentError: null}); }) - .catch(result => this.setState({errorMessage: result.message, defaultDepartmentError: null})); + .catch(result => this.setState({errorMessage: result.message, showErrorMessage: true, defaultDepartmentError: null})); } updateForm(index) { diff --git a/client/src/app/admin/panel/staff/staff-editor.js b/client/src/app/admin/panel/staff/staff-editor.js index a8b417ae..8337dfa9 100644 --- a/client/src/app/admin/panel/staff/staff-editor.js +++ b/client/src/app/admin/panel/staff/staff-editor.js @@ -56,6 +56,8 @@ class StaffEditor extends React.Component { loadingReInviteStaff: false, reInviteStaff: "", loadingStats: true, + showMessage: true, + showReInviteStaffMessage: true, rawForm: { dateRange: statsUtils.getInitialDateRange(), departments: [], @@ -181,12 +183,17 @@ class StaffEditor extends React.Component { } renderReInviteStaffMessage() { - const { reInviteStaff } = this.state; + const { reInviteStaff, showReInviteStaffMessage } = this.state; if (reInviteStaff) { return ( - - {(reInviteStaff === "success") ? i18n('RESEND_STAFF_INVITATION_SUCCESS') : i18n('RESEND_STAFF_INVITATION_FAIL')} + + {(reInviteStaff === "success") ? i18n('RESEND_STAFF_INVITATION_SUCCESS') : i18n('RESEND_STAFF_INVITATION_FAIL')} ); } else { @@ -207,19 +214,21 @@ class StaffEditor extends React.Component { }).then(() => { this.setState({ loadingReInviteStaff: false, - reInviteStaff: 'success' + reInviteStaff: 'success', + showReInviteStaffMessage: true }) }).catch(() => { this.setState({ loadingReInviteStaff: false, - reInviteStaff: 'error' + reInviteStaff: 'error', + showReInviteStaffMessage: true }) }) } renderMessage() { - const { message } = this.state; - let messageType = (message === 'FAIL') ? 'error' : 'success'; + const { message, showMessage } = this.state; + const messageType = (message === 'FAIL') ? 'error' : 'success'; let _message = null; switch (message) { @@ -243,7 +252,15 @@ class StaffEditor extends React.Component { break; } - return {i18n(_message)}; + return ( + + {i18n(_message)} + + ); } renderSendEmailOnNewTicketForm() { @@ -406,6 +423,8 @@ class StaffEditor extends React.Component { } onSubmit(eventType, form) { + this.setState({loadingStats: true}); + const { myAccount, staffId, onChange } = this.props; let departments; @@ -428,13 +447,11 @@ class StaffEditor extends React.Component { }).then(() => { this.retrieveStaffMembers(); window.scrollTo(0,250); - this.setState({message: eventType}); + this.setState({message: eventType, showMessage: true}); const departmentsAssigned = SessionStore.getDepartments().filter((_department, index) => this.state.departments.includes(index)); const departmentsAssignedId = departmentsAssigned.map(department => department.id); - this.setState({loadingStats: true}); - statsUtils.retrieveStats({ rawForm: this.state.rawForm, departments: departmentsAssignedId @@ -448,7 +465,7 @@ class StaffEditor extends React.Component { onChange && onChange(); }).catch(() => { window.scrollTo(0,250); - this.setState({message: 'FAIL'}); + this.setState({message: 'FAIL', loadingStats: false, showMessage: true}); }); } @@ -462,7 +479,7 @@ class StaffEditor extends React.Component { } }).then(onDelete).catch(() => { window.scrollTo(0,0); - this.setState({message: 'FAIL'}); + this.setState({message: 'FAIL', showMessage: true}); }); } @@ -488,7 +505,7 @@ class StaffEditor extends React.Component { onChange && onChange(); }).catch(() => { window.scrollTo(0,0); - this.setState({message: 'FAIL', loadingPicture: false}); + this.setState({message: 'FAIL', loadingPicture: false, showMessage: true}); }); } @@ -557,6 +574,12 @@ class StaffEditor extends React.Component { department: newDepartmentFilter ? `[${newDepartmentFilter}]` : undefined } } + + onCloseMessage(showMessage) { + this.setState({ + [showMessage]: false + }); + } } export default connect((store) => { diff --git a/client/src/app/admin/panel/tickets/admin-panel-custom-responses.js b/client/src/app/admin/panel/tickets/admin-panel-custom-responses.js index 423b9c43..b8c71fc3 100644 --- a/client/src/app/admin/panel/tickets/admin-panel-custom-responses.js +++ b/client/src/app/admin/panel/tickets/admin-panel-custom-responses.js @@ -41,7 +41,8 @@ class AdminPanelCustomResponses extends React.Component { title: '', content: TextEditor.createEmpty(), language: this.props.language - } + }, + showErrorMessage: true }; componentDidMount() { @@ -103,8 +104,16 @@ class AdminPanelCustomResponses extends React.Component { ); } renderErrorMessage() { + const { showErrorMessage, error } = this.state; + return( - {i18n(this.state.error)} + + {i18n(error)} + ) } renderOptionalButtons() { @@ -202,7 +211,7 @@ class AdminPanelCustomResponses extends React.Component { this.onItemChange(-1); }).catch((e) => { this.onItemChange.bind(this, -1) - this.setState({error: e.message, formLoading:false}); + this.setState({error: e.message, formLoading:false, showErrorMessage: true}); }); } } @@ -267,6 +276,12 @@ class AdminPanelCustomResponses extends React.Component { ) ); } + + onCloseMessage(showMessage) { + this.setState({ + [showMessage]: false + }); + } } export default connect((store) => { diff --git a/client/src/app/admin/panel/tickets/admin-panel-my-tickets.js b/client/src/app/admin/panel/tickets/admin-panel-my-tickets.js index 414d28a5..4792b1a1 100644 --- a/client/src/app/admin/panel/tickets/admin-panel-my-tickets.js +++ b/client/src/app/admin/panel/tickets/admin-panel-my-tickets.js @@ -36,7 +36,7 @@ class AdminPanelMyTickets extends React.Component { return (
- {(this.props.error) ? {i18n('ERROR_RETRIEVING_TICKETS')} : } + {(this.props.error) ? {i18n('ERROR_RETRIEVING_TICKETS')} : }