@atlaskit/teams-public 0.52.0 → 0.52.2

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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/teams-public
2
2
 
3
+ ## 0.52.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#198716](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/198716)
8
+ [`e08b5c9322b2e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e08b5c9322b2e) -
9
+ NO ISSUE Added isLoading check in getTeamWebLinks action to prevent parallel API calls when a
10
+ request is already in progress.
11
+ - Updated dependencies
12
+
13
+ ## 0.52.1
14
+
15
+ ### Patch Changes
16
+
17
+ - [#196973](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/196973)
18
+ [`6080c11c001ff`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6080c11c001ff) -
19
+ Mark old product permission hook as deprecated
20
+ - Updated dependencies
21
+
3
22
  ## 0.52.0
4
23
 
5
24
  ### Minor Changes
@@ -10,6 +10,9 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
  var _react = require("react");
12
12
  var _main = require("../../product-permission/main");
13
+ /**
14
+ * @deprecated Use useProductPermissions from "@atlaskit/teams-app-internal-product-permissions" instead
15
+ */
13
16
  var useProductPermissions = exports.useProductPermissions = function useProductPermissions(_ref) {
14
17
  var userId = _ref.userId,
15
18
  cloudId = _ref.cloudId,
@@ -10,6 +10,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
12
  var _reactSweetState = require("react-sweet-state");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _teamsClient = require("@atlaskit/teams-client");
14
15
  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; }
15
16
  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; }
@@ -30,12 +31,18 @@ var actions = exports.actions = {
30
31
  getTeamWebLinks: function getTeamWebLinks(teamId) {
31
32
  return /*#__PURE__*/function () {
32
33
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
33
- var getState, setState, dispatch, _getState, links, currentTeamId, initialLinks, _yield$teamsClient$ge, entities;
34
+ var getState, setState, dispatch, _getState, links, currentTeamId, hasLoaded, isLoading, initialLinks, _yield$teamsClient$ge, entities;
34
35
  return _regenerator.default.wrap(function _callee$(_context) {
35
36
  while (1) switch (_context.prev = _context.next) {
36
37
  case 0:
37
38
  getState = _ref.getState, setState = _ref.setState, dispatch = _ref.dispatch;
38
- _getState = getState(), links = _getState.links, currentTeamId = _getState.teamId;
39
+ _getState = getState(), links = _getState.links, currentTeamId = _getState.teamId, hasLoaded = _getState.hasLoaded, isLoading = _getState.isLoading;
40
+ if (!((isLoading || teamId === currentTeamId && hasLoaded && links.length > 0) && (0, _platformFeatureFlags.fg)('prevent_parallel_team_web_links_fetch'))) {
41
+ _context.next = 4;
42
+ break;
43
+ }
44
+ return _context.abrupt("return");
45
+ case 4:
39
46
  initialLinks = teamId === currentTeamId ? links : [];
40
47
  setState({
41
48
  teamId: teamId,
@@ -45,18 +52,18 @@ var actions = exports.actions = {
45
52
  shouldReload: false,
46
53
  links: initialLinks
47
54
  });
48
- _context.prev = 4;
49
- _context.next = 7;
55
+ _context.prev = 6;
56
+ _context.next = 9;
50
57
  return _teamsClient.teamsClient.getTeamLinksByTeamId(teamId);
51
- case 7:
58
+ case 9:
52
59
  _yield$teamsClient$ge = _context.sent;
53
60
  entities = _yield$teamsClient$ge.entities;
54
61
  if (!(getState().teamId !== teamId)) {
55
- _context.next = 11;
62
+ _context.next = 13;
56
63
  break;
57
64
  }
58
65
  return _context.abrupt("return");
59
- case 11:
66
+ case 13:
60
67
  setState({
61
68
  isLoading: false,
62
69
  hasLoaded: true,
@@ -67,17 +74,17 @@ var actions = exports.actions = {
67
74
  if (entities.length > 0) {
68
75
  dispatch(actions.getTeamWebLinkIcons(teamId));
69
76
  }
70
- _context.next = 20;
77
+ _context.next = 22;
71
78
  break;
72
- case 15:
73
- _context.prev = 15;
74
- _context.t0 = _context["catch"](4);
79
+ case 17:
80
+ _context.prev = 17;
81
+ _context.t0 = _context["catch"](6);
75
82
  if (!(getState().teamId !== teamId)) {
76
- _context.next = 19;
83
+ _context.next = 21;
77
84
  break;
78
85
  }
79
86
  return _context.abrupt("return");
80
- case 19:
87
+ case 21:
81
88
  setState({
82
89
  isLoading: false,
83
90
  hasLoaded: true,
@@ -86,11 +93,11 @@ var actions = exports.actions = {
86
93
  shouldReload: false,
87
94
  links: []
88
95
  });
89
- case 20:
96
+ case 22:
90
97
  case "end":
91
98
  return _context.stop();
92
99
  }
93
- }, _callee, null, [[4, 15]]);
100
+ }, _callee, null, [[6, 17]]);
94
101
  }));
95
102
  return function (_x) {
96
103
  return _ref2.apply(this, arguments);
@@ -123,4 +123,8 @@ var Store = (0, _reactSweetState.createStore)({
123
123
  actions: actions,
124
124
  name: 'product-permissions-old'
125
125
  });
126
+
127
+ /**
128
+ * @deprecated Use useProductPermissionsStore from "@atlaskit/teams-app-internal-product-permissions" instead
129
+ */
126
130
  var useProductPermissionsStore = exports.useProductPermissionsStore = (0, _reactSweetState.createHook)(Store);
@@ -38,6 +38,10 @@ var getProductPermissionRequestBody = exports.getProductPermissionRequestBody =
38
38
  }, []);
39
39
  return JSON.stringify(body);
40
40
  };
41
+
42
+ /**
43
+ * @deprecated Use hasProductPermission from "@atlaskit/teams-app-internal-product-permissions" instead
44
+ */
41
45
  var hasProductPermission = exports.hasProductPermission = function hasProductPermission(permissions, product, permissionIds) {
42
46
  if (!permissions[product]) {
43
47
  return false;
@@ -1,5 +1,8 @@
1
1
  import { useCallback, useEffect } from 'react';
2
2
  import { useProductPermissionsStore } from '../../product-permission/main';
3
+ /**
4
+ * @deprecated Use useProductPermissions from "@atlaskit/teams-app-internal-product-permissions" instead
5
+ */
3
6
  export const useProductPermissions = ({
4
7
  userId,
5
8
  cloudId,
@@ -1,4 +1,5 @@
1
1
  import { createHook, createStore } from 'react-sweet-state';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { teamsClient } from '@atlaskit/teams-client';
3
4
  const initialState = {
4
5
  teamId: '',
@@ -21,8 +22,13 @@ export const actions = {
21
22
  }) => {
22
23
  const {
23
24
  links,
24
- teamId: currentTeamId
25
+ teamId: currentTeamId,
26
+ hasLoaded,
27
+ isLoading
25
28
  } = getState();
29
+ if ((isLoading || teamId === currentTeamId && hasLoaded && links.length > 0) && fg('prevent_parallel_team_web_links_fetch')) {
30
+ return;
31
+ }
26
32
  const initialLinks = teamId === currentTeamId ? links : [];
27
33
  setState({
28
34
  teamId,
@@ -84,4 +84,8 @@ const Store = createStore({
84
84
  actions,
85
85
  name: 'product-permissions-old'
86
86
  });
87
+
88
+ /**
89
+ * @deprecated Use useProductPermissionsStore from "@atlaskit/teams-app-internal-product-permissions" instead
90
+ */
87
91
  export const useProductPermissionsStore = createHook(Store);
@@ -32,6 +32,10 @@ export const getProductPermissionRequestBody = (cloudId, userId, permissionIds)
32
32
  }, []);
33
33
  return JSON.stringify(body);
34
34
  };
35
+
36
+ /**
37
+ * @deprecated Use hasProductPermission from "@atlaskit/teams-app-internal-product-permissions" instead
38
+ */
35
39
  export const hasProductPermission = (permissions, product, permissionIds) => {
36
40
  if (!permissions[product]) {
37
41
  return false;
@@ -3,6 +3,9 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import { useCallback, useEffect } from 'react';
5
5
  import { useProductPermissionsStore } from '../../product-permission/main';
6
+ /**
7
+ * @deprecated Use useProductPermissions from "@atlaskit/teams-app-internal-product-permissions" instead
8
+ */
6
9
  export var useProductPermissions = function useProductPermissions(_ref) {
7
10
  var userId = _ref.userId,
8
11
  cloudId = _ref.cloudId,
@@ -5,6 +5,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
5
5
  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) { _defineProperty(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; }
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import { createHook, createStore } from 'react-sweet-state';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
8
9
  import { teamsClient } from '@atlaskit/teams-client';
9
10
  var _initialState = {
10
11
  teamId: '',
@@ -23,12 +24,18 @@ export var actions = {
23
24
  getTeamWebLinks: function getTeamWebLinks(teamId) {
24
25
  return /*#__PURE__*/function () {
25
26
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
26
- var getState, setState, dispatch, _getState, links, currentTeamId, initialLinks, _yield$teamsClient$ge, entities;
27
+ var getState, setState, dispatch, _getState, links, currentTeamId, hasLoaded, isLoading, initialLinks, _yield$teamsClient$ge, entities;
27
28
  return _regeneratorRuntime.wrap(function _callee$(_context) {
28
29
  while (1) switch (_context.prev = _context.next) {
29
30
  case 0:
30
31
  getState = _ref.getState, setState = _ref.setState, dispatch = _ref.dispatch;
31
- _getState = getState(), links = _getState.links, currentTeamId = _getState.teamId;
32
+ _getState = getState(), links = _getState.links, currentTeamId = _getState.teamId, hasLoaded = _getState.hasLoaded, isLoading = _getState.isLoading;
33
+ if (!((isLoading || teamId === currentTeamId && hasLoaded && links.length > 0) && fg('prevent_parallel_team_web_links_fetch'))) {
34
+ _context.next = 4;
35
+ break;
36
+ }
37
+ return _context.abrupt("return");
38
+ case 4:
32
39
  initialLinks = teamId === currentTeamId ? links : [];
33
40
  setState({
34
41
  teamId: teamId,
@@ -38,18 +45,18 @@ export var actions = {
38
45
  shouldReload: false,
39
46
  links: initialLinks
40
47
  });
41
- _context.prev = 4;
42
- _context.next = 7;
48
+ _context.prev = 6;
49
+ _context.next = 9;
43
50
  return teamsClient.getTeamLinksByTeamId(teamId);
44
- case 7:
51
+ case 9:
45
52
  _yield$teamsClient$ge = _context.sent;
46
53
  entities = _yield$teamsClient$ge.entities;
47
54
  if (!(getState().teamId !== teamId)) {
48
- _context.next = 11;
55
+ _context.next = 13;
49
56
  break;
50
57
  }
51
58
  return _context.abrupt("return");
52
- case 11:
59
+ case 13:
53
60
  setState({
54
61
  isLoading: false,
55
62
  hasLoaded: true,
@@ -60,17 +67,17 @@ export var actions = {
60
67
  if (entities.length > 0) {
61
68
  dispatch(actions.getTeamWebLinkIcons(teamId));
62
69
  }
63
- _context.next = 20;
70
+ _context.next = 22;
64
71
  break;
65
- case 15:
66
- _context.prev = 15;
67
- _context.t0 = _context["catch"](4);
72
+ case 17:
73
+ _context.prev = 17;
74
+ _context.t0 = _context["catch"](6);
68
75
  if (!(getState().teamId !== teamId)) {
69
- _context.next = 19;
76
+ _context.next = 21;
70
77
  break;
71
78
  }
72
79
  return _context.abrupt("return");
73
- case 19:
80
+ case 21:
74
81
  setState({
75
82
  isLoading: false,
76
83
  hasLoaded: true,
@@ -79,11 +86,11 @@ export var actions = {
79
86
  shouldReload: false,
80
87
  links: []
81
88
  });
82
- case 20:
89
+ case 22:
83
90
  case "end":
84
91
  return _context.stop();
85
92
  }
86
- }, _callee, null, [[4, 15]]);
93
+ }, _callee, null, [[6, 17]]);
87
94
  }));
88
95
  return function (_x) {
89
96
  return _ref2.apply(this, arguments);
@@ -116,4 +116,8 @@ var Store = createStore({
116
116
  actions: actions,
117
117
  name: 'product-permissions-old'
118
118
  });
119
+
120
+ /**
121
+ * @deprecated Use useProductPermissionsStore from "@atlaskit/teams-app-internal-product-permissions" instead
122
+ */
119
123
  export var useProductPermissionsStore = createHook(Store);
@@ -31,6 +31,10 @@ export var getProductPermissionRequestBody = function getProductPermissionReques
31
31
  }, []);
32
32
  return JSON.stringify(body);
33
33
  };
34
+
35
+ /**
36
+ * @deprecated Use hasProductPermission from "@atlaskit/teams-app-internal-product-permissions" instead
37
+ */
34
38
  export var hasProductPermission = function hasProductPermission(permissions, product, permissionIds) {
35
39
  if (!permissions[product]) {
36
40
  return false;
@@ -1,2 +1,5 @@
1
1
  import { type ProductPermissions } from '../../product-permission/types';
2
+ /**
3
+ * @deprecated Use useProductPermissions from "@atlaskit/teams-app-internal-product-permissions" instead
4
+ */
2
5
  export declare const useProductPermissions: ProductPermissions;
@@ -1,3 +1,6 @@
1
1
  /// <reference types="react-sweet-state" />
2
2
  import type { ProductPermissionsActions, ProductPermissionsStore } from './types';
3
+ /**
4
+ * @deprecated Use useProductPermissionsStore from "@atlaskit/teams-app-internal-product-permissions" instead
5
+ */
3
6
  export declare const useProductPermissionsStore: import("react-sweet-state").HookFunction<ProductPermissionsStore, import("react-sweet-state").BoundActions<ProductPermissionsStore, ProductPermissionsActions>, void>;
@@ -1,4 +1,7 @@
1
1
  import { type ProductPermissionsResponse, type ProductPermissionsType, type UserProductPermissions } from './types';
2
2
  export declare const transformPermissions: (permissions: ProductPermissionsResponse[]) => UserProductPermissions;
3
3
  export declare const getProductPermissionRequestBody: (cloudId: string, userId: string, permissionIds: Array<keyof ProductPermissionsType>) => string;
4
+ /**
5
+ * @deprecated Use hasProductPermission from "@atlaskit/teams-app-internal-product-permissions" instead
6
+ */
4
7
  export declare const hasProductPermission: (permissions: UserProductPermissions, product: keyof UserProductPermissions, permissionIds?: string[]) => boolean | undefined;
@@ -1,2 +1,5 @@
1
1
  import { type ProductPermissions } from '../../product-permission/types';
2
+ /**
3
+ * @deprecated Use useProductPermissions from "@atlaskit/teams-app-internal-product-permissions" instead
4
+ */
2
5
  export declare const useProductPermissions: ProductPermissions;
@@ -1,3 +1,6 @@
1
1
  /// <reference types="react-sweet-state" />
2
2
  import type { ProductPermissionsActions, ProductPermissionsStore } from './types';
3
+ /**
4
+ * @deprecated Use useProductPermissionsStore from "@atlaskit/teams-app-internal-product-permissions" instead
5
+ */
3
6
  export declare const useProductPermissionsStore: import("react-sweet-state").HookFunction<ProductPermissionsStore, import("react-sweet-state").BoundActions<ProductPermissionsStore, ProductPermissionsActions>, void>;
@@ -1,4 +1,7 @@
1
1
  import { type ProductPermissionsResponse, type ProductPermissionsType, type UserProductPermissions } from './types';
2
2
  export declare const transformPermissions: (permissions: ProductPermissionsResponse[]) => UserProductPermissions;
3
3
  export declare const getProductPermissionRequestBody: (cloudId: string, userId: string, permissionIds: Array<keyof ProductPermissionsType>) => string;
4
+ /**
5
+ * @deprecated Use hasProductPermission from "@atlaskit/teams-app-internal-product-permissions" instead
6
+ */
4
7
  export declare const hasProductPermission: (permissions: UserProductPermissions, product: keyof UserProductPermissions, permissionIds?: string[]) => boolean | undefined;
package/package.json CHANGED
@@ -39,8 +39,8 @@
39
39
  "@atlaskit/flag": "^17.3.0",
40
40
  "@atlaskit/frontend-utilities": "^3.1.0",
41
41
  "@atlaskit/heading": "^5.2.0",
42
- "@atlaskit/icon": "^27.9.0",
43
- "@atlaskit/icon-lab": "^5.3.0",
42
+ "@atlaskit/icon": "^27.11.0",
43
+ "@atlaskit/icon-lab": "^5.4.0",
44
44
  "@atlaskit/image": "^3.0.0",
45
45
  "@atlaskit/link": "^3.2.0",
46
46
  "@atlaskit/logo": "^19.6.0",
@@ -117,7 +117,7 @@
117
117
  }
118
118
  },
119
119
  "name": "@atlaskit/teams-public",
120
- "version": "0.52.0",
120
+ "version": "0.52.2",
121
121
  "description": "Public components related to teams",
122
122
  "author": "Atlassian Pty Ltd",
123
123
  "license": "Apache-2.0",
@@ -152,6 +152,9 @@
152
152
  },
153
153
  "migrate-product-permissions": {
154
154
  "type": "boolean"
155
+ },
156
+ "prevent_parallel_team_web_links_fetch": {
157
+ "type": "boolean"
155
158
  }
156
159
  }
157
160
  }