feat: Add the ability to change the agent availability status (#6855)

* Add the option change agent availability

* Remove callout

* Move `AVAILABILITY_STATUS_KEYS` to constants

* Update app/javascript/dashboard/i18n/locale/en/agentMgmt.json

Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>

---------

Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
Muhsin Keloth
2023-04-10 13:37:12 +05:30
committed by GitHub
parent 91dc7733b0
commit e753365493
5 changed files with 50 additions and 1 deletions

View File

@@ -52,8 +52,9 @@ import WootDropdownMenu from 'shared/components/ui/dropdown/DropdownMenu';
import WootDropdownHeader from 'shared/components/ui/dropdown/DropdownHeader'; import WootDropdownHeader from 'shared/components/ui/dropdown/DropdownHeader';
import WootDropdownDivider from 'shared/components/ui/dropdown/DropdownDivider'; import WootDropdownDivider from 'shared/components/ui/dropdown/DropdownDivider';
import AvailabilityStatusBadge from '../widgets/conversation/AvailabilityStatusBadge'; import AvailabilityStatusBadge from '../widgets/conversation/AvailabilityStatusBadge';
import wootConstants from 'dashboard/constants';
const AVAILABILITY_STATUS_KEYS = ['online', 'busy', 'offline']; const { AVAILABILITY_STATUS_KEYS } = wootConstants;
export default { export default {
components: { components: {

View File

@@ -24,5 +24,6 @@ export default {
DOCS_URL: '//www.chatwoot.com/docs/product/', DOCS_URL: '//www.chatwoot.com/docs/product/',
TESTIMONIAL_URL: 'https://testimonials.cdn.chatwoot.com/content.json', TESTIMONIAL_URL: 'https://testimonials.cdn.chatwoot.com/content.json',
SMALL_SCREEN_BREAKPOINT: 1024, SMALL_SCREEN_BREAKPOINT: 1024,
AVAILABILITY_STATUS_KEYS: ['online', 'busy', 'offline'],
}; };
export const DEFAULT_REDIRECT_URL = '/app/'; export const DEFAULT_REDIRECT_URL = '/app/';

View File

@@ -33,6 +33,7 @@
"PLACEHOLDER": "Please select a role", "PLACEHOLDER": "Please select a role",
"ERROR": "Role is required" "ERROR": "Role is required"
}, },
"EMAIL": { "EMAIL": {
"LABEL": "Email Address", "LABEL": "Email Address",
"PLACEHOLDER": "Please enter an email address of the agent" "PLACEHOLDER": "Please enter an email address of the agent"
@@ -74,6 +75,11 @@
"LABEL": "Email Address", "LABEL": "Email Address",
"PLACEHOLDER": "Please enter an email address of the agent" "PLACEHOLDER": "Please enter an email address of the agent"
}, },
"AGENT_AVAILABILITY": {
"LABEL": "Availability",
"PLACEHOLDER": "Please select an availability status",
"ERROR": "Availability is required"
},
"SUBMIT": "Edit Agent" "SUBMIT": "Edit Agent"
}, },
"BUTTON_TEXT": "Edit", "BUTTON_TEXT": "Edit",

View File

@@ -28,6 +28,24 @@
</span> </span>
</label> </label>
</div> </div>
<div class="medium-12 columns">
<label :class="{ error: $v.agentAvailability.$error }">
{{ $t('PROFILE_SETTINGS.FORM.AVAILABILITY.LABEL') }}
<select v-model="agentAvailability">
<option
v-for="role in availabilityStatuses"
:key="role.value"
:value="role.value"
>
{{ role.label }}
</option>
</select>
<span v-if="$v.agentAvailability.$error" class="message">
{{ $t('AGENT_MGMT.EDIT.FORM.AGENT_AVAILABILITY.ERROR') }}
</span>
</label>
</div>
<div class="medium-12 modal-footer"> <div class="medium-12 modal-footer">
<div class="medium-6 columns"> <div class="medium-6 columns">
<woot-submit-button <woot-submit-button
@@ -64,6 +82,9 @@ import { mapGetters } from 'vuex';
import WootSubmitButton from '../../../../components/buttons/FormSubmitButton'; import WootSubmitButton from '../../../../components/buttons/FormSubmitButton';
import Modal from '../../../../components/Modal'; import Modal from '../../../../components/Modal';
import Auth from '../../../../api/auth'; import Auth from '../../../../api/auth';
import wootConstants from 'dashboard/constants';
const { AVAILABILITY_STATUS_KEYS } = wootConstants;
export default { export default {
components: { components: {
@@ -87,6 +108,10 @@ export default {
type: String, type: String,
default: '', default: '',
}, },
availability: {
type: String,
default: '',
},
onClose: { onClose: {
type: Function, type: Function,
required: true, required: true,
@@ -105,6 +130,7 @@ export default {
}, },
], ],
agentName: this.name, agentName: this.name,
agentAvailability: this.availability,
agentType: this.type, agentType: this.type,
agentCredentials: { agentCredentials: {
email: this.email, email: this.email,
@@ -120,6 +146,9 @@ export default {
agentType: { agentType: {
required, required,
}, },
agentAvailability: {
required,
},
}, },
computed: { computed: {
pageTitle() { pageTitle() {
@@ -128,6 +157,16 @@ export default {
...mapGetters({ ...mapGetters({
uiFlags: 'agents/getUIFlags', uiFlags: 'agents/getUIFlags',
}), }),
availabilityStatuses() {
return this.$t('PROFILE_SETTINGS.FORM.AVAILABILITY.STATUSES_LIST').map(
(statusLabel, index) => ({
label: statusLabel,
value: AVAILABILITY_STATUS_KEYS[index],
disabled:
this.currentUserAvailability === AVAILABILITY_STATUS_KEYS[index],
})
);
},
}, },
methods: { methods: {
showAlert(message) { showAlert(message) {
@@ -139,6 +178,7 @@ export default {
id: this.id, id: this.id,
name: this.agentName, name: this.agentName,
role: this.agentType, role: this.agentType,
availability: this.agentAvailability,
}); });
this.showAlert(this.$t('AGENT_MGMT.EDIT.API.SUCCESS_MESSAGE')); this.showAlert(this.$t('AGENT_MGMT.EDIT.API.SUCCESS_MESSAGE'));
this.onClose(); this.onClose();

View File

@@ -108,6 +108,7 @@
:name="currentAgent.name" :name="currentAgent.name"
:type="currentAgent.role" :type="currentAgent.role"
:email="currentAgent.email" :email="currentAgent.email"
:availability="currentAgent.availability_status"
:on-close="hideEditPopup" :on-close="hideEditPopup"
/> />
</woot-modal> </woot-modal>