@atlaskit/teams-public 0.49.0 → 0.50.1

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 (50) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/controllers/hooks/use-requested-container/index.js +196 -51
  3. package/dist/cjs/controllers/hooks/use-requested-container/utils.js +42 -7
  4. package/dist/cjs/controllers/hooks/use-team-containers/index.js +18 -9
  5. package/dist/cjs/i18n/en.js +4 -1
  6. package/dist/cjs/i18n/en_GB.js +4 -1
  7. package/dist/cjs/i18n/en_ZZ.js +4 -1
  8. package/dist/cjs/i18n/fr.js +4 -1
  9. package/dist/cjs/i18n/ru.js +4 -1
  10. package/dist/cjs/i18n/uk.js +4 -1
  11. package/dist/cjs/ui/team-containers/main.js +1 -0
  12. package/dist/es2019/controllers/hooks/use-requested-container/index.js +140 -42
  13. package/dist/es2019/controllers/hooks/use-requested-container/utils.js +41 -7
  14. package/dist/es2019/controllers/hooks/use-team-containers/index.js +2 -1
  15. package/dist/es2019/i18n/en.js +4 -1
  16. package/dist/es2019/i18n/en_GB.js +4 -1
  17. package/dist/es2019/i18n/en_ZZ.js +4 -1
  18. package/dist/es2019/i18n/fr.js +4 -1
  19. package/dist/es2019/i18n/ru.js +4 -1
  20. package/dist/es2019/i18n/uk.js +4 -1
  21. package/dist/es2019/ui/team-containers/main.js +1 -0
  22. package/dist/esm/controllers/hooks/use-requested-container/index.js +195 -52
  23. package/dist/esm/controllers/hooks/use-requested-container/utils.js +40 -6
  24. package/dist/esm/controllers/hooks/use-team-containers/index.js +18 -9
  25. package/dist/esm/i18n/en.js +4 -1
  26. package/dist/esm/i18n/en_GB.js +4 -1
  27. package/dist/esm/i18n/en_ZZ.js +4 -1
  28. package/dist/esm/i18n/fr.js +4 -1
  29. package/dist/esm/i18n/ru.js +4 -1
  30. package/dist/esm/i18n/uk.js +4 -1
  31. package/dist/esm/ui/team-containers/main.js +1 -0
  32. package/dist/types/controllers/hooks/use-requested-container/index.d.ts +3 -4
  33. package/dist/types/controllers/hooks/use-requested-container/utils.d.ts +13 -2
  34. package/dist/types/controllers/hooks/use-team-containers/index.d.ts +1 -1
  35. package/dist/types/i18n/en.d.ts +3 -0
  36. package/dist/types/i18n/en_GB.d.ts +3 -0
  37. package/dist/types/i18n/en_ZZ.d.ts +3 -0
  38. package/dist/types/i18n/fr.d.ts +3 -0
  39. package/dist/types/i18n/ru.d.ts +3 -0
  40. package/dist/types/i18n/uk.d.ts +3 -0
  41. package/dist/types-ts4.5/controllers/hooks/use-requested-container/index.d.ts +3 -4
  42. package/dist/types-ts4.5/controllers/hooks/use-requested-container/utils.d.ts +13 -2
  43. package/dist/types-ts4.5/controllers/hooks/use-team-containers/index.d.ts +1 -1
  44. package/dist/types-ts4.5/i18n/en.d.ts +3 -0
  45. package/dist/types-ts4.5/i18n/en_GB.d.ts +3 -0
  46. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +3 -0
  47. package/dist/types-ts4.5/i18n/fr.d.ts +3 -0
  48. package/dist/types-ts4.5/i18n/ru.d.ts +3 -0
  49. package/dist/types-ts4.5/i18n/uk.d.ts +3 -0
  50. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/teams-public
2
2
 
3
+ ## 0.50.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#190537](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/190537)
8
+ [`cc7e5ed8bb6e1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cc7e5ed8bb6e1) -
9
+ Update the polling interval for the requested containers hook
10
+ - Updated dependencies
11
+
12
+ ## 0.50.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [#189223](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/189223)
17
+ [`2b465d07bf40a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2b465d07bf40a) -
18
+ Update useRequestedContainers to support try again behaviour
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+
3
24
  ## 0.49.0
4
25
 
5
26
  ### Minor Changes
