feat: Adds ability to edit out webhook URL of API Channel (#3013)

This commit is contained in:
Sivin Varghese 2021-09-28 12:33:08 +05:30 committed by GitHub
parent 15aaa8883c
commit 1761bec615
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 3 deletions

View file

@ -56,6 +56,11 @@
"CHANNEL_AVATAR": {
"LABEL": "Channel Avatar"
},
"CHANNEL_WEBHOOK_URL": {
"LABEL": "Webhook URL",
"PLACEHOLDER": "Enter your Webhook URL",
"ERROR": "Please enter a valid URL"
},
"CHANNEL_DOMAIN": {
"LABEL": "Website Domain",
"PLACEHOLDER": "Enter your website domain (eg: acme.com)"
@ -127,11 +132,11 @@
"ERROR_MESSAGE": "We were not able to authenticate Twilio credentials, please try again"
}
},
"SMS": {
"SMS": {
"TITLE": "SMS Channel via Twilio",
"DESC": "Start supporting your customers via SMS with Twilio integration."
},
"WHATSAPP": {
"WHATSAPP": {
"TITLE": "Whatsapp Channel via Twilio",
"DESC": "Start supporting your customers via Whatsapp with Twilio integration."
},

View file

@ -22,7 +22,7 @@
<woot-avatar-uploader
:label="$t('INBOX_MGMT.ADD.WEBSITE_CHANNEL.CHANNEL_AVATAR.LABEL')"
:src="avatarUrl"
deleteAvatar
delete-avatar
@change="handleImageUpload"
@onAvatarDelete="handleAvatarDelete"
/>
@ -32,6 +32,24 @@
:label="inboxNameLabel"
:placeholder="inboxNamePlaceHolder"
/>
<woot-input
v-if="isAPIInbox"
v-model.trim="webhookUrl"
class="medium-9 columns"
:class="{ error: $v.webhookUrl.$error }"
:label="
$t('INBOX_MGMT.ADD.WEBSITE_CHANNEL.CHANNEL_WEBHOOK_URL.LABEL')
"
:placeholder="
$t('INBOX_MGMT.ADD.WEBSITE_CHANNEL.CHANNEL_WEBHOOK_URL.PLACEHOLDER')
"
:error="
$v.webhookUrl.$error
? $t('INBOX_MGMT.ADD.WEBSITE_CHANNEL.CHANNEL_WEBHOOK_URL.ERROR')
: ''
"
@blur="$v.webhookUrl.$touch"
/>
<woot-input
v-if="isAWebWidgetInbox"
v-model.trim="channelWebsiteUrl"
@ -212,6 +230,16 @@
</div>
<woot-submit-button
v-if="isAPIInbox"
type="submit"
:disabled="$v.webhookUrl.$invalid"
:button-text="$t('INBOX_MGMT.SETTINGS_POPUP.UPDATE')"
:loading="uiFlags.isUpdatingInbox"
@click="updateInbox"
/>
<woot-submit-button
v-else
type="submit"
:button-text="$t('INBOX_MGMT.SETTINGS_POPUP.UPDATE')"
:loading="uiFlags.isUpdatingInbox"
@click="updateInbox"
@ -324,6 +352,8 @@
<script>
import { mapGetters } from 'vuex';
import { createMessengerScript } from 'dashboard/helper/scriptGenerator';
import { required } from 'vuelidate/lib/validators';
import { shouldBeUrl } from 'shared/helpers/Validators';
import configMixin from 'shared/mixins/configMixin';
import alertMixin from 'shared/mixins/alertMixin';
import SettingIntroBanner from 'dashboard/components/widgets/SettingIntroBanner';
@ -357,6 +387,7 @@ export default {
csatSurveyEnabled: false,
selectedInboxName: '',
channelWebsiteUrl: '',
webhookUrl: '',
channelWelcomeTitle: '',
channelWelcomeTagline: '',
selectedFeatureFlags: [],
@ -503,6 +534,7 @@ export default {
this.fetchAttachedAgents();
this.avatarUrl = this.inbox.avatar_url;
this.selectedInboxName = this.inbox.name;
this.webhookUrl = this.inbox.webhook_url;
this.greetingEnabled = this.inbox.greeting_enabled || false;
this.greetingMessage = this.inbox.greeting_message || '';
this.autoAssignment = this.inbox.enable_auto_assignment;
@ -555,6 +587,7 @@ export default {
channel: {
widget_color: this.inbox.widget_color,
website_url: this.channelWebsiteUrl,
webhook_url: this.webhookUrl,
welcome_title: this.channelWelcomeTitle || '',
welcome_tagline: this.channelWelcomeTagline || '',
selectedFeatureFlags: this.selectedFeatureFlags,
@ -593,6 +626,10 @@ export default {
},
},
validations: {
webhookUrl: {
required,
shouldBeUrl,
},
selectedAgents: {
isEmpty() {
return !!this.selectedAgents.length;

View file

@ -1,2 +1,4 @@
export const isPhoneE164 = value => !!value.match(/^\+[1-9]\d{1,14}$/);
export const isPhoneE164OrEmpty = value => isPhoneE164(value) || value === '';
export const shouldBeUrl = (value = '') =>
value ? value.startsWith('http') : true;

View file

@ -0,0 +1,7 @@
import { shouldBeUrl } from '../Validators';
describe('#shouldBeUrl', () => {
it('should return correct url', () => {
expect(shouldBeUrl('http')).toEqual(true);
});
});