@atlaskit/profilecard 20.4.3 → 20.6.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +3 -14
  3. package/dist/cjs/client/ProfileCardClient.js +68 -9
  4. package/dist/cjs/client/TeamCentralCardClient.js +74 -2
  5. package/dist/cjs/client/getTeamFromAGG.js +1 -1
  6. package/dist/cjs/components/Team/TeamProfileCardTrigger.js +3 -3
  7. package/dist/cjs/components/User/ProfileCardResourced.js +9 -6
  8. package/dist/cjs/components/User/ProfileCardTrigger.js +12 -12
  9. package/dist/cjs/i18n/languages.js +4 -2
  10. package/dist/cjs/util/analytics.js +1 -1
  11. package/dist/es2019/client/ProfileCardClient.js +13 -6
  12. package/dist/es2019/client/TeamCentralCardClient.js +41 -2
  13. package/dist/es2019/client/getTeamFromAGG.js +1 -1
  14. package/dist/es2019/components/Team/TeamProfileCardTrigger.js +3 -3
  15. package/dist/es2019/components/User/ProfileCardResourced.js +9 -6
  16. package/dist/es2019/components/User/ProfileCardTrigger.js +3 -3
  17. package/dist/es2019/i18n/index.js +2 -2
  18. package/dist/es2019/i18n/languages.js +4 -2
  19. package/dist/es2019/util/analytics.js +1 -1
  20. package/dist/esm/client/ProfileCardClient.js +69 -10
  21. package/dist/esm/client/TeamCentralCardClient.js +74 -2
  22. package/dist/esm/client/getTeamFromAGG.js +1 -1
  23. package/dist/esm/components/Team/TeamProfileCardTrigger.js +3 -3
  24. package/dist/esm/components/User/ProfileCardResourced.js +9 -6
  25. package/dist/esm/components/User/ProfileCardTrigger.js +12 -12
  26. package/dist/esm/i18n/index.js +2 -2
  27. package/dist/esm/i18n/languages.js +4 -2
  28. package/dist/esm/util/analytics.js +1 -1
  29. package/dist/types/client/ProfileCardClient.d.ts +1 -1
  30. package/dist/types/client/TeamCentralCardClient.d.ts +5 -0
  31. package/dist/types/components/Team/TeamProfileCardTrigger.d.ts +1 -1
  32. package/dist/types/components/User/ProfileCardResourced.d.ts +1 -1
  33. package/dist/types/i18n/index.d.ts +2 -2
  34. package/dist/types/i18n/languages.d.ts +3 -2
  35. package/dist/types/types.d.ts +2 -1
  36. package/dist/types-ts4.5/client/ProfileCardClient.d.ts +1 -1
  37. package/dist/types-ts4.5/client/TeamCentralCardClient.d.ts +5 -0
  38. package/dist/types-ts4.5/components/Team/TeamProfileCardTrigger.d.ts +1 -1
  39. package/dist/types-ts4.5/components/User/ProfileCardResourced.d.ts +1 -1
  40. package/dist/types-ts4.5/i18n/index.d.ts +2 -2
  41. package/dist/types-ts4.5/i18n/languages.d.ts +3 -2
  42. package/dist/types-ts4.5/types.d.ts +2 -1
  43. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/profilecard
2
2
 
3
+ ## 20.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#153669](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/153669)
8
+ [`5f8a2c39f1282`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5f8a2c39f1282) -
9
+ Fix links to go to home.a.c or team.a.c depending on the workspace type for profile card
10
+
11
+ ## 20.5.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#153098](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/153098)
16
+ [`1e9b8abfd8903`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1e9b8abfd8903) -
17
+ Adding support for en-ZZ locale
18
+
3
19
  ## 20.4.3
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -2,17 +2,6 @@
2
2
 
3
3
  ## i18n
4
4
 