@@ -1,18 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.useRequestedContainers = useRequestedContainers;
8
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
- var _react = require("react");
12
+ var _react = _interopRequireWildcard(require("react"));
13
13
  var _reactIntlNext = require("react-intl-next");
14
+ var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
15
+ var _compiled = require("@atlaskit/primitives/compiled");
16
+ var _teamsClient = require("@atlaskit/teams-client");
14
17
  var _useTeamContainers2 = require("../use-team-containers");
15
18
  var _utils = require("./utils");
19
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
20
  /**
17
21
  * Hook to track and poll for requested product containers (such as a Jira Project).
18
22
  * The initial list of requested containers is derived from the URL parameters, however it can be updated based on user interactions.
@@ -27,48 +31,198 @@ var _utils = require("./utils");
27
31
  */
28
32
  function useRequestedContainers(_ref) {
29
33
  var teamId = _ref.teamId,
34
+ cloudId = _ref.cloudId,
30
35
  onRequestedContainerTimeout = _ref.onRequestedContainerTimeout;
31
36
  var _useIntl = (0, _reactIntlNext.useIntl)(),
32
37
  formatMessage = _useIntl.formatMessage;
33
38
  var _useTeamContainers = (0, _useTeamContainers2.useTeamContainers)(teamId),
34
39
  refetchTeamContainers = _useTeamContainers.refetchTeamContainers,
35
40
  teamContainers = _useTeamContainers.teamContainers;
36
- var _useState = (0, _react.useState)(function () {
37
- return (0, _utils.userCanAccessFeature)() ? (0, _utils.getRequestedContainersFromUrl)() : [];
38
- }),
41
+ var _useState = (0, _react.useState)(false),
39
42
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
40
- requestedContainers = _useState2[0],
41
- setRequestedContainers = _useState2[1];
43
+ isTryingAgain = _useState2[0],
44
+ setIsTryingAgain = _useState2[1];
45
+ var tryAgainCountRef = (0, _react.useRef)(0);
46
+ var _useState3 = (0, _react.useState)(0),
47
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
48
+ refetchErrorCount = _useState4[0],
49
+ setRefetchErrorCount = _useState4[1];
50
+ var _useState5 = (0, _react.useState)(function () {
51
+ return (0, _utils.getRequestedContainersFromUrl)();
52
+ }),
53
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
54
+ requestedContainers = _useState6[0],
55
+ setRequestedContainers = _useState6[1];
42
56
  var checkContainers = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
43
57
  return _regenerator.default.wrap(function _callee$(_context) {
44
58
  while (1) switch (_context.prev = _context.next) {
45
59
  case 0:
46
- _context.next = 2;
60
+ _context.prev = 0;
61
+ _context.next = 3;
47
62
  return refetchTeamContainers();
48
- case 2:
63
+ case 3:
64
+ _context.next = 8;
65
+ break;
66
+ case 5:
67
+ _context.prev = 5;
68
+ _context.t0 = _context["catch"](0);
69
+ setRefetchErrorCount(function (prev) {
70
+ return prev + 1;
71
+ });
72
+ case 8:
49
73
  case "end":
50
74
  return _context.stop();
51
75
  }
52
- }, _callee);
76
+ }, _callee, null, [[0, 5]]);
53
77
  })), [refetchTeamContainers]);
