@atlaskit/teams-public 0.31.0 → 0.32.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 +8 -0
- package/dist/cjs/controllers/hooks/use-team-containers/index.js +11 -4
- package/dist/cjs/controllers/hooks/use-team-links-and-containers/index.js +144 -0
- package/dist/cjs/index.js +7 -0
- package/dist/es2019/controllers/hooks/use-team-containers/index.js +9 -4
- package/dist/es2019/controllers/hooks/use-team-links-and-containers/index.js +68 -0
- package/dist/es2019/index.js +1 -0
- package/dist/esm/controllers/hooks/use-team-containers/index.js +11 -4
- package/dist/esm/controllers/hooks/use-team-links-and-containers/index.js +137 -0
- package/dist/esm/index.js +1 -0
- package/dist/types/controllers/hooks/use-team-containers/index.d.ts +3 -0
- package/dist/types/controllers/hooks/use-team-links-and-containers/index.d.ts +16 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types-ts4.5/controllers/hooks/use-team-containers/index.d.ts +3 -0
- package/dist/types-ts4.5/controllers/hooks/use-team-links-and-containers/index.d.ts +16 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/teams-public
|
|
2
2
|
|
|
3
|
+
## 0.32.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#158233](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/158233)
|
|
8
|
+
[`e23647a437f46`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e23647a437f46) -
|
|
9
|
+
PTC-11755 Build useTeamLinksAndContainers to retrieve all containers data
|
|
10
|
+
|
|
3
11
|
## 0.31.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -28,6 +28,7 @@ var initialConnectedTeamsState = {
|
|
|
28
28
|
var initialState = {
|
|
29
29
|
teamContainers: [],
|
|
30
30
|
loading: true,
|
|
31
|
+
hasLoaded: false,
|
|
31
32
|
error: null,
|
|
32
33
|
unlinkError: null,
|
|
33
34
|
teamId: null,
|
|
@@ -53,7 +54,8 @@ var actions = {
|
|
|
53
54
|
loading: true,
|
|
54
55
|
error: null,
|
|
55
56
|
teamContainers: [],
|
|
56
|
-
teamId: teamId
|
|
57
|
+
teamId: teamId,
|
|
58
|
+
hasLoaded: false
|
|
57
59
|
});
|
|
58
60
|
_context.prev = 5;
|
|
59
61
|
_context.next = 8;
|
|
@@ -64,7 +66,8 @@ var actions = {
|
|
|
64
66
|
setState({
|
|
65
67
|
teamContainers: containers,
|
|
66
68
|
loading: false,
|
|
67
|
-
error: null
|
|
69
|
+
error: null,
|
|
70
|
+
hasLoaded: true
|
|
68
71
|
});
|
|
69
72
|
_context.next = 17;
|
|
70
73
|
break;
|
|
@@ -75,7 +78,8 @@ var actions = {
|
|
|
75
78
|
setState({
|
|
76
79
|
teamContainers: [],
|
|
77
80
|
error: _context.t0,
|
|
78
|
-
loading: false
|
|
81
|
+
loading: false,
|
|
82
|
+
hasLoaded: true
|
|
79
83
|
});
|
|
80
84
|
case 17:
|
|
81
85
|
case "end":
|
|
@@ -366,7 +370,10 @@ var useTeamContainers = exports.useTeamContainers = function useTeamContainers(t
|
|
|
366
370
|
}
|
|
367
371
|
}, [teamId, actions, enable, fireOperationalAnalytics]);
|
|
368
372
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
369
|
-
addTeamContainer: actions.addTeamContainer
|
|
373
|
+
addTeamContainer: actions.addTeamContainer,
|
|
374
|
+
unlinkTeamContainers: function unlinkTeamContainers(containerId) {
|
|
375
|
+
return actions.unlinkTeamContainers(teamId, containerId);
|
|
376
|
+
}
|
|
370
377
|
});
|
|
371
378
|
};
|
|
372
379
|
var useConnectedTeams = exports.useConnectedTeams = function useConnectedTeams() {
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useTeamLinksAndContainers = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
var _teamWebLinkConverters = require("../../../common/utils/team-web-link-converters");
|
|
14
|
+
var _useTeamContainers2 = require("../use-team-containers");
|
|
15
|
+
var _useTeamWebLinks3 = require("../use-team-web-links");
|
|
16
|
+
var MAX_LINKS_LIMIT = 10;
|
|
17
|
+
var useTeamLinksAndContainers = exports.useTeamLinksAndContainers = function useTeamLinksAndContainers(teamId) {
|
|
18
|
+
var enableContainers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
19
|
+
var _useTeamContainers = (0, _useTeamContainers2.useTeamContainers)(teamId, enableContainers),
|
|
20
|
+
teamContainers = _useTeamContainers.teamContainers,
|
|
21
|
+
containersLoading = _useTeamContainers.loading,
|
|
22
|
+
containersHasLoaded = _useTeamContainers.hasLoaded,
|
|
23
|
+
containersError = _useTeamContainers.error,
|
|
24
|
+
addTeamContainer = _useTeamContainers.addTeamContainer,
|
|
25
|
+
unlinkTeamContainers = _useTeamContainers.unlinkTeamContainers;
|
|
26
|
+
var _useTeamWebLinks = (0, _useTeamWebLinks3.useTeamWebLinks)(),
|
|
27
|
+
_useTeamWebLinks2 = (0, _slicedToArray2.default)(_useTeamWebLinks, 2),
|
|
28
|
+
_useTeamWebLinks2$ = _useTeamWebLinks2[0],
|
|
29
|
+
links = _useTeamWebLinks2$.links,
|
|
30
|
+
webLinksLoading = _useTeamWebLinks2$.isLoading,
|
|
31
|
+
webLinksError = _useTeamWebLinks2$.hasError,
|
|
32
|
+
webLinksHasLoaded = _useTeamWebLinks2$.hasLoaded,
|
|
33
|
+
_useTeamWebLinks2$2 = _useTeamWebLinks2[1],
|
|
34
|
+
getTeamWebLinks = _useTeamWebLinks2$2.getTeamWebLinks,
|
|
35
|
+
createTeamWebLink = _useTeamWebLinks2$2.createTeamWebLink,
|
|
36
|
+
updateTeamWebLink = _useTeamWebLinks2$2.updateTeamWebLink,
|
|
37
|
+
removeWebLink = _useTeamWebLinks2$2.removeWebLink;
|
|
38
|
+
(0, _react.useEffect)(function () {
|
|
39
|
+
getTeamWebLinks(teamId);
|
|
40
|
+
}, [getTeamWebLinks, teamId]);
|
|
41
|
+
var webLinkContainers = (0, _react.useMemo)(function () {
|
|
42
|
+
return (0, _teamWebLinkConverters.webLinksToContainers)(links);
|
|
43
|
+
}, [links]);
|
|
44
|
+
var allContainers = (0, _react.useMemo)(function () {
|
|
45
|
+
return [].concat((0, _toConsumableArray2.default)(teamContainers), (0, _toConsumableArray2.default)(webLinkContainers));
|
|
46
|
+
}, [teamContainers, webLinkContainers]);
|
|
47
|
+
var canAddMoreLink = (0, _react.useMemo)(function () {
|
|
48
|
+
return allContainers.length <= MAX_LINKS_LIMIT;
|
|
49
|
+
}, [allContainers.length]);
|
|
50
|
+
var addTeamLink = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
51
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(container) {
|
|
52
|
+
var webLink;
|
|
53
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
54
|
+
while (1) switch (_context.prev = _context.next) {
|
|
55
|
+
case 0:
|
|
56
|
+
if (!(container.type === 'WebLink')) {
|
|
57
|
+
_context.next = 7;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
webLink = (0, _teamWebLinkConverters.containerToNewWebLink)(container);
|
|
61
|
+
_context.next = 4;
|
|
62
|
+
return createTeamWebLink(teamId, webLink);
|
|
63
|
+
case 4:
|
|
64
|
+
return _context.abrupt("return", _context.sent);
|
|
65
|
+
case 7:
|
|
66
|
+
addTeamContainer(container);
|
|
67
|
+
return _context.abrupt("return", Promise.resolve(container));
|
|
68
|
+
case 9:
|
|
69
|
+
case "end":
|
|
70
|
+
return _context.stop();
|
|
71
|
+
}
|
|
72
|
+
}, _callee);
|
|
73
|
+
}));
|
|
74
|
+
return function (_x) {
|
|
75
|
+
return _ref.apply(this, arguments);
|
|
76
|
+
};
|
|
77
|
+
}(), [teamId, createTeamWebLink, addTeamContainer]);
|
|
78
|
+
var updateTeamLink = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
79
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(container, newContainer) {
|
|
80
|
+
var webLink;
|
|
81
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
82
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
83
|
+
case 0:
|
|
84
|
+
if (!(container.type === 'WebLink')) {
|
|
85
|
+
_context2.next = 5;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
webLink = (0, _teamWebLinkConverters.containerToNewWebLink)(newContainer);
|
|
89
|
+
_context2.next = 4;
|
|
90
|
+
return updateTeamWebLink(teamId, container.id, webLink);
|
|
91
|
+
case 4:
|
|
92
|
+
return _context2.abrupt("return", _context2.sent);
|
|
93
|
+
case 5:
|
|
94
|
+
case "end":
|
|
95
|
+
return _context2.stop();
|
|
96
|
+
}
|
|
97
|
+
}, _callee2);
|
|
98
|
+
}));
|
|
99
|
+
return function (_x2, _x3) {
|
|
100
|
+
return _ref2.apply(this, arguments);
|
|
101
|
+
};
|
|
102
|
+
}(), [teamId, updateTeamWebLink]);
|
|
103
|
+
var removeTeamLink = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
104
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(container) {
|
|
105
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
106
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
107
|
+
case 0:
|
|
108
|
+
if (!(container.type === 'WebLink')) {
|
|
109
|
+
_context3.next = 5;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
_context3.next = 3;
|
|
113
|
+
return removeWebLink(teamId, container.id);
|
|
114
|
+
case 3:
|
|
115
|
+
_context3.next = 7;
|
|
116
|
+
break;
|
|
117
|
+
case 5:
|
|
118
|
+
_context3.next = 7;
|
|
119
|
+
return unlinkTeamContainers(container.id);
|
|
120
|
+
case 7:
|
|
121
|
+
case "end":
|
|
122
|
+
return _context3.stop();
|
|
123
|
+
}
|
|
124
|
+
}, _callee3);
|
|
125
|
+
}));
|
|
126
|
+
return function (_x4) {
|
|
127
|
+
return _ref3.apply(this, arguments);
|
|
128
|
+
};
|
|
129
|
+
}(), [teamId, removeWebLink, unlinkTeamContainers]);
|
|
130
|
+
return {
|
|
131
|
+
isLoading: containersLoading || webLinksLoading,
|
|
132
|
+
hasError: !!containersError || webLinksError,
|
|
133
|
+
containersError: !!containersError,
|
|
134
|
+
webLinksError: webLinksError,
|
|
135
|
+
containersHasLoaded: containersHasLoaded,
|
|
136
|
+
webLinksHasLoaded: webLinksHasLoaded,
|
|
137
|
+
hasLoaded: containersHasLoaded && webLinksHasLoaded,
|
|
138
|
+
teamLinks: allContainers,
|
|
139
|
+
canAddMoreLink: canAddMoreLink,
|
|
140
|
+
addTeamLink: addTeamLink,
|
|
141
|
+
updateTeamLink: updateTeamLink,
|
|
142
|
+
removeTeamLink: removeTeamLink
|
|
143
|
+
};
|
|
144
|
+
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -57,6 +57,12 @@ Object.defineProperty(exports, "useTeamContainers", {
|
|
|
57
57
|
return _useTeamContainers.useTeamContainers;
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
+
Object.defineProperty(exports, "useTeamLinksAndContainers", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _useTeamLinksAndContainers.useTeamLinksAndContainers;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
60
66
|
Object.defineProperty(exports, "useTeamWebLinks", {
|
|
61
67
|
enumerable: true,
|
|
62
68
|
get: function get() {
|
|
@@ -72,6 +78,7 @@ Object.defineProperty(exports, "useTeamWebLinksActions", {
|
|
|
72
78
|
var _teamContainers = require("./ui/team-containers");
|
|
73
79
|
var _useTeamContainers = require("./controllers/hooks/use-team-containers");
|
|
74
80
|
var _useTeamWebLinks = require("./controllers/hooks/use-team-web-links");
|
|
81
|
+
var _useTeamLinksAndContainers = require("./controllers/hooks/use-team-links-and-containers");
|
|
75
82
|
var _useProductPermission = require("./controllers/hooks/use-product-permission");
|
|
76
83
|
var _utils = require("./controllers/product-permission/utils");
|
|
77
84
|
var _getContainerProperties = require("./common/utils/get-container-properties");
|
|
@@ -14,6 +14,7 @@ const initialConnectedTeamsState = {
|
|
|
14
14
|
const initialState = {
|
|
15
15
|
teamContainers: [],
|
|
16
16
|
loading: true,
|
|
17
|
+
hasLoaded: false,
|
|
17
18
|
error: null,
|
|
18
19
|
unlinkError: null,
|
|
19
20
|
teamId: null,
|
|
@@ -34,7 +35,8 @@ const actions = {
|
|
|
34
35
|
loading: true,
|
|
35
36
|
error: null,
|
|
36
37
|
teamContainers: [],
|
|
37
|
-
teamId
|
|
38
|
+
teamId,
|
|
39
|
+
hasLoaded: false
|
|
38
40
|
});
|
|
39
41
|
try {
|
|
40
42
|
const containers = await teamsClient.getTeamContainers(teamId);
|
|
@@ -42,14 +44,16 @@ const actions = {
|
|
|
42
44
|
setState({
|
|
43
45
|
teamContainers: containers,
|
|
44
46
|
loading: false,
|
|
45
|
-
error: null
|
|
47
|
+
error: null,
|
|
48
|
+
hasLoaded: true
|
|
46
49
|
});
|
|
47
50
|
} catch (err) {
|
|
48
51
|
fireAnalytics(AnalyticsAction.FAILED, 'fetchTeamContainers', err);
|
|
49
52
|
setState({
|
|
50
53
|
teamContainers: [],
|
|
51
54
|
error: err,
|
|
52
|
-
loading: false
|
|
55
|
+
loading: false,
|
|
56
|
+
hasLoaded: true
|
|
53
57
|
});
|
|
54
58
|
}
|
|
55
59
|
},
|
|
@@ -263,7 +267,8 @@ export const useTeamContainers = (teamId, enable = true) => {
|
|
|
263
267
|
}, [teamId, actions, enable, fireOperationalAnalytics]);
|
|
264
268
|
return {
|
|
265
269
|
...state,
|
|
266
|
-
addTeamContainer: actions.addTeamContainer
|
|
270
|
+
addTeamContainer: actions.addTeamContainer,
|
|
271
|
+
unlinkTeamContainers: containerId => actions.unlinkTeamContainers(teamId, containerId)
|
|
267
272
|
};
|
|
268
273
|
};
|
|
269
274
|
export const useConnectedTeams = () => {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
import { containerToNewWebLink, webLinksToContainers } from '../../../common/utils/team-web-link-converters';
|
|
3
|
+
import { useTeamContainers } from '../use-team-containers';
|
|
4
|
+
import { useTeamWebLinks } from '../use-team-web-links';
|
|
5
|
+
const MAX_LINKS_LIMIT = 10;
|
|
6
|
+
export const useTeamLinksAndContainers = (teamId, enableContainers = true) => {
|
|
7
|
+
const {
|
|
8
|
+
teamContainers,
|
|
9
|
+
loading: containersLoading,
|
|
10
|
+
hasLoaded: containersHasLoaded,
|
|
11
|
+
error: containersError,
|
|
12
|
+
addTeamContainer,
|
|
13
|
+
unlinkTeamContainers
|
|
14
|
+
} = useTeamContainers(teamId, enableContainers);
|
|
15
|
+
const [{
|
|
16
|
+
links,
|
|
17
|
+
isLoading: webLinksLoading,
|
|
18
|
+
hasError: webLinksError,
|
|
19
|
+
hasLoaded: webLinksHasLoaded
|
|
20
|
+
}, {
|
|
21
|
+
getTeamWebLinks,
|
|
22
|
+
createTeamWebLink,
|
|
23
|
+
updateTeamWebLink,
|
|
24
|
+
removeWebLink
|
|
25
|
+
}] = useTeamWebLinks();
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
getTeamWebLinks(teamId);
|
|
28
|
+
}, [getTeamWebLinks, teamId]);
|
|
29
|
+
const webLinkContainers = useMemo(() => webLinksToContainers(links), [links]);
|
|
30
|
+
const allContainers = useMemo(() => [...teamContainers, ...webLinkContainers], [teamContainers, webLinkContainers]);
|
|
31
|
+
const canAddMoreLink = useMemo(() => allContainers.length <= MAX_LINKS_LIMIT, [allContainers.length]);
|
|
32
|
+
const addTeamLink = useCallback(async container => {
|
|
33
|
+
if (container.type === 'WebLink') {
|
|
34
|
+
const webLink = containerToNewWebLink(container);
|
|
35
|
+
return await createTeamWebLink(teamId, webLink);
|
|
36
|
+
} else {
|
|
37
|
+
addTeamContainer(container);
|
|
38
|
+
return Promise.resolve(container);
|
|
39
|
+
}
|
|
40
|
+
}, [teamId, createTeamWebLink, addTeamContainer]);
|
|
41
|
+
const updateTeamLink = useCallback(async (container, newContainer) => {
|
|
42
|
+
if (container.type === 'WebLink') {
|
|
43
|
+
const webLink = containerToNewWebLink(newContainer);
|
|
44
|
+
return await updateTeamWebLink(teamId, container.id, webLink);
|
|
45
|
+
}
|
|
46
|
+
}, [teamId, updateTeamWebLink]);
|
|
47
|
+
const removeTeamLink = useCallback(async container => {
|
|
48
|
+
if (container.type === 'WebLink') {
|
|
49
|
+
await removeWebLink(teamId, container.id);
|
|
50
|
+
} else {
|
|
51
|
+
await unlinkTeamContainers(container.id);
|
|
52
|
+
}
|
|
53
|
+
}, [teamId, removeWebLink, unlinkTeamContainers]);
|
|
54
|
+
return {
|
|
55
|
+
isLoading: containersLoading || webLinksLoading,
|
|
56
|
+
hasError: !!containersError || webLinksError,
|
|
57
|
+
containersError: !!containersError,
|
|
58
|
+
webLinksError,
|
|
59
|
+
containersHasLoaded,
|
|
60
|
+
webLinksHasLoaded,
|
|
61
|
+
hasLoaded: containersHasLoaded && webLinksHasLoaded,
|
|
62
|
+
teamLinks: allContainers,
|
|
63
|
+
canAddMoreLink,
|
|
64
|
+
addTeamLink,
|
|
65
|
+
updateTeamLink,
|
|
66
|
+
removeTeamLink
|
|
67
|
+
};
|
|
68
|
+
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { TeamContainers } from './ui/team-containers';
|
|
2
2
|
export { useTeamContainers, useConnectedTeams } from './controllers/hooks/use-team-containers';
|
|
3
3
|
export { useTeamWebLinks, useTeamWebLinksActions } from './controllers/hooks/use-team-web-links';
|
|
4
|
+
export { useTeamLinksAndContainers } from './controllers/hooks/use-team-links-and-containers';
|
|
4
5
|
export { useProductPermissions } from './controllers/hooks/use-product-permission';
|
|
5
6
|
export { hasProductPermission } from './controllers/product-permission/utils';
|
|
6
7
|
export { getContainerProperties } from './common/utils/get-container-properties';
|
|
@@ -21,6 +21,7 @@ var initialConnectedTeamsState = {
|
|
|
21
21
|
var initialState = {
|
|
22
22
|
teamContainers: [],
|
|
23
23
|
loading: true,
|
|
24
|
+
hasLoaded: false,
|
|
24
25
|
error: null,
|
|
25
26
|
unlinkError: null,
|
|
26
27
|
teamId: null,
|
|
@@ -46,7 +47,8 @@ var actions = {
|
|
|
46
47
|
loading: true,
|
|
47
48
|
error: null,
|
|
48
49
|
teamContainers: [],
|
|
49
|
-
teamId: teamId
|
|
50
|
+
teamId: teamId,
|
|
51
|
+
hasLoaded: false
|
|
50
52
|
});
|
|
51
53
|
_context.prev = 5;
|
|
52
54
|
_context.next = 8;
|
|
@@ -57,7 +59,8 @@ var actions = {
|
|
|
57
59
|
setState({
|
|
58
60
|
teamContainers: containers,
|
|
59
61
|
loading: false,
|
|
60
|
-
error: null
|
|
62
|
+
error: null,
|
|
63
|
+
hasLoaded: true
|
|
61
64
|
});
|
|
62
65
|
_context.next = 17;
|
|
63
66
|
break;
|
|
@@ -68,7 +71,8 @@ var actions = {
|
|
|
68
71
|
setState({
|
|
69
72
|
teamContainers: [],
|
|
70
73
|
error: _context.t0,
|
|
71
|
-
loading: false
|
|
74
|
+
loading: false,
|
|
75
|
+
hasLoaded: true
|
|
72
76
|
});
|
|
73
77
|
case 17:
|
|
74
78
|
case "end":
|
|
@@ -359,7 +363,10 @@ export var useTeamContainers = function useTeamContainers(teamId) {
|
|
|
359
363
|
}
|
|
360
364
|
}, [teamId, actions, enable, fireOperationalAnalytics]);
|
|
361
365
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
362
|
-
addTeamContainer: actions.addTeamContainer
|
|
366
|
+
addTeamContainer: actions.addTeamContainer,
|
|
367
|
+
unlinkTeamContainers: function unlinkTeamContainers(containerId) {
|
|
368
|
+
return actions.unlinkTeamContainers(teamId, containerId);
|
|
369
|
+
}
|
|
363
370
|
});
|
|
364
371
|
};
|
|
365
372
|
export var useConnectedTeams = function useConnectedTeams() {
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
6
|
+
import { containerToNewWebLink, webLinksToContainers } from '../../../common/utils/team-web-link-converters';
|
|
7
|
+
import { useTeamContainers } from '../use-team-containers';
|
|
8
|
+
import { useTeamWebLinks } from '../use-team-web-links';
|
|
9
|
+
var MAX_LINKS_LIMIT = 10;
|
|
10
|
+
export var useTeamLinksAndContainers = function useTeamLinksAndContainers(teamId) {
|
|
11
|
+
var enableContainers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
12
|
+
var _useTeamContainers = useTeamContainers(teamId, enableContainers),
|
|
13
|
+
teamContainers = _useTeamContainers.teamContainers,
|
|
14
|
+
containersLoading = _useTeamContainers.loading,
|
|
15
|
+
containersHasLoaded = _useTeamContainers.hasLoaded,
|
|
16
|
+
containersError = _useTeamContainers.error,
|
|
17
|
+
addTeamContainer = _useTeamContainers.addTeamContainer,
|
|
18
|
+
unlinkTeamContainers = _useTeamContainers.unlinkTeamContainers;
|
|
19
|
+
var _useTeamWebLinks = useTeamWebLinks(),
|
|
20
|
+
_useTeamWebLinks2 = _slicedToArray(_useTeamWebLinks, 2),
|
|
21
|
+
_useTeamWebLinks2$ = _useTeamWebLinks2[0],
|
|
22
|
+
links = _useTeamWebLinks2$.links,
|
|
23
|
+
webLinksLoading = _useTeamWebLinks2$.isLoading,
|
|
24
|
+
webLinksError = _useTeamWebLinks2$.hasError,
|
|
25
|
+
webLinksHasLoaded = _useTeamWebLinks2$.hasLoaded,
|
|
26
|
+
_useTeamWebLinks2$2 = _useTeamWebLinks2[1],
|
|
27
|
+
getTeamWebLinks = _useTeamWebLinks2$2.getTeamWebLinks,
|
|
28
|
+
createTeamWebLink = _useTeamWebLinks2$2.createTeamWebLink,
|
|
29
|
+
updateTeamWebLink = _useTeamWebLinks2$2.updateTeamWebLink,
|
|
30
|
+
removeWebLink = _useTeamWebLinks2$2.removeWebLink;
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
getTeamWebLinks(teamId);
|
|
33
|
+
}, [getTeamWebLinks, teamId]);
|
|
34
|
+
var webLinkContainers = useMemo(function () {
|
|
35
|
+
return webLinksToContainers(links);
|
|
36
|
+
}, [links]);
|
|
37
|
+
var allContainers = useMemo(function () {
|
|
38
|
+
return [].concat(_toConsumableArray(teamContainers), _toConsumableArray(webLinkContainers));
|
|
39
|
+
}, [teamContainers, webLinkContainers]);
|
|
40
|
+
var canAddMoreLink = useMemo(function () {
|
|
41
|
+
return allContainers.length <= MAX_LINKS_LIMIT;
|
|
42
|
+
}, [allContainers.length]);
|
|
43
|
+
var addTeamLink = useCallback( /*#__PURE__*/function () {
|
|
44
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(container) {
|
|
45
|
+
var webLink;
|
|
46
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
47
|
+
while (1) switch (_context.prev = _context.next) {
|
|
48
|
+
case 0:
|
|
49
|
+
if (!(container.type === 'WebLink')) {
|
|
50
|
+
_context.next = 7;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
webLink = containerToNewWebLink(container);
|
|
54
|
+
_context.next = 4;
|
|
55
|
+
return createTeamWebLink(teamId, webLink);
|
|
56
|
+
case 4:
|
|
57
|
+
return _context.abrupt("return", _context.sent);
|
|
58
|
+
case 7:
|
|
59
|
+
addTeamContainer(container);
|
|
60
|
+
return _context.abrupt("return", Promise.resolve(container));
|
|
61
|
+
case 9:
|
|
62
|
+
case "end":
|
|
63
|
+
return _context.stop();
|
|
64
|
+
}
|
|
65
|
+
}, _callee);
|
|
66
|
+
}));
|
|
67
|
+
return function (_x) {
|
|
68
|
+
return _ref.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
}(), [teamId, createTeamWebLink, addTeamContainer]);
|
|
71
|
+
var updateTeamLink = useCallback( /*#__PURE__*/function () {
|
|
72
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(container, newContainer) {
|
|
73
|
+
var webLink;
|
|
74
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
75
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
if (!(container.type === 'WebLink')) {
|
|
78
|
+
_context2.next = 5;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
webLink = containerToNewWebLink(newContainer);
|
|
82
|
+
_context2.next = 4;
|
|
83
|
+
return updateTeamWebLink(teamId, container.id, webLink);
|
|
84
|
+
case 4:
|
|
85
|
+
return _context2.abrupt("return", _context2.sent);
|
|
86
|
+
case 5:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context2.stop();
|
|
89
|
+
}
|
|
90
|
+
}, _callee2);
|
|
91
|
+
}));
|
|
92
|
+
return function (_x2, _x3) {
|
|
93
|
+
return _ref2.apply(this, arguments);
|
|
94
|
+
};
|
|
95
|
+
}(), [teamId, updateTeamWebLink]);
|
|
96
|
+
var removeTeamLink = useCallback( /*#__PURE__*/function () {
|
|
97
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(container) {
|
|
98
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
99
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
100
|
+
case 0:
|
|
101
|
+
if (!(container.type === 'WebLink')) {
|
|
102
|
+
_context3.next = 5;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
_context3.next = 3;
|
|
106
|
+
return removeWebLink(teamId, container.id);
|
|
107
|
+
case 3:
|
|
108
|
+
_context3.next = 7;
|
|
109
|
+
break;
|
|
110
|
+
case 5:
|
|
111
|
+
_context3.next = 7;
|
|
112
|
+
return unlinkTeamContainers(container.id);
|
|
113
|
+
case 7:
|
|
114
|
+
case "end":
|
|
115
|
+
return _context3.stop();
|
|
116
|
+
}
|
|
117
|
+
}, _callee3);
|
|
118
|
+
}));
|
|
119
|
+
return function (_x4) {
|
|
120
|
+
return _ref3.apply(this, arguments);
|
|
121
|
+
};
|
|
122
|
+
}(), [teamId, removeWebLink, unlinkTeamContainers]);
|
|
123
|
+
return {
|
|
124
|
+
isLoading: containersLoading || webLinksLoading,
|
|
125
|
+
hasError: !!containersError || webLinksError,
|
|
126
|
+
containersError: !!containersError,
|
|
127
|
+
webLinksError: webLinksError,
|
|
128
|
+
containersHasLoaded: containersHasLoaded,
|
|
129
|
+
webLinksHasLoaded: webLinksHasLoaded,
|
|
130
|
+
hasLoaded: containersHasLoaded && webLinksHasLoaded,
|
|
131
|
+
teamLinks: allContainers,
|
|
132
|
+
canAddMoreLink: canAddMoreLink,
|
|
133
|
+
addTeamLink: addTeamLink,
|
|
134
|
+
updateTeamLink: updateTeamLink,
|
|
135
|
+
removeTeamLink: removeTeamLink
|
|
136
|
+
};
|
|
137
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { TeamContainers } from './ui/team-containers';
|
|
2
2
|
export { useTeamContainers, useConnectedTeams } from './controllers/hooks/use-team-containers';
|
|
3
3
|
export { useTeamWebLinks, useTeamWebLinksActions } from './controllers/hooks/use-team-web-links';
|
|
4
|
+
export { useTeamLinksAndContainers } from './controllers/hooks/use-team-links-and-containers';
|
|
4
5
|
export { useProductPermissions } from './controllers/hooks/use-product-permission';
|
|
5
6
|
export { hasProductPermission } from './controllers/product-permission/utils';
|
|
6
7
|
export { getContainerProperties } from './common/utils/get-container-properties';
|
|
@@ -12,6 +12,7 @@ type ConnectedTeams = {
|
|
|
12
12
|
type State = {
|
|
13
13
|
teamContainers: TeamContainers;
|
|
14
14
|
loading: boolean;
|
|
15
|
+
hasLoaded: boolean;
|
|
15
16
|
error: Error | null;
|
|
16
17
|
unlinkError: UnlinkContainerMutationError | null;
|
|
17
18
|
teamId: string | null;
|
|
@@ -33,8 +34,10 @@ export declare const useTeamContainersHook: import("react-sweet-state").HookFunc
|
|
|
33
34
|
}>, void>;
|
|
34
35
|
export declare const useTeamContainers: (teamId: string, enable?: boolean) => {
|
|
35
36
|
addTeamContainer: (teamContainer: TeamContainer) => void | Promise<void>;
|
|
37
|
+
unlinkTeamContainers: (containerId: string) => void | Promise<void>;
|
|
36
38
|
teamContainers: TeamContainers;
|
|
37
39
|
loading: boolean;
|
|
40
|
+
hasLoaded: boolean;
|
|
38
41
|
error: Error | null;
|
|
39
42
|
unlinkError: UnlinkContainerMutationError | null;
|
|
40
43
|
teamId: string | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type TeamContainer } from '../../../common/types';
|
|
2
|
+
export type UseTeamLinksAndContainersResult = {
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
hasError: boolean;
|
|
5
|
+
containersError: boolean;
|
|
6
|
+
webLinksError: boolean;
|
|
7
|
+
webLinksHasLoaded: boolean;
|
|
8
|
+
containersHasLoaded: boolean;
|
|
9
|
+
hasLoaded: boolean;
|
|
10
|
+
teamLinks: TeamContainer[];
|
|
11
|
+
canAddMoreLink: boolean;
|
|
12
|
+
addTeamLink: (container: TeamContainer) => Promise<any>;
|
|
13
|
+
updateTeamLink: (container: TeamContainer, newContainer: TeamContainer) => Promise<any>;
|
|
14
|
+
removeTeamLink: (container: TeamContainer) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
export declare const useTeamLinksAndContainers: (teamId: string, enableContainers?: boolean) => UseTeamLinksAndContainersResult;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type { TeamContainersSkeletonProps } from './ui/team-containers';
|
|
|
4
4
|
export type { TeamContainerProps } from './ui/team-containers/types';
|
|
5
5
|
export { useTeamContainers, useConnectedTeams } from './controllers/hooks/use-team-containers';
|
|
6
6
|
export { useTeamWebLinks, useTeamWebLinksActions } from './controllers/hooks/use-team-web-links';
|
|
7
|
+
export { useTeamLinksAndContainers } from './controllers/hooks/use-team-links-and-containers';
|
|
7
8
|
export type { TeamContainer, ContainerSubTypes } from './common/types';
|
|
8
9
|
export { useProductPermissions } from './controllers/hooks/use-product-permission';
|
|
9
10
|
export { hasProductPermission } from './controllers/product-permission/utils';
|
|
@@ -12,6 +12,7 @@ type ConnectedTeams = {
|
|
|
12
12
|
type State = {
|
|
13
13
|
teamContainers: TeamContainers;
|
|
14
14
|
loading: boolean;
|
|
15
|
+
hasLoaded: boolean;
|
|
15
16
|
error: Error | null;
|
|
16
17
|
unlinkError: UnlinkContainerMutationError | null;
|
|
17
18
|
teamId: string | null;
|
|
@@ -33,8 +34,10 @@ export declare const useTeamContainersHook: import("react-sweet-state").HookFunc
|
|
|
33
34
|
}>, void>;
|
|
34
35
|
export declare const useTeamContainers: (teamId: string, enable?: boolean) => {
|
|
35
36
|
addTeamContainer: (teamContainer: TeamContainer) => void | Promise<void>;
|
|
37
|
+
unlinkTeamContainers: (containerId: string) => void | Promise<void>;
|
|
36
38
|
teamContainers: TeamContainers;
|
|
37
39
|
loading: boolean;
|
|
40
|
+
hasLoaded: boolean;
|
|
38
41
|
error: Error | null;
|
|
39
42
|
unlinkError: UnlinkContainerMutationError | null;
|
|
40
43
|
teamId: string | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type TeamContainer } from '../../../common/types';
|
|
2
|
+
export type UseTeamLinksAndContainersResult = {
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
hasError: boolean;
|
|
5
|
+
containersError: boolean;
|
|
6
|
+
webLinksError: boolean;
|
|
7
|
+
webLinksHasLoaded: boolean;
|
|
8
|
+
containersHasLoaded: boolean;
|
|
9
|
+
hasLoaded: boolean;
|
|
10
|
+
teamLinks: TeamContainer[];
|
|
11
|
+
canAddMoreLink: boolean;
|
|
12
|
+
addTeamLink: (container: TeamContainer) => Promise<any>;
|
|
13
|
+
updateTeamLink: (container: TeamContainer, newContainer: TeamContainer) => Promise<any>;
|
|
14
|
+
removeTeamLink: (container: TeamContainer) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
export declare const useTeamLinksAndContainers: (teamId: string, enableContainers?: boolean) => UseTeamLinksAndContainersResult;
|
|
@@ -4,6 +4,7 @@ export type { TeamContainersSkeletonProps } from './ui/team-containers';
|
|
|
4
4
|
export type { TeamContainerProps } from './ui/team-containers/types';
|
|
5
5
|
export { useTeamContainers, useConnectedTeams } from './controllers/hooks/use-team-containers';
|
|
6
6
|
export { useTeamWebLinks, useTeamWebLinksActions } from './controllers/hooks/use-team-web-links';
|
|
7
|
+
export { useTeamLinksAndContainers } from './controllers/hooks/use-team-links-and-containers';
|
|
7
8
|
export type { TeamContainer, ContainerSubTypes } from './common/types';
|
|
8
9
|
export { useProductPermissions } from './controllers/hooks/use-product-permission';
|
|
9
10
|
export { hasProductPermission } from './controllers/product-permission/utils';
|