@atlaskit/profilecard 19.17.6 → 19.18.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 +20 -0
- package/dist/cjs/client/RovoAgentCardClient.js +6 -3
- package/dist/cjs/client/getAgentInfo.js +7 -18
- package/dist/cjs/client/getTeamFromAGG.js +1 -1
- package/dist/cjs/components/Agent/Actions.js +175 -0
- package/dist/cjs/components/Agent/AgentProfileCard.js +65 -7
- package/dist/cjs/components/Agent/AgentProfileCardResourced.js +10 -4
- package/dist/cjs/components/Agent/AgentProfileCardTrigger.js +27 -13
- package/dist/cjs/components/Agent/AgentProfileCardWrapper.js +1 -2
- package/dist/cjs/components/Agent/ConversationStarters.js +26 -0
- package/dist/cjs/components/Agent/useAgentActions.js +39 -0
- package/dist/cjs/components/Agent/useSetFavouriteAgent.js +85 -0
- package/dist/cjs/components/User/ProfileCardTrigger.js +3 -1
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/util/analytics.js +1 -1
- package/dist/cjs/util/rovoAgentUtils.js +24 -0
- package/dist/cjs/util/url.js +20 -0
- package/dist/es2019/client/RovoAgentCardClient.js +6 -3
- package/dist/es2019/client/getAgentInfo.js +5 -15
- package/dist/es2019/client/getTeamFromAGG.js +1 -1
- package/dist/es2019/components/Agent/Actions.js +168 -0
- package/dist/es2019/components/Agent/AgentProfileCard.js +59 -8
- package/dist/es2019/components/Agent/AgentProfileCardResourced.js +9 -5
- package/dist/es2019/components/Agent/AgentProfileCardTrigger.js +17 -6
- package/dist/es2019/components/Agent/AgentProfileCardWrapper.js +1 -2
- package/dist/es2019/components/Agent/ConversationStarters.js +20 -0
- package/dist/es2019/components/Agent/useAgentActions.js +34 -0
- package/dist/es2019/components/Agent/useSetFavouriteAgent.js +45 -0
- package/dist/es2019/components/User/ProfileCardTrigger.js +3 -1
- package/dist/es2019/index.js +4 -0
- package/dist/es2019/util/analytics.js +1 -1
- package/dist/es2019/util/rovoAgentUtils.js +16 -0
- package/dist/es2019/util/url.js +9 -0
- package/dist/esm/client/RovoAgentCardClient.js +6 -3
- package/dist/esm/client/getAgentInfo.js +7 -18
- package/dist/esm/client/getTeamFromAGG.js +1 -1
- package/dist/esm/components/Agent/Actions.js +165 -0
- package/dist/esm/components/Agent/AgentProfileCard.js +66 -8
- package/dist/esm/components/Agent/AgentProfileCardResourced.js +11 -5
- package/dist/esm/components/Agent/AgentProfileCardTrigger.js +24 -13
- package/dist/esm/components/Agent/AgentProfileCardWrapper.js +1 -2
- package/dist/esm/components/Agent/ConversationStarters.js +19 -0
- package/dist/esm/components/Agent/useAgentActions.js +33 -0
- package/dist/esm/components/Agent/useSetFavouriteAgent.js +78 -0
- package/dist/esm/components/User/ProfileCardTrigger.js +3 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/util/analytics.js +1 -1
- package/dist/esm/util/rovoAgentUtils.js +17 -0
- package/dist/esm/util/url.js +13 -0
- package/dist/types/client/RovoAgentCardClient.d.ts +1 -1
- package/dist/types/client/getAgentInfo.d.ts +2 -2
- package/dist/types/components/Agent/Actions.d.ts +11 -0
- package/dist/types/components/Agent/AgentProfileCard.d.ts +5 -1
- package/dist/types/components/Agent/AgentProfileCardResourced.d.ts +2 -0
- package/dist/types/components/Agent/AgentProfileCardTrigger.d.ts +2 -2
- package/dist/types/components/Agent/ConversationStarters.d.ts +3 -0
- package/dist/types/components/Agent/lazyAgentProfileCard.d.ts +5 -1
- package/dist/types/components/Agent/useAgentActions.d.ts +7 -0
- package/dist/types/components/Agent/useSetFavouriteAgent.d.ts +10 -0
- package/dist/types/components/User/ProfileCardTrigger.d.ts +1 -1
- package/dist/types/index.d.ts +5 -1
- package/dist/types/types.d.ts +24 -3
- package/dist/types/util/rovoAgentUtils.d.ts +2 -0
- package/dist/types/util/url.d.ts +1 -0
- package/dist/types-ts4.5/client/RovoAgentCardClient.d.ts +1 -1
- package/dist/types-ts4.5/client/getAgentInfo.d.ts +2 -2
- package/dist/types-ts4.5/components/Agent/Actions.d.ts +11 -0
- package/dist/types-ts4.5/components/Agent/AgentProfileCard.d.ts +5 -1
- package/dist/types-ts4.5/components/Agent/AgentProfileCardResourced.d.ts +2 -0
- package/dist/types-ts4.5/components/Agent/AgentProfileCardTrigger.d.ts +2 -2
- package/dist/types-ts4.5/components/Agent/ConversationStarters.d.ts +3 -0
- package/dist/types-ts4.5/components/Agent/lazyAgentProfileCard.d.ts +5 -1
- package/dist/types-ts4.5/components/Agent/useAgentActions.d.ts +7 -0
- package/dist/types-ts4.5/components/Agent/useSetFavouriteAgent.d.ts +10 -0
- package/dist/types-ts4.5/components/User/ProfileCardTrigger.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +5 -1
- package/dist/types-ts4.5/types.d.ts +27 -3
- package/dist/types-ts4.5/util/rovoAgentUtils.d.ts +2 -0
- package/dist/types-ts4.5/util/url.d.ts +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useSetFavouriteAgent = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _react = require("react");
|
|
12
|
+
var _rovoAgentUtils = require("../../util/rovoAgentUtils");
|
|
13
|
+
var useSetFavouriteAgent = exports.useSetFavouriteAgent = function useSetFavouriteAgent(_ref) {
|
|
14
|
+
var agentId = _ref.agentId,
|
|
15
|
+
cloudId = _ref.cloudId,
|
|
16
|
+
isStarred = _ref.isStarred,
|
|
17
|
+
product = _ref.product;
|
|
18
|
+
var _useState = (0, _react.useState)(false),
|
|
19
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
20
|
+
isLoading = _useState2[0],
|
|
21
|
+
setIsLoading = _useState2[1];
|
|
22
|
+
var _useState3 = (0, _react.useState)(isStarred),
|
|
23
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
24
|
+
isFavourite = _useState4[0],
|
|
25
|
+
setIsFavourite = _useState4[1];
|
|
26
|
+
var setFavourite = /*#__PURE__*/function () {
|
|
27
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
28
|
+
var headers;
|
|
29
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
30
|
+
while (1) switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
setIsLoading(true);
|
|
33
|
+
_context.prev = 1;
|
|
34
|
+
headers = (0, _rovoAgentUtils.createHeaders)(product, cloudId);
|
|
35
|
+
if (!isFavourite) {
|
|
36
|
+
_context.next = 8;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
_context.next = 6;
|
|
40
|
+
return fetch(new Request("/agents/v1/".concat(agentId, "/favourite"), {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
credentials: 'include',
|
|
43
|
+
mode: 'cors',
|
|
44
|
+
headers: headers
|
|
45
|
+
})).then(function () {
|
|
46
|
+
setIsFavourite(true);
|
|
47
|
+
});
|
|
48
|
+
case 6:
|
|
49
|
+
_context.next = 10;
|
|
50
|
+
break;
|
|
51
|
+
case 8:
|
|
52
|
+
_context.next = 10;
|
|
53
|
+
return fetch(new Request("/agents/v1/".concat(agentId, "/favourite"), {
|
|
54
|
+
method: 'DELETE',
|
|
55
|
+
credentials: 'include',
|
|
56
|
+
mode: 'cors',
|
|
57
|
+
headers: headers
|
|
58
|
+
})).then(function () {
|
|
59
|
+
setIsFavourite(false);
|
|
60
|
+
});
|
|
61
|
+
case 10:
|
|
62
|
+
setIsLoading(false);
|
|
63
|
+
_context.next = 16;
|
|
64
|
+
break;
|
|
65
|
+
case 13:
|
|
66
|
+
_context.prev = 13;
|
|
67
|
+
_context.t0 = _context["catch"](1);
|
|
68
|
+
setIsLoading(false);
|
|
69
|
+
case 16:
|
|
70
|
+
case "end":
|
|
71
|
+
return _context.stop();
|
|
72
|
+
}
|
|
73
|
+
}, _callee, null, [[1, 13]]);
|
|
74
|
+
}));
|
|
75
|
+
return function setFavourite() {
|
|
76
|
+
return _ref2.apply(this, arguments);
|
|
77
|
+
};
|
|
78
|
+
}();
|
|
79
|
+
return {
|
|
80
|
+
isLoading: isLoading,
|
|
81
|
+
isStarred: isFavourite,
|
|
82
|
+
// hasError: Boolean(error) || cannotLoadUser,
|
|
83
|
+
setFavourite: setFavourite
|
|
84
|
+
};
|
|
85
|
+
};
|
|
@@ -51,7 +51,8 @@ function ProfilecardTriggerNext(_ref) {
|
|
|
51
51
|
ariaLabelledBy = _ref.ariaLabelledBy,
|
|
52
52
|
prepopulatedData = _ref.prepopulatedData,
|
|
53
53
|
disabledAriaAttributes = _ref.disabledAriaAttributes,
|
|
54
|
-
onVisibilityChange = _ref.onVisibilityChange
|
|
54
|
+
onVisibilityChange = _ref.onVisibilityChange,
|
|
55
|
+
offset = _ref.offset;
|
|
55
56
|
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
56
57
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
57
58
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
@@ -292,6 +293,7 @@ function ProfilecardTriggerNext(_ref) {
|
|
|
292
293
|
handleKeyboardClose(event);
|
|
293
294
|
},
|
|
294
295
|
placement: position,
|
|
296
|
+
offset: offset !== null && offset !== void 0 ? offset : [0, 8],
|
|
295
297
|
content: function content() {
|
|
296
298
|
return /*#__PURE__*/_react.default.createElement("div", wrapperProps, showLoading ? /*#__PURE__*/_react.default.createElement(LoadingView, {
|
|
297
299
|
fireAnalytics: fireAnalytics
|
package/dist/cjs/index.js
CHANGED
|
@@ -5,6 +5,24 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
Object.defineProperty(exports, "AgentProfileCard", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _AgentProfileCard.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "AgentProfileCardResourced", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _AgentProfileCardResourced.AgentProfileCardResourced;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "AgentProfileCardTrigger", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _AgentProfileCardTrigger.AgentProfileCardTrigger;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
8
26
|
Object.defineProperty(exports, "DELAY_MS_HIDE", {
|
|
9
27
|
enumerable: true,
|
|
10
28
|
get: function get() {
|
|
@@ -75,6 +93,7 @@ Object.defineProperty(exports, "withOuterListeners", {
|
|
|
75
93
|
var _ProfileCardClient = _interopRequireDefault(require("./client/ProfileCardClient"));
|
|
76
94
|
var _TeamProfileCardClient = _interopRequireDefault(require("./client/TeamProfileCardClient"));
|
|
77
95
|
var _UserProfileCardClient = _interopRequireWildcard(require("./client/UserProfileCardClient"));
|
|
96
|
+
var _AgentProfileCard = _interopRequireDefault(require("./components/Agent/AgentProfileCard"));
|
|
78
97
|
var _TeamProfileCardTrigger = _interopRequireDefault(require("./components/Team/TeamProfileCardTrigger"));
|
|
79
98
|
var _ProfileCard = _interopRequireDefault(require("./components/User/ProfileCard"));
|
|
80
99
|
var _ProfileCardResourced = _interopRequireDefault(require("./components/User/ProfileCardResourced"));
|
|
@@ -82,6 +101,8 @@ var _ProfileCardTrigger = _interopRequireDefault(require("./components/User/Prof
|
|
|
82
101
|
var _config = require("./util/config");
|
|
83
102
|
var _withOuterListeners = _interopRequireDefault(require("./util/withOuterListeners"));
|
|
84
103
|
var _TeamProfileCard = _interopRequireDefault(require("./components/Team/TeamProfileCard"));
|
|
104
|
+
var _AgentProfileCardTrigger = require("./components/Agent/AgentProfileCardTrigger");
|
|
105
|
+
var _AgentProfileCardResourced = require("./components/Agent/AgentProfileCardResourced");
|
|
85
106
|
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); }
|
|
86
107
|
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; }
|
|
87
108
|
// Avoid exporting new components in this file as they will affect the bundle size of all consumers
|
|
@@ -45,7 +45,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
|
|
|
45
45
|
actionSubjectId: actionSubjectId,
|
|
46
46
|
attributes: _objectSpread(_objectSpread({
|
|
47
47
|
packageName: "@atlaskit/profilecard",
|
|
48
|
-
packageVersion: "19.
|
|
48
|
+
packageVersion: "19.18.0"
|
|
49
49
|
}, attributes), {}, {
|
|
50
50
|
firedAt: Math.round((0, _performance.getPageTime)())
|
|
51
51
|
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getAAIDFromARI = exports.createHeaders = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
var createHeaders = exports.createHeaders = function createHeaders(product, cloudId) {
|
|
12
|
+
var config = {
|
|
13
|
+
headers: {
|
|
14
|
+
'X-Product': product,
|
|
15
|
+
'X-Experience-Id': 'profile-card',
|
|
16
|
+
'X-Cloudid': cloudId
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return new Headers(_objectSpread({}, config.headers || {}));
|
|
20
|
+
};
|
|
21
|
+
var getAAIDFromARI = exports.getAAIDFromARI = function getAAIDFromARI(ari) {
|
|
22
|
+
var matched = ari.match(/\/([a-zA-Z0-9_\|\-\:]{1,128})$/);
|
|
23
|
+
return matched ? matched[1] : undefined;
|
|
24
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.encodeParamsToUrl = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var encodeParamsToUrl = exports.encodeParamsToUrl = function encodeParamsToUrl(baseUrl, params) {
|
|
10
|
+
var url = new URL(baseUrl);
|
|
11
|
+
var searchParams = new URLSearchParams();
|
|
12
|
+
for (var _i = 0, _Object$entries = Object.entries(params); _i < _Object$entries.length; _i++) {
|
|
13
|
+
var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
|
|
14
|
+
key = _Object$entries$_i[0],
|
|
15
|
+
value = _Object$entries$_i[1];
|
|
16
|
+
searchParams.append(key, String(value));
|
|
17
|
+
}
|
|
18
|
+
url.search = searchParams.toString();
|
|
19
|
+
return url.toString();
|
|
20
|
+
};
|
|
@@ -8,16 +8,19 @@ export default class RovoAgentCardClient extends CachingClient {
|
|
|
8
8
|
super(options);
|
|
9
9
|
this.options = options;
|
|
10
10
|
}
|
|
11
|
-
makeRequest(agentId) {
|
|
11
|
+
makeRequest(agentId, cloudId) {
|
|
12
12
|
if (!this.options.productIdentifier) {
|
|
13
13
|
throw new Error('Trying to fetch agents data with no specified config.productIdentifier');
|
|
14
14
|
}
|
|
15
|
-
return getAgentDetailsByAgentId(agentId, this.options.productIdentifier);
|
|
15
|
+
return getAgentDetailsByAgentId(agentId, this.options.productIdentifier, cloudId);
|
|
16
16
|
}
|
|
17
17
|
getProfile(agentId, analytics) {
|
|
18
18
|
if (!agentId) {
|
|
19
19
|
return Promise.reject(new Error('agentId is missing'));
|
|
20
20
|
}
|
|
21
|
+
if (!this.options.cloudId) {
|
|
22
|
+
return Promise.reject(new Error('cloudId is missing'));
|
|
23
|
+
}
|
|
21
24
|
const cache = this.getCachedProfile(agentId);
|
|
22
25
|
if (cache) {
|
|
23
26
|
return Promise.resolve(cache);
|
|
@@ -27,7 +30,7 @@ export default class RovoAgentCardClient extends CachingClient {
|
|
|
27
30
|
if (analytics) {
|
|
28
31
|
analytics(agentRequestAnalytics('triggered'));
|
|
29
32
|
}
|
|
30
|
-
this.makeRequest(agentId).then(data => {
|
|
33
|
+
this.makeRequest(agentId, this.options.cloudId || '').then(data => {
|
|
31
34
|
if (this.cache) {
|
|
32
35
|
this.setCachedProfile(agentId, data);
|
|
33
36
|
}
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
'x-product': product,
|
|
5
|
-
'x-experience-id': 'profile-card'
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
return new Headers({
|
|
9
|
-
...(config.headers || {})
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
export async function getAgentDetailsByAgentId(agentId, product) {
|
|
13
|
-
const headers = createHeaders(product);
|
|
1
|
+
import { createHeaders } from '../util/rovoAgentUtils';
|
|
2
|
+
export async function getAgentDetailsByAgentId(agentId, product, cloudId) {
|
|
3
|
+
const headers = createHeaders(product, cloudId);
|
|
14
4
|
return await fetch(new Request(`assist/agents/v1/${agentId}`, {
|
|
15
5
|
method: 'GET',
|
|
16
6
|
credentials: 'include',
|
|
@@ -18,8 +8,8 @@ export async function getAgentDetailsByAgentId(agentId, product) {
|
|
|
18
8
|
headers
|
|
19
9
|
})).then(response => response.json());
|
|
20
10
|
}
|
|
21
|
-
export async function getAgentDetailsByUserId(userId, product) {
|
|
22
|
-
const headers = createHeaders(product);
|
|
11
|
+
export async function getAgentDetailsByUserId(userId, product, cloudId) {
|
|
12
|
+
const headers = createHeaders(product, cloudId);
|
|
23
13
|
return await fetch(new Request(`assist/agents/v1/accountid/${userId}`, {
|
|
24
14
|
method: 'GET',
|
|
25
15
|
credentials: 'include',
|
|
@@ -67,7 +67,7 @@ export const addHeaders = headers => {
|
|
|
67
67
|
headers.append('X-ExperimentalApi', 'teams-beta');
|
|
68
68
|
headers.append('X-ExperimentalApi', 'team-members-beta');
|
|
69
69
|
headers.append('atl-client-name', "@atlaskit/profilecard");
|
|
70
|
-
headers.append('atl-client-version', "19.
|
|
70
|
+
headers.append('atl-client-version', "19.18.0");
|
|
71
71
|
return headers;
|
|
72
72
|
};
|
|
73
73
|
export async function getTeamFromAGG(url, teamId, siteId) {
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { defineMessages, FormattedMessage, useIntl } from 'react-intl-next';
|
|
4
|
+
import Button, { IconButton } from '@atlaskit/button/new';
|
|
5
|
+
import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
6
|
+
import MoreIcon from '@atlaskit/icon/core/migration/show-more-horizontal--more';
|
|
7
|
+
import { Box, Inline, xcss } from '@atlaskit/primitives';
|
|
8
|
+
import { ChatPillIcon } from '@atlaskit/rovo-agent-components';
|
|
9
|
+
const chatToAgentButtonContainer = xcss({
|
|
10
|
+
width: '100%'
|
|
11
|
+
});
|
|
12
|
+
const buttonStyles = xcss({
|
|
13
|
+
borderRadius: '3px',
|
|
14
|
+
color: 'color.text',
|
|
15
|
+
backgroundColor: 'color.background.neutral',
|
|
16
|
+
':hover': {
|
|
17
|
+
backgroundColor: 'color.background.neutral.hovered'
|
|
18
|
+
},
|
|
19
|
+
':active': {
|
|
20
|
+
backgroundColor: 'color.background.neutral.pressed'
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const chatToAgentButtonWrapper = xcss({
|
|
24
|
+
display: 'flex',
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
lineHeight: '20px',
|
|
27
|
+
padding: 'space.075',
|
|
28
|
+
fontWeight: '500'
|
|
29
|
+
});
|
|
30
|
+
const chatPillButtonInlineStyles = xcss({
|
|
31
|
+
paddingInline: 'space.025'
|
|
32
|
+
});
|
|
33
|
+
const chatPillTextStyles = xcss({
|
|
34
|
+
wordBreak: 'break-word',
|
|
35
|
+
textAlign: 'left',
|
|
36
|
+
whiteSpace: 'pre-wrap'
|
|
37
|
+
});
|
|
38
|
+
const chatPillIconWrapper = xcss({
|
|
39
|
+
minWidth: '20px',
|
|
40
|
+
height: '20px'
|
|
41
|
+
});
|
|
42
|
+
const actopnsWrapperStyles = xcss({
|
|
43
|
+
borderTop: '1px',
|
|
44
|
+
borderTopStyle: 'solid',
|
|
45
|
+
borderColor: 'color.border',
|
|
46
|
+
padding: 'space.200',
|
|
47
|
+
marginBlockStart: 'space.200',
|
|
48
|
+
color: 'color.text'
|
|
49
|
+
});
|
|
50
|
+
const buildAgentActions = ({
|
|
51
|
+
onDuplicateAgent,
|
|
52
|
+
onCopyAgent
|
|
53
|
+
}) => {
|
|
54
|
+
return [{
|
|
55
|
+
text: /*#__PURE__*/React.createElement(FormattedMessage, messages.actionDuplicate),
|
|
56
|
+
onClick: onDuplicateAgent
|
|
57
|
+
}, {
|
|
58
|
+
text: /*#__PURE__*/React.createElement(FormattedMessage, messages.actionCopyLink),
|
|
59
|
+
onClick: onCopyAgent
|
|
60
|
+
}];
|
|
61
|
+
};
|
|
62
|
+
const buildAgentSettings = ({
|
|
63
|
+
onEditAgent,
|
|
64
|
+
onDeleteAgent
|
|
65
|
+
}) => {
|
|
66
|
+
return [{
|
|
67
|
+
text: /*#__PURE__*/React.createElement(FormattedMessage, messages.actionEdit),
|
|
68
|
+
onClick: onEditAgent
|
|
69
|
+
}, {
|
|
70
|
+
text: /*#__PURE__*/React.createElement(FormattedMessage, messages.actionDelete),
|
|
71
|
+
onClick: onDeleteAgent
|
|
72
|
+
}];
|
|
73
|
+
};
|
|
74
|
+
export const AgentActions = ({
|
|
75
|
+
isAgentCreatedByCurrentUser,
|
|
76
|
+
onEditAgent,
|
|
77
|
+
onDeleteAgent,
|
|
78
|
+
onDuplicateAgent,
|
|
79
|
+
onCopyAgent,
|
|
80
|
+
onChatClick
|
|
81
|
+
}) => {
|
|
82
|
+
const {
|
|
83
|
+
formatMessage
|
|
84
|
+
} = useIntl();
|
|
85
|
+
const agentActions = buildAgentActions({
|
|
86
|
+
onDuplicateAgent,
|
|
87
|
+
onCopyAgent
|
|
88
|
+
});
|
|
89
|
+
const agentSetting = buildAgentSettings({
|
|
90
|
+
onEditAgent,
|
|
91
|
+
onDeleteAgent
|
|
92
|
+
});
|
|
93
|
+
return /*#__PURE__*/React.createElement(Inline, {
|
|
94
|
+
space: "space.100",
|
|
95
|
+
xcss: actopnsWrapperStyles
|
|
96
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
97
|
+
xcss: [chatToAgentButtonContainer, buttonStyles]
|
|
98
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
99
|
+
shouldFitContainer: true,
|
|
100
|
+
onClick: onChatClick
|
|
101
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
102
|
+
xcss: chatToAgentButtonWrapper
|
|
103
|
+
}, /*#__PURE__*/React.createElement(Inline, {
|
|
104
|
+
space: "space.050",
|
|
105
|
+
xcss: chatPillButtonInlineStyles
|
|
106
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
107
|
+
xcss: chatPillIconWrapper
|
|
108
|
+
}, /*#__PURE__*/React.createElement(ChatPillIcon, null)), /*#__PURE__*/React.createElement(Box, {
|
|
109
|
+
xcss: chatPillTextStyles
|
|
110
|
+
}, formatMessage(messages.actionChatToAgent)))))), /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
111
|
+
trigger: ({
|
|
112
|
+
triggerRef,
|
|
113
|
+
...props
|
|
114
|
+
}) => /*#__PURE__*/React.createElement(Box, {
|
|
115
|
+
xcss: buttonStyles
|
|
116
|
+
}, /*#__PURE__*/React.createElement(IconButton, _extends({}, props, {
|
|
117
|
+
icon: MoreIcon,
|
|
118
|
+
label: "more",
|
|
119
|
+
ref: triggerRef
|
|
120
|
+
}))),
|
|
121
|
+
placement: "bottom-end"
|
|
122
|
+
}, /*#__PURE__*/React.createElement(DropdownItemGroup, null, agentActions.map(({
|
|
123
|
+
text,
|
|
124
|
+
onClick
|
|
125
|
+
}, idx) => {
|
|
126
|
+
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
127
|
+
key: idx,
|
|
128
|
+
onClick: onClick
|
|
129
|
+
}, text);
|
|
130
|
+
})), isAgentCreatedByCurrentUser && /*#__PURE__*/React.createElement(DropdownItemGroup, {
|
|
131
|
+
hasSeparator: true
|
|
132
|
+
}, agentSetting.map(({
|
|
133
|
+
text,
|
|
134
|
+
onClick
|
|
135
|
+
}, idx) => {
|
|
136
|
+
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
137
|
+
key: idx,
|
|
138
|
+
onClick: onClick
|
|
139
|
+
}, text);
|
|
140
|
+
}))));
|
|
141
|
+
};
|
|
142
|
+
const messages = defineMessages({
|
|
143
|
+
actionChatToAgent: {
|
|
144
|
+
id: 'ptc-directory.agent-profile.action.dropdown.chat-to-agent.nonfinal',
|
|
145
|
+
defaultMessage: 'Chat to Agent',
|
|
146
|
+
description: 'Text for the "chat to agent" action to chat to the agent'
|
|
147
|
+
},
|
|
148
|
+
actionDelete: {
|
|
149
|
+
id: 'ptc-directory.agent-profile.action.dropdown.delete.nonfinal',
|
|
150
|
+
defaultMessage: 'Delete Agent',
|
|
151
|
+
description: 'Text for the "Delete" action to delete an agent'
|
|
152
|
+
},
|
|
153
|
+
actionEdit: {
|
|
154
|
+
id: 'ptc-directory.agent-profile.action.dropdown.edit.nonfinal',
|
|
155
|
+
defaultMessage: 'Edit Agent',
|
|
156
|
+
description: 'Text for the "Edit" action to edit an agent'
|
|
157
|
+
},
|
|
158
|
+
actionCopyLink: {
|
|
159
|
+
id: 'ptc-directory.agent-profile.action.dropdown.copy-link.nonfinal',
|
|
160
|
+
defaultMessage: 'Copy link',
|
|
161
|
+
description: 'Text for the Copy link of an agent'
|
|
162
|
+
},
|
|
163
|
+
actionDuplicate: {
|
|
164
|
+
id: 'ptc-directory.agent-profile.action.dropdown.duplicate.nonfinal',
|
|
165
|
+
defaultMessage: 'Duplicate Agent',
|
|
166
|
+
description: 'Text for the Duplicate Agent action to create a duplicate'
|
|
167
|
+
}
|
|
168
|
+
});
|
|
@@ -1,21 +1,51 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Box, Stack, xcss } from '@atlaskit/primitives';
|
|
3
|
-
import { AgentProfileCreator, AgentProfileInfo, AgentStarCount } from '@atlaskit/rovo-agent-components';
|
|
3
|
+
import { AgentAvatar, AgentBanner, AgentProfileCreator, AgentProfileInfo, AgentStarCount } from '@atlaskit/rovo-agent-components';
|
|
4
4
|
import LoadingState from '../common/LoadingState';
|
|
5
|
+
import { AgentActions } from './Actions';
|
|
5
6
|
import { AgentProfileCardWrapper } from './AgentProfileCardWrapper';
|
|
7
|
+
import { ConversationStarters } from './ConversationStarters';
|
|
8
|
+
import { useAgentUrlActions } from './useAgentActions';
|
|
9
|
+
import { useSetFavouriteAgent } from './useSetFavouriteAgent';
|
|
6
10
|
const styles = xcss({
|
|
7
|
-
|
|
11
|
+
paddingBlockStart: 'space.400',
|
|
8
12
|
paddingInline: 'space.200'
|
|
9
13
|
});
|
|
14
|
+
const avatarStyles = xcss({
|
|
15
|
+
position: 'absolute',
|
|
16
|
+
top: 'space.300',
|
|
17
|
+
left: 'space.200'
|
|
18
|
+
});
|
|
10
19
|
const cardContainerStyles = xcss({
|
|
11
20
|
borderRadius: 'border.radius.200',
|
|
12
|
-
boxShadow: 'elevation.shadow.overlay'
|
|
21
|
+
boxShadow: 'elevation.shadow.overlay',
|
|
22
|
+
position: 'relative'
|
|
13
23
|
});
|
|
14
24
|
const AgentProfileCard = ({
|
|
15
25
|
agent,
|
|
16
|
-
isLoading
|
|
26
|
+
isLoading,
|
|
27
|
+
isCreatedByViewingUser,
|
|
28
|
+
cloudId,
|
|
29
|
+
onOpenChat,
|
|
30
|
+
product = 'rovo'
|
|
17
31
|
}) => {
|
|
18
32
|
var _agent$creatorInfo, _agent$creatorInfo2, _agent$creatorInfo3, _agent$creatorInfo4;
|
|
33
|
+
const {
|
|
34
|
+
onEditAgent,
|
|
35
|
+
onCopyAgent,
|
|
36
|
+
onDuplicateAgent
|
|
37
|
+
} = useAgentUrlActions({
|
|
38
|
+
cloudId: cloudId || ''
|
|
39
|
+
});
|
|
40
|
+
const {
|
|
41
|
+
isStarred,
|
|
42
|
+
setFavourite
|
|
43
|
+
} = useSetFavouriteAgent({
|
|
44
|
+
agentId: agent.id,
|
|
45
|
+
cloudId: cloudId || '',
|
|
46
|
+
isStarred: agent.favourite,
|
|
47
|
+
product
|
|
48
|
+
});
|
|
19
49
|
if (isLoading) {
|
|
20
50
|
return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(LoadingState, {
|
|
21
51
|
profileType: "agent"
|
|
@@ -23,13 +53,19 @@ const AgentProfileCard = ({
|
|
|
23
53
|
}
|
|
24
54
|
return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(Box, {
|
|
25
55
|
xcss: cardContainerStyles
|
|
26
|
-
}, /*#__PURE__*/React.createElement(
|
|
56
|
+
}, /*#__PURE__*/React.createElement(AgentBanner, {
|
|
57
|
+
height: 96
|
|
58
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
59
|
+
xcss: avatarStyles
|
|
60
|
+
}, /*#__PURE__*/React.createElement(AgentAvatar, {
|
|
61
|
+
size: "xlarge"
|
|
62
|
+
})), /*#__PURE__*/React.createElement(Stack, {
|
|
27
63
|
space: "space.100",
|
|
28
64
|
xcss: styles
|
|
29
65
|
}, /*#__PURE__*/React.createElement(AgentProfileInfo, {
|
|
30
66
|
agentName: agent.name,
|
|
31
|
-
isStarred:
|
|
32
|
-
onStarToggle:
|
|
67
|
+
isStarred: isStarred,
|
|
68
|
+
onStarToggle: setFavourite,
|
|
33
69
|
creatorRender: ((_agent$creatorInfo = agent.creatorInfo) === null || _agent$creatorInfo === void 0 ? void 0 : _agent$creatorInfo.type) && /*#__PURE__*/React.createElement(AgentProfileCreator, {
|
|
34
70
|
creator: {
|
|
35
71
|
type: (_agent$creatorInfo2 = agent.creatorInfo) === null || _agent$creatorInfo2 === void 0 ? void 0 : _agent$creatorInfo2.type,
|
|
@@ -44,6 +80,21 @@ const AgentProfileCard = ({
|
|
|
44
80
|
isLoading: false
|
|
45
81
|
}),
|
|
46
82
|
agentDescription: agent.description
|
|
47
|
-
})
|
|
83
|
+
}), /*#__PURE__*/React.createElement(ConversationStarters, {
|
|
84
|
+
isAgentDefault: agent.is_default,
|
|
85
|
+
userDefinedConversationStarters: agent.user_defined_conversation_starters,
|
|
86
|
+
onConversationStarterClick: function (conversationStarter) {
|
|
87
|
+
throw new Error('Function not implemented.');
|
|
88
|
+
}
|
|
89
|
+
})), /*#__PURE__*/React.createElement(AgentActions, {
|
|
90
|
+
isAgentCreatedByCurrentUser: isCreatedByViewingUser,
|
|
91
|
+
onEditAgent: () => onEditAgent(agent.id),
|
|
92
|
+
onCopyAgent: () => onCopyAgent(agent.id),
|
|
93
|
+
onDuplicateAgent: () => onDuplicateAgent(agent.id),
|
|
94
|
+
onDeleteAgent: function () {
|
|
95
|
+
throw new Error('Function not implemented.');
|
|
96
|
+
},
|
|
97
|
+
onChatClick: () => onOpenChat === null || onOpenChat === void 0 ? void 0 : onOpenChat(agent.id)
|
|
98
|
+
})));
|
|
48
99
|
};
|
|
49
100
|
export default AgentProfileCard;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { getAAIDFromARI } from '../../util/rovoAgentUtils';
|
|
2
3
|
import ErrorMessage from '../Error/ErrorMessage';
|
|
3
4
|
import { AgentProfileCardWrapper } from './AgentProfileCardWrapper';
|
|
4
5
|
import { AgentProfileCardLazy } from './lazyAgentProfileCard';
|
|
@@ -6,6 +7,7 @@ export const AgentProfileCardResourced = props => {
|
|
|
6
7
|
const [agentData, setAgentData] = useState();
|
|
7
8
|
const [isLoading, setIsLoading] = useState(false);
|
|
8
9
|
const [error, setError] = useState();
|
|
10
|
+
const creatorUserId = useMemo(() => (agentData === null || agentData === void 0 ? void 0 : agentData.creator_type) === 'CUSTOMER' && agentData.creator ? getAAIDFromARI(agentData.creator) : '', [agentData === null || agentData === void 0 ? void 0 : agentData.creator_type, agentData === null || agentData === void 0 ? void 0 : agentData.creator]);
|
|
9
11
|
const getCreator = useCallback(async (creator_type, creator) => {
|
|
10
12
|
if (!creator) {
|
|
11
13
|
return undefined;
|
|
@@ -21,16 +23,16 @@ export const AgentProfileCardResourced = props => {
|
|
|
21
23
|
name: creator !== null && creator !== void 0 ? creator : ''
|
|
22
24
|
};
|
|
23
25
|
case 'CUSTOMER':
|
|
24
|
-
const creatorInfo = await props.resourceClient.getProfile(
|
|
26
|
+
const creatorInfo = await props.resourceClient.getProfile(creatorUserId || '', props.cloudId || '');
|
|
25
27
|
return {
|
|
26
28
|
type: 'CUSTOMER',
|
|
27
29
|
name: creatorInfo.fullName,
|
|
28
|
-
profileLink: `/people/${
|
|
30
|
+
profileLink: `/people/${creatorUserId}`
|
|
29
31
|
};
|
|
30
32
|
default:
|
|
31
33
|
return undefined;
|
|
32
34
|
}
|
|
33
|
-
}, [props.cloudId, props.resourceClient]);
|
|
35
|
+
}, [creatorUserId, props.cloudId, props.resourceClient]);
|
|
34
36
|
const getAgentInfo = useCallback(() => {
|
|
35
37
|
return props.resourceClient.getRovoAgentProfile(props.agentId);
|
|
36
38
|
}, [props.agentId, props.resourceClient]);
|
|
@@ -69,7 +71,9 @@ export const AgentProfileCardResourced = props => {
|
|
|
69
71
|
return /*#__PURE__*/React.createElement(AgentProfileCardLazy, {
|
|
70
72
|
agent: agentData,
|
|
71
73
|
isLoading: isLoading,
|
|
72
|
-
hasError: !!error
|
|
74
|
+
hasError: !!error,
|
|
75
|
+
isCreatedByViewingUser: creatorUserId === props.viewingUserId,
|
|
76
|
+
product: props.product
|
|
73
77
|
});
|
|
74
78
|
}
|
|
75
79
|
return null;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { Suspense } from 'react';
|
|
3
|
+
import { getAAIDFromARI } from '../../util/rovoAgentUtils';
|
|
3
4
|
import ProfileCardTrigger from '../common/ProfileCardTrigger';
|
|
4
5
|
import { AgentProfileCardLazy } from './lazyAgentProfileCard';
|
|
5
6
|
export const AgentProfileCardTrigger = ({
|
|
6
7
|
trigger = 'hover',
|
|
8
|
+
viewingUserId,
|
|
9
|
+
product,
|
|
7
10
|
...props
|
|
8
11
|
}) => {
|
|
9
12
|
const {
|
|
@@ -26,11 +29,13 @@ export const AgentProfileCardTrigger = ({
|
|
|
26
29
|
name: creator !== null && creator !== void 0 ? creator : ''
|
|
27
30
|
};
|
|
28
31
|
case 'CUSTOMER':
|
|
29
|
-
const
|
|
32
|
+
const userId = getAAIDFromARI(creator) || '';
|
|
33
|
+
const creatorInfo = await props.resourceClient.getProfile(userId, cloudId || '');
|
|
30
34
|
return {
|
|
31
35
|
type: 'CUSTOMER',
|
|
32
36
|
name: creatorInfo.fullName,
|
|
33
|
-
profileLink: `/people/${
|
|
37
|
+
profileLink: `/people/${userId}`,
|
|
38
|
+
id: userId
|
|
34
39
|
};
|
|
35
40
|
default:
|
|
36
41
|
return undefined;
|
|
@@ -48,13 +53,19 @@ export const AgentProfileCardTrigger = ({
|
|
|
48
53
|
profileData,
|
|
49
54
|
isLoading
|
|
50
55
|
}) => {
|
|
56
|
+
var _profileData$creatorI;
|
|
51
57
|
if (!profileData) {
|
|
52
58
|
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
53
59
|
}
|
|
54
|
-
return /*#__PURE__*/React.createElement(
|
|
60
|
+
return /*#__PURE__*/React.createElement(Suspense, {
|
|
61
|
+
fallback: null
|
|
62
|
+
}, /*#__PURE__*/React.createElement(AgentProfileCardLazy, {
|
|
55
63
|
agent: profileData,
|
|
56
|
-
isLoading: isLoading
|
|
57
|
-
|
|
64
|
+
isLoading: isLoading,
|
|
65
|
+
isCreatedByViewingUser: ((_profileData$creatorI = profileData.creatorInfo) === null || _profileData$creatorI === void 0 ? void 0 : _profileData$creatorI.id) === viewingUserId,
|
|
66
|
+
cloudId: props.cloudId,
|
|
67
|
+
product: product
|
|
68
|
+
}));
|
|
58
69
|
};
|
|
59
70
|
return /*#__PURE__*/React.createElement(ProfileCardTrigger, _extends({}, props, {
|
|
60
71
|
renderProfileCard: renderProfileCard,
|