@subiz/widget-v4 4.1.70 → 4.1.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled_src/chatbox/AgentsAvatar.js +102 -108
- package/compiled_src/chatbox/ButtonAttachments.js +16 -23
- package/compiled_src/chatbox/Buttons.js +36 -43
- package/compiled_src/chatbox/ChatButton.js +5 -1
- package/compiled_src/chatbox/Rating.js +1 -1
- package/package.json +1 -1
- package/src/chatbox/AgentsAvatar.js +118 -134
- package/src/chatbox/ButtonAttachments.js +13 -20
- package/src/chatbox/Buttons.js +29 -37
- package/src/chatbox/ChatButton.js +6 -1
- package/src/chatbox/Rating.js +1 -1
|
@@ -3,142 +3,136 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = AgentsAvatar;
|
|
7
7
|
var _index = _interopRequireDefault(require("../util/index.js"));
|
|
8
8
|
var _common = require("../common.js");
|
|
9
9
|
var _preact = require("preact");
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
function AgentsAvatar(props) {
|
|
12
|
+
let accountSetting = props.plugin.chatbox;
|
|
13
|
+
let acc = props.store.matchAccount() || {};
|
|
14
|
+
var tooltippos = props.tooltipPos || 'bottom';
|
|
15
|
+
var mode = props.mode || 'primary';
|
|
16
|
+
if (accountSetting && accountSetting.hide_agent_profile) {
|
|
17
|
+
return (0, _preact.h)("div", {
|
|
18
|
+
class: `group-avatar group-avatar--${mode}`
|
|
19
|
+
}, (0, _preact.h)("div", {
|
|
20
|
+
class: "d-inline-block pos-relative",
|
|
21
|
+
"data-tooltip": acc.name,
|
|
22
|
+
"data-tooltip-position": tooltippos
|
|
23
|
+
}, (0, _preact.h)("img", {
|
|
24
|
+
width: 35,
|
|
25
|
+
height: 35,
|
|
26
|
+
alt: "agent avatar left",
|
|
27
|
+
class: "avatar group-avatar--agent-left",
|
|
28
|
+
src: props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')
|
|
29
|
+
})));
|
|
14
30
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class: "d-inline-block pos-relative",
|
|
25
|
-
"data-tooltip": acc.name,
|
|
26
|
-
"data-tooltip-position": tooltippos
|
|
27
|
-
}, (0, _preact.h)("img", {
|
|
28
|
-
width: 35,
|
|
29
|
-
height: 35,
|
|
30
|
-
alt: "agent avatar left",
|
|
31
|
-
class: "avatar group-avatar--agent-left",
|
|
32
|
-
src: this.props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')
|
|
33
|
-
})));
|
|
34
|
-
}
|
|
35
|
-
let agentM = this.props.store.matchAgent('*');
|
|
36
|
-
var agents = _index.default.map(this.props.agent_ids, id => agentM[id]);
|
|
37
|
-
if (this.props.agent_ids === undefined || _index.default.size(this.props.agent_ids) === 0) {
|
|
38
|
-
var agids = _index.default.get(accountSetting, 'header.agent_ids', []);
|
|
39
|
-
agids = _index.default.filter(agids, id => !!agentM[id]);
|
|
40
|
-
if (agids.length !== 0) {
|
|
41
|
-
agents = _index.default.map(agids, id => agentM[id]);
|
|
42
|
-
} else {
|
|
43
|
-
agents = _index.default.filter(agentM, agent => agent.type === 'agent');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
agents = _index.default.filter(agents, ag => !!ag);
|
|
47
|
-
if (agents.length === 0) {
|
|
48
|
-
return (0, _preact.h)("div", {
|
|
49
|
-
class: `group-avatar group-avatar--${mode}`
|
|
50
|
-
}, (0, _preact.h)("div", {
|
|
51
|
-
class: "d-inline-block pos-relative",
|
|
52
|
-
"data-tooltip": acc.name,
|
|
53
|
-
"data-tooltip-position": tooltippos
|
|
54
|
-
}, (0, _preact.h)("img", {
|
|
55
|
-
width: 35,
|
|
56
|
-
height: 35,
|
|
57
|
-
alt: "agent avatar left",
|
|
58
|
-
class: "avatar group-avatar--agent-left",
|
|
59
|
-
src: this.props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')
|
|
60
|
-
})));
|
|
61
|
-
}
|
|
62
|
-
if (agents.length === 1) {
|
|
63
|
-
var agent = agents[0];
|
|
64
|
-
var groupClass = mode === 'primary' ? 'group-avatar--agent-middle' : 'group-avatar--agent-left';
|
|
65
|
-
return (0, _preact.h)("div", {
|
|
66
|
-
class: `group-avatar group-avatar--${mode}`
|
|
67
|
-
}, (0, _preact.h)("div", {
|
|
68
|
-
class: "d-inline-block pos-relative",
|
|
69
|
-
"data-tooltip": agent.fullname || acc.name,
|
|
70
|
-
"data-tooltip-position": tooltippos
|
|
71
|
-
}, (0, _preact.h)("img", {
|
|
72
|
-
width: 35,
|
|
73
|
-
height: 35,
|
|
74
|
-
class: `avatar ${groupClass}`,
|
|
75
|
-
alt: "agent avatar",
|
|
76
|
-
src: this.props.store.replaceFileUrl(agent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
77
|
-
})));
|
|
78
|
-
}
|
|
79
|
-
if (agents.length === 2) {
|
|
80
|
-
let leftAgent = agents[0];
|
|
81
|
-
let rightAgent = agents[1];
|
|
82
|
-
return (0, _preact.h)("div", {
|
|
83
|
-
class: `group-avatar group-avatar--${mode}`
|
|
84
|
-
}, (0, _preact.h)("div", {
|
|
85
|
-
class: "d-inline-block pos-relative",
|
|
86
|
-
"data-tooltip": leftAgent.fullname || acc.name,
|
|
87
|
-
"data-tooltip-position": tooltippos
|
|
88
|
-
}, (0, _preact.h)("img", {
|
|
89
|
-
width: 35,
|
|
90
|
-
height: 35,
|
|
91
|
-
alt: "agent avatar left",
|
|
92
|
-
class: "avatar group-avatar--agent-left",
|
|
93
|
-
src: this.props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
94
|
-
})), (0, _preact.h)("div", {
|
|
95
|
-
class: "d-inline-block pos-relative",
|
|
96
|
-
"data-tooltip": rightAgent.fullname || acc.name,
|
|
97
|
-
"data-tooltip-position": tooltippos
|
|
98
|
-
}, (0, _preact.h)("img", {
|
|
99
|
-
alt: "agent avatar right",
|
|
100
|
-
width: 35,
|
|
101
|
-
height: 35,
|
|
102
|
-
class: "avatar group-avatar--agent-right",
|
|
103
|
-
src: this.props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
104
|
-
})));
|
|
31
|
+
let agentM = props.store.matchAgent('*');
|
|
32
|
+
var agents = _index.default.map(props.agent_ids, id => agentM[id]);
|
|
33
|
+
if (props.agent_ids === undefined || _index.default.size(props.agent_ids) === 0) {
|
|
34
|
+
var agids = _index.default.get(accountSetting, 'header.agent_ids', []);
|
|
35
|
+
agids = _index.default.filter(agids, id => !!agentM[id]);
|
|
36
|
+
if (agids.length !== 0) {
|
|
37
|
+
agents = _index.default.map(agids, id => agentM[id]);
|
|
38
|
+
} else {
|
|
39
|
+
agents = _index.default.filter(agentM, agent => agent.type === 'agent');
|
|
105
40
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
41
|
+
}
|
|
42
|
+
agents = _index.default.filter(agents, ag => !!ag);
|
|
43
|
+
if (agents.length === 0) {
|
|
109
44
|
return (0, _preact.h)("div", {
|
|
110
45
|
class: `group-avatar group-avatar--${mode}`
|
|
111
46
|
}, (0, _preact.h)("div", {
|
|
112
47
|
class: "d-inline-block pos-relative",
|
|
113
|
-
"data-tooltip":
|
|
48
|
+
"data-tooltip": acc.name,
|
|
114
49
|
"data-tooltip-position": tooltippos
|
|
115
50
|
}, (0, _preact.h)("img", {
|
|
116
51
|
width: 35,
|
|
117
52
|
height: 35,
|
|
118
53
|
alt: "agent avatar left",
|
|
119
54
|
class: "avatar group-avatar--agent-left",
|
|
120
|
-
src:
|
|
121
|
-
}))
|
|
55
|
+
src: props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')
|
|
56
|
+
})));
|
|
57
|
+
}
|
|
58
|
+
if (agents.length === 1) {
|
|
59
|
+
var agent = agents[0];
|
|
60
|
+
var groupClass = mode === 'primary' ? 'group-avatar--agent-middle' : 'group-avatar--agent-left';
|
|
61
|
+
return (0, _preact.h)("div", {
|
|
62
|
+
class: `group-avatar group-avatar--${mode}`
|
|
63
|
+
}, (0, _preact.h)("div", {
|
|
64
|
+
class: "d-inline-block pos-relative",
|
|
65
|
+
"data-tooltip": agent.fullname || acc.name,
|
|
66
|
+
"data-tooltip-position": tooltippos
|
|
67
|
+
}, (0, _preact.h)("img", {
|
|
68
|
+
width: 35,
|
|
69
|
+
height: 35,
|
|
70
|
+
class: `avatar ${groupClass}`,
|
|
71
|
+
alt: "agent avatar",
|
|
72
|
+
src: props.store.replaceFileUrl(agent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
73
|
+
})));
|
|
74
|
+
}
|
|
75
|
+
if (agents.length === 2) {
|
|
76
|
+
let leftAgent = agents[0];
|
|
77
|
+
let rightAgent = agents[1];
|
|
78
|
+
return (0, _preact.h)("div", {
|
|
79
|
+
class: `group-avatar group-avatar--${mode}`
|
|
80
|
+
}, (0, _preact.h)("div", {
|
|
122
81
|
class: "d-inline-block pos-relative",
|
|
123
|
-
"data-tooltip":
|
|
82
|
+
"data-tooltip": leftAgent.fullname || acc.name,
|
|
124
83
|
"data-tooltip-position": tooltippos
|
|
125
84
|
}, (0, _preact.h)("img", {
|
|
126
|
-
alt: "agent avatar middle",
|
|
127
85
|
width: 35,
|
|
128
86
|
height: 35,
|
|
129
|
-
|
|
130
|
-
|
|
87
|
+
alt: "agent avatar left",
|
|
88
|
+
class: "avatar group-avatar--agent-left",
|
|
89
|
+
src: props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
131
90
|
})), (0, _preact.h)("div", {
|
|
132
91
|
class: "d-inline-block pos-relative",
|
|
133
92
|
"data-tooltip": rightAgent.fullname || acc.name,
|
|
134
93
|
"data-tooltip-position": tooltippos
|
|
135
94
|
}, (0, _preact.h)("img", {
|
|
95
|
+
alt: "agent avatar right",
|
|
136
96
|
width: 35,
|
|
137
97
|
height: 35,
|
|
138
|
-
alt: "agent avatar right",
|
|
139
98
|
class: "avatar group-avatar--agent-right",
|
|
140
|
-
src:
|
|
99
|
+
src: props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
141
100
|
})));
|
|
142
101
|
}
|
|
143
|
-
|
|
144
|
-
|
|
102
|
+
let leftAgent = agents[0];
|
|
103
|
+
let middleAgent = agents[1];
|
|
104
|
+
let rightAgent = agents[2];
|
|
105
|
+
return (0, _preact.h)("div", {
|
|
106
|
+
class: `group-avatar group-avatar--${mode}`
|
|
107
|
+
}, (0, _preact.h)("div", {
|
|
108
|
+
class: "d-inline-block pos-relative",
|
|
109
|
+
"data-tooltip": leftAgent.fullname || acc.name,
|
|
110
|
+
"data-tooltip-position": tooltippos
|
|
111
|
+
}, (0, _preact.h)("img", {
|
|
112
|
+
width: 35,
|
|
113
|
+
height: 35,
|
|
114
|
+
alt: "agent avatar left",
|
|
115
|
+
class: "avatar group-avatar--agent-left",
|
|
116
|
+
src: props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
117
|
+
})), (0, _preact.h)("div", {
|
|
118
|
+
class: "d-inline-block pos-relative",
|
|
119
|
+
"data-tooltip": middleAgent.fullname || acc.name,
|
|
120
|
+
"data-tooltip-position": tooltippos
|
|
121
|
+
}, (0, _preact.h)("img", {
|
|
122
|
+
alt: "agent avatar middle",
|
|
123
|
+
width: 35,
|
|
124
|
+
height: 35,
|
|
125
|
+
class: "avatar group-avatar--agent-middle",
|
|
126
|
+
src: props.store.replaceFileUrl(middleAgent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
127
|
+
})), (0, _preact.h)("div", {
|
|
128
|
+
class: "d-inline-block pos-relative",
|
|
129
|
+
"data-tooltip": rightAgent.fullname || acc.name,
|
|
130
|
+
"data-tooltip-position": tooltippos
|
|
131
|
+
}, (0, _preact.h)("img", {
|
|
132
|
+
width: 35,
|
|
133
|
+
height: 35,
|
|
134
|
+
alt: "agent avatar right",
|
|
135
|
+
class: "avatar group-avatar--agent-right",
|
|
136
|
+
src: props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
137
|
+
})));
|
|
138
|
+
}
|
|
@@ -3,30 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = ButtonAttachments;
|
|
7
7
|
var _Buttons = _interopRequireDefault(require("./Buttons.js"));
|
|
8
8
|
var _index = _interopRequireDefault(require("../util/index.js"));
|
|
9
|
-
var _common = require("../common.js");
|
|
10
9
|
var _preact = require("preact");
|
|
11
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
buttons: buttons,
|
|
28
|
-
t: this.props.t
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.default = ButtonAttachments;
|
|
11
|
+
function ButtonAttachments(props) {
|
|
12
|
+
let byType = _index.default.get(props.ev, 'by.type');
|
|
13
|
+
if (byType === 'user') return null;
|
|
14
|
+
let buttons = [];
|
|
15
|
+
let attachments = _index.default.get(props.ev, 'data.message.attachments', []);
|
|
16
|
+
_index.default.each(attachments, (att, i) => {
|
|
17
|
+
if (!att || _index.default.get(att, 'type') !== 'button') return;
|
|
18
|
+
_index.default.each(_index.default.get(att, 'buttons') || [], btn => buttons.push(btn));
|
|
19
|
+
});
|
|
20
|
+
return (0, _preact.h)(_Buttons.default, {
|
|
21
|
+
store: props.store,
|
|
22
|
+
buttons: buttons,
|
|
23
|
+
t: props.t
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -3,49 +3,42 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = Buttons;
|
|
7
7
|
var _index = _interopRequireDefault(require("../util/index.js"));
|
|
8
|
-
var _common = require("../common.js");
|
|
9
8
|
var _preact = require("preact");
|
|
10
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return (0, _preact.h)("div", {
|
|
47
|
-
class: "button-attachments"
|
|
48
|
-
}, $buttons);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.default = Buttons;
|
|
10
|
+
function Buttons(props) {
|
|
11
|
+
if (_index.default.size(props.buttons) === 0) return null;
|
|
12
|
+
var $buttons = _index.default.map(props.buttons, (button, index) => {
|
|
13
|
+
if (button.type === 'call_button') {
|
|
14
|
+
return (0, _preact.h)("a", {
|
|
15
|
+
class: "url-button-attachment",
|
|
16
|
+
href: 'tel:' + button.phone_number,
|
|
17
|
+
key: index,
|
|
18
|
+
title: button.title
|
|
19
|
+
}, props.t.i18n(button.i18n_title) || button.title);
|
|
20
|
+
}
|
|
21
|
+
if (button.type === 'url_button') {
|
|
22
|
+
return (0, _preact.h)("a", {
|
|
23
|
+
class: "url-button-attachment",
|
|
24
|
+
href: button.url,
|
|
25
|
+
target: "_blank",
|
|
26
|
+
key: index,
|
|
27
|
+
title: button.title
|
|
28
|
+
}, props.t.i18n(button.i18n_title) || button.title || button.url);
|
|
29
|
+
}
|
|
30
|
+
if (button.type === 'postback_button') {
|
|
31
|
+
return (0, _preact.h)("a", {
|
|
32
|
+
class: "url-button-attachment",
|
|
33
|
+
href: "javascript:;",
|
|
34
|
+
onClick: _ => props.onSelect(button)
|
|
35
|
+
}, props.t.i18n(button.i18n_title) || button.title);
|
|
36
|
+
}
|
|
37
|
+
if (button.type === 'widget_ask_desktop_notify_button') return null;
|
|
38
|
+
if (button.type === 'widget_ask_contact_info_button') return null;
|
|
39
|
+
return null;
|
|
40
|
+
});
|
|
41
|
+
return (0, _preact.h)("div", {
|
|
42
|
+
class: "button-attachments"
|
|
43
|
+
}, $buttons);
|
|
44
|
+
}
|
|
@@ -117,7 +117,11 @@ class ChatButton extends _common.Com {
|
|
|
117
117
|
if (new _index.default.Date().getTime() - this.props.store.matchClosePreviewAt() < Ms30Mins) return;
|
|
118
118
|
let greeting = _index.default.get(accountSetting, 'greeting', {});
|
|
119
119
|
let text = this.props.t.i18n(_index.default.get(greeting, 'greeting', {})) || greeting.message;
|
|
120
|
-
|
|
120
|
+
let enabled = greeting.enabled;
|
|
121
|
+
if (this.props.store.isMobile()) {
|
|
122
|
+
enabled = enabled && !_index.default.get(greeting, 'mobile_disabled');
|
|
123
|
+
}
|
|
124
|
+
if (!text || !enabled) {
|
|
121
125
|
this.setState({
|
|
122
126
|
previewEvent: {}
|
|
123
127
|
});
|
|
@@ -145,7 +145,7 @@ class Rating extends _common.Com {
|
|
|
145
145
|
let foundUser = false;
|
|
146
146
|
_index.default.map(this.props.store.listEvents(this.props.cid), ev => {
|
|
147
147
|
if (!ev || !ev.by) return;
|
|
148
|
-
if (ev.by.type == 'user') foundUser = true;
|
|
148
|
+
if (ev.by.type == 'user' && ev.type == 'message_sent') foundUser = true;
|
|
149
149
|
if (ev.type === 'conversation_state_updated' && _index.default.get(ev, 'data.conversation.state') === 'ended') {
|
|
150
150
|
ended = ev;
|
|
151
151
|
}
|
package/package.json
CHANGED
|
@@ -3,161 +3,98 @@ import {Com} from '../common.js'
|
|
|
3
3
|
import {h} from 'preact'
|
|
4
4
|
|
|
5
5
|
// ['mode', 'tooltipPos', 'agent_ids', 'border'],
|
|
6
|
-
export default
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
render() {
|
|
12
|
-
let accountSetting = this.props.plugin.chatbox
|
|
13
|
-
let acc = this.props.store.matchAccount() || {}
|
|
14
|
-
var tooltippos = this.props.tooltipPos || 'bottom'
|
|
15
|
-
var mode = this.props.mode || 'primary'
|
|
16
|
-
|
|
17
|
-
if (accountSetting && accountSetting.hide_agent_profile) {
|
|
18
|
-
return (
|
|
19
|
-
<div class={`group-avatar group-avatar--${mode}`}>
|
|
20
|
-
<div class='d-inline-block pos-relative' data-tooltip={acc.name} data-tooltip-position={tooltippos}>
|
|
21
|
-
<img
|
|
22
|
-
width={35}
|
|
23
|
-
height={35}
|
|
24
|
-
alt='agent avatar left'
|
|
25
|
-
class='avatar group-avatar--agent-left'
|
|
26
|
-
src={this.props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')}
|
|
27
|
-
/>
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let agentM = this.props.store.matchAgent('*')
|
|
34
|
-
var agents = sb.map(this.props.agent_ids, (id) => agentM[id])
|
|
35
|
-
if (this.props.agent_ids === undefined || sb.size(this.props.agent_ids) === 0) {
|
|
36
|
-
var agids = sb.get(accountSetting, 'header.agent_ids', [])
|
|
37
|
-
agids = sb.filter(agids, (id) => !!agentM[id])
|
|
38
|
-
if (agids.length !== 0) {
|
|
39
|
-
agents = sb.map(agids, (id) => agentM[id])
|
|
40
|
-
} else {
|
|
41
|
-
agents = sb.filter(agentM, (agent) => agent.type === 'agent')
|
|
42
|
-
}
|
|
43
|
-
}
|
|
6
|
+
export default function AgentsAvatar(props) {
|
|
7
|
+
let accountSetting = props.plugin.chatbox
|
|
8
|
+
let acc = props.store.matchAccount() || {}
|
|
9
|
+
var tooltippos = props.tooltipPos || 'bottom'
|
|
10
|
+
var mode = props.mode || 'primary'
|
|
44
11
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
src={this.props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')}
|
|
57
|
-
/>
|
|
58
|
-
</div>
|
|
12
|
+
if (accountSetting && accountSetting.hide_agent_profile) {
|
|
13
|
+
return (
|
|
14
|
+
<div class={`group-avatar group-avatar--${mode}`}>
|
|
15
|
+
<div class='d-inline-block pos-relative' data-tooltip={acc.name} data-tooltip-position={tooltippos}>
|
|
16
|
+
<img
|
|
17
|
+
width={35}
|
|
18
|
+
height={35}
|
|
19
|
+
alt='agent avatar left'
|
|
20
|
+
class='avatar group-avatar--agent-left'
|
|
21
|
+
src={props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')}
|
|
22
|
+
/>
|
|
59
23
|
</div>
|
|
60
|
-
|
|
61
|
-
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
62
27
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
data-tooltip-position={tooltippos}
|
|
73
|
-
>
|
|
74
|
-
<img
|
|
75
|
-
width={35}
|
|
76
|
-
height={35}
|
|
77
|
-
class={`avatar ${groupClass}`}
|
|
78
|
-
alt='agent avatar'
|
|
79
|
-
src={this.props.store.replaceFileUrl(agent.avatar_url) || require('../../assets/img/default_avatar.png')}
|
|
80
|
-
/>
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
)
|
|
28
|
+
let agentM = props.store.matchAgent('*')
|
|
29
|
+
var agents = sb.map(props.agent_ids, (id) => agentM[id])
|
|
30
|
+
if (props.agent_ids === undefined || sb.size(props.agent_ids) === 0) {
|
|
31
|
+
var agids = sb.get(accountSetting, 'header.agent_ids', [])
|
|
32
|
+
agids = sb.filter(agids, (id) => !!agentM[id])
|
|
33
|
+
if (agids.length !== 0) {
|
|
34
|
+
agents = sb.map(agids, (id) => agentM[id])
|
|
35
|
+
} else {
|
|
36
|
+
agents = sb.filter(agentM, (agent) => agent.type === 'agent')
|
|
84
37
|
}
|
|
38
|
+
}
|
|
85
39
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<div class=
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
height={35}
|
|
100
|
-
alt='agent avatar left'
|
|
101
|
-
class='avatar group-avatar--agent-left'
|
|
102
|
-
src={
|
|
103
|
-
this.props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
104
|
-
}
|
|
105
|
-
/>
|
|
106
|
-
</div>
|
|
107
|
-
<div
|
|
108
|
-
class='d-inline-block pos-relative'
|
|
109
|
-
data-tooltip={rightAgent.fullname || acc.name}
|
|
110
|
-
data-tooltip-position={tooltippos}
|
|
111
|
-
>
|
|
112
|
-
<img
|
|
113
|
-
alt='agent avatar right'
|
|
114
|
-
width={35}
|
|
115
|
-
height={35}
|
|
116
|
-
class='avatar group-avatar--agent-right'
|
|
117
|
-
src={
|
|
118
|
-
this.props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
119
|
-
}
|
|
120
|
-
/>
|
|
121
|
-
</div>
|
|
40
|
+
agents = sb.filter(agents, (ag) => !!ag)
|
|
41
|
+
if (agents.length === 0) {
|
|
42
|
+
// use account avatar
|
|
43
|
+
return (
|
|
44
|
+
<div class={`group-avatar group-avatar--${mode}`}>
|
|
45
|
+
<div class='d-inline-block pos-relative' data-tooltip={acc.name} data-tooltip-position={tooltippos}>
|
|
46
|
+
<img
|
|
47
|
+
width={35}
|
|
48
|
+
height={35}
|
|
49
|
+
alt='agent avatar left'
|
|
50
|
+
class='avatar group-avatar--agent-left'
|
|
51
|
+
src={props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')}
|
|
52
|
+
/>
|
|
122
53
|
</div>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// >=3 agent
|
|
54
|
+
</div>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
127
57
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
58
|
+
// 1 agent
|
|
59
|
+
if (agents.length === 1) {
|
|
60
|
+
var agent = agents[0]
|
|
61
|
+
var groupClass = mode === 'primary' ? 'group-avatar--agent-middle' : 'group-avatar--agent-left'
|
|
131
62
|
return (
|
|
132
63
|
<div class={`group-avatar group-avatar--${mode}`}>
|
|
133
64
|
<div
|
|
134
65
|
class='d-inline-block pos-relative'
|
|
135
|
-
data-tooltip={
|
|
66
|
+
data-tooltip={agent.fullname || acc.name}
|
|
136
67
|
data-tooltip-position={tooltippos}
|
|
137
68
|
>
|
|
138
69
|
<img
|
|
139
70
|
width={35}
|
|
140
71
|
height={35}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
src={
|
|
144
|
-
this.props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
145
|
-
}
|
|
72
|
+
class={`avatar ${groupClass}`}
|
|
73
|
+
alt='agent avatar'
|
|
74
|
+
src={props.store.replaceFileUrl(agent.avatar_url) || require('../../assets/img/default_avatar.png')}
|
|
146
75
|
/>
|
|
147
76
|
</div>
|
|
77
|
+
</div>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 2 agent
|
|
82
|
+
if (agents.length === 2) {
|
|
83
|
+
let leftAgent = agents[0]
|
|
84
|
+
let rightAgent = agents[1]
|
|
85
|
+
return (
|
|
86
|
+
<div class={`group-avatar group-avatar--${mode}`}>
|
|
148
87
|
<div
|
|
149
88
|
class='d-inline-block pos-relative'
|
|
150
|
-
data-tooltip={
|
|
89
|
+
data-tooltip={leftAgent.fullname || acc.name}
|
|
151
90
|
data-tooltip-position={tooltippos}
|
|
152
91
|
>
|
|
153
92
|
<img
|
|
154
|
-
alt='agent avatar middle'
|
|
155
93
|
width={35}
|
|
156
94
|
height={35}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
95
|
+
alt='agent avatar left'
|
|
96
|
+
class='avatar group-avatar--agent-left'
|
|
97
|
+
src={props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')}
|
|
161
98
|
/>
|
|
162
99
|
</div>
|
|
163
100
|
<div
|
|
@@ -166,16 +103,63 @@ export default class AgentsAvatar extends Com {
|
|
|
166
103
|
data-tooltip-position={tooltippos}
|
|
167
104
|
>
|
|
168
105
|
<img
|
|
106
|
+
alt='agent avatar right'
|
|
169
107
|
width={35}
|
|
170
108
|
height={35}
|
|
171
|
-
alt='agent avatar right'
|
|
172
109
|
class='avatar group-avatar--agent-right'
|
|
173
|
-
src={
|
|
174
|
-
this.props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')
|
|
175
|
-
}
|
|
110
|
+
src={props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')}
|
|
176
111
|
/>
|
|
177
112
|
</div>
|
|
178
113
|
</div>
|
|
179
114
|
)
|
|
180
115
|
}
|
|
116
|
+
|
|
117
|
+
// >=3 agent
|
|
118
|
+
|
|
119
|
+
let leftAgent = agents[0]
|
|
120
|
+
let middleAgent = agents[1]
|
|
121
|
+
let rightAgent = agents[2]
|
|
122
|
+
return (
|
|
123
|
+
<div class={`group-avatar group-avatar--${mode}`}>
|
|
124
|
+
<div
|
|
125
|
+
class='d-inline-block pos-relative'
|
|
126
|
+
data-tooltip={leftAgent.fullname || acc.name}
|
|
127
|
+
data-tooltip-position={tooltippos}
|
|
128
|
+
>
|
|
129
|
+
<img
|
|
130
|
+
width={35}
|
|
131
|
+
height={35}
|
|
132
|
+
alt='agent avatar left'
|
|
133
|
+
class='avatar group-avatar--agent-left'
|
|
134
|
+
src={props.store.replaceFileUrl(leftAgent.avatar_url) || require('../../assets/img/default_avatar.png')}
|
|
135
|
+
/>
|
|
136
|
+
</div>
|
|
137
|
+
<div
|
|
138
|
+
class='d-inline-block pos-relative'
|
|
139
|
+
data-tooltip={middleAgent.fullname || acc.name}
|
|
140
|
+
data-tooltip-position={tooltippos}
|
|
141
|
+
>
|
|
142
|
+
<img
|
|
143
|
+
alt='agent avatar middle'
|
|
144
|
+
width={35}
|
|
145
|
+
height={35}
|
|
146
|
+
class='avatar group-avatar--agent-middle'
|
|
147
|
+
src={props.store.replaceFileUrl(middleAgent.avatar_url) || require('../../assets/img/default_avatar.png')}
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
<div
|
|
151
|
+
class='d-inline-block pos-relative'
|
|
152
|
+
data-tooltip={rightAgent.fullname || acc.name}
|
|
153
|
+
data-tooltip-position={tooltippos}
|
|
154
|
+
>
|
|
155
|
+
<img
|
|
156
|
+
width={35}
|
|
157
|
+
height={35}
|
|
158
|
+
alt='agent avatar right'
|
|
159
|
+
class='avatar group-avatar--agent-right'
|
|
160
|
+
src={props.store.replaceFileUrl(rightAgent.avatar_url) || require('../../assets/img/default_avatar.png')}
|
|
161
|
+
/>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
)
|
|
181
165
|
}
|
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
import Buttons from './Buttons.js'
|
|
2
2
|
import sb from '../util/index.js'
|
|
3
|
-
import {
|
|
4
|
-
import { h } from 'preact'
|
|
3
|
+
import {h} from 'preact'
|
|
5
4
|
|
|
6
|
-
export default
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export default function ButtonAttachments(props) {
|
|
6
|
+
// dont support user sent button yet
|
|
7
|
+
let byType = sb.get(props.ev, 'by.type')
|
|
8
|
+
if (byType === 'user') return null
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
// filter out all button
|
|
11
|
+
let buttons = []
|
|
12
|
+
let attachments = sb.get(props.ev, 'data.message.attachments', [])
|
|
13
|
+
sb.each(attachments, (att, i) => {
|
|
14
|
+
if (!att || sb.get(att, 'type') !== 'button') return
|
|
15
|
+
sb.each(sb.get(att, 'buttons') || [], (btn) => buttons.push(btn))
|
|
16
|
+
})
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
let buttons = []
|
|
18
|
-
let attachments = sb.get(this.props.ev, 'data.message.attachments', [])
|
|
19
|
-
sb.each(attachments, (att, i) => {
|
|
20
|
-
if (!att || sb.get(att, 'type') !== 'button') return
|
|
21
|
-
sb.each(sb.get(att, 'buttons') || [], btn => buttons.push(btn))
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
return <Buttons store={this.props.store} buttons={buttons} t={this.props.t}/>
|
|
25
|
-
}
|
|
18
|
+
return <Buttons store={props.store} buttons={buttons} t={props.t} />
|
|
26
19
|
}
|
package/src/chatbox/Buttons.js
CHANGED
|
@@ -1,44 +1,36 @@
|
|
|
1
1
|
import sb from '../util/index.js'
|
|
2
|
-
import {Com} from '../common.js'
|
|
3
2
|
import {h} from 'preact'
|
|
4
3
|
|
|
5
|
-
export default
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export default function Buttons(props) {
|
|
5
|
+
if (sb.size(props.buttons) === 0) return null
|
|
6
|
+
var $buttons = sb.map(props.buttons, (button, index) => {
|
|
7
|
+
if (button.type === 'call_button') {
|
|
8
|
+
return (
|
|
9
|
+
<a class='url-button-attachment' href={'tel:' + button.phone_number} key={index} title={button.title}>
|
|
10
|
+
{props.t.i18n(button.i18n_title) || button.title}
|
|
11
|
+
</a>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
</a>
|
|
18
|
-
)
|
|
19
|
-
}
|
|
15
|
+
if (button.type === 'url_button') {
|
|
16
|
+
return (
|
|
17
|
+
<a class='url-button-attachment' href={button.url} target='_blank' key={index} title={button.title}>
|
|
18
|
+
{props.t.i18n(button.i18n_title) || button.title || button.url}
|
|
19
|
+
</a>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
if (button.type === 'postback_button') {
|
|
24
|
+
return (
|
|
25
|
+
<a class='url-button-attachment' href='javascript:;' onClick={(_) => props.onSelect(button)}>
|
|
26
|
+
{props.t.i18n(button.i18n_title) || button.title}
|
|
27
|
+
</a>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (button.type === 'widget_ask_desktop_notify_button') return null
|
|
38
|
-
if (button.type === 'widget_ask_contact_info_button') return null
|
|
39
|
-
return null
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
return <div class='button-attachments'>{$buttons}</div>
|
|
43
|
-
}
|
|
31
|
+
if (button.type === 'widget_ask_desktop_notify_button') return null
|
|
32
|
+
if (button.type === 'widget_ask_contact_info_button') return null
|
|
33
|
+
return null
|
|
34
|
+
})
|
|
35
|
+
return <div class='button-attachments'>{$buttons}</div>
|
|
44
36
|
}
|
|
@@ -128,7 +128,12 @@ export default class ChatButton extends Com {
|
|
|
128
128
|
|
|
129
129
|
let greeting = sb.get(accountSetting, 'greeting', {})
|
|
130
130
|
let text = this.props.t.i18n(sb.get(greeting, 'greeting', {})) || greeting.message
|
|
131
|
-
|
|
131
|
+
|
|
132
|
+
let enabled = greeting.enabled
|
|
133
|
+
if (this.props.store.isMobile()) {
|
|
134
|
+
enabled = enabled && !sb.get(greeting, 'mobile_disabled')
|
|
135
|
+
}
|
|
136
|
+
if (!text || !enabled) {
|
|
132
137
|
this.setState({previewEvent: {}})
|
|
133
138
|
return
|
|
134
139
|
}
|
package/src/chatbox/Rating.js
CHANGED
|
@@ -121,7 +121,7 @@ export default class Rating extends Com {
|
|
|
121
121
|
let foundUser = false
|
|
122
122
|
sb.map(this.props.store.listEvents(this.props.cid), (ev) => {
|
|
123
123
|
if (!ev || !ev.by) return
|
|
124
|
-
if (ev.by.type == 'user') foundUser = true
|
|
124
|
+
if (ev.by.type == 'user' && ev.type == 'message_sent') foundUser = true
|
|
125
125
|
if (ev.type === 'conversation_state_updated' && sb.get(ev, 'data.conversation.state') === 'ended') {
|
|
126
126
|
ended = ev
|
|
127
127
|
}
|