fix: Welcome email copy changes and canned response API error handling [cw-1290] (#6905)
* fix: Welcome email copy changes and canned response API error handling * Review fixes * Uses mixin for alerts in canned page * Typo fixes * Copy changes * Fixes broken tests * Fixes review comments * Fixes typo errors with mail template * Removes unwanted case * Fixes repetitive texts --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
committed by
GitHub
parent
520bdabefe
commit
07aaa046c1
@@ -34,7 +34,7 @@
|
|||||||
},
|
},
|
||||||
"API": {
|
"API": {
|
||||||
"SUCCESS_MESSAGE": "Canned Response added successfully",
|
"SUCCESS_MESSAGE": "Canned Response added successfully",
|
||||||
"ERROR_MESSAGE": "Could not connect to Woot Server, Please try again later"
|
"ERROR_MESSAGE": "Could not create canned response, Please try again later"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"EDIT": {
|
"EDIT": {
|
||||||
@@ -56,14 +56,14 @@
|
|||||||
"BUTTON_TEXT": "Edit",
|
"BUTTON_TEXT": "Edit",
|
||||||
"API": {
|
"API": {
|
||||||
"SUCCESS_MESSAGE": "Canned Response updated successfully",
|
"SUCCESS_MESSAGE": "Canned Response updated successfully",
|
||||||
"ERROR_MESSAGE": "Could not connect to Woot Server, Please try again later"
|
"ERROR_MESSAGE": "Could not update canned response, Please try again later"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DELETE": {
|
"DELETE": {
|
||||||
"BUTTON_TEXT": "Delete",
|
"BUTTON_TEXT": "Delete",
|
||||||
"API": {
|
"API": {
|
||||||
"SUCCESS_MESSAGE": "Canned response deleted successfully",
|
"SUCCESS_MESSAGE": "Canned response deleted successfully",
|
||||||
"ERROR_MESSAGE": "Could not connect to Woot Server, Please try again later"
|
"ERROR_MESSAGE": "Could not delete canned response, Please try again later"
|
||||||
},
|
},
|
||||||
"CONFIRM": {
|
"CONFIRM": {
|
||||||
"TITLE": "Confirm Deletion",
|
"TITLE": "Confirm Deletion",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
:header-title="$t('CANNED_MGMT.ADD.TITLE')"
|
:header-title="$t('CANNED_MGMT.ADD.TITLE')"
|
||||||
:header-content="$t('CANNED_MGMT.ADD.DESC')"
|
:header-content="$t('CANNED_MGMT.ADD.DESC')"
|
||||||
/>
|
/>
|
||||||
<form class="row" @submit.prevent="addAgent()">
|
<form class="row" @submit.prevent="addCannedResponse()">
|
||||||
<div class="medium-12 columns">
|
<div class="medium-12 columns">
|
||||||
<label :class="{ error: $v.shortCode.$error }">
|
<label :class="{ error: $v.shortCode.$error }">
|
||||||
{{ $t('CANNED_MGMT.ADD.FORM.SHORT_CODE.LABEL') }}
|
{{ $t('CANNED_MGMT.ADD.FORM.SHORT_CODE.LABEL') }}
|
||||||
@@ -107,7 +107,7 @@ export default {
|
|||||||
this.$v.shortCode.$reset();
|
this.$v.shortCode.$reset();
|
||||||
this.$v.content.$reset();
|
this.$v.content.$reset();
|
||||||
},
|
},
|
||||||
addAgent() {
|
addCannedResponse() {
|
||||||
// Show loading on button
|
// Show loading on button
|
||||||
this.addCanned.showLoading = true;
|
this.addCanned.showLoading = true;
|
||||||
// Make API Calls
|
// Make API Calls
|
||||||
@@ -123,9 +123,11 @@ export default {
|
|||||||
this.resetForm();
|
this.resetForm();
|
||||||
this.onClose();
|
this.onClose();
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(error => {
|
||||||
this.addCanned.showLoading = false;
|
this.addCanned.showLoading = false;
|
||||||
this.showAlert(this.$t('CANNED_MGMT.ADD.API.ERROR_MESSAGE'));
|
const errorMessage =
|
||||||
|
error?.message || this.$t('CANNED_MGMT.ADD.API.ERROR_MESSAGE');
|
||||||
|
this.showAlert(errorMessage);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
import { required, minLength } from 'vuelidate/lib/validators';
|
import { required, minLength } from 'vuelidate/lib/validators';
|
||||||
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor';
|
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor';
|
||||||
import WootSubmitButton from '../../../../components/buttons/FormSubmitButton';
|
import WootSubmitButton from '../../../../components/buttons/FormSubmitButton';
|
||||||
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
import Modal from '../../../../components/Modal';
|
import Modal from '../../../../components/Modal';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -65,6 +66,7 @@ export default {
|
|||||||
Modal,
|
Modal,
|
||||||
WootMessageEditor,
|
WootMessageEditor,
|
||||||
},
|
},
|
||||||
|
mixins: [alertMixin],
|
||||||
props: {
|
props: {
|
||||||
id: { type: Number, default: null },
|
id: { type: Number, default: null },
|
||||||
edcontent: { type: String, default: '' },
|
edcontent: { type: String, default: '' },
|
||||||
@@ -76,7 +78,6 @@ export default {
|
|||||||
editCanned: {
|
editCanned: {
|
||||||
showAlert: false,
|
showAlert: false,
|
||||||
showLoading: false,
|
showLoading: false,
|
||||||
message: '',
|
|
||||||
},
|
},
|
||||||
shortCode: this.edshortCode,
|
shortCode: this.edshortCode,
|
||||||
content: this.edcontent,
|
content: this.edcontent,
|
||||||
@@ -102,9 +103,6 @@ export default {
|
|||||||
this.$v.content.$touch();
|
this.$v.content.$touch();
|
||||||
this.content = name;
|
this.content = name;
|
||||||
},
|
},
|
||||||
showAlert() {
|
|
||||||
bus.$emit('newToastMessage', this.editCanned.message);
|
|
||||||
},
|
|
||||||
resetForm() {
|
resetForm() {
|
||||||
this.shortCode = '';
|
this.shortCode = '';
|
||||||
this.content = '';
|
this.content = '';
|
||||||
@@ -124,21 +122,17 @@ export default {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
// Reset Form, Show success message
|
// Reset Form, Show success message
|
||||||
this.editCanned.showLoading = false;
|
this.editCanned.showLoading = false;
|
||||||
this.editCanned.message = this.$t(
|
this.showAlert(this.$t('CANNED_MGMT.EDIT.API.SUCCESS_MESSAGE'));
|
||||||
'CANNED_MGMT.EDIT.API.SUCCESS_MESSAGE'
|
|
||||||
);
|
|
||||||
this.showAlert();
|
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.onClose();
|
this.onClose();
|
||||||
}, 10);
|
}, 10);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(error => {
|
||||||
this.editCanned.showLoading = false;
|
this.editCanned.showLoading = false;
|
||||||
this.editCanned.message = this.$t(
|
const errorMessage =
|
||||||
'CANNED_MGMT.EDIT.API.ERROR_MESSAGE'
|
error?.message || this.$t('CANNED_MGMT.EDIT.API.ERROR_MESSAGE');
|
||||||
);
|
this.showAlert(errorMessage);
|
||||||
this.showAlert();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -198,8 +198,10 @@ export default {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
this.showAlert(this.$t('CANNED_MGMT.DELETE.API.SUCCESS_MESSAGE'));
|
this.showAlert(this.$t('CANNED_MGMT.DELETE.API.SUCCESS_MESSAGE'));
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(error => {
|
||||||
this.showAlert(this.$t('CANNED_MGMT.DELETE.API.ERROR_MESSAGE'));
|
const errorMessage =
|
||||||
|
error?.message || this.$t('CANNED_MGMT.DELETE.API.ERROR_MESSAGE');
|
||||||
|
this.showAlert(errorMessage);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { throwErrorMessage } from 'dashboard/store/utils/api';
|
||||||
import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
|
import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
|
||||||
import * as types from '../mutation-types';
|
import * as types from '../mutation-types';
|
||||||
import CannedResponseAPI from '../../api/cannedResponse';
|
import CannedResponseAPI from '../../api/cannedResponse';
|
||||||
@@ -46,8 +47,10 @@ const actions = {
|
|||||||
const response = await CannedResponseAPI.create(cannedObj);
|
const response = await CannedResponseAPI.create(cannedObj);
|
||||||
commit(types.default.ADD_CANNED, response.data);
|
commit(types.default.ADD_CANNED, response.data);
|
||||||
commit(types.default.SET_CANNED_UI_FLAG, { creatingItem: false });
|
commit(types.default.SET_CANNED_UI_FLAG, { creatingItem: false });
|
||||||
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
commit(types.default.SET_CANNED_UI_FLAG, { creatingItem: false });
|
commit(types.default.SET_CANNED_UI_FLAG, { creatingItem: false });
|
||||||
|
return throwErrorMessage(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -60,8 +63,10 @@ const actions = {
|
|||||||
const response = await CannedResponseAPI.update(id, updateObj);
|
const response = await CannedResponseAPI.update(id, updateObj);
|
||||||
commit(types.default.EDIT_CANNED, response.data);
|
commit(types.default.EDIT_CANNED, response.data);
|
||||||
commit(types.default.SET_CANNED_UI_FLAG, { updatingItem: false });
|
commit(types.default.SET_CANNED_UI_FLAG, { updatingItem: false });
|
||||||
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
commit(types.default.SET_CANNED_UI_FLAG, { updatingItem: false });
|
commit(types.default.SET_CANNED_UI_FLAG, { updatingItem: false });
|
||||||
|
return throwErrorMessage(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -71,8 +76,10 @@ const actions = {
|
|||||||
await CannedResponseAPI.delete(id);
|
await CannedResponseAPI.delete(id);
|
||||||
commit(types.default.DELETE_CANNED, id);
|
commit(types.default.DELETE_CANNED, id);
|
||||||
commit(types.default.SET_CANNED_UI_FLAG, { deletingItem: true });
|
commit(types.default.SET_CANNED_UI_FLAG, { deletingItem: true });
|
||||||
|
return id;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
commit(types.default.SET_CANNED_UI_FLAG, { deletingItem: true });
|
commit(types.default.SET_CANNED_UI_FLAG, { deletingItem: true });
|
||||||
|
return throwErrorMessage(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,22 +1,27 @@
|
|||||||
<p>Welcome, <%= @resource.name %>!</p>
|
<p>Hi, <%= @resource.name %>!</p>
|
||||||
|
|
||||||
<% account_user = @resource&.account_users&.first %>
|
<% account_user = @resource&.account_users&.first %>
|
||||||
|
|
||||||
<% if account_user&.inviter.present? && @resource.unconfirmed_email.blank? %>
|
<% if account_user&.inviter.present? && @resource.unconfirmed_email.blank? %>
|
||||||
<p><%= account_user.inviter.name %>, with <%= account_user.account.name %>, has invited you to try out <%= global_config['BRAND_NAME'] || 'Chatwoot' %>! </p>
|
<p><%= account_user.inviter.name %>, with <%= account_user.account.name %>, has invited you to try out <%= global_config['BRAND_NAME'] || 'Chatwoot' %>.</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @resource.confirmed? %>
|
<% if @resource.confirmed? %>
|
||||||
<p>You can login to your account through the link below:</p>
|
<p>You can login to your <%= global_config['BRAND_NAME'] || 'Chatwoot' %> account through the link below:</p>
|
||||||
<% else %>
|
<% else %>
|
||||||
<p>You can confirm your account email through the link below:</p>
|
<p>
|
||||||
|
Welcome to <%= global_config['BRAND_NAME'] || 'Chatwoot' %>! We have a suite of powerful tools ready for you to explore. Before that we quickly need to verify your email address to know it's really you.
|
||||||
|
</p>
|
||||||
|
<p>Please take a moment and click the link below and activate your account.</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
<% if @resource.unconfirmed_email.present? %>
|
<% if @resource.unconfirmed_email.present? %>
|
||||||
<p><%= link_to 'Confirm my account', frontend_url('auth/confirmation', confirmation_token: @token) %></p>
|
<p><%= link_to 'Confirm my account', frontend_url('auth/confirmation', confirmation_token: @token) %></p>
|
||||||
<% elsif @resource.confirmed? %>
|
<% elsif @resource.confirmed? %>
|
||||||
<p><%= link_to 'Login to my account', frontend_url('auth/sign_in') %></p>
|
<p><%= link_to 'Login to my account', frontend_url('auth/sign_in') %></p>
|
||||||
<% elsif account_user&.inviter.present? %>
|
<% elsif account_user&.inviter.present? %>
|
||||||
<p><%= link_to 'Confirm my account', frontend_url('auth/password/edit', reset_password_token: @resource.send(:set_reset_password_token)) %></p>
|
<p><%= link_to 'Confirm my account', frontend_url('auth/password/edit', reset_password_token: @resource.send(:set_reset_password_token)) %></p>
|
||||||
<% else %>
|
<% else %>
|
||||||
<p><%= link_to 'Confirm my account', frontend_url('auth/confirmation', confirmation_token: @token) %></p>
|
<p><%= link_to 'Confirm my account', frontend_url('auth/confirmation', confirmation_token: @token) %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ RSpec.describe 'Confirmation Instructions', type: :mailer do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'uses the user\'s name' do
|
it 'uses the user\'s name' do
|
||||||
expect(mail.body).to match("Welcome, #{CGI.escapeHTML(confirmable_user.name)}!")
|
expect(mail.body).to match("Hi #{CGI.escapeHTML(confirmable_user.name)},")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not refer to the inviter and their account' do
|
it 'does not refer to the inviter and their account' do
|
||||||
@@ -39,7 +39,7 @@ RSpec.describe 'Confirmation Instructions', type: :mailer do
|
|||||||
|
|
||||||
it 'refers to the inviter and their account' do
|
it 'refers to the inviter and their account' do
|
||||||
expect(mail.body).to match(
|
expect(mail.body).to match(
|
||||||
"#{CGI.escapeHTML(inviter_val.name)}, with #{CGI.escapeHTML(account.name)}, has invited you to try out Chatwoot!"
|
"#{CGI.escapeHTML(inviter_val.name)}, with #{CGI.escapeHTML(account.name)}, has invited you to try out Chatwoot."
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user