5
- `src/i18n` is generated folder by `yarn i18:pull`, so don't update any files in that folder manually.
6
- Contact Atlaskit team to get `TRANSIFEX_API_TOKEN` as a global variable
7
-
8
- ### Pushing translation
9
-
10
- In `atlaskit-mk-2/packages/people-and-teams/profilecard` folder:
11
-
12
- - Run `yarn i18n:push` to build and then find messages in `dis/esm/src` and push them to Transifex
13
-
14
- ### Pulling translation
15
-
16
- In `atlaskit-mk-2/packages/people-and-teams/profilecard` folder:
17
-
18
- - Run `yarn i18n:pull` to delete current `src/i18n` folder and download all messages from Transifex and generate `src/i18n` again.
5
+ Localization is now handled by Traduki 2.0. Please refer to the
6
+ [People and Teams](https://go.atlassian.com/traduki-people-and-teams) subscription in Traduki for
7
+ more information.
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -62,18 +64,75 @@ var ProfileCardClient = /*#__PURE__*/function () {
62
64
  }
63
65
  }, {
64
66
  key: "getTeamCentralBaseUrl",
65
- value: function getTeamCentralBaseUrl() {
66
- var _this$tcClient3;
67
- return (_this$tcClient3 = this.tcClient) === null || _this$tcClient3 === void 0 ? void 0 : _this$tcClient3.options.teamCentralBaseUrl;
68
- }
67
+ value: function () {
68
+ var _getTeamCentralBaseUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
69
+ var _this$tcClient3, isGlobalExperienceWorkspace;
70
+ return _regenerator.default.wrap(function _callee$(_context) {
71
+ while (1) switch (_context.prev = _context.next) {
72
+ case 0:
73
+ if ((0, _platformFeatureFlags.fg)('enable_ptc_sharded_townsquare_calls')) {
74
+ _context.next = 2;
75
+ break;
76
+ }
77
+ return _context.abrupt("return", Promise.resolve((_this$tcClient3 = this.tcClient) === null || _this$tcClient3 === void 0 ? void 0 : _this$tcClient3.options.teamCentralBaseUrl));
78
+ case 2:
79
+ if (!(this.tcClient === undefined)) {
80
+ _context.next = 4;
81
+ break;
82
+ }
83
+ return _context.abrupt("return", Promise.resolve(undefined));
84
+ case 4:
85
+ _context.next = 6;
86
+ return this.tcClient.getIsGlobalExperienceWorkspace();
87
+ case 6:
88
+ isGlobalExperienceWorkspace = _context.sent;
89
+ return _context.abrupt("return", Promise.resolve(isGlobalExperienceWorkspace ? (0, _atlassianContext.getATLContextUrl)('home') : (0, _atlassianContext.getATLContextUrl)('team')));
90
+ case 8:
91
+ case "end":
92
+ return _context.stop();
93
+ }
94
+ }, _callee, this);
95
+ }));
96
+ function getTeamCentralBaseUrl() {
97
+ return _getTeamCentralBaseUrl.apply(this, arguments);
98
+ }
99
+ return getTeamCentralBaseUrl;
100
+ }()
69
101
  }, {
70
102
  key: "shouldShowGiveKudos",
71
- value: function shouldShowGiveKudos() {
72
- if (!this.tcClient || !this.getTeamCentralBaseUrl()) {
73
- return Promise.resolve(false);
103
+ value: function () {
104
+ var _shouldShowGiveKudos = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
105
+ return _regenerator.default.wrap(function _callee2$(_context2) {
106
+ while (1) switch (_context2.prev = _context2.next) {
107
+ case 0:
108
+ _context2.t0 = !this.tcClient;
109
+ if (_context2.t0) {
110
+ _context2.next = 5;
111
+ break;
112
+ }
113
+ _context2.next = 4;
114
+ return this.getTeamCentralBaseUrl();
115
+ case 4:
116
+ _context2.t0 = !_context2.sent;
117
+ case 5:
118
+ if (!_context2.t0) {
119
+ _context2.next = 7;
120
+ break;
121
+ }
122
+ return _context2.abrupt("return", Promise.resolve(false));
123
+ case 7:
124
+ return _context2.abrupt("return", this.tcClient.checkWorkspaceExists());
125
+ case 8:
126
+ case "end":
127
+ return _context2.stop();
128
+ }
129
+ }, _callee2, this);
130
+ }));
131
+ function shouldShowGiveKudos() {
132
+ return _shouldShowGiveKudos.apply(this, arguments);
74
133
  }
75
- return this.tcClient.checkWorkspaceExists();
76
- }
134
+ return shouldShowGiveKudos;
135
+ }()
77
136
  }, {
78
137
  key: "getRovoAgentProfile",
79
138
  value: function getRovoAgentProfile(id, analytics) {
@@ -26,6 +26,7 @@ var buildReportingLinesQuery = exports.buildReportingLinesQuery = function build
26
26
  };
27
27
  };
28
28
  var isTCReadyPromiseMap = new Map();
29
+ var globalExperiencePromiseCache = new Map();
29
30
  var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
30
31
  (0, _inherits2.default)(TeamCentralCardClient, _CachingClient);
31
32
  var _super = _createSuper(TeamCentralCardClient);
@@ -45,6 +46,7 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
45
46
  _this.options = options;