54
- var _useAsyncPolling = (0, _utils.useAsyncPolling)(checkContainers),
78
+ var onTimeout = (0, _react.useCallback)(function (_ref3) {
79
+ var startPolling = _ref3.startPolling,
80
+ reset = _ref3.reset;
81
+ if (!onRequestedContainerTimeout) {
82
+ return;
83
+ }
84
+ var flagId = "requested-container-timeout-".concat(requestedContainers.join('-'), "-").concat(tryAgainCountRef.current);
85
+ var createTryAgainFlag = function createTryAgainFlag(_ref4) {
86
+ var onAction = _ref4.onAction;
87
+ return {
88
+ id: flagId,
89
+ title: requestedContainers.length === 1 ? formatMessage(messages.timeoutTitle, {
90
+ container: (0, _utils.containerDisplayName)(requestedContainers[0])
91
+ }) : formatMessage(messages.timeoutTitleMultiple),
92
+ description: formatMessage(messages.timeoutDescription),
93
+ actions: [{
94
+ content: formatMessage(messages.timeoutAction),
95
+ onClick: function onClick() {
96
+ onAction(flagId);
97
+ _tryAgainAction();
98
+ }
99
+ }]
100
+ };
101
+ };
102
+ var createContactSupportFlag = function createContactSupportFlag(_ref5) {
103
+ var onAction = _ref5.onAction;
104
+ return {
105
+ id: flagId,
106
+ title: formatMessage(messages.noConnectionTitle),
107
+ description: formatMessage(messages.noConnectionDescription),
108
+ actions: [{
109
+ content: /*#__PURE__*/_react.default.createElement(_compiled.Flex, {
110
+ alignItems: "center",
111
+ columnGap: "space.100"
112
+ }, formatMessage(messages.noConnectionAction), /*#__PURE__*/_react.default.createElement(_linkExternal.default, {
113
+ label: ""
114
+ })),
115
+ onClick: function onClick() {
116
+ onAction(flagId);
117
+ },
118
+ href: 'https://support.atlassian.com/contact/#/&support_type=customer'
119
+ }]
120
+ };
121
+ };
122
+ var _tryAgainAction = /*#__PURE__*/function () {
123
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
124
+ var containers, response, containersNotCreated;
125
+ return _regenerator.default.wrap(function _callee2$(_context2) {
126
+ while (1) switch (_context2.prev = _context2.next) {
127
+ case 0:
128
+ setIsTryingAgain(true);
129
+ tryAgainCountRef.current = tryAgainCountRef.current + 1;
130
+
131
+ //todo: add analytics event here
132
+ containers = requestedContainers.map(function (container) {
133
+ return {
134
+ type: (0, _utils.convertContainerToType)(container),
135
+ containerSiteId: cloudId
136
+ };
137
+ }).filter(function (_ref7) {
138
+ var type = _ref7.type;
139
+ return Boolean(type);
140
+ });
141
+ _context2.prev = 3;
142
+ _context2.next = 6;
143
+ return _teamsClient.teamsClient.createTeamContainers({
144
+ teamId: teamId,
145
+ containers: containers
146
+ });
147
+ case 6:
148
+ response = _context2.sent;
149
+ containersNotCreated = requestedContainers.filter(function (containerType) {
150
+ var _response$containersC;
151
+ return !((_response$containersC = response.containersCreated) !== null && _response$containersC !== void 0 && _response$containersC.some(function (container) {
152
+ return container.containerType === (0, _utils.convertContainerToType)(containerType);
153
+ }));
154
+ }); //containers are still being created
155
+ if (!(containersNotCreated.length > 0)) {
156
+ _context2.next = 12;
157
+ break;
158
+ }
159
+ startPolling();
160
+ _context2.next = 15;
161
+ break;
162
+ case 12:
163
+ //all containers created so reset and update state
164
+ reset();
165
+ _context2.next = 15;
166
+ return refetchTeamContainers();
167
+ case 15:
168
+ _context2.next = 24;
169
+ break;
170
+ case 17:
171
+ _context2.prev = 17;
172
+ _context2.t0 = _context2["catch"](3);
173
+ if (!(_context2.t0 instanceof _teamsClient.HttpError)) {
174
+ _context2.next = 23;
175
+ break;
176
+ }
177
+ if (!(_context2.t0.status === 500)) {
178
+ _context2.next = 23;
179
+ break;
180
+ }
181
+ if (!(tryAgainCountRef.current < 2)) {
182
+ _context2.next = 23;
183
+ break;
184
+ }
185
+ return _context2.abrupt("return", setTimeout(function () {
186
+ //bug: this can cause two flags to be shown
187
+ _tryAgainAction();
188
+ }, _utils.POLLING_INTERVAL));
189
+ case 23:
190
+ onRequestedContainerTimeout(createContactSupportFlag);
191
+ case 24:
192
+ _context2.prev = 24;
193
+ setIsTryingAgain(false);
194
+ return _context2.finish(24);
195
+ case 27:
196
+ case "end":
197
+ return _context2.stop();
198
+ }
199
+ }, _callee2, null, [[3, 17, 24, 27]]);
200
+ }));
201
+ return function tryAgainAction() {
202
+ return _ref6.apply(this, arguments);
203
+ };
204
+ }();
205
+ onRequestedContainerTimeout(tryAgainCountRef.current === 0 ? createTryAgainFlag : createContactSupportFlag);
206
+ }, [cloudId, formatMessage, onRequestedContainerTimeout, refetchTeamContainers, requestedContainers, teamId]);
207
+ var _useAsyncPolling = (0, _utils.useAsyncPolling)(checkContainers, {
208
+ onTimeout: onTimeout
209
+ }),
55
210
  startPolling = _useAsyncPolling.startPolling,
