@atlaskit/teams-public 0.28.0 → 0.30.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 +21 -0
- package/dist/cjs/common/ui/loom-avatar/index.js +12 -0
- package/dist/cjs/common/ui/loom-avatar/main.compiled.css +13 -0
- package/dist/cjs/common/ui/loom-avatar/main.js +33 -0
- package/dist/cjs/common/ui/loom-avatar/utils.js +39 -0
- package/dist/cjs/common/utils/team-web-link-converters.js +25 -0
- package/dist/cjs/controllers/hooks/use-team-web-links/index.js +162 -0
- package/dist/cjs/controllers/hooks/use-team-web-links/types.js +5 -0
- package/dist/cjs/controllers/index.js +13 -0
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/ui/team-containers/linked-container-card/index.js +16 -6
- package/dist/es2019/common/ui/loom-avatar/index.js +1 -0
- package/dist/es2019/common/ui/loom-avatar/main.compiled.css +13 -0
- package/dist/es2019/common/ui/loom-avatar/main.js +23 -0
- package/dist/es2019/common/ui/loom-avatar/utils.js +33 -0
- package/dist/es2019/common/utils/team-web-link-converters.js +19 -0
- package/dist/es2019/controllers/hooks/use-team-web-links/index.js +86 -0
- package/dist/es2019/controllers/hooks/use-team-web-links/types.js +1 -0
- package/dist/es2019/controllers/index.js +1 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/ui/team-containers/linked-container-card/index.js +16 -6
- package/dist/esm/common/ui/loom-avatar/index.js +1 -0
- package/dist/esm/common/ui/loom-avatar/main.compiled.css +13 -0
- package/dist/esm/common/ui/loom-avatar/main.js +24 -0
- package/dist/esm/common/ui/loom-avatar/utils.js +33 -0
- package/dist/esm/common/utils/team-web-link-converters.js +19 -0
- package/dist/esm/controllers/hooks/use-team-web-links/index.js +155 -0
- package/dist/esm/controllers/hooks/use-team-web-links/types.js +1 -0
- package/dist/esm/controllers/index.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/ui/team-containers/linked-container-card/index.js +16 -6
- package/dist/types/common/types.d.ts +9 -1
- package/dist/types/common/ui/loom-avatar/index.d.ts +1 -0
- package/dist/types/common/ui/loom-avatar/main.d.ts +10 -0
- package/dist/types/common/ui/loom-avatar/utils.d.ts +16 -0
- package/dist/types/common/utils/team-web-link-converters.d.ts +4 -0
- package/dist/types/controllers/hooks/use-team-web-links/index.d.ts +24 -0
- package/dist/types/controllers/hooks/use-team-web-links/types.d.ts +14 -0
- package/dist/types/controllers/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types-ts4.5/common/types.d.ts +9 -1
- package/dist/types-ts4.5/common/ui/loom-avatar/index.d.ts +1 -0
- package/dist/types-ts4.5/common/ui/loom-avatar/main.d.ts +10 -0
- package/dist/types-ts4.5/common/ui/loom-avatar/utils.d.ts +16 -0
- package/dist/types-ts4.5/common/utils/team-web-link-converters.d.ts +4 -0
- package/dist/types-ts4.5/controllers/hooks/use-team-web-links/index.d.ts +24 -0
- package/dist/types-ts4.5/controllers/hooks/use-team-web-links/types.d.ts +14 -0
- package/dist/types-ts4.5/controllers/index.d.ts +1 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/loom-avatar/package.json +17 -0
- package/package.json +12 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/teams-public
|
|
2
2
|
|
|
3
|
+
## 0.30.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#158122](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/158122)
|
|
8
|
+
[`cacbe1d41fcc6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cacbe1d41fcc6) -
|
|
9
|
+
[ux] Add loom space avatar
|
|
10
|
+
|
|
11
|
+
## 0.29.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#156784](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/156784)
|
|
16
|
+
[`a614e25bb80c9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a614e25bb80c9) -
|
|
17
|
+
PTC-11532 Add useTeamWebLink in teams-public, allow get/delete/update team web links in
|
|
18
|
+
teams-public
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 0.28.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "LoomSpaceAvatar", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _main.LoomSpaceAvatar;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _main = require("./main");
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
._11c8140y{font:var(--ds-font-heading-xsmall,normal 600 14px/1pc ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
|
|
2
|
+
._11c8lodh{font:var(--ds-font-heading-medium,normal 500 20px/24px ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
|
|
3
|
+
._2rkoiti9{border-radius:var(--ds-border-radius-100,4px)}
|
|
4
|
+
._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
5
|
+
._1dqonqa1{border-style:solid}
|
|
6
|
+
._1h6dmuej{border-color:var(--ds-border,#091e4224)}
|
|
7
|
+
._1bah1h6o{justify-content:center}
|
|
8
|
+
._1bsb1tcg{width:24px}
|
|
9
|
+
._1bsbzwfg{width:2pc}
|
|
10
|
+
._1e0c1txw{display:flex}
|
|
11
|
+
._4cvr1h6o{align-items:center}
|
|
12
|
+
._4t3i1tcg{height:24px}
|
|
13
|
+
._4t3izwfg{height:2pc}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* main.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.LoomSpaceAvatar = LoomSpaceAvatar;
|
|
9
|
+
require("./main.compiled.css");
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _runtime = require("@compiled/react/runtime");
|
|
12
|
+
var _utils = require("./utils");
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
var boxStyle = null;
|
|
16
|
+
var smallBoxStyle = null;
|
|
17
|
+
var largeBoxStyle = null;
|
|
18
|
+
function LoomSpaceAvatar(_ref) {
|
|
19
|
+
var _ref$spaceName = _ref.spaceName,
|
|
20
|
+
spaceName = _ref$spaceName === void 0 ? '' : _ref$spaceName,
|
|
21
|
+
_ref$size = _ref.size,
|
|
22
|
+
size = _ref$size === void 0 ? 'small' : _ref$size;
|
|
23
|
+
var avatarText = (0, _utils.getAvatarText)(spaceName);
|
|
24
|
+
var containerColor = (0, _utils.pickContainerColor)(spaceName);
|
|
25
|
+
var textColor = (0, _utils.pickTextColor)(spaceName);
|
|
26
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
style: {
|
|
28
|
+
backgroundColor: containerColor,
|
|
29
|
+
color: textColor
|
|
30
|
+
},
|
|
31
|
+
className: (0, _runtime.ax)(["_2rkoiti9 _189ee4h9 _1dqonqa1 _1h6dmuej _1e0c1txw _4cvr1h6o _1bah1h6o", size === 'small' ? "_11c8140y _4t3i1tcg _1bsb1tcg" : "_11c8lodh _4t3izwfg _1bsbzwfg"])
|
|
32
|
+
}, avatarText);
|
|
33
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.pickTextColor = exports.pickContainerColor = exports.getAvatarText = void 0;
|
|
7
|
+
var stringHash = require('string-hash');
|
|
8
|
+
var SpaceColors = /*#__PURE__*/function (SpaceColors) {
|
|
9
|
+
SpaceColors["ORANGE_LIGHT"] = "#FFD5D2";
|
|
10
|
+
SpaceColors["BLUE_LIGHT"] = "#CFE1FD";
|
|
11
|
+
SpaceColors["YELLOW_LIGHT"] = "#FCE4A6";
|
|
12
|
+
SpaceColors["TEAL"] = "#BAF3DB";
|
|
13
|
+
return SpaceColors;
|
|
14
|
+
}(SpaceColors || {});
|
|
15
|
+
var AvatarTextColors = /*#__PURE__*/function (AvatarTextColors) {
|
|
16
|
+
AvatarTextColors["ORANGE_DARK"] = "#AE2E24";
|
|
17
|
+
AvatarTextColors["BLUE_DARK"] = "#123263";
|
|
18
|
+
AvatarTextColors["YELLOW_DARK"] = "#9E4C00";
|
|
19
|
+
AvatarTextColors["TEAL_DARK"] = "#164B35";
|
|
20
|
+
return AvatarTextColors;
|
|
21
|
+
}(AvatarTextColors || {});
|
|
22
|
+
var AVATAR_CONTAINER_COLORS = [SpaceColors.ORANGE_LIGHT, SpaceColors.BLUE_LIGHT, SpaceColors.YELLOW_LIGHT, SpaceColors.TEAL];
|
|
23
|
+
var AVATAR_TEXT_COLORS = [AvatarTextColors.ORANGE_DARK, AvatarTextColors.BLUE_DARK, AvatarTextColors.YELLOW_DARK, AvatarTextColors.TEAL_DARK];
|
|
24
|
+
var hash = function hash(str) {
|
|
25
|
+
var hash = stringHash(str);
|
|
26
|
+
hash = ~hash;
|
|
27
|
+
return Math.abs(Number(hash));
|
|
28
|
+
};
|
|
29
|
+
var getAvatarText = exports.getAvatarText = function getAvatarText(spaceName) {
|
|
30
|
+
return spaceName !== null && spaceName !== void 0 && spaceName.trim().length ? spaceName.trim()[0].toUpperCase() : '';
|
|
31
|
+
};
|
|
32
|
+
var pickContainerColor = exports.pickContainerColor = function pickContainerColor(spaceName) {
|
|
33
|
+
var avatarHash = hash(spaceName);
|
|
34
|
+
return AVATAR_CONTAINER_COLORS[avatarHash % AVATAR_CONTAINER_COLORS.length];
|
|
35
|
+
};
|
|
36
|
+
var pickTextColor = exports.pickTextColor = function pickTextColor(spaceName) {
|
|
37
|
+
var avatarHash = hash(spaceName);
|
|
38
|
+
return AVATAR_TEXT_COLORS[avatarHash % AVATAR_TEXT_COLORS.length];
|
|
39
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.webLinksToContainers = exports.webLinkToContainer = exports.containerToNewWebLink = void 0;
|
|
7
|
+
var containerToNewWebLink = exports.containerToNewWebLink = function containerToNewWebLink(container) {
|
|
8
|
+
return {
|
|
9
|
+
contentTitle: container.name,
|
|
10
|
+
description: '',
|
|
11
|
+
linkUri: container.link || ''
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
var webLinkToContainer = exports.webLinkToContainer = function webLinkToContainer(link) {
|
|
15
|
+
return {
|
|
16
|
+
id: link.linkId,
|
|
17
|
+
type: 'WebLink',
|
|
18
|
+
name: link.contentTitle,
|
|
19
|
+
icon: null,
|
|
20
|
+
link: link.linkUri
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
var webLinksToContainers = exports.webLinksToContainers = function webLinksToContainers(links) {
|
|
24
|
+
return links.map(webLinkToContainer);
|
|
25
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useTeamWebLinksActions = exports.useTeamWebLinks = exports.actions = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _reactSweetState = require("react-sweet-state");
|
|
12
|
+
var _teamsClient = require("@atlaskit/teams-client");
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
var _initialState = {
|
|
16
|
+
teamId: '',
|
|
17
|
+
isLoading: false,
|
|
18
|
+
hasLoaded: false,
|
|
19
|
+
hasError: false,
|
|
20
|
+
shouldReload: false,
|
|
21
|
+
errorType: null,
|
|
22
|
+
links: []
|
|
23
|
+
};
|
|
24
|
+
var actions = exports.actions = {
|
|
25
|
+
getTeamWebLinks: function getTeamWebLinks(teamId) {
|
|
26
|
+
return /*#__PURE__*/function () {
|
|
27
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
28
|
+
var getState, setState, _getState, links, currentTeamId, initialLinks, _yield$teamsClient$ge, entities;
|
|
29
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
30
|
+
while (1) switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
getState = _ref.getState, setState = _ref.setState;
|
|
33
|
+
_getState = getState(), links = _getState.links, currentTeamId = _getState.teamId;
|
|
34
|
+
initialLinks = teamId === currentTeamId ? links : [];
|
|
35
|
+
setState({
|
|
36
|
+
teamId: teamId,
|
|
37
|
+
isLoading: true,
|
|
38
|
+
hasLoaded: false,
|
|
39
|
+
hasError: false,
|
|
40
|
+
shouldReload: false,
|
|
41
|
+
links: initialLinks
|
|
42
|
+
});
|
|
43
|
+
_context.prev = 4;
|
|
44
|
+
_context.next = 7;
|
|
45
|
+
return _teamsClient.teamsClient.getTeamLinksByTeamId(teamId);
|
|
46
|
+
case 7:
|
|
47
|
+
_yield$teamsClient$ge = _context.sent;
|
|
48
|
+
entities = _yield$teamsClient$ge.entities;
|
|
49
|
+
if (!(getState().teamId !== teamId)) {
|
|
50
|
+
_context.next = 11;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
return _context.abrupt("return");
|
|
54
|
+
case 11:
|
|
55
|
+
setState({
|
|
56
|
+
isLoading: false,
|
|
57
|
+
hasLoaded: true,
|
|
58
|
+
hasError: false,
|
|
59
|
+
shouldReload: false,
|
|
60
|
+
links: entities
|
|
61
|
+
});
|
|
62
|
+
_context.next = 19;
|
|
63
|
+
break;
|
|
64
|
+
case 14:
|
|
65
|
+
_context.prev = 14;
|
|
66
|
+
_context.t0 = _context["catch"](4);
|
|
67
|
+
if (!(getState().teamId !== teamId)) {
|
|
68
|
+
_context.next = 18;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
return _context.abrupt("return");
|
|
72
|
+
case 18:
|
|
73
|
+
setState({
|
|
74
|
+
isLoading: false,
|
|
75
|
+
hasLoaded: true,
|
|
76
|
+
hasError: true,
|
|
77
|
+
errorType: _context.t0 instanceof Error ? _context.t0 : undefined,
|
|
78
|
+
shouldReload: false,
|
|
79
|
+
links: []
|
|
80
|
+
});
|
|
81
|
+
case 19:
|
|
82
|
+
case "end":
|
|
83
|
+
return _context.stop();
|
|
84
|
+
}
|
|
85
|
+
}, _callee, null, [[4, 14]]);
|
|
86
|
+
}));
|
|
87
|
+
return function (_x) {
|
|
88
|
+
return _ref2.apply(this, arguments);
|
|
89
|
+
};
|
|
90
|
+
}();
|
|
91
|
+
},
|
|
92
|
+
createTeamWebLink: function createTeamWebLink(teamId, newLink) {
|
|
93
|
+
return /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
94
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
95
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
96
|
+
case 0:
|
|
97
|
+
_context2.next = 2;
|
|
98
|
+
return _teamsClient.teamsClient.createTeamLink(teamId, newLink);
|
|
99
|
+
case 2:
|
|
100
|
+
return _context2.abrupt("return", _context2.sent);
|
|
101
|
+
case 3:
|
|
102
|
+
case "end":
|
|
103
|
+
return _context2.stop();
|
|
104
|
+
}
|
|
105
|
+
}, _callee2);
|
|
106
|
+
}));
|
|
107
|
+
},
|
|
108
|
+
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
|
+
return /*#__PURE__*/function () {
|
|
126
|
+
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(_ref5) {
|
|
127
|
+
var dispatch;
|
|
128
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
129
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
130
|
+
case 0:
|
|
131
|
+
dispatch = _ref5.dispatch;
|
|
132
|
+
_context4.next = 3;
|
|
133
|
+
return _teamsClient.teamsClient.deleteTeamLink(teamId, linkId);
|
|
134
|
+
case 3:
|
|
135
|
+
_context4.next = 5;
|
|
136
|
+
return dispatch(actions.getTeamWebLinks(teamId));
|
|
137
|
+
case 5:
|
|
138
|
+
case "end":
|
|
139
|
+
return _context4.stop();
|
|
140
|
+
}
|
|
141
|
+
}, _callee4);
|
|
142
|
+
}));
|
|
143
|
+
return function (_x2) {
|
|
144
|
+
return _ref6.apply(this, arguments);
|
|
145
|
+
};
|
|
146
|
+
}();
|
|
147
|
+
},
|
|
148
|
+
initialState: function initialState(state) {
|
|
149
|
+
return function (_ref7) {
|
|
150
|
+
var setState = _ref7.setState;
|
|
151
|
+
setState(_objectSpread(_objectSpread({}, _initialState), state));
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
var TeamWebLinksStore = (0, _reactSweetState.createStore)({
|
|
156
|
+
initialState: _initialState,
|
|
157
|
+
actions: actions
|
|
158
|
+
});
|
|
159
|
+
var useTeamWebLinks = exports.useTeamWebLinks = (0, _reactSweetState.createHook)(TeamWebLinksStore);
|
|
160
|
+
var useTeamWebLinksActions = exports.useTeamWebLinksActions = (0, _reactSweetState.createHook)(TeamWebLinksStore, {
|
|
161
|
+
selector: null
|
|
162
|
+
});
|
|
@@ -15,5 +15,18 @@ Object.defineProperty(exports, "useTeamContainers", {
|
|
|
15
15
|
return _useTeamContainers.useTeamContainers;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "useTeamWebLinks", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _useTeamWebLinks.useTeamWebLinks;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "useTeamWebLinksActions", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _useTeamWebLinks.useTeamWebLinksActions;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
18
30
|
var _useTeamContainers = require("./hooks/use-team-containers");
|
|
31
|
+
var _useTeamWebLinks = require("./hooks/use-team-web-links");
|
|
19
32
|
var _utils = require("./product-permission/utils");
|
package/dist/cjs/index.js
CHANGED
|
@@ -57,8 +57,21 @@ Object.defineProperty(exports, "useTeamContainers", {
|
|
|
57
57
|
return _useTeamContainers.useTeamContainers;
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
+
Object.defineProperty(exports, "useTeamWebLinks", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _useTeamWebLinks.useTeamWebLinks;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "useTeamWebLinksActions", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _useTeamWebLinks.useTeamWebLinksActions;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
60
72
|
var _teamContainers = require("./ui/team-containers");
|
|
61
73
|
var _useTeamContainers = require("./controllers/hooks/use-team-containers");
|
|
74
|
+
var _useTeamWebLinks = require("./controllers/hooks/use-team-web-links");
|
|
62
75
|
var _useProductPermission = require("./controllers/hooks/use-product-permission");
|
|
63
76
|
var _utils = require("./controllers/product-permission/utils");
|
|
64
77
|
var _getContainerProperties = require("./common/utils/get-container-properties");
|
|
@@ -21,6 +21,7 @@ var _link = _interopRequireDefault(require("@atlaskit/link"));
|
|
|
21
21
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
22
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
23
23
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
24
|
+
var _loomAvatar = require("../../../common/ui/loom-avatar");
|
|
24
25
|
var _analytics = require("../../../common/utils/analytics");
|
|
25
26
|
var _getContainerProperties = require("../../../common/utils/get-container-properties");
|
|
26
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -78,6 +79,20 @@ var LinkedCardWrapper = function LinkedCardWrapper(_ref) {
|
|
|
78
79
|
}
|
|
79
80
|
}, children));
|
|
80
81
|
};
|
|
82
|
+
var getContainerIcon = function getContainerIcon(containerType, title, containerIcon) {
|
|
83
|
+
if (containerType === 'LoomSpace') {
|
|
84
|
+
return /*#__PURE__*/_react.default.createElement(_loomAvatar.LoomSpaceAvatar, {
|
|
85
|
+
spaceName: title,
|
|
86
|
+
size: 'large'
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return /*#__PURE__*/_react.default.createElement(_avatar.default, {
|
|
90
|
+
appearance: "square",
|
|
91
|
+
size: "medium",
|
|
92
|
+
src: containerIcon,
|
|
93
|
+
testId: "linked-container-icon"
|
|
94
|
+
});
|
|
95
|
+
};
|
|
81
96
|
var LinkedContainerCard = exports.LinkedContainerCard = function LinkedContainerCard(_ref2) {
|
|
82
97
|
var containerType = _ref2.containerType,
|
|
83
98
|
title = _ref2.title,
|
|
@@ -113,12 +128,7 @@ var LinkedContainerCard = exports.LinkedContainerCard = function LinkedContainer
|
|
|
113
128
|
}, /*#__PURE__*/_react.default.createElement(_compiled.Inline, {
|
|
114
129
|
space: "space.100",
|
|
115
130
|
xcss: styles.card
|
|
116
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
117
|
-
appearance: "square",
|
|
118
|
-
size: "medium",
|
|
119
|
-
src: containerIcon,
|
|
120
|
-
testId: "linked-container-icon"
|
|
121
|
-
}), /*#__PURE__*/_react.default.createElement(_compiled.Stack, null, /*#__PURE__*/_react.default.createElement(_compiled.Text, {
|
|
131
|
+
}, getContainerIcon(containerType, title, containerIcon), /*#__PURE__*/_react.default.createElement(_compiled.Stack, null, /*#__PURE__*/_react.default.createElement(_compiled.Text, {
|
|
122
132
|
maxLines: 1,
|
|
123
133
|
weight: "medium",
|
|
124
134
|
color: "color.text"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LoomSpaceAvatar } from './main';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
._11c8140y{font:var(--ds-font-heading-xsmall,normal 600 14px/1pc ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
|
|
2
|
+
._11c8lodh{font:var(--ds-font-heading-medium,normal 500 20px/24px ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
|
|
3
|
+
._2rkoiti9{border-radius:var(--ds-border-radius-100,4px)}
|
|
4
|
+
._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
5
|
+
._1dqonqa1{border-style:solid}
|
|
6
|
+
._1h6dmuej{border-color:var(--ds-border,#091e4224)}
|
|
7
|
+
._1bah1h6o{justify-content:center}
|
|
8
|
+
._1bsb1tcg{width:24px}
|
|
9
|
+
._1bsbzwfg{width:2pc}
|
|
10
|
+
._1e0c1txw{display:flex}
|
|
11
|
+
._4cvr1h6o{align-items:center}
|
|
12
|
+
._4t3i1tcg{height:24px}
|
|
13
|
+
._4t3izwfg{height:2pc}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* main.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./main.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { getAvatarText, pickContainerColor, pickTextColor } from './utils';
|
|
6
|
+
const boxStyle = null;
|
|
7
|
+
const smallBoxStyle = null;
|
|
8
|
+
const largeBoxStyle = null;
|
|
9
|
+
export function LoomSpaceAvatar({
|
|
10
|
+
spaceName = '',
|
|
11
|
+
size = 'small'
|
|
12
|
+
}) {
|
|
13
|
+
const avatarText = getAvatarText(spaceName);
|
|
14
|
+
const containerColor = pickContainerColor(spaceName);
|
|
15
|
+
const textColor = pickTextColor(spaceName);
|
|
16
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
17
|
+
style: {
|
|
18
|
+
backgroundColor: containerColor,
|
|
19
|
+
color: textColor
|
|
20
|
+
},
|
|
21
|
+
className: ax(["_2rkoiti9 _189ee4h9 _1dqonqa1 _1h6dmuej _1e0c1txw _4cvr1h6o _1bah1h6o", size === 'small' ? "_11c8140y _4t3i1tcg _1bsb1tcg" : "_11c8lodh _4t3izwfg _1bsbzwfg"])
|
|
22
|
+
}, avatarText);
|
|
23
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const stringHash = require('string-hash');
|
|
2
|
+
var SpaceColors = /*#__PURE__*/function (SpaceColors) {
|
|
3
|
+
SpaceColors["ORANGE_LIGHT"] = "#FFD5D2";
|
|
4
|
+
SpaceColors["BLUE_LIGHT"] = "#CFE1FD";
|
|
5
|
+
SpaceColors["YELLOW_LIGHT"] = "#FCE4A6";
|
|
6
|
+
SpaceColors["TEAL"] = "#BAF3DB";
|
|
7
|
+
return SpaceColors;
|
|
8
|
+
}(SpaceColors || {});
|
|
9
|
+
var AvatarTextColors = /*#__PURE__*/function (AvatarTextColors) {
|
|
10
|
+
AvatarTextColors["ORANGE_DARK"] = "#AE2E24";
|
|
11
|
+
AvatarTextColors["BLUE_DARK"] = "#123263";
|
|
12
|
+
AvatarTextColors["YELLOW_DARK"] = "#9E4C00";
|
|
13
|
+
AvatarTextColors["TEAL_DARK"] = "#164B35";
|
|
14
|
+
return AvatarTextColors;
|
|
15
|
+
}(AvatarTextColors || {});
|
|
16
|
+
const AVATAR_CONTAINER_COLORS = [SpaceColors.ORANGE_LIGHT, SpaceColors.BLUE_LIGHT, SpaceColors.YELLOW_LIGHT, SpaceColors.TEAL];
|
|
17
|
+
const AVATAR_TEXT_COLORS = [AvatarTextColors.ORANGE_DARK, AvatarTextColors.BLUE_DARK, AvatarTextColors.YELLOW_DARK, AvatarTextColors.TEAL_DARK];
|
|
18
|
+
const hash = str => {
|
|
19
|
+
let hash = stringHash(str);
|
|
20
|
+
hash = ~hash;
|
|
21
|
+
return Math.abs(Number(hash));
|
|
22
|
+
};
|
|
23
|
+
export const getAvatarText = spaceName => {
|
|
24
|
+
return spaceName !== null && spaceName !== void 0 && spaceName.trim().length ? spaceName.trim()[0].toUpperCase() : '';
|
|
25
|
+
};
|
|
26
|
+
export const pickContainerColor = spaceName => {
|
|
27
|
+
const avatarHash = hash(spaceName);
|
|
28
|
+
return AVATAR_CONTAINER_COLORS[avatarHash % AVATAR_CONTAINER_COLORS.length];
|
|
29
|
+
};
|
|
30
|
+
export const pickTextColor = spaceName => {
|
|
31
|
+
const avatarHash = hash(spaceName);
|
|
32
|
+
return AVATAR_TEXT_COLORS[avatarHash % AVATAR_TEXT_COLORS.length];
|
|
33
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const containerToNewWebLink = container => {
|
|
2
|
+
return {
|
|
3
|
+
contentTitle: container.name,
|
|
4
|
+
description: '',
|
|
5
|
+
linkUri: container.link || ''
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export const webLinkToContainer = link => {
|
|
9
|
+
return {
|
|
10
|
+
id: link.linkId,
|
|
11
|
+
type: 'WebLink',
|
|
12
|
+
name: link.contentTitle,
|
|
13
|
+
icon: null,
|
|
14
|
+
link: link.linkUri
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export const webLinksToContainers = links => {
|
|
18
|
+
return links.map(webLinkToContainer);
|
|
19
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createHook, createStore } from 'react-sweet-state';
|
|
2
|
+
import { teamsClient } from '@atlaskit/teams-client';
|
|
3
|
+
const initialState = {
|
|
4
|
+
teamId: '',
|
|
5
|
+
isLoading: false,
|
|
6
|
+
hasLoaded: false,
|
|
7
|
+
hasError: false,
|
|
8
|
+
shouldReload: false,
|
|
9
|
+
errorType: null,
|
|
10
|
+
links: []
|
|
11
|
+
};
|
|
12
|
+
export const actions = {
|
|
13
|
+
getTeamWebLinks: teamId => async ({
|
|
14
|
+
getState,
|
|
15
|
+
setState
|
|
16
|
+
}) => {
|
|
17
|
+
const {
|
|
18
|
+
links,
|
|
19
|
+
teamId: currentTeamId
|
|
20
|
+
} = getState();
|
|
21
|
+
const initialLinks = teamId === currentTeamId ? links : [];
|
|
22
|
+
setState({
|
|
23
|
+
teamId,
|
|
24
|
+
isLoading: true,
|
|
25
|
+
hasLoaded: false,
|
|
26
|
+
hasError: false,
|
|
27
|
+
shouldReload: false,
|
|
28
|
+
links: initialLinks
|
|
29
|
+
});
|
|
30
|
+
try {
|
|
31
|
+
const {
|
|
32
|
+
entities
|
|
33
|
+
} = await teamsClient.getTeamLinksByTeamId(teamId);
|
|
34
|
+
if (getState().teamId !== teamId) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
setState({
|
|
38
|
+
isLoading: false,
|
|
39
|
+
hasLoaded: true,
|
|
40
|
+
hasError: false,
|
|
41
|
+
shouldReload: false,
|
|
42
|
+
links: entities
|
|
43
|
+
});
|
|
44
|
+
} catch (e) {
|
|
45
|
+
if (getState().teamId !== teamId) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setState({
|
|
49
|
+
isLoading: false,
|
|
50
|
+
hasLoaded: true,
|
|
51
|
+
hasError: true,
|
|
52
|
+
errorType: e instanceof Error ? e : undefined,
|
|
53
|
+
shouldReload: false,
|
|
54
|
+
links: []
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
createTeamWebLink: (teamId, newLink) => async () => {
|
|
59
|
+
return await teamsClient.createTeamLink(teamId, newLink);
|
|
60
|
+
},
|
|
61
|
+
updateTeamWebLink: (teamId, linkId, newLink) => async () => {
|
|
62
|
+
return await teamsClient.updateTeamLink(teamId, linkId, newLink);
|
|
63
|
+
},
|
|
64
|
+
removeWebLink: (teamId, linkId) => async ({
|
|
65
|
+
dispatch
|
|
66
|
+
}) => {
|
|
67
|
+
await teamsClient.deleteTeamLink(teamId, linkId);
|
|
68
|
+
await dispatch(actions.getTeamWebLinks(teamId));
|
|
69
|
+
},
|
|
70
|
+
initialState: state => ({
|
|
71
|
+
setState
|
|
72
|
+
}) => {
|
|
73
|
+
setState({
|
|
74
|
+
...initialState,
|
|
75
|
+
...state
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const TeamWebLinksStore = createStore({
|
|
80
|
+
initialState,
|
|
81
|
+
actions
|
|
82
|
+
});
|
|
83
|
+
export const useTeamWebLinks = createHook(TeamWebLinksStore);
|
|
84
|
+
export const useTeamWebLinksActions = createHook(TeamWebLinksStore, {
|
|
85
|
+
selector: null
|
|
86
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { TeamContainers } from './ui/team-containers';
|
|
2
2
|
export { useTeamContainers, useConnectedTeams } from './controllers/hooks/use-team-containers';
|
|
3
|
+
export { useTeamWebLinks, useTeamWebLinksActions } from './controllers/hooks/use-team-web-links';
|
|
3
4
|
export { useProductPermissions } from './controllers/hooks/use-product-permission';
|
|
4
5
|
export { hasProductPermission } from './controllers/product-permission/utils';
|
|
5
6
|
export { getContainerProperties } from './common/utils/get-container-properties';
|
|
@@ -12,6 +12,7 @@ import Link from '@atlaskit/link';
|
|
|
12
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
13
|
import { Box, Flex, Inline, Stack, Text } from '@atlaskit/primitives/compiled';
|
|
14
14
|
import Tooltip from '@atlaskit/tooltip';
|
|
15
|
+
import { LoomSpaceAvatar } from '../../../common/ui/loom-avatar';
|
|
15
16
|
import { AnalyticsAction, usePeopleAndTeamAnalytics } from '../../../common/utils/analytics';
|
|
16
17
|
import { getContainerProperties } from '../../../common/utils/get-container-properties';
|
|
17
18
|
const styles = {
|
|
@@ -67,6 +68,20 @@ const LinkedCardWrapper = ({
|
|
|
67
68
|
}
|
|
68
69
|
}, children));
|
|
69
70
|
};
|
|
71
|
+
const getContainerIcon = (containerType, title, containerIcon) => {
|
|
72
|
+
if (containerType === 'LoomSpace') {
|
|
73
|
+
return /*#__PURE__*/React.createElement(LoomSpaceAvatar, {
|
|
74
|
+
spaceName: title,
|
|
75
|
+
size: 'large'
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return /*#__PURE__*/React.createElement(Avatar, {
|
|
79
|
+
appearance: "square",
|
|
80
|
+
size: "medium",
|
|
81
|
+
src: containerIcon,
|
|
82
|
+
testId: "linked-container-icon"
|
|
83
|
+
});
|
|
84
|
+
};
|
|
70
85
|
export const LinkedContainerCard = ({
|
|
71
86
|
containerType,
|
|
72
87
|
title,
|
|
@@ -100,12 +115,7 @@ export const LinkedContainerCard = ({
|
|
|
100
115
|
}, /*#__PURE__*/React.createElement(Inline, {
|
|
101
116
|
space: "space.100",
|
|
102
117
|
xcss: styles.card
|
|
103
|
-
}, /*#__PURE__*/React.createElement(
|
|
104
|
-
appearance: "square",
|
|
105
|
-
size: "medium",
|
|
106
|
-
src: containerIcon,
|
|
107
|
-
testId: "linked-container-icon"
|
|
108
|
-
}), /*#__PURE__*/React.createElement(Stack, null, /*#__PURE__*/React.createElement(Text, {
|
|
118
|
+
}, getContainerIcon(containerType, title, containerIcon), /*#__PURE__*/React.createElement(Stack, null, /*#__PURE__*/React.createElement(Text, {
|
|
109
119
|
maxLines: 1,
|
|
110
120
|
weight: "medium",
|
|
111
121
|
color: "color.text"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LoomSpaceAvatar } from './main';
|