46
47
  _this.bypassOnFailure = false;
47
48
  _this.isTCReadyPromise = _this.createTcReadyPromise(options);
49
+ _this.isGlobalExperienceWorkspacePromise = _this.preloadIsGlobalExperienceWorkspace(options.cloudId);
48
50
  return _this;
49
51
  }
50
52
  (0, _createClass2.default)(TeamCentralCardClient, [{
@@ -175,18 +177,88 @@ var TeamCentralCardClient = /*#__PURE__*/function (_CachingClient) {
175
177
  return Promise.resolve(false);
176
178
  });
177
179
  }
180
+ }, {
181
+ key: "getIsGlobalExperienceWorkspace",
182
+ value: function getIsGlobalExperienceWorkspace() {
183
+ return this.isGlobalExperienceWorkspacePromise;
184
+ }
185
+ }, {
186
+ key: "preloadIsGlobalExperienceWorkspace",
187
+ value: function preloadIsGlobalExperienceWorkspace(cloudId) {
188
+ if (!(0, _platformFeatureFlags.fg)('enable_ptc_sharded_townsquare_calls')) {
189
+ return Promise.resolve(false);
190
+ }
191
+ if (cloudId === undefined) {
192
+ return Promise.resolve(false);
193
+ }
194
+ var maybeIsGlobalExperienceWorkspaceForCloudIdPromise = globalExperiencePromiseCache.get(cloudId);
195
+ if (maybeIsGlobalExperienceWorkspaceForCloudIdPromise !== undefined) {
196
+ return maybeIsGlobalExperienceWorkspaceForCloudIdPromise;
197
+ }
198
+ var isGlobalExperienceWorkspaceForCloudIdPromise = this.isGlobalExperienceWorkspaceForCloudId(cloudId);
199
+ globalExperiencePromiseCache.set(cloudId, isGlobalExperienceWorkspaceForCloudIdPromise);
200
+ return isGlobalExperienceWorkspaceForCloudIdPromise;
201
+ }
178
202
  }, {
179
203
  key: "hasTCWorkspace",
180
204
  value: function hasTCWorkspace(config) {
181
205
  if (config.cloudId) {
182
- var maybeShardedPath = (0, _platformFeatureFlags.fg)('enable_ptc_sharded_townsquare_calls') ? "/townsquare/s/".concat(config.cloudId) : '/watermelon';
183
- return fetch("/gateway/api".concat(maybeShardedPath, "/organization/containsAnyWorkspace?cloudId=").concat(config.cloudId)).then(function (res) {
206
+ var maybeShardedApiPath = this.getMaybeShardedApiPath(config.cloudId);
207
+ return fetch("".concat(maybeShardedApiPath, "/organization/containsAnyWorkspace?cloudId=").concat(config.cloudId)).then(function (res) {
184
208
  return !res || res && res.ok;
185
209
  });
186
210
  } else {
187
211
  return Promise.resolve(false);
188
212
  }
189
213
  }
214
+ }, {
215
+ key: "isGlobalExperienceWorkspaceForCloudId",
216
+ value: function () {
217
+ var _isGlobalExperienceWorkspaceForCloudId = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(cloudId) {
218
+ var maybeShardedApiPath, response, workspaceType;
219
+ return _regenerator.default.wrap(function _callee2$(_context2) {
220
+ while (1) switch (_context2.prev = _context2.next) {
221
+ case 0:
222
+ maybeShardedApiPath = this.getMaybeShardedApiPath(cloudId);
223
+ _context2.prev = 1;
224
+ _context2.next = 4;
225
+ return fetch("".concat(maybeShardedApiPath, "/workspace/existsWithWorkspaceType?cloudId=").concat(cloudId), {
226
+ credentials: 'include'
227
+ });
228
+ case 4:
229
+ response = _context2.sent;
230
+ if (!response.ok) {
231
+ _context2.next = 10;
232
+ break;
233
+ }
234
+ _context2.next = 8;
235
+ return response.text();
236
+ case 8:
237
+ workspaceType = _context2.sent;
238
+ return _context2.abrupt("return", Promise.resolve(workspaceType === 'GLOBAL_EXPERIENCE'));
239
+ case 10:
240
+ return _context2.abrupt("return", Promise.resolve(false));
241
+ case 13:
242
+ _context2.prev = 13;
243
+ _context2.t0 = _context2["catch"](1);
244
+ return _context2.abrupt("return", Promise.resolve(false));
245
+ case 16:
246
+ case "end":
247
+ return _context2.stop();
248
+ }
249
+ }, _callee2, this, [[1, 13]]);
250
+ }));
251
+ function isGlobalExperienceWorkspaceForCloudId(_x2) {
252
+ return _isGlobalExperienceWorkspaceForCloudId.apply(this, arguments);
253
+ }
254
+ return isGlobalExperienceWorkspaceForCloudId;
255
+ }()
256
+ }, {
257
+ key: "getMaybeShardedApiPath",
258
+ value: function getMaybeShardedApiPath(cloudId) {
259
+ var maybeShardedPath = (0, _platformFeatureFlags.fg)('enable_ptc_sharded_townsquare_calls') ? "/townsquare/s/".concat(cloudId) : '/watermelon';
260
+ return "/gateway/api".concat(maybeShardedPath);
261
+ }
190
262
  }, {
191
263
  key: "filterReportingLinesUser",
192
264
  value: function filterReportingLinesUser() {
@@ -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', "20.4.3");
60
+ headers.append('atl-client-version', "20.6.0");
61
61
  return headers;
62
62
  };
63
63
  function getTeamFromAGG(_x, _x2, _x3) {
@@ -186,7 +186,7 @@ var TeamProfileCardTriggerInternal = exports.TeamProfileCardTriggerInternal = /*
186
186
  var fireEvent = function fireEvent(event) {
187
187
  _this.fireAnalytics(event);
188
188
  };
189
- var requests = Promise.all([_this.props.resourceClient.getTeamProfile(teamId, orgId, fireEvent), _this.props.resourceClient.shouldShowGiveKudos()]);
189
+ var requests = Promise.all([_this.props.resourceClient.getTeamProfile(teamId, orgId, fireEvent), _this.props.resourceClient.shouldShowGiveKudos(), _this.props.resourceClient.getTeamCentralBaseUrl()]);
190
190
  requests.then(function (res) {
191
191
  var _this2;
192
192
  return (_this2 = _this).handleClientSuccess.apply(_this2, (0, _toConsumableArray2.default)(res));
@@ -309,7 +309,7 @@ var TeamProfileCardTriggerInternal = exports.TeamProfileCardTriggerInternal = /*
309
309
  }
310
310
  }, {
311
311
  key: "handleClientSuccess",
312
- value: function handleClientSuccess(team, shouldShowGiveKudos) {
312
+ value: function handleClientSuccess(team, shouldShowGiveKudos, teamCentralBaseUrl) {
313
313
  if (!this._isMounted) {
314
314
  return;
315
315
  }
@@ -318,7 +318,7 @@ var TeamProfileCardTriggerInternal = exports.TeamProfileCardTriggerInternal = /*
318
318
  hasError: false,
319
319
  data: team,
320
320
  shouldShowGiveKudos: shouldShowGiveKudos,
321
- teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl()
321
+ teamCentralBaseUrl: teamCentralBaseUrl
322
322
  });
323
323
  }
324
324
  }, {
@@ -49,7 +49,8 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
49
49
  data: null,
50
50
  reportingLinesData: undefined,
51
51
  isKudosEnabled: false,
52
- kudosDrawerOpen: false
52
+ kudosDrawerOpen: false,
53
+ teamCentralBaseUrl: undefined
53
54
  });
54
55
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fireAnalytics", function (payload) {
55
56
  // Don't fire analytics if the component is unmounted
@@ -74,7 +75,7 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
74
75
  hasError: false,
75
76
  data: null
76
77
  }, function () {
77
- var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId, userId, _this.fireAnalytics), _this.props.resourceClient.getReportingLines(userId), _this.props.resourceClient.shouldShowGiveKudos()]);
78
+ var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId, userId, _this.fireAnalytics), _this.props.resourceClient.getReportingLines(userId), _this.props.resourceClient.shouldShowGiveKudos(), _this.props.resourceClient.getTeamCentralBaseUrl()]);
78
79
  requests.then(function (res) {
79
80
  var _this2;
80
81
  return (_this2 = _this).handleClientSuccess.apply(_this2, (0, _toConsumableArray2.default)(res));
@@ -126,7 +127,7 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
126
127
  }
127
128
  }, {
128
129
  key: "handleClientSuccess",
129
- value: function handleClientSuccess(profileData, reportingLinesData, shouldShowGiveKudos) {
130
+ value: function handleClientSuccess(profileData, reportingLinesData, shouldShowGiveKudos, teamCentralBaseUrl) {
130
131
  if (!this._isMounted) {
131
132
  return;
132
133
  }
@@ -135,7 +136,8 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
135
136
  hasError: false,
136
137
  data: profileData,
137
138
  reportingLinesData: reportingLinesData,
138
- isKudosEnabled: shouldShowGiveKudos
139
+ isKudosEnabled: shouldShowGiveKudos,
140
+ teamCentralBaseUrl: teamCentralBaseUrl
139
141
  });
140
142
  }
141
143
  }, {
@@ -159,7 +161,8 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
159
161
  error = _this$state.error,
160
162
  data = _this$state.data,
161
163
  reportingLinesData = _this$state.reportingLinesData,
162
- isKudosEnabled = _this$state.isKudosEnabled;
164
+ isKudosEnabled = _this$state.isKudosEnabled,
165
+ teamCentralBaseUrl = _this$state.teamCentralBaseUrl;
163
166
  var _this$props3 = this.props,
164
167
  onReportingLinesClick = _this$props3.onReportingLinesClick,
165
168
  cloudId = _this$props3.cloudId,
@@ -190,7 +193,7 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
190
193
  addFlag: addFlag
191
194
  }, data), {}, {
192
195
  isKudosEnabled: isKudosEnabled,
193
- teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl(),
196
+ teamCentralBaseUrl: teamCentralBaseUrl,
194
197
  openKudosDrawer: this.openKudosDrawer
195
198
  });
196
199
  return /*#__PURE__*/_react.default.createElement(_Card.CardWrapper, null, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isKudosEnabled && /*#__PURE__*/_react.default.createElement(_react.Suspense, {
@@ -191,7 +191,7 @@ function ProfilecardTriggerNext(_ref2) {
191
191
  setVisible(false);
192
192
  onVisibilityChange && onVisibilityChange(false);
193
193
  }, [setTriggeredUsingKeyboard, setVisible, onVisibilityChange]);
194
- var handleClientSuccess = (0, _react.useCallback)(function (profileData, reportingLinesData, shouldShowGiveKudos) {
194
+ var handleClientSuccess = (0, _react.useCallback)(function (profileData, reportingLinesData, shouldShowGiveKudos, teamCentralBaseUrl) {
195
195
  if (!isMounted.current) {
196
196
  return;
197
197
  }
@@ -199,6 +199,7 @@ function ProfilecardTriggerNext(_ref2) {
199
199
  setHasError(false);
200
200
  setData(profileData);
201
201
  setReportingLinesData(reportingLinesData);
202
+ setTeamCentralBaseUrl(teamCentralBaseUrl);
202
203
  setShouldShowGiveKudos(shouldShowGiveKudos);
203
204
  }, [setHasError, setIsLoading, setData, setReportingLinesData, setShouldShowGiveKudos]);
204
205
  var handleClientError = (0, _react.useCallback)(function (err) {
@@ -220,29 +221,28 @@ function ProfilecardTriggerNext(_ref2) {
220
221
  }
221
222
  return _context.abrupt("return");
222
223
  case 2:
223
- setTeamCentralBaseUrl(resourceClient.getTeamCentralBaseUrl());
224
224
  setIsLoading(true);
225
225
  setHasError(false);
226
226
  setError(null);
227
227
  setData(null);
228
- _context.prev = 7;
229
- requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos()]);
230
- _context.next = 11;
228
+ _context.prev = 6;
229
+ requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos(), resourceClient.getTeamCentralBaseUrl()]);
230
+ _context.next = 10;
231
231
  return requests;
232
- case 11:
232
+ case 10:
233
233
  responses = _context.sent;
234
234
  handleClientSuccess.apply(void 0, (0, _toConsumableArray2.default)(responses));
235
- _context.next = 18;
235
+ _context.next = 17;
236
236
  break;
237
- case 15:
238
- _context.prev = 15;
239
- _context.t0 = _context["catch"](7);
237
+ case 14:
238
+ _context.prev = 14;
239
+ _context.t0 = _context["catch"](6);
240
240
  handleClientError(_context.t0);
241
- case 18:
241
+ case 17:
242
242
  case "end":
243
243
  return _context.stop();
244
244
  }
245
- }, _callee, null, [[7, 15]]);
245
+ }, _callee, null, [[6, 14]]);
246
246
  })), [cloudId, fireAnalytics, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
247
247
  var showProfilecard = (0, _react.useCallback)(function () {
248
248
  clearTimeout(hideTimer.current);
@@ -7,8 +7,8 @@ exports.default = void 0;
7
7
  /**
8
8
  * NOTE:
9
9
  *
10
- * This file is automatically generated by i18n-tools.
11
- * DO NOT CHANGE IT BY HAND or your changes will be lost.
10
+ * This file was generated by i18n-tools which has been deprecated.
11
+ * It now requires manual updates.
12
12
  */
13
13
  var _default = exports.default = {
14
14
  zh: 'Chinese',
@@ -17,6 +17,8 @@ var _default = exports.default = {
17
17
  nl: 'Dutch',
18
18
  en: 'English',
19
19
  en_GB: 'English (United Kingdom)',
20
+ en_ZZ: 'English (Instrumented)',
21
+ // Used by i18n team in staging
20
22
  et: 'Estonian',
21
23
  fi: 'Finnish',
22
24
  fr: 'French',
@@ -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: "20.4.3"
48
+ packageVersion: "20.6.0"
49
49
  }, attributes), {}, {
50
50
  firedAt: Math.round((0, _performance.getPageTime)())
51
51
  })
@@ -1,4 +1,4 @@
1
- import { isFedRamp } from '@atlaskit/atlassian-context';
1
+ import { getATLContextUrl, isFedRamp } from '@atlaskit/atlassian-context';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import RovoAgentCardClient from './RovoAgentCardClient';
4
4
  import TeamCentralCardClient from './TeamCentralCardClient';
@@ -43,12 +43,19 @@ class ProfileCardClient {
43
43
  reports: []
44
44
  });
45
45
  }
