@atlaskit/profilecard 19.23.0 → 19.25.0
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/CHANGELOG.md +23 -0
- package/dist/cjs/client/ProfileCardClient.js +12 -0
- package/dist/cjs/client/RovoAgentCardClient.js +131 -9
- package/dist/cjs/client/getTeamFromAGG.js +1 -1
- package/dist/cjs/components/Agent/Actions.js +4 -3
- package/dist/cjs/components/Agent/AgentDeleteConfirmationModal.js +9 -9
- package/dist/cjs/components/Agent/AgentProfileCard.js +89 -39
- package/dist/cjs/components/Agent/AgentProfileCardResourced.js +3 -1
- package/dist/cjs/components/Agent/AgentProfileCardTrigger.js +4 -2
- package/dist/cjs/components/Agent/messages.js +29 -0
- package/dist/cjs/components/User/ProfileCardTrigger.js +6 -3
- package/dist/cjs/components/common/ProfileCardTrigger.js +13 -25
- package/dist/cjs/util/analytics.js +3 -3
- package/dist/cjs/util/rovoAgentUtils.js +1 -15
- package/dist/es2019/client/ProfileCardClient.js +8 -0
- package/dist/es2019/client/RovoAgentCardClient.js +103 -6
- package/dist/es2019/client/getTeamFromAGG.js +1 -1
- package/dist/es2019/components/Agent/Actions.js +4 -3
- package/dist/es2019/components/Agent/AgentDeleteConfirmationModal.js +9 -9
- package/dist/es2019/components/Agent/AgentProfileCard.js +50 -23
- package/dist/es2019/components/Agent/AgentProfileCardResourced.js +3 -1
- package/dist/es2019/components/Agent/AgentProfileCardTrigger.js +4 -2
- package/dist/es2019/components/Agent/messages.js +23 -0
- package/dist/es2019/components/User/ProfileCardTrigger.js +6 -3
- package/dist/es2019/components/common/ProfileCardTrigger.js +2 -2
- package/dist/es2019/util/analytics.js +2 -2
- package/dist/es2019/util/rovoAgentUtils.js +0 -12
- package/dist/esm/client/ProfileCardClient.js +12 -0
- package/dist/esm/client/RovoAgentCardClient.js +131 -9
- package/dist/esm/client/getTeamFromAGG.js +1 -1
- package/dist/esm/components/Agent/Actions.js +4 -3
- package/dist/esm/components/Agent/AgentDeleteConfirmationModal.js +9 -9
- package/dist/esm/components/Agent/AgentProfileCard.js +90 -40
- package/dist/esm/components/Agent/AgentProfileCardResourced.js +3 -1
- package/dist/esm/components/Agent/AgentProfileCardTrigger.js +4 -2
- package/dist/esm/components/Agent/messages.js +23 -0
- package/dist/esm/components/User/ProfileCardTrigger.js +6 -3
- package/dist/esm/components/common/ProfileCardTrigger.js +13 -25
- package/dist/esm/util/analytics.js +3 -3
- package/dist/esm/util/rovoAgentUtils.js +0 -13
- package/dist/types/client/ProfileCardClient.d.ts +2 -0
- package/dist/types/client/RovoAgentCardClient.d.ts +2 -0
- package/dist/types/components/Agent/Actions.d.ts +3 -1
- package/dist/types/components/Agent/AgentProfileCard.d.ts +2 -11
- package/dist/types/components/Agent/AgentProfileCardResourced.d.ts +2 -1
- package/dist/types/components/Agent/lazyAgentProfileCard.d.ts +1 -9
- package/dist/types/components/Agent/messages.d.ts +22 -0
- package/dist/types/components/common/LoadingState.d.ts +2 -1
- package/dist/types/components/common/types.d.ts +2 -2
- package/dist/types/types.d.ts +31 -1
- package/dist/types/util/analytics.d.ts +6 -5
- package/dist/types/util/rovoAgentUtils.d.ts +0 -1
- package/dist/types-ts4.5/client/ProfileCardClient.d.ts +2 -0
- package/dist/types-ts4.5/client/RovoAgentCardClient.d.ts +2 -0
- package/dist/types-ts4.5/components/Agent/Actions.d.ts +3 -1
- package/dist/types-ts4.5/components/Agent/AgentProfileCard.d.ts +2 -11
- package/dist/types-ts4.5/components/Agent/AgentProfileCardResourced.d.ts +2 -1
- package/dist/types-ts4.5/components/Agent/lazyAgentProfileCard.d.ts +1 -9
- package/dist/types-ts4.5/components/Agent/messages.d.ts +22 -0
- package/dist/types-ts4.5/components/common/LoadingState.d.ts +2 -1
- package/dist/types-ts4.5/components/common/types.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +31 -1
- package/dist/types-ts4.5/util/analytics.d.ts +6 -5
- package/dist/types-ts4.5/util/rovoAgentUtils.d.ts +0 -1
- package/package.json +4 -8
- package/dist/cjs/client/getAgentInfo.js +0 -66
- package/dist/cjs/components/Agent/hooks/useDeleteAgent.js +0 -70
- package/dist/cjs/components/Agent/hooks/useSetFavouriteAgent.js +0 -91
- package/dist/es2019/client/getAgentInfo.js +0 -21
- package/dist/es2019/components/Agent/hooks/useDeleteAgent.js +0 -33
- package/dist/es2019/components/Agent/hooks/useSetFavouriteAgent.js +0 -48
- package/dist/esm/client/getAgentInfo.js +0 -58
- package/dist/esm/components/Agent/hooks/useDeleteAgent.js +0 -63
- package/dist/esm/components/Agent/hooks/useSetFavouriteAgent.js +0 -84
- package/dist/types/client/getAgentInfo.d.ts +0 -3
- package/dist/types/components/Agent/hooks/useDeleteAgent.d.ts +0 -8
- package/dist/types/components/Agent/hooks/useSetFavouriteAgent.d.ts +0 -10
- package/dist/types-ts4.5/client/getAgentInfo.d.ts +0 -3
- package/dist/types-ts4.5/components/Agent/hooks/useDeleteAgent.d.ts +0 -8
- package/dist/types-ts4.5/components/Agent/hooks/useSetFavouriteAgent.d.ts +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/profilecard
|
|
2
2
|
|
|
3
|
+
## 19.25.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#134139](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/134139)
|
|
8
|
+
[`6cb20b026ce66`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6cb20b026ce66) -
|
|
9
|
+
Set start count after making agent favourite
|
|
10
|
+
- [#135893](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/135893)
|
|
11
|
+
[`089338b763495`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/089338b763495) -
|
|
12
|
+
Show agents in team profile
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
18
|
+
## 19.24.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- [#135350](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/135350)
|
|
23
|
+
[`e22e1c78bb96d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e22e1c78bb96d) -
|
|
24
|
+
[ux] Move api call to agent clients
|
|
25
|
+
|
|
3
26
|
## 19.23.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
|
@@ -79,6 +79,18 @@ var ProfileCardClient = /*#__PURE__*/function () {
|
|
|
79
79
|
var _this$rovoAgentClient2;
|
|
80
80
|
return (_this$rovoAgentClient2 = this.rovoAgentClient) === null || _this$rovoAgentClient2 === void 0 ? void 0 : _this$rovoAgentClient2.getProfile(id, analytics);
|
|
81
81
|
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "deleteAgent",
|
|
84
|
+
value: function deleteAgent(id, analytics) {
|
|
85
|
+
var _this$rovoAgentClient3;
|
|
86
|
+
return (_this$rovoAgentClient3 = this.rovoAgentClient) === null || _this$rovoAgentClient3 === void 0 ? void 0 : _this$rovoAgentClient3.deleteAgent(id, analytics);
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
key: "setFavouriteAgent",
|
|
90
|
+
value: function setFavouriteAgent(id, isFavourite, analytics) {
|
|
91
|
+
var _this$rovoAgentClient4;
|
|
92
|
+
return (_this$rovoAgentClient4 = this.rovoAgentClient) === null || _this$rovoAgentClient4 === void 0 ? void 0 : _this$rovoAgentClient4.setFavouriteAgent(id, isFavourite, analytics);
|
|
93
|
+
}
|
|
82
94
|
}]);
|
|
83
95
|
return ProfileCardClient;
|
|
84
96
|
}();
|
|
@@ -5,21 +5,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
9
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
12
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
16
|
var _analytics = require("../util/analytics");
|
|
15
17
|
var _performance = require("../util/performance");
|
|
16
18
|
var _CachingClient2 = _interopRequireDefault(require("./CachingClient"));
|
|
17
19
|
var _errorUtils = require("./errorUtils");
|
|
18
|
-
var _getAgentInfo = require("./getAgentInfo");
|
|
19
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
20
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
22
21
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
22
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
|
+
var createHeaders = function createHeaders(product, cloudId) {
|
|
25
|
+
var config = {
|
|
26
|
+
headers: {
|
|
27
|
+
'X-Product': product,
|
|
28
|
+
'X-Experience-Id': 'profile-card',
|
|
29
|
+
'X-Cloudid': cloudId || ''
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return new Headers(_objectSpread({}, config.headers || {}));
|
|
33
|
+
};
|
|
23
34
|
var RovoAgentCardClient = exports.default = /*#__PURE__*/function (_CachingClient) {
|
|
24
35
|
(0, _inherits2.default)(RovoAgentCardClient, _CachingClient);
|
|
25
36
|
var _super = _createSuper(RovoAgentCardClient);
|
|
@@ -33,17 +44,33 @@ var RovoAgentCardClient = exports.default = /*#__PURE__*/function (_CachingClien
|
|
|
33
44
|
(0, _createClass2.default)(RovoAgentCardClient, [{
|
|
34
45
|
key: "makeRequest",
|
|
35
46
|
value: function makeRequest(id, cloudId) {
|
|
47
|
+
var product = this.options.productIdentifier || 'rovo';
|
|
48
|
+
var headers = createHeaders(product, this.options.cloudId);
|
|
36
49
|
if (id.type === 'identity') {
|
|
37
|
-
return (
|
|
50
|
+
return fetch(new Request("/gateway/api/assist/agents/v1/accountid/".concat(id.value), {
|
|
51
|
+
method: 'GET',
|
|
52
|
+
credentials: 'include',
|
|
53
|
+
mode: 'cors',
|
|
54
|
+
headers: headers
|
|
55
|
+
})).then(function (response) {
|
|
56
|
+
return response.json();
|
|
57
|
+
});
|
|
38
58
|
}
|
|
39
|
-
return (
|
|
59
|
+
return fetch(new Request("/gateway/api/assist/agents/v1/".concat(id.value), {
|
|
60
|
+
method: 'GET',
|
|
61
|
+
credentials: 'include',
|
|
62
|
+
mode: 'cors',
|
|
63
|
+
headers: headers
|
|
64
|
+
})).then(function (response) {
|
|
65
|
+
return response.json();
|
|
66
|
+
});
|
|
40
67
|
}
|
|
41
68
|
}, {
|
|
42
69
|
key: "getProfile",
|
|
43
70
|
value: function getProfile(id, analytics) {
|
|
44
71
|
var _this2 = this;
|
|
45
72
|
if (!id.value) {
|
|
46
|
-
return Promise.reject(new Error('
|
|
73
|
+
return Promise.reject(new Error('Id is missing'));
|
|
47
74
|
}
|
|
48
75
|
if (!this.options.cloudId) {
|
|
49
76
|
return Promise.reject(new Error('cloudId is missing'));
|
|
@@ -62,7 +89,7 @@ var RovoAgentCardClient = exports.default = /*#__PURE__*/function (_CachingClien
|
|
|
62
89
|
_this2.setCachedProfile(id.value, data);
|
|
63
90
|
}
|
|
64
91
|
if (analytics) {
|
|
65
|
-
analytics((0, _analytics.agentRequestAnalytics)('succeeded', {
|
|
92
|
+
analytics((0, _analytics.agentRequestAnalytics)('succeeded', 'request', {
|
|
66
93
|
duration: (0, _performance.getPageTime)() - startTime,
|
|
67
94
|
gateway: true
|
|
68
95
|
}));
|
|
@@ -70,7 +97,7 @@ var RovoAgentCardClient = exports.default = /*#__PURE__*/function (_CachingClien
|
|
|
70
97
|
resolve(data);
|
|
71
98
|
}).catch(function (error) {
|
|
72
99
|
if (analytics) {
|
|
73
|
-
analytics((0, _analytics.agentRequestAnalytics)('failed', _objectSpread(_objectSpread({
|
|
100
|
+
analytics((0, _analytics.agentRequestAnalytics)('failed', 'request', _objectSpread(_objectSpread({
|
|
74
101
|
duration: (0, _performance.getPageTime)() - startTime
|
|
75
102
|
}, (0, _errorUtils.getErrorAttributes)(error)), {}, {
|
|
76
103
|
gateway: true
|
|
@@ -80,6 +107,101 @@ var RovoAgentCardClient = exports.default = /*#__PURE__*/function (_CachingClien
|
|
|
80
107
|
});
|
|
81
108
|
});
|
|
82
109
|
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "deleteAgent",
|
|
112
|
+
value: function deleteAgent(agentId, analytics) {
|
|
113
|
+
var _this3 = this;
|
|
114
|
+
if (!this.options.cloudId) {
|
|
115
|
+
return Promise.reject(new Error('cloudId is missing'));
|
|
116
|
+
}
|
|
117
|
+
return new Promise(function (resolve, reject) {
|
|
118
|
+
var startTime = (0, _performance.getPageTime)();
|
|
119
|
+
var product = _this3.options.productIdentifier || 'rovo';
|
|
120
|
+
if (analytics) {
|
|
121
|
+
analytics((0, _analytics.agentRequestAnalytics)('triggered'));
|
|
122
|
+
}
|
|
123
|
+
var headers = createHeaders(product, _this3.options.cloudId);
|
|
124
|
+
fetch(new Request("/gateway/api/assist/agents/v1/".concat(agentId), {
|
|
125
|
+
method: 'DELETE',
|
|
126
|
+
credentials: 'include',
|
|
127
|
+
mode: 'cors',
|
|
128
|
+
headers: headers
|
|
129
|
+
})).then(function () {
|
|
130
|
+
if (analytics) {
|
|
131
|
+
analytics((0, _analytics.agentRequestAnalytics)('succeeded', 'deleteAgent', {
|
|
132
|
+
duration: (0, _performance.getPageTime)() - startTime,
|
|
133
|
+
gateway: true
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
resolve();
|
|
137
|
+
}).catch(function (error) {
|
|
138
|
+
if (analytics) {
|
|
139
|
+
analytics((0, _analytics.agentRequestAnalytics)('failed', 'deleteAgent', _objectSpread(_objectSpread({
|
|
140
|
+
duration: (0, _performance.getPageTime)() - startTime
|
|
141
|
+
}, (0, _errorUtils.getErrorAttributes)(error)), {}, {
|
|
142
|
+
gateway: true
|
|
143
|
+
})));
|
|
144
|
+
}
|
|
145
|
+
reject(error);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}, {
|
|
150
|
+
key: "setFavouriteAgent",
|
|
151
|
+
value: function setFavouriteAgent(agentId, isFavourite, analytics) {
|
|
152
|
+
var _this4 = this;
|
|
153
|
+
if (!this.options.cloudId) {
|
|
154
|
+
return Promise.reject(new Error('cloudId is missing'));
|
|
155
|
+
}
|
|
156
|
+
return new Promise( /*#__PURE__*/function () {
|
|
157
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(resolve, reject) {
|
|
158
|
+
var startTime, product, actionSubjectId, requestMethod, headers;
|
|
159
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
160
|
+
while (1) switch (_context.prev = _context.next) {
|
|
161
|
+
case 0:
|
|
162
|
+
startTime = (0, _performance.getPageTime)();
|
|
163
|
+
product = _this4.options.productIdentifier || 'rovo';
|
|
164
|
+
actionSubjectId = isFavourite ? 'favourite' : 'unfavourite';
|
|
165
|
+
requestMethod = isFavourite ? 'POST' : 'DELETE';
|
|
166
|
+
if (analytics) {
|
|
167
|
+
analytics((0, _analytics.agentRequestAnalytics)('triggered', 'actionSubjectId'));
|
|
168
|
+
}
|
|
169
|
+
headers = createHeaders(product, _this4.options.cloudId);
|
|
170
|
+
_context.next = 8;
|
|
171
|
+
return fetch(new Request("/gateway/api/assist/agents/v1/".concat(agentId, "/favourite"), {
|
|
172
|
+
method: requestMethod,
|
|
173
|
+
credentials: 'include',
|
|
174
|
+
mode: 'cors',
|
|
175
|
+
headers: headers
|
|
176
|
+
})).then(function () {
|
|
177
|
+
if (analytics) {
|
|
178
|
+
analytics((0, _analytics.agentRequestAnalytics)('succeeded', actionSubjectId, {
|
|
179
|
+
duration: (0, _performance.getPageTime)() - startTime,
|
|
180
|
+
gateway: true
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
resolve();
|
|
184
|
+
}).catch(function (error) {
|
|
185
|
+
if (analytics) {
|
|
186
|
+
analytics((0, _analytics.agentRequestAnalytics)('failed', actionSubjectId, _objectSpread(_objectSpread({
|
|
187
|
+
duration: (0, _performance.getPageTime)() - startTime
|
|
188
|
+
}, (0, _errorUtils.getErrorAttributes)(error)), {}, {
|
|
189
|
+
gateway: true
|
|
190
|
+
})));
|
|
191
|
+
}
|
|
192
|
+
reject(error);
|
|
193
|
+
});
|
|
194
|
+
case 8:
|
|
195
|
+
case "end":
|
|
196
|
+
return _context.stop();
|
|
197
|
+
}
|
|
198
|
+
}, _callee);
|
|
199
|
+
}));
|
|
200
|
+
return function (_x, _x2) {
|
|
201
|
+
return _ref.apply(this, arguments);
|
|
202
|
+
};
|
|
203
|
+
}());
|
|
204
|
+
}
|
|
83
205
|
}]);
|
|
84
206
|
return RovoAgentCardClient;
|
|
85
207
|
}(_CachingClient2.default);
|
|
@@ -57,7 +57,7 @@ var addHeaders = exports.addHeaders = function addHeaders(headers) {
|
|
|
57
57
|
headers.append('X-ExperimentalApi', 'teams-beta');
|
|
58
58
|
headers.append('X-ExperimentalApi', 'team-members-beta');
|
|
59
59
|
headers.append('atl-client-name', "@atlaskit/profilecard");
|
|
60
|
-
headers.append('atl-client-version', "19.
|
|
60
|
+
headers.append('atl-client-version', "19.25.0");
|
|
61
61
|
return headers;
|
|
62
62
|
};
|
|
63
63
|
function getTeamFromAGG(_x, _x2, _x3) {
|
|
@@ -78,7 +78,8 @@ var AgentActions = exports.AgentActions = function AgentActions(_ref3) {
|
|
|
78
78
|
onDeleteAgent = _ref3.onDeleteAgent,
|
|
79
79
|
onDuplicateAgent = _ref3.onDuplicateAgent,
|
|
80
80
|
onCopyAgent = _ref3.onCopyAgent,
|
|
81
|
-
onChatClick = _ref3.onChatClick
|
|
81
|
+
onChatClick = _ref3.onChatClick,
|
|
82
|
+
agent = _ref3.agent;
|
|
82
83
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
83
84
|
formatMessage = _useIntl.formatMessage;
|
|
84
85
|
var _useState = (0, _react.useState)(false),
|
|
@@ -159,8 +160,8 @@ var AgentActions = exports.AgentActions = function AgentActions(_ref3) {
|
|
|
159
160
|
setIsDeleteModalOpen(false);
|
|
160
161
|
},
|
|
161
162
|
onSubmit: onDeleteAgent,
|
|
162
|
-
agentId:
|
|
163
|
-
agentName:
|
|
163
|
+
agentId: agent.id,
|
|
164
|
+
agentName: agent.name
|
|
164
165
|
}));
|
|
165
166
|
};
|
|
166
167
|
var messages = (0, _reactIntlNext.defineMessages)({
|
|
@@ -59,45 +59,45 @@ var AgentDeleteConfirmationModal = exports.AgentDeleteConfirmationModal = functi
|
|
|
59
59
|
};
|
|
60
60
|
var messages = (0, _reactIntlNext.defineMessages)({
|
|
61
61
|
cancelText: {
|
|
62
|
-
id: '
|
|
62
|
+
id: 'profilecard.agent-profile.agent-delete-confirm.cancel-text',
|
|
63
63
|
defaultMessage: 'Cancel'
|
|
64
64
|
},
|
|
65
65
|
confirmText: {
|
|
66
|
-
id: '
|
|
66
|
+
id: 'profilecard.agent-profile.agent-delete-confirm.confirm-text',
|
|
67
67
|
defaultMessage: 'Delete'
|
|
68
68
|
},
|
|
69
69
|
title: {
|
|
70
|
-
id: '
|
|
70
|
+
id: 'profilecard.agent-profile.delete-agent-confirm-title',
|
|
71
71
|
defaultMessage: 'Delete "{agentName}"?',
|
|
72
72
|
description: 'Title text for the delete agent confirmation modal'
|
|
73
73
|
},
|
|
74
74
|
body: {
|
|
75
|
-
id: '
|
|
75
|
+
id: 'profilecard.agent-profile.delete-agent-confirm-body',
|
|
76
76
|
defaultMessage: "Are you sure you want to delete this agent? This action cannot be undone.",
|
|
77
77
|
description: 'Body text for the delete agent confirmation modal'
|
|
78
78
|
},
|
|
79
79
|
error: {
|
|
80
|
-
id: '
|
|
80
|
+
id: 'profilecard.agent-profile.delete-agent-error',
|
|
81
81
|
defaultMessage: 'Could not delete agent',
|
|
82
82
|
description: 'Error message displayed when an agent cannot be deleted'
|
|
83
83
|
},
|
|
84
84
|
errorAgentNotFound: {
|
|
85
|
-
id: '
|
|
85
|
+
id: 'profilecard.agent-profile.delete-agent-error.agent-not-found',
|
|
86
86
|
defaultMessage: 'That agent could not be found.',
|
|
87
87
|
description: 'Error message displayed when an agent cannot be found'
|
|
88
88
|
},
|
|
89
89
|
errorAgentInUse: {
|
|
90
|
-
id: '
|
|
90
|
+
id: 'profilecard.agent-profile.delete-agent-error.agent-in-use',
|
|
91
91
|
defaultMessage: 'Agent is currently in use. Try again later.',
|
|
92
92
|
description: 'Error message displayed when an agent is in use'
|
|
93
93
|
},
|
|
94
94
|
errorIncorrectOwner: {
|
|
95
|
-
id: '
|
|
95
|
+
id: 'profilecard.agent-profile.delete-agent-error.incorrect-owner',
|
|
96
96
|
defaultMessage: 'You cannot delete agents you have not created yourself. Please contact the agent owner.',
|
|
97
97
|
description: 'Error message displayed when the agent owner is incorrect'
|
|
98
98
|
},
|
|
99
99
|
agentDeletedSuccess: {
|
|
100
|
-
id: '
|
|
100
|
+
id: 'profilecard.agent-profile.delete-agent-success',
|
|
101
101
|
defaultMessage: 'Agent has been deleted!',
|
|
102
102
|
description: 'Success message displayed when an agent is deleted'
|
|
103
103
|
}
|
|
@@ -8,7 +8,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _reactIntlNext = require("react-intl-next");
|
|
12
14
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
13
15
|
var _primitives = require("@atlaskit/primitives");
|
|
14
16
|
var _rovoAgentComponents = require("@atlaskit/rovo-agent-components");
|
|
@@ -19,8 +21,7 @@ var _Actions = require("./Actions");
|
|
|
19
21
|
var _AgentProfileCardWrapper = require("./AgentProfileCardWrapper");
|
|
20
22
|
var _ConversationStarters = require("./ConversationStarters");
|
|
21
23
|
var _useAgentActions = require("./hooks/useAgentActions");
|
|
22
|
-
var
|
|
23
|
-
var _useSetFavouriteAgent2 = require("./hooks/useSetFavouriteAgent");
|
|
24
|
+
var _messages = require("./messages");
|
|
24
25
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
25
26
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
27
|
var styles = (0, _primitives.xcss)({
|
|
@@ -48,7 +49,9 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
|
48
49
|
product = _ref$product === void 0 ? 'rovo' : _ref$product,
|
|
49
50
|
hasError = _ref.hasError,
|
|
50
51
|
errorType = _ref.errorType,
|
|
51
|
-
onConversationStartersClick = _ref.onConversationStartersClick
|
|
52
|
+
onConversationStartersClick = _ref.onConversationStartersClick,
|
|
53
|
+
resourceClient = _ref.resourceClient,
|
|
54
|
+
addFlag = _ref.addFlag;
|
|
52
55
|
var _useAgentUrlActions = (0, _useAgentActions.useAgentUrlActions)({
|
|
53
56
|
cloudId: cloudId || ''
|
|
54
57
|
}),
|
|
@@ -57,19 +60,20 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
|
57
60
|
_onDuplicateAgent = _useAgentUrlActions.onDuplicateAgent,
|
|
58
61
|
onOpenChatFullScreecn = _useAgentUrlActions.onOpenChat,
|
|
59
62
|
onConversationStarter = _useAgentUrlActions.onConversationStarter;
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
var _useState = (0, _react.useState)(false),
|
|
64
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
65
|
+
isStarred = _useState2[0],
|
|
66
|
+
setIsStarred = _useState2[1];
|
|
67
|
+
var _useState3 = (0, _react.useState)(),
|
|
68
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
69
|
+
starCount = _useState4[0],
|
|
70
|
+
setStarCount = _useState4[1];
|
|
71
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
72
|
+
formatMessage = _useIntl.formatMessage;
|
|
73
|
+
(0, _react.useEffect)(function () {
|
|
74
|
+
setIsStarred(!!(agent !== null && agent !== void 0 && agent.favourite));
|
|
75
|
+
setStarCount(agent === null || agent === void 0 ? void 0 : agent.favourite_count);
|
|
76
|
+
}, [agent === null || agent === void 0 ? void 0 : agent.favourite, agent === null || agent === void 0 ? void 0 : agent.favourite_count]);
|
|
73
77
|
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
74
78
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
75
79
|
var fireAnalytics = (0, _react.useCallback)(function (payload) {
|
|
@@ -77,27 +81,72 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
|
77
81
|
(0, _analytics.fireEvent)(createAnalyticsEvent, payload);
|
|
78
82
|
}
|
|
79
83
|
}, [createAnalyticsEvent]);
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
84
|
+
var handleSetFavourite = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
85
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
86
|
+
while (1) switch (_context.prev = _context.next) {
|
|
87
|
+
case 0:
|
|
88
|
+
if (!(agent !== null && agent !== void 0 && agent.id)) {
|
|
89
|
+
_context.next = 10;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
_context.prev = 1;
|
|
93
|
+
_context.next = 4;
|
|
94
|
+
return resourceClient.setFavouriteAgent(agent.id, !isStarred, fireAnalytics);
|
|
95
|
+
case 4:
|
|
96
|
+
if (isStarred) {
|
|
97
|
+
setStarCount(starCount ? starCount - 1 : 0);
|
|
98
|
+
} else {
|
|
99
|
+
setStarCount((starCount || 0) + 1);
|
|
100
|
+
}
|
|
101
|
+
setIsStarred(!isStarred);
|
|
102
|
+
_context.next = 10;
|
|
103
|
+
break;
|
|
104
|
+
case 8:
|
|
105
|
+
_context.prev = 8;
|
|
106
|
+
_context.t0 = _context["catch"](1);
|
|
107
|
+
case 10:
|
|
108
|
+
case "end":
|
|
109
|
+
return _context.stop();
|
|
110
|
+
}
|
|
111
|
+
}, _callee, null, [[1, 8]]);
|
|
112
|
+
})), [agent === null || agent === void 0 ? void 0 : agent.id, fireAnalytics, isStarred, resourceClient, starCount]);
|
|
113
|
+
var handleOnDelete = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
114
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
115
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
116
|
+
case 0:
|
|
117
|
+
if (!agent) {
|
|
118
|
+
_context2.next = 10;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
_context2.prev = 1;
|
|
122
|
+
_context2.next = 4;
|
|
123
|
+
return resourceClient.deleteAgent(agent.id, fireAnalytics);
|
|
124
|
+
case 4:
|
|
125
|
+
addFlag === null || addFlag === void 0 || addFlag({
|
|
126
|
+
title: formatMessage(_messages.messages.agentDeletedSuccessFlagTitle),
|
|
127
|
+
description: formatMessage(_messages.messages.agentDeletedSuccessFlagDescription, {
|
|
128
|
+
agentName: agent.name
|
|
129
|
+
}),
|
|
130
|
+
type: 'success',
|
|
131
|
+
id: 'ptc-directory.agent-profile.delete-agent-success'
|
|
132
|
+
});
|
|
133
|
+
_context2.next = 10;
|
|
134
|
+
break;
|
|
135
|
+
case 7:
|
|
136
|
+
_context2.prev = 7;
|
|
137
|
+
_context2.t0 = _context2["catch"](1);
|
|
138
|
+
addFlag === null || addFlag === void 0 || addFlag({
|
|
139
|
+
title: formatMessage(_messages.messages.agentDeletedErrorFlagTitle),
|
|
140
|
+
description: formatMessage(_messages.messages.agentDeletedErrorFlagDescription),
|
|
141
|
+
type: 'error',
|
|
142
|
+
id: 'ptc-directory.agent-profile.delete-agent-error'
|
|
143
|
+
});
|
|
144
|
+
case 10:
|
|
145
|
+
case "end":
|
|
146
|
+
return _context2.stop();
|
|
147
|
+
}
|
|
148
|
+
}, _callee2, null, [[1, 7]]);
|
|
149
|
+
})), [addFlag, agent, fireAnalytics, formatMessage, resourceClient]);
|
|
101
150
|
(0, _react.useEffect)(function () {
|
|
102
151
|
if (!isLoading && agent) {
|
|
103
152
|
fireAnalytics((0, _analytics.profileCardRendered)('agent', 'content'));
|
|
@@ -133,7 +182,7 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
|
133
182
|
}, /*#__PURE__*/_react.default.createElement(_rovoAgentComponents.AgentProfileInfo, {
|
|
134
183
|
agentName: agent.name,
|
|
135
184
|
isStarred: isStarred,
|
|
136
|
-
onStarToggle:
|
|
185
|
+
onStarToggle: handleSetFavourite,
|
|
137
186
|
isHidden: agent.visibility === 'PRIVATE',
|
|
138
187
|
creatorRender: ((_agent$creatorInfo = agent.creatorInfo) === null || _agent$creatorInfo === void 0 ? void 0 : _agent$creatorInfo.type) && /*#__PURE__*/_react.default.createElement(_rovoAgentComponents.AgentProfileCreator, {
|
|
139
188
|
creator: {
|
|
@@ -145,7 +194,7 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
|
145
194
|
onCreatorLinkClick: function onCreatorLinkClick() {}
|
|
146
195
|
}),
|
|
147
196
|
starCountRender: /*#__PURE__*/_react.default.createElement(_rovoAgentComponents.AgentStarCount, {
|
|
148
|
-
starCount:
|
|
197
|
+
starCount: starCount,
|
|
149
198
|
isLoading: false
|
|
150
199
|
}),
|
|
151
200
|
agentDescription: agent.description
|
|
@@ -159,6 +208,7 @@ var AgentProfileCard = function AgentProfileCard(_ref) {
|
|
|
159
208
|
});
|
|
160
209
|
}
|
|
161
210
|
})), /*#__PURE__*/_react.default.createElement(_Actions.AgentActions, {
|
|
211
|
+
agent: agent,
|
|
162
212
|
isAgentCreatedByCurrentUser: isCreatedByViewingUser,
|
|
163
213
|
onEditAgent: function onEditAgent() {
|
|
164
214
|
return _onEditAgent(agent.id);
|
|
@@ -178,7 +178,9 @@ var AgentProfileCardResourced = exports.AgentProfileCardResourced = function Age
|
|
|
178
178
|
isCreatedByViewingUser: creatorUserId === props.viewingUserId,
|
|
179
179
|
product: props.product,
|
|
180
180
|
onConversationStartersClick: props.onConversationStartersClick,
|
|
181
|
-
onChatClick: props.onChatClick
|
|
181
|
+
onChatClick: props.onChatClick,
|
|
182
|
+
addFlag: props.addFlag,
|
|
183
|
+
resourceClient: props.resourceClient
|
|
182
184
|
});
|
|
183
185
|
}
|
|
184
186
|
return null;
|
|
@@ -136,12 +136,14 @@ var AgentProfileCardTrigger = exports.AgentProfileCardTrigger = function AgentPr
|
|
|
136
136
|
}, /*#__PURE__*/_react.default.createElement(_lazyAgentProfileCard.AgentProfileCardLazy, {
|
|
137
137
|
agent: profileData,
|
|
138
138
|
hasError: !!error,
|
|
139
|
-
isCreatedByViewingUser: (profileData === null || profileData === void 0 || (_profileData$creatorI = profileData.creatorInfo) === null || _profileData$creatorI === void 0 ? void 0 : _profileData$creatorI.id) === viewingUserId,
|
|
139
|
+
isCreatedByViewingUser: (profileData === null || profileData === void 0 ? void 0 : profileData.creatorInfo) && (profileData === null || profileData === void 0 || (_profileData$creatorI = profileData.creatorInfo) === null || _profileData$creatorI === void 0 ? void 0 : _profileData$creatorI.id) === viewingUserId,
|
|
140
140
|
cloudId: props.cloudId,
|
|
141
141
|
product: product,
|
|
142
142
|
errorType: error,
|
|
143
143
|
onChatClick: props.onChatClick,
|
|
144
|
-
onConversationStartersClick: props.onConversationStartersClick
|
|
144
|
+
onConversationStartersClick: props.onConversationStartersClick,
|
|
145
|
+
resourceClient: props.resourceClient,
|
|
146
|
+
addFlag: props.addFlag
|
|
145
147
|
}));
|
|
146
148
|
};
|
|
147
149
|
return /*#__PURE__*/_react.default.createElement(_ProfileCardTrigger.default, (0, _extends2.default)({}, props, {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.messages = void 0;
|
|
7
|
+
var _reactIntlNext = require("react-intl-next");
|
|
8
|
+
var messages = exports.messages = (0, _reactIntlNext.defineMessages)({
|
|
9
|
+
agentDeletedSuccessFlagTitle: {
|
|
10
|
+
id: 'profilecard.agent-profile-card.delete-agent-success-flag-title',
|
|
11
|
+
defaultMessage: 'Agent deleted',
|
|
12
|
+
description: 'Flag message title displayed when an agent is deleted'
|
|
13
|
+
},
|
|
14
|
+
agentDeletedSuccessFlagDescription: {
|
|
15
|
+
id: 'profilecard.agent-profile-card.delete-agent-success-flag-description',
|
|
16
|
+
defaultMessage: 'You deleted {agentName}',
|
|
17
|
+
description: 'Flag message description displayed when an agent is deleted'
|
|
18
|
+
},
|
|
19
|
+
agentDeletedErrorFlagTitle: {
|
|
20
|
+
id: 'profilecard.agent-profile-card.delete-agent-error-flag-title',
|
|
21
|
+
defaultMessage: 'Failed to delete Agent',
|
|
22
|
+
description: 'Flag message title displayed when there is an error deleting agent'
|
|
23
|
+
},
|
|
24
|
+
agentDeletedErrorFlagDescription: {
|
|
25
|
+
id: 'profilecard.agent-profile-card.delete-agent-error-flag-description',
|
|
26
|
+
defaultMessage: 'Something went wrong while deleting the agent. Try again in a few moments.',
|
|
27
|
+
description: 'Flag message description displayed when there is an error deleting agent'
|
|
28
|
+
}
|
|
29
|
+
});
|
|
@@ -46,7 +46,8 @@ function ProfileCardContent(_ref) {
|
|
|
46
46
|
profileCardAction = _ref.profileCardAction,
|
|
47
47
|
hasError = _ref.hasError,
|
|
48
48
|
errorType = _ref.errorType,
|
|
49
|
-
agentActions = _ref.agentActions
|
|
49
|
+
agentActions = _ref.agentActions,
|
|
50
|
+
addFlag = _ref.addFlag;
|
|
50
51
|
if (isAgent && (0, _platformFeatureFlags.fg)('enable_agent_profile_card')) {
|
|
51
52
|
return /*#__PURE__*/_react.default.createElement(_AgentProfileCardResourced.AgentProfileCardResourced, {
|
|
52
53
|
accountId: userId,
|
|
@@ -56,7 +57,8 @@ function ProfileCardContent(_ref) {
|
|
|
56
57
|
trigger: trigger,
|
|
57
58
|
product: product,
|
|
58
59
|
onChatClick: agentActions === null || agentActions === void 0 ? void 0 : agentActions.onChatClick,
|
|
59
|
-
onConversationStartersClick: agentActions === null || agentActions === void 0 ? void 0 : agentActions.onConversationStartersClick
|
|
60
|
+
onConversationStartersClick: agentActions === null || agentActions === void 0 ? void 0 : agentActions.onConversationStartersClick,
|
|
61
|
+
addFlag: addFlag
|
|
60
62
|
});
|
|
61
63
|
} else {
|
|
62
64
|
return /*#__PURE__*/_react.default.createElement(_react.Suspense, {
|
|
@@ -349,7 +351,8 @@ function ProfilecardTriggerNext(_ref2) {
|
|
|
349
351
|
profileCardAction: filterActions(),
|
|
350
352
|
errorType: error,
|
|
351
353
|
hasError: hasError,
|
|
352
|
-
agentActions: agentActions
|
|
354
|
+
agentActions: agentActions,
|
|
355
|
+
addFlag: addFlag
|
|
353
356
|
}));
|
|
354
357
|
},
|
|
355
358
|
trigger: function trigger(triggerProps) {
|