@atlaskit/teams-public 0.34.1 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/cjs/common/ui/container-icon/index.compiled.css +16 -0
- package/dist/cjs/common/ui/container-icon/index.js +46 -0
- package/dist/cjs/common/utils/get-container-properties.js +17 -9
- package/dist/cjs/common/utils/team-web-link-converters.js +13 -4
- package/dist/cjs/controllers/hooks/use-team-links-and-containers/index.js +46 -23
- package/dist/cjs/controllers/hooks/use-team-web-links/index.js +193 -51
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/ui/team-containers/linked-container-card/index.js +2 -12
- package/dist/cjs/ui/team-containers/main.js +36 -8
- package/dist/cjs/ui/team-containers/team-link-card/index.compiled.css +22 -0
- package/dist/cjs/ui/team-containers/team-link-card/index.js +224 -0
- package/dist/es2019/common/ui/container-icon/index.compiled.css +16 -0
- package/dist/es2019/common/ui/container-icon/index.js +39 -0
- package/dist/es2019/common/utils/get-container-properties.js +17 -9
- package/dist/es2019/common/utils/team-web-link-converters.js +10 -4
- package/dist/es2019/controllers/hooks/use-team-links-and-containers/index.js +26 -13
- package/dist/es2019/controllers/hooks/use-team-web-links/index.js +98 -8
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/ui/team-containers/linked-container-card/index.js +0 -10
- package/dist/es2019/ui/team-containers/main.js +22 -8
- package/dist/es2019/ui/team-containers/team-link-card/index.compiled.css +22 -0
- package/dist/es2019/ui/team-containers/team-link-card/index.js +203 -0
- package/dist/esm/common/ui/container-icon/index.compiled.css +16 -0
- package/dist/esm/common/ui/container-icon/index.js +39 -0
- package/dist/esm/common/utils/get-container-properties.js +17 -9
- package/dist/esm/common/utils/team-web-link-converters.js +12 -3
- package/dist/esm/controllers/hooks/use-team-links-and-containers/index.js +47 -24
- package/dist/esm/controllers/hooks/use-team-web-links/index.js +193 -51
- package/dist/esm/index.js +1 -0
- package/dist/esm/ui/team-containers/linked-container-card/index.js +0 -10
- package/dist/esm/ui/team-containers/main.js +36 -8
- package/dist/esm/ui/team-containers/team-link-card/index.compiled.css +22 -0
- package/dist/esm/ui/team-containers/team-link-card/index.js +215 -0
- package/dist/types/common/ui/container-icon/index.d.ts +10 -0
- package/dist/types/common/utils/get-container-properties.d.ts +2 -1
- package/dist/types/common/utils/team-web-link-converters.d.ts +8 -2
- package/dist/types/controllers/hooks/use-team-links-and-containers/index.d.ts +3 -3
- package/dist/types/controllers/hooks/use-team-web-links/index.d.ts +15 -12
- package/dist/types/controllers/hooks/use-team-web-links/types.d.ts +8 -2
- package/dist/types/index.d.ts +3 -1
- package/dist/types/ui/team-containers/main.d.ts +1 -1
- package/dist/types/ui/team-containers/team-link-card/index.d.ts +16 -0
- package/dist/types/ui/team-containers/types.d.ts +5 -1
- package/dist/types-ts4.5/common/ui/container-icon/index.d.ts +10 -0
- package/dist/types-ts4.5/common/utils/get-container-properties.d.ts +2 -1
- package/dist/types-ts4.5/common/utils/team-web-link-converters.d.ts +8 -2
- package/dist/types-ts4.5/controllers/hooks/use-team-links-and-containers/index.d.ts +3 -3
- package/dist/types-ts4.5/controllers/hooks/use-team-web-links/index.d.ts +15 -12
- package/dist/types-ts4.5/controllers/hooks/use-team-web-links/types.d.ts +8 -2
- package/dist/types-ts4.5/index.d.ts +3 -1
- package/dist/types-ts4.5/ui/team-containers/main.d.ts +1 -1
- package/dist/types-ts4.5/ui/team-containers/team-link-card/index.d.ts +16 -0
- package/dist/types-ts4.5/ui/team-containers/types.d.ts +5 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/teams-public
|
|
2
2
|
|
|
3
|
+
## 0.36.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#165970](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/165970)
|
|
8
|
+
[`2f04674b589a3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2f04674b589a3) -
|
|
9
|
+
[ux] PTC-11538 Render team web link card in team profile card && fetch team web link icons
|
|
10
|
+
|
|
11
|
+
## 0.35.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#163866](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/163866)
|
|
16
|
+
[`e15fce4142e99`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e15fce4142e99) -
|
|
17
|
+
[ux] PTC-11966 Add actions of add/update/delete team link card
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 0.34.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
._2rko1hkb{border-radius:var(--ds-border-radius-050,4px)}
|
|
3
|
+
._2rkoop52{border-radius:var(--ds-border-radius-100,8px)}._12jimuej{outline-color:var(--ds-border,#091e4224)}
|
|
4
|
+
._18u0v77o{margin-left:var(--ds-space-025,2px)}
|
|
5
|
+
._19pkv77o{margin-top:var(--ds-space-025,2px)}
|
|
6
|
+
._1bah1h6o{justify-content:center}
|
|
7
|
+
._1bsb1tcg{width:24px}
|
|
8
|
+
._1bsb1u1b{width:34px}
|
|
9
|
+
._1e0c1txw{display:flex}
|
|
10
|
+
._1qu2nqa1{outline-style:solid}
|
|
11
|
+
._2hwxv77o{margin-right:var(--ds-space-025,2px)}
|
|
12
|
+
._4cvr1h6o{align-items:center}
|
|
13
|
+
._4t3i1tcg{height:24px}
|
|
14
|
+
._4t3i1u1b{height:34px}
|
|
15
|
+
._bfhkqbzx{background-color:var(--ds-surface-sunken,#f7f8f9)}
|
|
16
|
+
._otyrv77o{margin-bottom:var(--ds-space-025,2px)}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ContainerIcon = void 0;
|
|
9
|
+
require("./index.compiled.css");
|
|
10
|
+
var _runtime = require("@compiled/react/runtime");
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
12
|
+
var _avatar = _interopRequireDefault(require("@atlaskit/avatar"));
|
|
13
|
+
var _link = _interopRequireDefault(require("@atlaskit/icon/core/link"));
|
|
14
|
+
var _compiled = require("@atlaskit/primitives/compiled");
|
|
15
|
+
var _loomAvatar = require("../loom-avatar");
|
|
16
|
+
var styles = {
|
|
17
|
+
linkIconWrapperMedium: "_2rkoop52 _1bsb1u1b _4t3i1u1b _1e0c1txw _4cvr1h6o _1bah1h6o _12jimuej _1qu2nqa1 _bfhkqbzx",
|
|
18
|
+
linkIconWrapperSmall: "_2rko1hkb _1bsb1tcg _4t3i1tcg _1e0c1txw _4cvr1h6o _1bah1h6o _19pkv77o _2hwxv77o _otyrv77o _18u0v77o _12jimuej _1qu2nqa1 _bfhkqbzx"
|
|
19
|
+
};
|
|
20
|
+
var ContainerIcon = exports.ContainerIcon = function ContainerIcon(_ref) {
|
|
21
|
+
var containerType = _ref.containerType,
|
|
22
|
+
title = _ref.title,
|
|
23
|
+
containerIcon = _ref.containerIcon,
|
|
24
|
+
_ref$size = _ref.size,
|
|
25
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size;
|
|
26
|
+
if (containerType === 'LoomSpace') {
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_loomAvatar.LoomSpaceAvatar, {
|
|
28
|
+
spaceName: title,
|
|
29
|
+
size: size === 'medium' ? 'large' : size
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (containerType === 'WebLink' && !containerIcon) {
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
34
|
+
xcss: size === 'medium' ? styles.linkIconWrapperMedium : styles.linkIconWrapperSmall
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement(_link.default, {
|
|
36
|
+
label: "",
|
|
37
|
+
testId: "linked-container-WebLink-icon"
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
return /*#__PURE__*/_react.default.createElement(_avatar.default, {
|
|
41
|
+
appearance: "square",
|
|
42
|
+
size: size,
|
|
43
|
+
src: containerIcon,
|
|
44
|
+
testId: "linked-container-".concat(containerType, "-icon")
|
|
45
|
+
});
|
|
46
|
+
};
|
|
@@ -12,6 +12,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
12
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
13
|
var _reactIntlNext = require("react-intl-next");
|
|
14
14
|
var _globe = _interopRequireDefault(require("@atlaskit/icon/core/globe"));
|
|
15
|
+
var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
|
|
15
16
|
var _image = _interopRequireDefault(require("@atlaskit/image"));
|
|
16
17
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
17
18
|
var _ConfluenceIcon = _interopRequireDefault(require("../assets/ConfluenceIcon.svg"));
|
|
@@ -128,14 +129,19 @@ var getJiraContainerProperties = function getJiraContainerProperties(_ref) {
|
|
|
128
129
|
return baseProperties;
|
|
129
130
|
}
|
|
130
131
|
};
|
|
131
|
-
var
|
|
132
|
-
var isEmptyContainer = _ref3.isEmptyContainer
|
|
132
|
+
var getWebLinkContainerProperties = function getWebLinkContainerProperties(_ref3) {
|
|
133
|
+
var isEmptyContainer = _ref3.isEmptyContainer,
|
|
134
|
+
isDisplayedOnProfileCard = _ref3.isDisplayedOnProfileCard;
|
|
133
135
|
return {
|
|
134
136
|
description: isEmptyContainer ? /*#__PURE__*/_react.default.createElement(_compiled.Text, {
|
|
135
137
|
size: "medium",
|
|
136
138
|
weight: "medium"
|
|
137
139
|
}, /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.emptyWebLinkContainerDescription)) : /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.webLinkContainerDescription),
|
|
138
|
-
icon: isEmptyContainer ? null : /*#__PURE__*/_react.default.createElement(
|
|
140
|
+
icon: isEmptyContainer ? null : isDisplayedOnProfileCard ? /*#__PURE__*/_react.default.createElement(_linkExternal.default, {
|
|
141
|
+
label: "",
|
|
142
|
+
size: "small",
|
|
143
|
+
testId: "team-link-card-external-link-icon"
|
|
144
|
+
}) : /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
139
145
|
xcss: styles.globeIconWrapper,
|
|
140
146
|
testId: "team-link-card-globe-icon"
|
|
141
147
|
}, /*#__PURE__*/_react.default.createElement(_globe.default, {
|
|
@@ -151,7 +157,8 @@ var getContainerProperties = exports.getContainerProperties = function getContai
|
|
|
151
157
|
_ref4$iconSize = _ref4.iconSize,
|
|
152
158
|
iconSize = _ref4$iconSize === void 0 ? 'small' : _ref4$iconSize,
|
|
153
159
|
containerTypeProperties = _ref4.containerTypeProperties,
|
|
154
|
-
isEmptyContainer = _ref4.isEmptyContainer
|
|
160
|
+
isEmptyContainer = _ref4.isEmptyContainer,
|
|
161
|
+
isDisplayedOnProfileCard = _ref4.isDisplayedOnProfileCard;
|
|
155
162
|
switch (containerType) {
|
|
156
163
|
case 'ConfluenceSpace':
|
|
157
164
|
return {
|
|
@@ -163,7 +170,7 @@ var getContainerProperties = exports.getContainerProperties = function getContai
|
|
|
163
170
|
alt: "",
|
|
164
171
|
testId: "confluence-space-container-icon"
|
|
165
172
|
})),
|
|
166
|
-
title: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.
|
|
173
|
+
title: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.addConfluenceContainerTitle),
|
|
167
174
|
containerTypeText: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.spaceContainerText)
|
|
168
175
|
};
|
|
169
176
|
case 'LoomSpace':
|
|
@@ -174,9 +181,9 @@ var getContainerProperties = exports.getContainerProperties = function getContai
|
|
|
174
181
|
}, /*#__PURE__*/_react.default.createElement(_image.default, {
|
|
175
182
|
src: _LoomIcon.default,
|
|
176
183
|
alt: "",
|
|
177
|
-
testId: "
|
|
184
|
+
testId: "loom-space-container-icon"
|
|
178
185
|
})),
|
|
179
|
-
title: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.
|
|
186
|
+
title: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.addLoomContainerTitle),
|
|
180
187
|
containerTypeText: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.spaceContainerText)
|
|
181
188
|
};
|
|
182
189
|
case 'JiraProject':
|
|
@@ -185,8 +192,9 @@ var getContainerProperties = exports.getContainerProperties = function getContai
|
|
|
185
192
|
iconSize: iconSize
|
|
186
193
|
});
|
|
187
194
|
case 'WebLink':
|
|
188
|
-
return
|
|
189
|
-
isEmptyContainer: isEmptyContainer
|
|
195
|
+
return getWebLinkContainerProperties({
|
|
196
|
+
isEmptyContainer: isEmptyContainer,
|
|
197
|
+
isDisplayedOnProfileCard: isDisplayedOnProfileCard
|
|
190
198
|
});
|
|
191
199
|
default:
|
|
192
200
|
return {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.webLinksToContainers = exports.webLinkToContainer = exports.containerToNewWebLink = void 0;
|
|
6
|
+
exports.webLinksToContainers = exports.webLinkToContainer = exports.isNewTeamWebLink = exports.containerToNewWebLink = void 0;
|
|
7
7
|
var containerToNewWebLink = exports.containerToNewWebLink = function containerToNewWebLink(container) {
|
|
8
8
|
return {
|
|
9
9
|
contentTitle: container.name,
|
|
@@ -11,15 +11,24 @@ var containerToNewWebLink = exports.containerToNewWebLink = function containerTo
|
|
|
11
11
|
linkUri: container.link || ''
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
var webLinkToContainer = exports.webLinkToContainer = function webLinkToContainer(link) {
|
|
14
|
+
var webLinkToContainer = exports.webLinkToContainer = function webLinkToContainer(link, iconData) {
|
|
15
15
|
return {
|
|
16
16
|
id: link.linkId,
|
|
17
17
|
type: 'WebLink',
|
|
18
18
|
name: link.contentTitle,
|
|
19
|
-
icon: null,
|
|
19
|
+
icon: (iconData === null || iconData === void 0 ? void 0 : iconData.iconUrl) || null,
|
|
20
20
|
link: link.linkUri
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
var webLinksToContainers = exports.webLinksToContainers = function webLinksToContainers(links) {
|
|
24
|
-
|
|
24
|
+
var linkIcons = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
25
|
+
return links.map(function (link) {
|
|
26
|
+
var iconData = linkIcons.find(function (icon) {
|
|
27
|
+
return icon.linkUrl === link.linkUri;
|
|
28
|
+
});
|
|
29
|
+
return webLinkToContainer(link, iconData);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
var isNewTeamWebLink = exports.isNewTeamWebLink = function isNewTeamWebLink(input) {
|
|
33
|
+
return 'contentTitle' in input && 'linkUri' in input && !('type' in input) && !('id' in input);
|
|
25
34
|
};
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.useTeamLinksAndContainers = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
@@ -13,6 +14,8 @@ var _react = require("react");
|
|
|
13
14
|
var _teamWebLinkConverters = require("../../../common/utils/team-web-link-converters");
|
|
14
15
|
var _useTeamContainers2 = require("../use-team-containers");
|
|
15
16
|
var _useTeamWebLinks3 = require("../use-team-web-links");
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
16
19
|
var MAX_LINKS_LIMIT = 10;
|
|
17
20
|
var useTeamLinksAndContainers = exports.useTeamLinksAndContainers = function useTeamLinksAndContainers(teamId) {
|
|
18
21
|
var enableContainers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
@@ -27,6 +30,7 @@ var useTeamLinksAndContainers = exports.useTeamLinksAndContainers = function use
|
|
|
27
30
|
_useTeamWebLinks2 = (0, _slicedToArray2.default)(_useTeamWebLinks, 2),
|
|
28
31
|
_useTeamWebLinks2$ = _useTeamWebLinks2[0],
|
|
29
32
|
links = _useTeamWebLinks2$.links,
|
|
33
|
+
linkIcons = _useTeamWebLinks2$.linkIcons,
|
|
30
34
|
webLinksLoading = _useTeamWebLinks2$.isLoading,
|
|
31
35
|
webLinksError = _useTeamWebLinks2$.hasError,
|
|
32
36
|
webLinksHasLoaded = _useTeamWebLinks2$.hasLoaded,
|
|
@@ -39,8 +43,8 @@ var useTeamLinksAndContainers = exports.useTeamLinksAndContainers = function use
|
|
|
39
43
|
getTeamWebLinks(teamId);
|
|
40
44
|
}, [getTeamWebLinks, teamId]);
|
|
41
45
|
var webLinkContainers = (0, _react.useMemo)(function () {
|
|
42
|
-
return (0, _teamWebLinkConverters.webLinksToContainers)(links);
|
|
43
|
-
}, [links]);
|
|
46
|
+
return (0, _teamWebLinkConverters.webLinksToContainers)(links, linkIcons);
|
|
47
|
+
}, [links, linkIcons]);
|
|
44
48
|
var allContainers = (0, _react.useMemo)(function () {
|
|
45
49
|
return [].concat((0, _toConsumableArray2.default)(teamContainers), (0, _toConsumableArray2.default)(webLinkContainers));
|
|
46
50
|
}, [teamContainers, webLinkContainers]);
|
|
@@ -48,24 +52,33 @@ var useTeamLinksAndContainers = exports.useTeamLinksAndContainers = function use
|
|
|
48
52
|
return allContainers.length <= MAX_LINKS_LIMIT;
|
|
49
53
|
}, [allContainers.length]);
|
|
50
54
|
var addTeamLink = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
51
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(
|
|
55
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(containerOrWebLink) {
|
|
52
56
|
var webLink;
|
|
53
57
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
54
58
|
while (1) switch (_context.prev = _context.next) {
|
|
55
59
|
case 0:
|
|
56
|
-
if (!(
|
|
57
|
-
_context.next =
|
|
60
|
+
if (!(0, _teamWebLinkConverters.isNewTeamWebLink)(containerOrWebLink)) {
|
|
61
|
+
_context.next = 6;
|
|
58
62
|
break;
|
|
59
63
|
}
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
_context.next = 3;
|
|
65
|
+
return createTeamWebLink(teamId, containerOrWebLink);
|
|
66
|
+
case 3:
|
|
67
|
+
return _context.abrupt("return", _context.sent);
|
|
68
|
+
case 6:
|
|
69
|
+
if (!(containerOrWebLink.type === 'WebLink')) {
|
|
70
|
+
_context.next = 13;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
webLink = (0, _teamWebLinkConverters.containerToNewWebLink)(containerOrWebLink);
|
|
74
|
+
_context.next = 10;
|
|
62
75
|
return createTeamWebLink(teamId, webLink);
|
|
63
|
-
case
|
|
76
|
+
case 10:
|
|
64
77
|
return _context.abrupt("return", _context.sent);
|
|
65
|
-
case
|
|
66
|
-
addTeamContainer(
|
|
67
|
-
return _context.abrupt("return", Promise.resolve(
|
|
68
|
-
case
|
|
78
|
+
case 13:
|
|
79
|
+
addTeamContainer(containerOrWebLink);
|
|
80
|
+
return _context.abrupt("return", Promise.resolve(containerOrWebLink));
|
|
81
|
+
case 15:
|
|
69
82
|
case "end":
|
|
70
83
|
return _context.stop();
|
|
71
84
|
}
|
|
@@ -75,22 +88,32 @@ var useTeamLinksAndContainers = exports.useTeamLinksAndContainers = function use
|
|
|
75
88
|
return _ref.apply(this, arguments);
|
|
76
89
|
};
|
|
77
90
|
}(), [teamId, createTeamWebLink, addTeamContainer]);
|
|
78
|
-
var
|
|
79
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(
|
|
80
|
-
var
|
|
91
|
+
var updateTeamLinkById = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
92
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(linkId, updatedFields) {
|
|
93
|
+
var container, currentWebLink, updatedWebLink;
|
|
81
94
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
82
95
|
while (1) switch (_context2.prev = _context2.next) {
|
|
83
96
|
case 0:
|
|
97
|
+
container = allContainers.find(function (link) {
|
|
98
|
+
return link.id === linkId;
|
|
99
|
+
});
|
|
100
|
+
if (container) {
|
|
101
|
+
_context2.next = 3;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
return _context2.abrupt("return");
|
|
105
|
+
case 3:
|
|
84
106
|
if (!(container.type === 'WebLink')) {
|
|
85
|
-
_context2.next =
|
|
107
|
+
_context2.next = 9;
|
|
86
108
|
break;
|
|
87
109
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
110
|
+
currentWebLink = (0, _teamWebLinkConverters.containerToNewWebLink)(container);
|
|
111
|
+
updatedWebLink = _objectSpread(_objectSpread({}, currentWebLink), updatedFields);
|
|
112
|
+
_context2.next = 8;
|
|
113
|
+
return updateTeamWebLink(teamId, linkId, updatedWebLink);
|
|
114
|
+
case 8:
|
|
92
115
|
return _context2.abrupt("return", _context2.sent);
|
|
93
|
-
case
|
|
116
|
+
case 9:
|
|
94
117
|
case "end":
|
|
95
118
|
return _context2.stop();
|
|
96
119
|
}
|
|
@@ -99,7 +122,7 @@ var useTeamLinksAndContainers = exports.useTeamLinksAndContainers = function use
|
|
|
99
122
|
return function (_x2, _x3) {
|
|
100
123
|
return _ref2.apply(this, arguments);
|
|
101
124
|
};
|
|
102
|
-
}(), [teamId, updateTeamWebLink]);
|
|
125
|
+
}(), [teamId, allContainers, updateTeamWebLink]);
|
|
103
126
|
var removeTeamLink = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
104
127
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(container) {
|
|
105
128
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
@@ -138,7 +161,7 @@ var useTeamLinksAndContainers = exports.useTeamLinksAndContainers = function use
|
|
|
138
161
|
teamLinks: allContainers,
|
|
139
162
|
canAddMoreLink: canAddMoreLink,
|
|
140
163
|
addTeamLink: addTeamLink,
|
|
141
|
-
|
|
164
|
+
updateTeamLinkById: updateTeamLinkById,
|
|
142
165
|
removeTeamLink: removeTeamLink
|
|
143
166
|
};
|
|
144
167
|
};
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useTeamWebLinksActions = exports.useTeamWebLinks = exports.actions = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
12
|
var _reactSweetState = require("react-sweet-state");
|
|
12
13
|
var _teamsClient = require("@atlaskit/teams-client");
|
|
@@ -19,17 +20,20 @@ var _initialState = {
|
|
|
19
20
|
hasError: false,
|
|
20
21
|
shouldReload: false,
|
|
21
22
|
errorType: null,
|
|
22
|
-
links: []
|
|
23
|
+
links: [],
|
|
24
|
+
linkIcons: [],
|
|
25
|
+
iconsLoading: false,
|
|
26
|
+
iconsError: false
|
|
23
27
|
};
|
|
24
28
|
var actions = exports.actions = {
|
|
25
29
|
getTeamWebLinks: function getTeamWebLinks(teamId) {
|
|
26
30
|
return /*#__PURE__*/function () {
|
|
27
31
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
28
|
-
var getState, setState, _getState, links, currentTeamId, initialLinks, _yield$teamsClient$ge, entities;
|
|
32
|
+
var getState, setState, dispatch, _getState, links, currentTeamId, initialLinks, _yield$teamsClient$ge, entities;
|
|
29
33
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
30
34
|
while (1) switch (_context.prev = _context.next) {
|
|
31
35
|
case 0:
|
|
32
|
-
getState = _ref.getState, setState = _ref.setState;
|
|
36
|
+
getState = _ref.getState, setState = _ref.setState, dispatch = _ref.dispatch;
|
|
33
37
|
_getState = getState(), links = _getState.links, currentTeamId = _getState.teamId;
|
|
34
38
|
initialLinks = teamId === currentTeamId ? links : [];
|
|
35
39
|
setState({
|
|
@@ -59,17 +63,20 @@ var actions = exports.actions = {
|
|
|
59
63
|
shouldReload: false,
|
|
60
64
|
links: entities
|
|
61
65
|
});
|
|
62
|
-
|
|
66
|
+
if (entities.length > 0) {
|
|
67
|
+
dispatch(actions.getTeamWebLinkIcons(teamId));
|
|
68
|
+
}
|
|
69
|
+
_context.next = 20;
|
|
63
70
|
break;
|
|
64
|
-
case
|
|
65
|
-
_context.prev =
|
|
71
|
+
case 15:
|
|
72
|
+
_context.prev = 15;
|
|
66
73
|
_context.t0 = _context["catch"](4);
|
|
67
74
|
if (!(getState().teamId !== teamId)) {
|
|
68
|
-
_context.next =
|
|
75
|
+
_context.next = 19;
|
|
69
76
|
break;
|
|
70
77
|
}
|
|
71
78
|
return _context.abrupt("return");
|
|
72
|
-
case
|
|
79
|
+
case 19:
|
|
73
80
|
setState({
|
|
74
81
|
isLoading: false,
|
|
75
82
|
hasLoaded: true,
|
|
@@ -78,76 +85,211 @@ var actions = exports.actions = {
|
|
|
78
85
|
shouldReload: false,
|
|
79
86
|
links: []
|
|
80
87
|
});
|
|
81
|
-
case
|
|
88
|
+
case 20:
|
|
82
89
|
case "end":
|
|
83
90
|
return _context.stop();
|
|
84
91
|
}
|
|
85
|
-
}, _callee, null, [[4,
|
|
92
|
+
}, _callee, null, [[4, 15]]);
|
|
86
93
|
}));
|
|
87
94
|
return function (_x) {
|
|
88
95
|
return _ref2.apply(this, arguments);
|
|
89
96
|
};
|
|
90
97
|
}();
|
|
91
98
|
},
|
|
99
|
+
getTeamWebLinkIcons: function getTeamWebLinkIcons(teamId) {
|
|
100
|
+
return /*#__PURE__*/function () {
|
|
101
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref3) {
|
|
102
|
+
var getState, setState, _getState2, links, currentIcons, linkUrls, uncachedUrls, newIconData;
|
|
103
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
104
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
105
|
+
case 0:
|
|
106
|
+
getState = _ref3.getState, setState = _ref3.setState;
|
|
107
|
+
_getState2 = getState(), links = _getState2.links, currentIcons = _getState2.linkIcons;
|
|
108
|
+
if (!(links.length === 0)) {
|
|
109
|
+
_context2.next = 4;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return _context2.abrupt("return");
|
|
113
|
+
case 4:
|
|
114
|
+
linkUrls = links.map(function (link) {
|
|
115
|
+
return link.linkUri;
|
|
116
|
+
});
|
|
117
|
+
uncachedUrls = linkUrls.filter(function (url) {
|
|
118
|
+
return !currentIcons.some(function (icon) {
|
|
119
|
+
return icon.linkUrl === url;
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
if (!(uncachedUrls.length > 0)) {
|
|
123
|
+
_context2.next = 20;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
_context2.prev = 7;
|
|
127
|
+
setState({
|
|
128
|
+
iconsLoading: true,
|
|
129
|
+
iconsError: false
|
|
130
|
+
});
|
|
131
|
+
_context2.next = 11;
|
|
132
|
+
return _teamsClient.teamsClient.getTeamLinkIcons(uncachedUrls);
|
|
133
|
+
case 11:
|
|
134
|
+
newIconData = _context2.sent;
|
|
135
|
+
if (getState().teamId === teamId) {
|
|
136
|
+
setState({
|
|
137
|
+
linkIcons: [].concat((0, _toConsumableArray2.default)(currentIcons), (0, _toConsumableArray2.default)(newIconData || [])),
|
|
138
|
+
iconsLoading: false,
|
|
139
|
+
iconsError: false
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
_context2.next = 18;
|
|
143
|
+
break;
|
|
144
|
+
case 15:
|
|
145
|
+
_context2.prev = 15;
|
|
146
|
+
_context2.t0 = _context2["catch"](7);
|
|
147
|
+
if (getState().teamId === teamId) {
|
|
148
|
+
setState({
|
|
149
|
+
iconsLoading: false,
|
|
150
|
+
iconsError: true
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
case 18:
|
|
154
|
+
_context2.next = 21;
|
|
155
|
+
break;
|
|
156
|
+
case 20:
|
|
157
|
+
setState({
|
|
158
|
+
iconsLoading: false,
|
|
159
|
+
iconsError: false
|
|
160
|
+
});
|
|
161
|
+
case 21:
|
|
162
|
+
case "end":
|
|
163
|
+
return _context2.stop();
|
|
164
|
+
}
|
|
165
|
+
}, _callee2, null, [[7, 15]]);
|
|
166
|
+
}));
|
|
167
|
+
return function (_x2) {
|
|
168
|
+
return _ref4.apply(this, arguments);
|
|
169
|
+
};
|
|
170
|
+
}();
|
|
171
|
+
},
|
|
92
172
|
createTeamWebLink: function createTeamWebLink(teamId, newLink) {
|
|
93
|
-
return /*#__PURE__*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
173
|
+
return /*#__PURE__*/function () {
|
|
174
|
+
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref5) {
|
|
175
|
+
var getState, setState, dispatch, result, currentState;
|
|
176
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
177
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
178
|
+
case 0:
|
|
179
|
+
getState = _ref5.getState, setState = _ref5.setState, dispatch = _ref5.dispatch;
|
|
180
|
+
_context3.next = 3;
|
|
181
|
+
return _teamsClient.teamsClient.createTeamLink(teamId, newLink);
|
|
182
|
+
case 3:
|
|
183
|
+
result = _context3.sent;
|
|
184
|
+
currentState = getState();
|
|
185
|
+
if (!(currentState.teamId !== teamId)) {
|
|
186
|
+
_context3.next = 7;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
return _context3.abrupt("return", result);
|
|
190
|
+
case 7:
|
|
191
|
+
setState({
|
|
192
|
+
links: [].concat((0, _toConsumableArray2.default)(currentState.links), [result])
|
|
193
|
+
});
|
|
194
|
+
dispatch(actions.getTeamWebLinkIcons(teamId));
|
|
195
|
+
return _context3.abrupt("return", result);
|
|
196
|
+
case 10:
|
|
197
|
+
case "end":
|
|
198
|
+
return _context3.stop();
|
|
199
|
+
}
|
|
200
|
+
}, _callee3);
|
|
201
|
+
}));
|
|
202
|
+
return function (_x3) {
|
|
203
|
+
return _ref6.apply(this, arguments);
|
|
204
|
+
};
|
|
205
|
+
}();
|
|
107
206
|
},
|
|
108
207
|
updateTeamWebLink: function updateTeamWebLink(teamId, linkId, newLink) {
|
|
109
|
-
return /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
110
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
111
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
112
|
-
case 0:
|
|
113
|
-
_context3.next = 2;
|
|
114
|
-
return _teamsClient.teamsClient.updateTeamLink(teamId, linkId, newLink);
|
|
115
|
-
case 2:
|
|
116
|
-
return _context3.abrupt("return", _context3.sent);
|
|
117
|
-
case 3:
|
|
118
|
-
case "end":
|
|
119
|
-
return _context3.stop();
|
|
120
|
-
}
|
|
121
|
-
}, _callee3);
|
|
122
|
-
}));
|
|
123
|
-
},
|
|
124
|
-
removeWebLink: function removeWebLink(teamId, linkId) {
|
|
125
208
|
return /*#__PURE__*/function () {
|
|
126
|
-
var
|
|
127
|
-
var dispatch;
|
|
209
|
+
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(_ref7) {
|
|
210
|
+
var getState, setState, dispatch, result, currentState, oldLink, urlChanged, updatedIcons;
|
|
128
211
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
129
212
|
while (1) switch (_context4.prev = _context4.next) {
|
|
130
213
|
case 0:
|
|
131
|
-
dispatch =
|
|
214
|
+
getState = _ref7.getState, setState = _ref7.setState, dispatch = _ref7.dispatch;
|
|
132
215
|
_context4.next = 3;
|
|
133
|
-
return _teamsClient.teamsClient.
|
|
216
|
+
return _teamsClient.teamsClient.updateTeamLink(teamId, linkId, newLink);
|
|
134
217
|
case 3:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
218
|
+
result = _context4.sent;
|
|
219
|
+
currentState = getState();
|
|
220
|
+
if (!(currentState.teamId !== teamId)) {
|
|
221
|
+
_context4.next = 7;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
return _context4.abrupt("return", result);
|
|
225
|
+
case 7:
|
|
226
|
+
oldLink = currentState.links.find(function (link) {
|
|
227
|
+
return link.linkId === linkId;
|
|
228
|
+
});
|
|
229
|
+
urlChanged = oldLink && oldLink.linkUri !== result.linkUri;
|
|
230
|
+
setState({
|
|
231
|
+
links: currentState.links.map(function (link) {
|
|
232
|
+
return link.linkId === linkId ? result : link;
|
|
233
|
+
})
|
|
234
|
+
});
|
|
235
|
+
if (urlChanged) {
|
|
236
|
+
updatedIcons = currentState.linkIcons.filter(function (icon) {
|
|
237
|
+
return icon.linkUrl !== oldLink.linkUri;
|
|
238
|
+
});
|
|
239
|
+
setState({
|
|
240
|
+
linkIcons: updatedIcons
|
|
241
|
+
});
|
|
242
|
+
dispatch(actions.getTeamWebLinkIcons(teamId));
|
|
243
|
+
}
|
|
244
|
+
return _context4.abrupt("return", result);
|
|
245
|
+
case 12:
|
|
138
246
|
case "end":
|
|
139
247
|
return _context4.stop();
|
|
140
248
|
}
|
|
141
249
|
}, _callee4);
|
|
142
250
|
}));
|
|
143
|
-
return function (
|
|
144
|
-
return
|
|
251
|
+
return function (_x4) {
|
|
252
|
+
return _ref8.apply(this, arguments);
|
|
253
|
+
};
|
|
254
|
+
}();
|
|
255
|
+
},
|
|
256
|
+
removeWebLink: function removeWebLink(teamId, linkId) {
|
|
257
|
+
return /*#__PURE__*/function () {
|
|
258
|
+
var _ref0 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(_ref9) {
|
|
259
|
+
var getState, setState, currentState;
|
|
260
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
261
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
262
|
+
case 0:
|
|
263
|
+
getState = _ref9.getState, setState = _ref9.setState;
|
|
264
|
+
currentState = getState();
|
|
265
|
+
if (!(currentState.teamId !== teamId)) {
|
|
266
|
+
_context5.next = 4;
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
return _context5.abrupt("return");
|
|
270
|
+
case 4:
|
|
271
|
+
_context5.next = 6;
|
|
272
|
+
return _teamsClient.teamsClient.deleteTeamLink(teamId, linkId);
|
|
273
|
+
case 6:
|
|
274
|
+
setState({
|
|
275
|
+
links: currentState.links.filter(function (link) {
|
|
276
|
+
return link.linkId !== linkId;
|
|
277
|
+
})
|
|
278
|
+
});
|
|
279
|
+
case 7:
|
|
280
|
+
case "end":
|
|
281
|
+
return _context5.stop();
|
|
282
|
+
}
|
|
283
|
+
}, _callee5);
|
|
284
|
+
}));
|
|
285
|
+
return function (_x5) {
|
|
286
|
+
return _ref0.apply(this, arguments);
|
|
145
287
|
};
|
|
146
288
|
}();
|
|
147
289
|
},
|
|
148
290
|
initialState: function initialState(state) {
|
|
149
|
-
return function (
|
|
150
|
-
var setState =
|
|
291
|
+
return function (_ref1) {
|
|
292
|
+
var setState = _ref1.setState;
|
|
151
293
|
setState(_objectSpread(_objectSpread({}, _initialState), state));
|
|
152
294
|
};
|
|
153
295
|
}
|