46
- getTeamCentralBaseUrl() {
47
- var _this$tcClient3;
48
- return (_this$tcClient3 = this.tcClient) === null || _this$tcClient3 === void 0 ? void 0 : _this$tcClient3.options.teamCentralBaseUrl;
46
+ async getTeamCentralBaseUrl() {
47
+ if (!fg('enable_ptc_sharded_townsquare_calls')) {
48
+ var _this$tcClient3;
49
+ return Promise.resolve((_this$tcClient3 = this.tcClient) === null || _this$tcClient3 === void 0 ? void 0 : _this$tcClient3.options.teamCentralBaseUrl);
50
+ }
51
+ if (this.tcClient === undefined) {
52
+ return Promise.resolve(undefined);
53
+ }
54
+ const isGlobalExperienceWorkspace = await this.tcClient.getIsGlobalExperienceWorkspace();
55
+ return Promise.resolve(isGlobalExperienceWorkspace ? getATLContextUrl('home') : getATLContextUrl('team'));
49
56
  }
50
- shouldShowGiveKudos() {
51
- if (!this.tcClient || !this.getTeamCentralBaseUrl()) {
57
+ async shouldShowGiveKudos() {
58
+ if (!this.tcClient || !(await this.getTeamCentralBaseUrl())) {
52
59
  return Promise.resolve(false);
53
60
  }
54
61
  return this.tcClient.checkWorkspaceExists();
@@ -32,6 +32,7 @@ export const buildReportingLinesQuery = aaid => ({
32
32
  }
33
33
  });
34
34
  let isTCReadyPromiseMap = new Map();
35
+ const globalExperiencePromiseCache = new Map();
35
36
  class TeamCentralCardClient extends CachingClient {
36
37
  /**
37
38
  * Simple circuit breaker to avoid making unnecessary calls to Team Central on auth failures
@@ -47,6 +48,7 @@ class TeamCentralCardClient extends CachingClient {
47
48
  this.options = options;
48
49
  this.bypassOnFailure = false;
49
50
  this.isTCReadyPromise = this.createTcReadyPromise(options);
51
+ this.isGlobalExperienceWorkspacePromise = this.preloadIsGlobalExperienceWorkspace(options.cloudId);
50
52
  }
51
53
  createTcReadyPromise(config) {
52
54
  if (config.cloudId) {
@@ -134,16 +136,53 @@ class TeamCentralCardClient extends CachingClient {
134
136
  return Promise.resolve(false);
135
137
  }, () => Promise.resolve(false));
136
138
  }
139
+ getIsGlobalExperienceWorkspace() {
140
+ return this.isGlobalExperienceWorkspacePromise;
141
+ }
142
+ preloadIsGlobalExperienceWorkspace(cloudId) {
143
+ if (!fg('enable_ptc_sharded_townsquare_calls')) {
144
+ return Promise.resolve(false);
145
+ }
146
+ if (cloudId === undefined) {
147
+ return Promise.resolve(false);
148
+ }
149
+ const maybeIsGlobalExperienceWorkspaceForCloudIdPromise = globalExperiencePromiseCache.get(cloudId);
150
+ if (maybeIsGlobalExperienceWorkspaceForCloudIdPromise !== undefined) {
151
+ return maybeIsGlobalExperienceWorkspaceForCloudIdPromise;
152
+ }
153
+ const isGlobalExperienceWorkspaceForCloudIdPromise = this.isGlobalExperienceWorkspaceForCloudId(cloudId);
154
+ globalExperiencePromiseCache.set(cloudId, isGlobalExperienceWorkspaceForCloudIdPromise);
155
+ return isGlobalExperienceWorkspaceForCloudIdPromise;
156
+ }
137
157
  hasTCWorkspace(config) {
138
158
  if (config.cloudId) {
139
- const maybeShardedPath = fg('enable_ptc_sharded_townsquare_calls') ? `/townsquare/s/${config.cloudId}` : '/watermelon';
140
- return fetch(`/gateway/api${maybeShardedPath}/organization/containsAnyWorkspace?cloudId=${config.cloudId}`).then(res => {
159
+ const maybeShardedApiPath = this.getMaybeShardedApiPath(config.cloudId);
160
+ return fetch(`${maybeShardedApiPath}/organization/containsAnyWorkspace?cloudId=${config.cloudId}`).then(res => {
141
161
  return !res || res && res.ok;
142
162
  });
143
163
  } else {
144
164
  return Promise.resolve(false);
145
165
  }
146
166
  }
167
+ async isGlobalExperienceWorkspaceForCloudId(cloudId) {
168
+ const maybeShardedApiPath = this.getMaybeShardedApiPath(cloudId);
169
+ try {
170
+ const response = await fetch(`${maybeShardedApiPath}/workspace/existsWithWorkspaceType?cloudId=${cloudId}`, {
171
+ credentials: 'include'
172
+ });
173
+ if (response.ok) {
174
+ const workspaceType = await response.text();
175
+ return Promise.resolve(workspaceType === 'GLOBAL_EXPERIENCE');
176
+ }
177
+ return Promise.resolve(false);
178
+ } catch (err) {
179
+ return Promise.resolve(false);
180
+ }
181
+ }
182
+ getMaybeShardedApiPath(cloudId) {
183
+ const maybeShardedPath = fg('enable_ptc_sharded_townsquare_calls') ? `/townsquare/s/${cloudId}` : '/watermelon';
184
+ return `/gateway/api${maybeShardedPath}`;
185
+ }
147
186
  filterReportingLinesUser(users = []) {
148
187
  return users.filter(user => user.identifierType === 'ATLASSIAN_ID');
149
188
  }
@@ -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', "20.4.3");
70
+ headers.append('atl-client-version', "20.6.0");
71
71
  return headers;
72
72
  };
73
73
  export async function getTeamFromAGG(url, teamId, siteId) {
@@ -161,7 +161,7 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
161
161
  const fireEvent = event => {
162
162
  this.fireAnalytics(event);
163
163
  };
164
- const requests = Promise.all([this.props.resourceClient.getTeamProfile(teamId, orgId, fireEvent), this.props.resourceClient.shouldShowGiveKudos()]);
164
+ const requests = Promise.all([this.props.resourceClient.getTeamProfile(teamId, orgId, fireEvent), this.props.resourceClient.shouldShowGiveKudos(), this.props.resourceClient.getTeamCentralBaseUrl()]);
165
165
  requests.then(res => this.handleClientSuccess(...res), err => this.handleClientError(err)).catch(err => this.handleClientError(err));
166
166
  });
167
167
  });
@@ -274,7 +274,7 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
274
274
  clearTimeout(this.showTimer);
275
275
  clearTimeout(this.hideTimer);
276
276
  }
277
- handleClientSuccess(team, shouldShowGiveKudos) {
277
+ handleClientSuccess(team, shouldShowGiveKudos, teamCentralBaseUrl) {
278
278
  if (!this._isMounted) {
279
279
  return;
280
280
  }
@@ -283,7 +283,7 @@ export class TeamProfileCardTriggerInternal extends React.PureComponent {
283
283
  hasError: false,
284
284
  data: team,
285
285
  shouldShowGiveKudos,
286
- teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl()
286
+ teamCentralBaseUrl
287
287
  });
288
288
  }
289
289
  handleClientError(err) {
@@ -21,7 +21,8 @@ class ProfileCardResourced extends React.PureComponent {
21
21
  data: null,
22
22
  reportingLinesData: undefined,
23
23
  isKudosEnabled: false,
24
- kudosDrawerOpen: false
24
+ kudosDrawerOpen: false,
25
+ teamCentralBaseUrl: undefined
25
26
  });
26
27
  _defineProperty(this, "fireAnalytics", payload => {
27
28
  // Don't fire analytics if the component is unmounted
@@ -49,7 +50,7 @@ class ProfileCardResourced extends React.PureComponent {
49
50
  hasError: false,
50
51
  data: null
51
52
  }, () => {
52
- const requests = Promise.all([this.props.resourceClient.getProfile(cloudId, userId, this.fireAnalytics), this.props.resourceClient.getReportingLines(userId), this.props.resourceClient.shouldShowGiveKudos()]);
53
+ const requests = Promise.all([this.props.resourceClient.getProfile(cloudId, userId, this.fireAnalytics), this.props.resourceClient.getReportingLines(userId), this.props.resourceClient.shouldShowGiveKudos(), this.props.resourceClient.getTeamCentralBaseUrl()]);
53
54
  requests.then(res => this.handleClientSuccess(...res), err => this.handleClientError(err)).catch(err => this.handleClientError(err));
54
55
  });
55
56
  });
@@ -84,7 +85,7 @@ class ProfileCardResourced extends React.PureComponent {
84
85
  componentWillUnmount() {
85
86
  this._isMounted = false;
86
87
  }
87
- handleClientSuccess(profileData, reportingLinesData, shouldShowGiveKudos) {
88
+ handleClientSuccess(profileData, reportingLinesData, shouldShowGiveKudos, teamCentralBaseUrl) {
88
89
  if (!this._isMounted) {
89
90
  return;
90
91
  }
@@ -93,7 +94,8 @@ class ProfileCardResourced extends React.PureComponent {
93
94
  hasError: false,
94
95
  data: profileData,
95
96
  reportingLinesData,
96
- isKudosEnabled: shouldShowGiveKudos
97
+ isKudosEnabled: shouldShowGiveKudos,
98
+ teamCentralBaseUrl
97
99
  });
98
100
  }
99
101
  handleClientError(err) {
@@ -113,7 +115,8 @@ class ProfileCardResourced extends React.PureComponent {
113
115
  error,
114
116
  data,
115
117
  reportingLinesData,
116
- isKudosEnabled
118
+ isKudosEnabled,
119
+ teamCentralBaseUrl
117
120
  } = this.state;
118
121
  const {
119
122
  onReportingLinesClick,
@@ -146,7 +149,7 @@ class ProfileCardResourced extends React.PureComponent {
146
149
  addFlag,
147
150
  ...data,
148
151
  isKudosEnabled,
149
- teamCentralBaseUrl: this.props.resourceClient.getTeamCentralBaseUrl(),
152
+ teamCentralBaseUrl,
150
153
  openKudosDrawer: this.openKudosDrawer
151
154
  };
152
155
  return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(React.Fragment, null, isKudosEnabled && /*#__PURE__*/React.createElement(Suspense, {
@@ -142,7 +142,7 @@ export default function ProfilecardTriggerNext({
142
142
  setVisible(false);
143
143
  onVisibilityChange && onVisibilityChange(false);
144
144
  }, [setTriggeredUsingKeyboard, setVisible, onVisibilityChange]);
145
- const handleClientSuccess = useCallback((profileData, reportingLinesData, shouldShowGiveKudos) => {
145
+ const handleClientSuccess = useCallback((profileData, reportingLinesData, shouldShowGiveKudos, teamCentralBaseUrl) => {
146
146
  if (!isMounted.current) {
147
147
  return;
148
148
  }
@@ -150,6 +150,7 @@ export default function ProfilecardTriggerNext({
150
150
  setHasError(false);
151
151
  setData(profileData);
152
152
  setReportingLinesData(reportingLinesData);
153
+ setTeamCentralBaseUrl(teamCentralBaseUrl);
153
154
  setShouldShowGiveKudos(shouldShowGiveKudos);
154
155
  }, [setHasError, setIsLoading, setData, setReportingLinesData, setShouldShowGiveKudos]);
155
156
  const handleClientError = useCallback(err => {
@@ -165,13 +166,12 @@ export default function ProfilecardTriggerNext({
165
166
  // don't fetch data when fetching is in process
166
167
  return;
167
168
  }
168
- setTeamCentralBaseUrl(resourceClient.getTeamCentralBaseUrl());
169
169
  setIsLoading(true);
170
170
  setHasError(false);
171
171
  setError(null);
172
172
  setData(null);
173
173
  try {
174
- const requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos()]);
174
+ const requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos(), resourceClient.getTeamCentralBaseUrl()]);
175
175
  const responses = await requests;
176
176
  handleClientSuccess(...responses);
177
177
  } catch (err) {