forked from chatwoot/chatwoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: As an end-user, I should be able to see the list of agents i…
…n the widget. (chatwoot#461) Co-authored-by: Pranav Raj S <[email protected]>
- Loading branch information
1 parent
33e0bd4
commit 83b0bb4
Showing
20 changed files
with
406 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import endPoints from 'widget/api/endPoints'; | ||
import { API } from 'widget/helpers/axios'; | ||
|
||
export const getAvailableAgents = async websiteToken => { | ||
const urlData = endPoints.getAvailableAgents(websiteToken); | ||
const result = await API.get(urlData.url, { params: urlData.params }); | ||
return result; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<template> | ||
<div class="available-agents"> | ||
<div class="toast-bg"> | ||
<div class="avatars-wrap"> | ||
<GroupedAvatars :users="users" /> | ||
</div> | ||
<div class="title"> | ||
{{ title }} | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import GroupedAvatars from 'widget/components/GroupedAvatars.vue'; | ||
import { getAvailableAgentsText } from 'widget/helpers/utils'; | ||
export default { | ||
name: 'AvailableAgents', | ||
components: { GroupedAvatars }, | ||
props: { | ||
agents: { | ||
type: Array, | ||
default: () => [], | ||
}, | ||
onClose: { | ||
type: Function, | ||
default: () => {}, | ||
}, | ||
}, | ||
computed: { | ||
users() { | ||
return this.agents.map(agent => ({ | ||
id: agent.id, | ||
avatar: agent.avatar_url, | ||
name: agent.name, | ||
})); | ||
}, | ||
title() { | ||
return getAvailableAgentsText(this.agents); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
@import '~widget/assets/scss/variables.scss'; | ||
@import '~widget/assets/scss/mixins.scss'; | ||
.available-agents { | ||
display: flex; | ||
position: relative; | ||
justify-content: center; | ||
margin: $space-normal $space-medium; | ||
box-sizing: border-box; | ||
.toast-bg { | ||
border-radius: $space-large; | ||
background: $color-body; | ||
@include shadow-medium; | ||
} | ||
.title { | ||
font-size: $font-size-default; | ||
font-weight: $font-weight-medium; | ||
color: $color-white; | ||
padding: $space-one $space-normal $space-one $space-small; | ||
line-height: 1.4; | ||
display: inline-block; | ||
vertical-align: middle; | ||
} | ||
.avatars-wrap { | ||
display: inline-block; | ||
vertical-align: middle; | ||
margin-left: $space-small; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<template> | ||
<div class="avatars"> | ||
<span v-for="user in users" :key="user.id" class="avatar"> | ||
<Thumbnail | ||
size="24px" | ||
:username="user.name" | ||
status="online" | ||
:src="user.avatar" | ||
has-border | ||
/> | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Thumbnail from 'dashboard/components/widgets/Thumbnail.vue'; | ||
export default { | ||
name: 'GroupedAvatars', | ||
components: { Thumbnail }, | ||
props: { | ||
users: { | ||
type: Array, | ||
default: () => [], | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
@import '~widget/assets/scss/variables.scss'; | ||
@import '~widget/assets/scss/mixins.scss'; | ||
.avatars { | ||
display: inline-block; | ||
padding-left: $space-one; | ||
.avatar { | ||
margin-left: -$space-slab; | ||
position: relative; | ||
display: inline-block; | ||
overflow: hidden; | ||
width: $space-medium; | ||
height: $space-medium; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { getAvailableAgentsText } from '../utils'; | ||
|
||
describe('#getAvailableAgentsText', () => { | ||
it('returns the correct text is there is only one online agent', () => { | ||
expect(getAvailableAgentsText([{ name: 'Pranav' }])).toEqual( | ||
'Pranav is available' | ||
); | ||
}); | ||
|
||
it('returns the correct text is there are two online agents', () => { | ||
expect( | ||
getAvailableAgentsText([{ name: 'Pranav' }, { name: 'Nithin' }]) | ||
).toEqual('Pranav and Nithin is available'); | ||
}); | ||
|
||
it('returns the correct text is there are more than two online agents', () => { | ||
expect( | ||
getAvailableAgentsText([ | ||
{ name: 'Pranav' }, | ||
{ name: 'Nithin' }, | ||
{ name: 'Subin' }, | ||
{ name: 'Sojan' }, | ||
]) | ||
).toEqual('Pranav and 3 others are available'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.