56
211
  stopPolling = _useAsyncPolling.stopPolling,
57
212
  isPolling = _useAsyncPolling.isPolling,
58
213
  hasTimedOut = _useAsyncPolling.hasTimedOut;
59
- var checkForContainer = function checkForContainer(container) {
60
- if (!requestedContainers.includes(container)) {
61
- setRequestedContainers(function (prev) {
62
- return [].concat((0, _toConsumableArray2.default)(prev), [container]);
63
- });
64
- }
65
- startPolling();
66
- };
67
214
  (0, _react.useEffect)(function () {
68
215
  if (!(0, _utils.userCanAccessFeature)()) {
69
216
  return;
70
217
  }
71
- if (hasTimedOut) {
218
+
219
+ //stop gap to prevent sending too many failed errors
220
+ if (refetchErrorCount > 3) {
221
+ stopPolling();
222
+ //todo: add analytics event here
223
+ return;
224
+ }
225
+ if (hasTimedOut || isTryingAgain) {
72
226
  return;
73
227
  }
74
228
  var containerCount = requestedContainers.length;
@@ -77,9 +231,10 @@ function useRequestedContainers(_ref) {
77
231
  return;
78
232
  }
79
233
  if (!isPolling && containerCount > 0) {
234
+ setIsTryingAgain(false);
80
235
  startPolling();
81
236
  }
82
- }, [isPolling, requestedContainers.length, hasTimedOut, startPolling, stopPolling]);
237
+ }, [isPolling, refetchErrorCount, requestedContainers.length, hasTimedOut, startPolling, stopPolling, isTryingAgain]);
83
238
  (0, _react.useEffect)(function () {
84
239
  var containersNotFound = requestedContainers.filter(function (containerType) {
85
240
  return !teamContainers.some(function (teamContainer) {
@@ -90,36 +245,11 @@ function useRequestedContainers(_ref) {
90
245
  setRequestedContainers(containersNotFound);
91
246
  }
92
247
  }, [requestedContainers, checkContainers, teamContainers]);
93
- (0, _react.useEffect)(function () {
94
- if (hasTimedOut && onRequestedContainerTimeout) {
95
- var action = function action() {
96
- // @todo: send request to retry creating containers
97
- // This will be implemented in the next pull request
98
- };
99
- var flagId = "requested-container-timeout-".concat(requestedContainers.join('-'));
100
- var _createFlag = function _createFlag(_ref3) {
101
- var onAction = _ref3.onAction;
102
- return {
103
- id: flagId,
104
- title: requestedContainers.length === 1 ? formatMessage(messages.timeoutTitle, {
105
- container: (0, _utils.containerDisplayName)(requestedContainers[0])
106
- }) : formatMessage(messages.timeoutTitleMultiple),
107
- description: formatMessage(messages.timeoutDescription),
108
- actions: [{
109
- content: formatMessage(messages.timeoutAction),
110
- onClick: function onClick() {
111
- action();
112
- onAction(flagId);
113
- }
114
- }]
115
- };
116
- };
117
- onRequestedContainerTimeout(_createFlag);
118
- }
119
- }, [hasTimedOut, onRequestedContainerTimeout, requestedContainers, formatMessage]);
248
+ var containersLoading = (0, _react.useMemo)(function () {
249
+ return hasTimedOut && !isTryingAgain || refetchErrorCount > 3 ? [] : requestedContainers;
250
+ }, [hasTimedOut, requestedContainers, isTryingAgain, refetchErrorCount]);
120
251
  return {
121
- requestedContainers: requestedContainers,
122
- checkForContainer: checkForContainer
252
+ requestedContainers: containersLoading
123
253
  };
124
254
  }
125
255
  var messages = (0, _reactIntlNext.defineMessages)({
@@ -134,7 +264,7 @@ var messages = (0, _reactIntlNext.defineMessages)({
134
264
  description: 'Title for the timeout flag'
135
265
  },
136
266
  timeoutDescription: {
137
- id: 'teams-public..team-containers.timeout-description',
267
+ id: 'teams-public.team-containers.timeout-description',
138
268
  defaultMessage: 'Something went wrong. Verify your connection and retry.',
139
269
  description: 'Description for the timeout flag'
140
270
  },
@@ -142,5 +272,20 @@ var messages = (0, _reactIntlNext.defineMessages)({
142
272
  id: 'teams-public.team-containers.timeout-action',
143
273
  defaultMessage: 'Try again',
144
274
  description: 'Action text for the timeout flag'
275
+ },
276
+ noConnectionTitle: {
277
+ id: 'teams-public.team-containers.timeout-no-connection-title',
278
+ defaultMessage: 'Connection failed',
279
+ description: 'Title for the no connection flag'
280
+ },
281
+ noConnectionDescription: {
282
+ id: 'teams-public.team-containers.timeout-no-connection-description',
283
+ defaultMessage: 'Try manually creating the space yourself.',
284
+ description: 'Description for the no connection flag'
285
+ },
286
+ noConnectionAction: {
287
+ id: 'teams-public.team-containers.timeout-no-connection-action',
288
+ defaultMessage: 'Contact support',
289
+ description: 'Action text for the no connection flag'
145
290
  }
146
291
  });
@@ -4,9 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.POLLING_INTERVAL = exports.POLLING_DURATION = void 0;
7
+ exports.POLLING_INTERVAL = exports.POLLING_DURATION = exports.CONTAINER_MAP = void 0;
8
8
  exports.containerDisplayName = containerDisplayName;
9
9
  exports.containersEqual = containersEqual;
10
+ exports.convertContainerToType = convertContainerToType;
10
11
  exports.getRequestedContainersFromUrl = getRequestedContainersFromUrl;
11
12
  exports.useAsyncPolling = useAsyncPolling;
12
13
  exports.userCanAccessFeature = userCanAccessFeature;
@@ -19,7 +20,7 @@ var _react = require("react");
19
20
  var _featureGateJsClient = _interopRequireDefault(require("@atlaskit/feature-gate-js-client"));
20
21
  var _frontendUtilities = require("@atlaskit/frontend-utilities");
21
22
  var _types = require("@atlaskit/teams-client/types");
22
- var CONTAINER_MAP = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.ContainerType.CONFLUENCE_SPACE, 'ConfluenceSpace'), _types.ContainerType.JIRA_PROJECT, 'JiraProject'), _types.ContainerType.LOOM_SPACE, 'LoomSpace');
23
+ var CONTAINER_MAP = exports.CONTAINER_MAP = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.ContainerType.CONFLUENCE_SPACE, 'ConfluenceSpace'), _types.ContainerType.JIRA_PROJECT, 'JiraProject'), _types.ContainerType.LOOM_SPACE, 'LoomSpace');
23
24
  var CONTAINER_HUMAN_NAMES = {
24
25
  ConfluenceSpace: 'Confluence space',
25
26
  JiraProject: 'Jira project',
@@ -32,15 +33,31 @@ function getRequestedContainersFromUrl() {
32
33
  var _searchParams$get;
33
34
  var searchParams = new URLSearchParams(window.location.search);
34
35
  var values = ((_searchParams$get = searchParams.get('requestedContainers')) === null || _searchParams$get === void 0 ? void 0 : _searchParams$get.split(',').filter(Boolean)) || [];
35
- return values.filter(function (value) {
36
+ var containers = values.filter(function (value) {
36
37
  return Object.values(_types.ContainerType).includes(value);
37
38
  }).map(function (value) {
38
39
  return CONTAINER_MAP[value];
39
40
  });
41
+ if (containers.length === 0) {
42
+ return [];
43
+ }
44
+ return userCanAccessFeature() ? containers : [];
40
45
  }
41
46
  function containerDisplayName(container) {
42
47
  return CONTAINER_HUMAN_NAMES[container];
43
48
  }
49
+ function convertContainerToType(container) {
50
+ switch (container) {
51
+ case 'ConfluenceSpace':
52
+ return _types.ContainerType.CONFLUENCE_SPACE;
53
+ case 'JiraProject':
54
+ return _types.ContainerType.JIRA_PROJECT;
55
+ case 'LoomSpace':
56
+ return _types.ContainerType.LOOM_SPACE;
57
+ default:
58
+ return null;
59
+ }
60
+ }
44
61
  function userCanAccessFeature() {
45
62
  if (_featureGateJsClient.default.initializeCalled()) {
46
63
  var value = _featureGateJsClient.default.getExperimentValue('teams_app_auto_container_creation', 'cohort', 'control');
@@ -48,10 +65,8 @@ function userCanAccessFeature() {
48
65
  }
49
66
  return false;
50
67
  }
51
-
52
- //@todo: PTC-12250 update these to P90 value
53
68
  var POLLING_INTERVAL = exports.POLLING_INTERVAL = 1000;
54
- var POLLING_DURATION = exports.POLLING_DURATION = 10000;
69
+ var POLLING_DURATION = exports.POLLING_DURATION = 15000;
55
70
 
56
71
  /**
57
72
  * Hook for polling an async callback at a fixed interval, with timeout and pending state management.
@@ -60,9 +75,12 @@ var POLLING_DURATION = exports.POLLING_DURATION = 10000;
60
75
  * Ensures only one callback is pending at a time.
61
76
  *
62
77
  * @param callback - The async function to poll.
78
+ * @param onTimeout - Optional callback to execute when polling times out.
63
79
  * @returns An object with polling controls and state: startPolling, stopPolling, isPolling, hasTimedOut.
64
80
  */
65
81
  function useAsyncPolling(callback) {
82
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
83
+ onTimeout = _ref.onTimeout;
66
84
  var _useState = (0, _react.useState)(false),
67
85
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
68
86
  hasTimedOut = _useState2[0],
@@ -85,6 +103,15 @@ function useAsyncPolling(callback) {
85
103
  setHasTimedOut(false);
86
104
  setIsPending(false);
87
105
  }, []);
106
+ var reset = (0, _react.useCallback)(function () {
107
+ if (timeoutRef.current) {
108
+ clearTimeout(timeoutRef.current);
109
+ timeoutRef.current = null;
110
+ }
111
+ setHasTimedOut(false);
112
+ setIsPolling(false);
113
+ setIsPending(false);
114
+ }, []);
88
115
  var startPolling = (0, _react.useCallback)(function () {
89
116
  if (timeoutRef.current) {
90
117
  clearTimeout(timeoutRef.current);
@@ -96,8 +123,15 @@ function useAsyncPolling(callback) {
96
123
  timeoutRef.current = setTimeout(function () {
97
124
  stopPolling();
98
125
  setHasTimedOut(true);
126
+ if (onTimeout) {
127
+ onTimeout({
128
+ startPolling: startPolling,
129
+ stopPolling: stopPolling,
130
+ reset: reset
131
+ });
132
+ }
99
133
  }, POLLING_DURATION);
100
- }, [stopPolling]);
134
+ }, [stopPolling, onTimeout, reset]);
101
135
  var wrappedCallback = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
102
136
  return _regenerator.default.wrap(function _callee$(_context) {
103
137
  while (1) switch (_context.prev = _context.next) {
@@ -124,6 +158,7 @@ function useAsyncPolling(callback) {
124
158
  })), [callback, isPending]);
125
159
  (0, _frontendUtilities.useInterval)(isPolling ? wrappedCallback : function () {}, isPolling ? POLLING_INTERVAL : null);
126
160
  return {
161
+ reset: reset,
127
162
  startPolling: startPolling,
128
163
  stopPolling: stopPolling,
129
164
  isPolling: isPolling,
@@ -428,14 +428,23 @@ var useTeamContainers = exports.useTeamContainers = function useTeamContainers(t
428
428
  actions.fetchTeamContainers(teamId, fireOperationalAnalytics);
429
429
  }
430
430
  }, [teamId, actions, enable, fireOperationalAnalytics]);
431
+ var refetchTeamContainers = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
432
+ return _regenerator.default.wrap(function _callee7$(_context7) {
433
+ while (1) switch (_context7.prev = _context7.next) {
434
+ case 0:
435
+ return _context7.abrupt("return", actions.refetchTeamContainers(fireOperationalAnalytics));
436
+ case 1:
437
+ case "end":
438
+ return _context7.stop();
439
+ }
440
+ }, _callee7);
441
+ })), [actions, fireOperationalAnalytics]);
431
442
  return _objectSpread(_objectSpread({}, state), {}, {
432
443
  addTeamContainer: actions.addTeamContainer,
433
444
  unlinkTeamContainers: function unlinkTeamContainers(containerId) {
434
445
  return actions.unlinkTeamContainers(teamId, containerId);
435
446
  },
436
- refetchTeamContainers: function refetchTeamContainers() {
437
- return actions.refetchTeamContainers(fireOperationalAnalytics);
438
- }
447
+ refetchTeamContainers: refetchTeamContainers
439
448
  });
440
449
  };
441
450
  var useConnectedTeams = exports.useConnectedTeams = function useConnectedTeams() {
@@ -447,12 +456,12 @@ var useConnectedTeams = exports.useConnectedTeams = function useConnectedTeams()
447
456
  fireOperationalEvent = _usePeopleAndTeamAnal2.fireOperationalEvent;
448
457
  var _useAnalyticsEvents2 = (0, _analyticsNext.useAnalyticsEvents)(),
449
458
  createAnalyticsEvent = _useAnalyticsEvents2.createAnalyticsEvent;
450
- var fireOperationalAnalytics = (0, _react.useCallback)(function (_ref11) {
451
- var action = _ref11.action,
452
- actionSubject = _ref11.actionSubject,
453
- containerId = _ref11.containerId,
454
- numberOfTeams = _ref11.numberOfTeams,
455
- error = _ref11.error;
459
+ var fireOperationalAnalytics = (0, _react.useCallback)(function (_ref12) {
460
+ var action = _ref12.action,
461
+ actionSubject = _ref12.actionSubject,
462
+ containerId = _ref12.containerId,
463
+ numberOfTeams = _ref12.numberOfTeams,
464
+ error = _ref12.error;
456
465
  fireOperationalEvent(createAnalyticsEvent, {
457
466
  action: action,
458
467
  actionSubject: actionSubject,
@@ -35,5 +35,8 @@ var _default = exports.default = {
35
35
  'ptc-directory.team-profile-page.team-containers.show-more': 'Show more',
36
36
  'ptc-directory.team-profile-page.team-containers.space-container-text': 'space',
37
37
  'ptc.team-profile-page.team-containers.empty-state.description': 'Your team can link their Jira projects, Confluence spaces here to show where they work',
38
- 'ptc.team-profile-page.team-containers.empty-state.title': 'Add the places your team works'
38
+ 'ptc.team-profile-page.team-containers.empty-state.title': 'Add the places your team works',
39
+ 'teams-public..team-containers.timeout-description': 'Something went wrong. Verify your connection and retry.',
40
+ 'teams-public.team-containers.timeout-action': 'Try again',
41
+ 'teams-public.team-containers.timeout-title': 'We’re couldn’t connect your spaces'
39
42
  };
@@ -35,5 +35,8 @@ var _default = exports.default = {
35
35
  'ptc-directory.team-profile-page.team-containers.show-more': 'Show more',
36
36
  'ptc-directory.team-profile-page.team-containers.space-container-text': 'space',
37
37
  'ptc.team-profile-page.team-containers.empty-state.description': 'Your team can link their Jira projects, Confluence spaces here to show where they work',
38
- 'ptc.team-profile-page.team-containers.empty-state.title': 'Add the places your team works'
38
+ 'ptc.team-profile-page.team-containers.empty-state.title': 'Add the places your team works',
39
+ 'teams-public..team-containers.timeout-description': 'Something went wrong. Verify your connection and retry.',
40
+ 'teams-public.team-containers.timeout-action': 'Try again',
41
+ 'teams-public.team-containers.timeout-title': 'We’re couldn’t connect your spaces'
39
42
  };
@@ -35,5 +35,8 @@ var _default = exports.default = {
35
35
  'ptc-directory.team-profile-page.team-containers.show-more': '⁣⁢Show more⁡؜؜⁠‍⁠⁠⁡‌؜⁣⁤',
36
36
  'ptc-directory.team-profile-page.team-containers.space-container-text': '⁣⁢space‍⁠⁠‍⁡؜‍⁠⁣⁤',
37
37
  'ptc.team-profile-page.team-containers.empty-state.description': '⁣⁢Your team can link their Jira projects, Confluence spaces here to show where they work‍⁡⁡⁡‌‍⁠‌⁡⁣⁤',
38
- 'ptc.team-profile-page.team-containers.empty-state.title': '⁣⁢Add the places your team works؜⁡؜‌⁠⁡؜⁣⁤'
38
+ 'ptc.team-profile-page.team-containers.empty-state.title': '⁣⁢Add the places your team works؜⁡؜‌⁠⁡؜⁣⁤',
39
+ 'teams-public..team-containers.timeout-description': '⁣⁢Something went wrong. Verify your connection and retry.‌؜؜⁡⁠؜‍⁠⁠⁡⁠⁣⁤',
40
+ 'teams-public.team-containers.timeout-action': '⁣⁢Try again‌‍⁡‌‍⁡‍⁡‌⁣⁤',
41
+ 'teams-public.team-containers.timeout-title': '⁣⁢We’re couldn’t connect your spaces‍⁠‍⁡‍؜؜⁣⁤'
39
42
  };
@@ -33,5 +33,8 @@ var _default = exports.default = {
33
33
  'ptc-directory.team-profile-page.team-containers.show-less': 'Afficher moins',
34
34
  'ptc-directory.team-profile-page.team-containers.show-more': 'Afficher plus',
35
35
  'ptc.team-profile-page.team-containers.empty-state.description': 'Votre équipe peut associer ses projets Jira et ses espaces Confluence ici pour indiquer où elle travaille',
36
- 'ptc.team-profile-page.team-containers.empty-state.title': 'Ajouter les lieux de travail de votre équipe'
36
+ 'ptc.team-profile-page.team-containers.empty-state.title': 'Ajouter les lieux de travail de votre équipe',
37
+ 'teams-public..team-containers.timeout-description': "Une erreur s'est produite. Vérifiez votre connection et réessayez.",
38
+ 'teams-public.team-containers.timeout-action': 'Réessayer',
39
+ 'teams-public.team-containers.timeout-title': 'Impossible de connecter vos espaces'
37
40
  };
@@ -33,5 +33,8 @@ var _default = exports.default = {
33
33
  'ptc-directory.team-profile-page.team-containers.show-less': 'Свернуть',
34
34
  'ptc-directory.team-profile-page.team-containers.show-more': 'Развернуть',
35
35
  'ptc.team-profile-page.team-containers.empty-state.description': 'Команда может разместить здесь ссылки на свои проекты Jira и разделы Confluence, чтобы показать, где она работает',
36
- 'ptc.team-profile-page.team-containers.empty-state.title': 'Добавьте места, где работает команда'
36
+ 'ptc.team-profile-page.team-containers.empty-state.title': 'Добавьте места, где работает команда',
37
+ 'teams-public..team-containers.timeout-description': 'Что-то пошло не так. Проверьте подключение и повторите попытку.',
38
+ 'teams-public.team-containers.timeout-action': 'Повторить попытку',
39
+ 'teams-public.team-containers.timeout-title': 'Не удалось подключить разделы'
37
40
  };
@@ -33,5 +33,8 @@ var _default = exports.default = {
33
33
  'ptc-directory.team-profile-page.team-containers.show-less': 'Показати менше',
34
34
  'ptc-directory.team-profile-page.team-containers.show-more': 'Показати більше',
35
35
  'ptc.team-profile-page.team-containers.empty-state.description': 'Ваша команда може зв’язати свої проєкти Jira й розділи Confluence тут, щоб відобразити, з чим вона працює',
36
- 'ptc.team-profile-page.team-containers.empty-state.title': 'Додайте місця роботи вашої команди'
36
+ 'ptc.team-profile-page.team-containers.empty-state.title': 'Додайте місця роботи вашої команди',
37
+ 'teams-public..team-containers.timeout-description': 'Сталася помилка. Перевірте з’єднання та повторіть спробу.',
38
+ 'teams-public.team-containers.timeout-action': 'Повторити спробу',
39
+ 'teams-public.team-containers.timeout-title': 'Не вдалося підключити розділи'
37
40
  };
@@ -63,6 +63,7 @@ var TeamContainers = exports.TeamContainers = function TeamContainers(_ref) {
63
63
  iconHasLoaded = _useTeamLinksAndConta.iconHasLoaded;
64
64
  var _useRequestedContaine = (0, _useRequestedContainer.useRequestedContainers)({
65
65
  teamId: teamId,
66
+ cloudId: cloudId,
66
67
  onRequestedContainerTimeout: onRequestedContainerTimeout
67
68
  }),
68
69
  requestedContainers = _useRequestedContaine.requestedContainers;