@atlaskit/teams-public 0.47.0 → 0.49.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/controllers/hooks/use-requested-container/index.js +146 -0
- package/dist/cjs/controllers/hooks/use-requested-container/utils.js +132 -0
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/ui/team-containers/main.js +63 -29
- package/dist/cjs/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.js +29 -3
- package/dist/cjs/ui/team-containers/team-link-card/index.js +7 -2
- package/dist/es2019/controllers/hooks/use-requested-container/index.js +119 -0
- package/dist/es2019/controllers/hooks/use-requested-container/utils.js +94 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/ui/team-containers/main.js +56 -22
- package/dist/es2019/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.js +33 -4
- package/dist/es2019/ui/team-containers/team-link-card/index.js +7 -2
- package/dist/esm/controllers/hooks/use-requested-container/index.js +140 -0
- package/dist/esm/controllers/hooks/use-requested-container/utils.js +121 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/ui/team-containers/main.js +64 -30
- package/dist/esm/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.js +30 -4
- package/dist/esm/ui/team-containers/team-link-card/index.js +7 -2
- package/dist/types/controllers/hooks/use-requested-container/index.d.ts +25 -0
- package/dist/types/controllers/hooks/use-requested-container/utils.d.ts +23 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/ui/team-containers/main.d.ts +1 -1
- package/dist/types/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.d.ts +4 -1
- package/dist/types/ui/team-containers/team-link-card/index.d.ts +2 -1
- package/dist/types/ui/team-containers/types.d.ts +6 -1
- package/dist/types-ts4.5/controllers/hooks/use-requested-container/index.d.ts +25 -0
- package/dist/types-ts4.5/controllers/hooks/use-requested-container/utils.d.ts +23 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/team-containers/main.d.ts +1 -1
- package/dist/types-ts4.5/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.d.ts +4 -1
- package/dist/types-ts4.5/ui/team-containers/team-link-card/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/team-containers/types.d.ts +6 -1
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/teams-public
|
|
2
2
|
|
|
3
|
+
## 0.49.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#191837](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/191837)
|
|
8
|
+
[`45c985a1802dd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/45c985a1802dd) -
|
|
9
|
+
Implemented open in new tab link behaviour
|
|
10
|
+
|
|
11
|
+
## 0.48.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#187832](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/187832)
|
|
16
|
+
[`68ed62073dd56`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/68ed62073dd56) -
|
|
17
|
+
Integrate useRequestedContainers to team containers
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 0.47.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useRequestedContainers = useRequestedContainers;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
var _reactIntlNext = require("react-intl-next");
|
|
14
|
+
var _useTeamContainers2 = require("../use-team-containers");
|
|
15
|
+
var _utils = require("./utils");
|
|
16
|
+
/**
|
|
17
|
+
* Hook to track and poll for requested product containers (such as a Jira Project).
|
|
18
|
+
* The initial list of requested containers is derived from the URL parameters, however it can be updated based on user interactions.
|
|
19
|
+
*
|
|
20
|
+
* Manages a list of requested containers, polls for updates, and removes found containers from the list.
|
|
21
|
+
*
|
|
22
|
+
* Supported container types: CONFLUENCE_SPACE, JIRA_PROJECT, LOOM_SPACE.
|
|
23
|
+
*
|
|
24
|
+
* @param teamId - The ID of the team whose containers are being tracked.
|
|
25
|
+
* @param onRequestedContainerTimeout - Optional callback to handle timeout events for requested containers.
|
|
26
|
+
* @returns The current list of requested containers and a function to add a container.
|
|
27
|
+
*/
|
|
28
|
+
function useRequestedContainers(_ref) {
|
|
29
|
+
var teamId = _ref.teamId,
|
|
30
|
+
onRequestedContainerTimeout = _ref.onRequestedContainerTimeout;
|
|
31
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
32
|
+
formatMessage = _useIntl.formatMessage;
|
|
33
|
+
var _useTeamContainers = (0, _useTeamContainers2.useTeamContainers)(teamId),
|
|
34
|
+
refetchTeamContainers = _useTeamContainers.refetchTeamContainers,
|
|
35
|
+
teamContainers = _useTeamContainers.teamContainers;
|
|
36
|
+
var _useState = (0, _react.useState)(function () {
|
|
37
|
+
return (0, _utils.userCanAccessFeature)() ? (0, _utils.getRequestedContainersFromUrl)() : [];
|
|
38
|
+
}),
|
|
39
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
40
|
+
requestedContainers = _useState2[0],
|
|
41
|
+
setRequestedContainers = _useState2[1];
|
|
42
|
+
var checkContainers = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
43
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
44
|
+
while (1) switch (_context.prev = _context.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
_context.next = 2;
|
|
47
|
+
return refetchTeamContainers();
|
|
48
|
+
case 2:
|
|
49
|
+
case "end":
|
|
50
|
+
return _context.stop();
|
|
51
|
+
}
|
|
52
|
+
}, _callee);
|
|
53
|
+
})), [refetchTeamContainers]);
|
|
54
|
+
var _useAsyncPolling = (0, _utils.useAsyncPolling)(checkContainers),
|
|
55
|
+
startPolling = _useAsyncPolling.startPolling,
|
|
56
|
+
stopPolling = _useAsyncPolling.stopPolling,
|
|
57
|
+
isPolling = _useAsyncPolling.isPolling,
|
|
58
|
+
hasTimedOut = _useAsyncPolling.hasTimedOut;
|
|
59
|
+
var checkForContainer = function checkForContainer(container) {
|
|
60
|
+
if (!requestedContainers.includes(container)) {
|
|
61
|
+
setRequestedContainers(function (prev) {
|
|
62
|
+
return [].concat((0, _toConsumableArray2.default)(prev), [container]);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
startPolling();
|
|
66
|
+
};
|
|
67
|
+
(0, _react.useEffect)(function () {
|
|
68
|
+
if (!(0, _utils.userCanAccessFeature)()) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (hasTimedOut) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
var containerCount = requestedContainers.length;
|
|
75
|
+
if (isPolling && containerCount === 0) {
|
|
76
|
+
stopPolling();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (!isPolling && containerCount > 0) {
|
|
80
|
+
startPolling();
|
|
81
|
+
}
|
|
82
|
+
}, [isPolling, requestedContainers.length, hasTimedOut, startPolling, stopPolling]);
|
|
83
|
+
(0, _react.useEffect)(function () {
|
|
84
|
+
var containersNotFound = requestedContainers.filter(function (containerType) {
|
|
85
|
+
return !teamContainers.some(function (teamContainer) {
|
|
86
|
+
return teamContainer.type === containerType;
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
if (!(0, _utils.containersEqual)(containersNotFound, requestedContainers)) {
|
|
90
|
+
setRequestedContainers(containersNotFound);
|
|
91
|
+
}
|
|
92
|
+
}, [requestedContainers, checkContainers, teamContainers]);
|
|
93
|
+
(0, _react.useEffect)(function () {
|
|
94
|
+
if (hasTimedOut && onRequestedContainerTimeout) {
|
|
95
|
+
var action = function action() {
|
|
96
|
+
// @todo: send request to retry creating containers
|
|
97
|
+
// This will be implemented in the next pull request
|
|
98
|
+
};
|
|
99
|
+
var flagId = "requested-container-timeout-".concat(requestedContainers.join('-'));
|
|
100
|
+
var _createFlag = function _createFlag(_ref3) {
|
|
101
|
+
var onAction = _ref3.onAction;
|
|
102
|
+
return {
|
|
103
|
+
id: flagId,
|
|
104
|
+
title: requestedContainers.length === 1 ? formatMessage(messages.timeoutTitle, {
|
|
105
|
+
container: (0, _utils.containerDisplayName)(requestedContainers[0])
|
|
106
|
+
}) : formatMessage(messages.timeoutTitleMultiple),
|
|
107
|
+
description: formatMessage(messages.timeoutDescription),
|
|
108
|
+
actions: [{
|
|
109
|
+
content: formatMessage(messages.timeoutAction),
|
|
110
|
+
onClick: function onClick() {
|
|
111
|
+
action();
|
|
112
|
+
onAction(flagId);
|
|
113
|
+
}
|
|
114
|
+
}]
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
onRequestedContainerTimeout(_createFlag);
|
|
118
|
+
}
|
|
119
|
+
}, [hasTimedOut, onRequestedContainerTimeout, requestedContainers, formatMessage]);
|
|
120
|
+
return {
|
|
121
|
+
requestedContainers: requestedContainers,
|
|
122
|
+
checkForContainer: checkForContainer
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
var messages = (0, _reactIntlNext.defineMessages)({
|
|
126
|
+
timeoutTitle: {
|
|
127
|
+
id: 'teams-public.team-containers.timeout-title',
|
|
128
|
+
defaultMessage: 'We’re couldn’t connect your {container}',
|
|
129
|
+
description: 'Title for the timeout flag'
|
|
130
|
+
},
|
|
131
|
+
timeoutTitleMultiple: {
|
|
132
|
+
id: 'teams-public.team-containers.timeout-title',
|
|
133
|
+
defaultMessage: 'We’re couldn’t connect your spaces',
|
|
134
|
+
description: 'Title for the timeout flag'
|
|
135
|
+
},
|
|
136
|
+
timeoutDescription: {
|
|
137
|
+
id: 'teams-public..team-containers.timeout-description',
|
|
138
|
+
defaultMessage: 'Something went wrong. Verify your connection and retry.',
|
|
139
|
+
description: 'Description for the timeout flag'
|
|
140
|
+
},
|
|
141
|
+
timeoutAction: {
|
|
142
|
+
id: 'teams-public.team-containers.timeout-action',
|
|
143
|
+
defaultMessage: 'Try again',
|
|
144
|
+
description: 'Action text for the timeout flag'
|
|
145
|
+
}
|
|
146
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.POLLING_INTERVAL = exports.POLLING_DURATION = void 0;
|
|
8
|
+
exports.containerDisplayName = containerDisplayName;
|
|
9
|
+
exports.containersEqual = containersEqual;
|
|
10
|
+
exports.getRequestedContainersFromUrl = getRequestedContainersFromUrl;
|
|
11
|
+
exports.useAsyncPolling = useAsyncPolling;
|
|
12
|
+
exports.userCanAccessFeature = userCanAccessFeature;
|
|
13
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
14
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
16
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
|
+
var _react = require("react");
|
|
19
|
+
var _featureGateJsClient = _interopRequireDefault(require("@atlaskit/feature-gate-js-client"));
|
|
20
|
+
var _frontendUtilities = require("@atlaskit/frontend-utilities");
|
|
21
|
+
var _types = require("@atlaskit/teams-client/types");
|
|
22
|
+
var CONTAINER_MAP = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.ContainerType.CONFLUENCE_SPACE, 'ConfluenceSpace'), _types.ContainerType.JIRA_PROJECT, 'JiraProject'), _types.ContainerType.LOOM_SPACE, 'LoomSpace');
|
|
23
|
+
var CONTAINER_HUMAN_NAMES = {
|
|
24
|
+
ConfluenceSpace: 'Confluence space',
|
|
25
|
+
JiraProject: 'Jira project',
|
|
26
|
+
LoomSpace: 'Loom space'
|
|
27
|
+
};
|
|
28
|
+
function containersEqual(arr1, arr2) {
|
|
29
|
+
return JSON.stringify((0, _toConsumableArray2.default)(arr1).sort()) === JSON.stringify((0, _toConsumableArray2.default)(arr2).sort());
|
|
30
|
+
}
|
|
31
|
+
function getRequestedContainersFromUrl() {
|
|
32
|
+
var _searchParams$get;
|
|
33
|
+
var searchParams = new URLSearchParams(window.location.search);
|
|
34
|
+
var values = ((_searchParams$get = searchParams.get('requestedContainers')) === null || _searchParams$get === void 0 ? void 0 : _searchParams$get.split(',').filter(Boolean)) || [];
|
|
35
|
+
return values.filter(function (value) {
|
|
36
|
+
return Object.values(_types.ContainerType).includes(value);
|
|
37
|
+
}).map(function (value) {
|
|
38
|
+
return CONTAINER_MAP[value];
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function containerDisplayName(container) {
|
|
42
|
+
return CONTAINER_HUMAN_NAMES[container];
|
|
43
|
+
}
|
|
44
|
+
function userCanAccessFeature() {
|
|
45
|
+
if (_featureGateJsClient.default.initializeCalled()) {
|
|
46
|
+
var value = _featureGateJsClient.default.getExperimentValue('teams_app_auto_container_creation', 'cohort', 'control');
|
|
47
|
+
return value === 'universal_create' || value === 'profile_page';
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//@todo: PTC-12250 update these to P90 value
|
|
53
|
+
var POLLING_INTERVAL = exports.POLLING_INTERVAL = 1000;
|
|
54
|
+
var POLLING_DURATION = exports.POLLING_DURATION = 10000;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Hook for polling an async callback at a fixed interval, with timeout and pending state management.
|
|
58
|
+
*
|
|
59
|
+
* Starts polling the provided callback and stops after a set duration or when stopped manually.
|
|
60
|
+
* Ensures only one callback is pending at a time.
|
|
61
|
+
*
|
|
62
|
+
* @param callback - The async function to poll.
|
|
63
|
+
* @returns An object with polling controls and state: startPolling, stopPolling, isPolling, hasTimedOut.
|
|
64
|
+
*/
|
|
65
|
+
function useAsyncPolling(callback) {
|
|
66
|
+
var _useState = (0, _react.useState)(false),
|
|
67
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
68
|
+
hasTimedOut = _useState2[0],
|
|
69
|
+
setHasTimedOut = _useState2[1];
|
|
70
|
+
var timeoutRef = (0, _react.useRef)(null);
|
|
71
|
+
var _useState3 = (0, _react.useState)(false),
|
|
72
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
73
|
+
isPolling = _useState4[0],
|
|
74
|
+
setIsPolling = _useState4[1];
|
|
75
|
+
var _useState5 = (0, _react.useState)(false),
|
|
76
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
77
|
+
isPending = _useState6[0],
|
|
78
|
+
setIsPending = _useState6[1];
|
|
79
|
+
var stopPolling = (0, _react.useCallback)(function () {
|
|
80
|
+
if (timeoutRef.current) {
|
|
81
|
+
clearTimeout(timeoutRef.current);
|
|
82
|
+
timeoutRef.current = null;
|
|
83
|
+
}
|
|
84
|
+
setIsPolling(false);
|
|
85
|
+
setHasTimedOut(false);
|
|
86
|
+
setIsPending(false);
|
|
87
|
+
}, []);
|
|
88
|
+
var startPolling = (0, _react.useCallback)(function () {
|
|
89
|
+
if (timeoutRef.current) {
|
|
90
|
+
clearTimeout(timeoutRef.current);
|
|
91
|
+
timeoutRef.current = null;
|
|
92
|
+
}
|
|
93
|
+
setHasTimedOut(false);
|
|
94
|
+
setIsPolling(true);
|
|
95
|
+
setIsPending(false);
|
|
96
|
+
timeoutRef.current = setTimeout(function () {
|
|
97
|
+
stopPolling();
|
|
98
|
+
setHasTimedOut(true);
|
|
99
|
+
}, POLLING_DURATION);
|
|
100
|
+
}, [stopPolling]);
|
|
101
|
+
var wrappedCallback = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
102
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
103
|
+
while (1) switch (_context.prev = _context.next) {
|
|
104
|
+
case 0:
|
|
105
|
+
if (!isPending) {
|
|
106
|
+
_context.next = 2;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
return _context.abrupt("return");
|
|
110
|
+
case 2:
|
|
111
|
+
setIsPending(true);
|
|
112
|
+
_context.prev = 3;
|
|
113
|
+
_context.next = 6;
|
|
114
|
+
return callback();
|
|
115
|
+
case 6:
|
|
116
|
+
_context.prev = 6;
|
|
117
|
+
setIsPending(false);
|
|
118
|
+
return _context.finish(6);
|
|
119
|
+
case 9:
|
|
120
|
+
case "end":
|
|
121
|
+
return _context.stop();
|
|
122
|
+
}
|
|
123
|
+
}, _callee, null, [[3,, 6, 9]]);
|
|
124
|
+
})), [callback, isPending]);
|
|
125
|
+
(0, _frontendUtilities.useInterval)(isPolling ? wrappedCallback : function () {}, isPolling ? POLLING_INTERVAL : null);
|
|
126
|
+
return {
|
|
127
|
+
startPolling: startPolling,
|
|
128
|
+
stopPolling: stopPolling,
|
|
129
|
+
isPolling: isPolling,
|
|
130
|
+
hasTimedOut: hasTimedOut
|
|
131
|
+
};
|
|
132
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "TeamContainers", {
|
|
|
33
33
|
return _teamContainers.TeamContainers;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "TeamLinkCard", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _teamLinkCard.TeamLinkCard;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
36
42
|
Object.defineProperty(exports, "getContainerProperties", {
|
|
37
43
|
enumerable: true,
|
|
38
44
|
get: function get() {
|
|
@@ -82,6 +88,7 @@ Object.defineProperty(exports, "useTeamWebLinksActions", {
|
|
|
82
88
|
}
|
|
83
89
|
});
|
|
84
90
|
var _teamContainers = require("./ui/team-containers");
|
|
91
|
+
var _teamLinkCard = require("./ui/team-containers/team-link-card");
|
|
85
92
|
var _containerIcon = require("./common/ui/container-icon");
|
|
86
93
|
var _useTeamContainers = require("./controllers/hooks/use-team-containers");
|
|
87
94
|
var _useTeamWebLinks = require("./controllers/hooks/use-team-web-links");
|
|
@@ -21,6 +21,7 @@ var _colors = require("@atlaskit/theme/colors");
|
|
|
21
21
|
var _analytics = require("../../common/utils/analytics");
|
|
22
22
|
var _controllers = require("../../controllers");
|
|
23
23
|
var _useProductPermission3 = require("../../controllers/hooks/use-product-permission");
|
|
24
|
+
var _useRequestedContainer = require("../../controllers/hooks/use-requested-container");
|
|
24
25
|
var _useTeamContainers2 = require("../../controllers/hooks/use-team-containers");
|
|
25
26
|
var _useTeamLinksAndContainers = require("../../controllers/hooks/use-team-links-and-containers");
|
|
26
27
|
var _addContainerCard = require("./add-container-card");
|
|
@@ -28,6 +29,7 @@ var _async = require("./disconnect-dialog/async");
|
|
|
28
29
|
var _linkedContainerCard = require("./linked-container-card");
|
|
29
30
|
var _noProductAccessEmptyState = require("./no-product-access-empty-state");
|
|
30
31
|
var _teamContainersSkeleton = require("./team-containers-skeleton");
|
|
32
|
+
var _linkedContainerCardSkeleton = require("./team-containers-skeleton/linked-container-card-skeleton");
|
|
31
33
|
var _teamLinkCard = require("./team-link-card");
|
|
32
34
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
33
35
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
@@ -39,6 +41,8 @@ var TeamContainers = exports.TeamContainers = function TeamContainers(_ref) {
|
|
|
39
41
|
var teamId = _ref.teamId,
|
|
40
42
|
_onAddAContainerClick = _ref.onAddAContainerClick,
|
|
41
43
|
onEditContainerClick = _ref.onEditContainerClick,
|
|
44
|
+
_ref$onRequestedConta = _ref.onRequestedContainerTimeout,
|
|
45
|
+
onRequestedContainerTimeout = _ref$onRequestedConta === void 0 ? function () {} : _ref$onRequestedConta,
|
|
42
46
|
components = _ref.components,
|
|
43
47
|
userId = _ref.userId,
|
|
44
48
|
cloudId = _ref.cloudId,
|
|
@@ -57,6 +61,11 @@ var TeamContainers = exports.TeamContainers = function TeamContainers(_ref) {
|
|
|
57
61
|
removeTeamLink = _useTeamLinksAndConta.removeTeamLink,
|
|
58
62
|
iconsLoading = _useTeamLinksAndConta.iconsLoading,
|
|
59
63
|
iconHasLoaded = _useTeamLinksAndConta.iconHasLoaded;
|
|
64
|
+
var _useRequestedContaine = (0, _useRequestedContainer.useRequestedContainers)({
|
|
65
|
+
teamId: teamId,
|
|
66
|
+
onRequestedContainerTimeout: onRequestedContainerTimeout
|
|
67
|
+
}),
|
|
68
|
+
requestedContainers = _useRequestedContaine.requestedContainers;
|
|
60
69
|
var _useTeamContainersHoo = (0, _useTeamContainers2.useTeamContainersHook)(),
|
|
61
70
|
_useTeamContainersHoo2 = (0, _slicedToArray2.default)(_useTeamContainersHoo, 2),
|
|
62
71
|
_ = _useTeamContainersHoo2[0],
|
|
@@ -114,7 +123,7 @@ var TeamContainers = exports.TeamContainers = function TeamContainers(_ref) {
|
|
|
114
123
|
if ((0, _platformFeatureFlags.fg)('enable_web_links_in_team_containers')) {
|
|
115
124
|
if (isDisplayedOnProfileCard && filterContainerId) {
|
|
116
125
|
setFilteredTeamLinks(teamLinks.filter(function (container) {
|
|
117
|
-
return container.id !== filterContainerId;
|
|
126
|
+
return container.id !== filterContainerId && !requestedContainers.includes(container.type);
|
|
118
127
|
}));
|
|
119
128
|
} else {
|
|
120
129
|
setFilteredTeamLinks(teamLinks);
|
|
@@ -128,7 +137,7 @@ var TeamContainers = exports.TeamContainers = function TeamContainers(_ref) {
|
|
|
128
137
|
setFilteredTeamContainers(teamContainers);
|
|
129
138
|
}
|
|
130
139
|
}
|
|
131
|
-
}, [teamLinks, teamContainers, isDisplayedOnProfileCard, filterContainerId]);
|
|
140
|
+
}, [teamLinks, teamContainers, isDisplayedOnProfileCard, filterContainerId, requestedContainers]);
|
|
132
141
|
(0, _react.useEffect)(function () {
|
|
133
142
|
var containersToCheck = (0, _platformFeatureFlags.fg)('enable_web_links_in_team_containers') ? filteredTeamLinks : filteredTeamContainers;
|
|
134
143
|
if (containersToCheck.length > maxNumberOfContainersToShow || isDisplayedOnProfileCard) {
|
|
@@ -139,31 +148,31 @@ var TeamContainers = exports.TeamContainers = function TeamContainers(_ref) {
|
|
|
139
148
|
WebLink: false
|
|
140
149
|
});
|
|
141
150
|
} else {
|
|
142
|
-
var
|
|
143
|
-
return
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
Jira:
|
|
161
|
-
Confluence:
|
|
162
|
-
Loom:
|
|
163
|
-
WebLink: !
|
|
151
|
+
var containerExists = function containerExists(type) {
|
|
152
|
+
return containersToCheck.some(function (container) {
|
|
153
|
+
return container.type === type;
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
var containerRequested = function containerRequested(type) {
|
|
157
|
+
return requestedContainers.includes(type);
|
|
158
|
+
};
|
|
159
|
+
var showContainer = function showContainer(containerExists, isRequesting, product) {
|
|
160
|
+
if (containerExists || isRequesting) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
if ((0, _platformFeatureFlags.fg)('migrate-product-permissions')) {
|
|
164
|
+
return productPermissions && (0, _teamsAppInternalProductPermissions.hasProductPermission)(productPermissions, product) || false;
|
|
165
|
+
}
|
|
166
|
+
return productPermissionsOld && (0, _controllers.hasProductPermission)(productPermissionsOld, product) || false;
|
|
167
|
+
};
|
|
168
|
+
setShowAddContainer({
|
|
169
|
+
Jira: showContainer(containerExists('JiraProject'), containerRequested('JiraProject'), 'jira'),
|
|
170
|
+
Confluence: showContainer(containerExists('ConfluenceSpace'), containerRequested('ConfluenceSpace'), 'confluence'),
|
|
171
|
+
Loom: showContainer(containerExists('LoomSpace'), containerRequested('LoomSpace'), 'loom'),
|
|
172
|
+
WebLink: !containerExists('WebLink')
|
|
164
173
|
});
|
|
165
174
|
}
|
|
166
|
-
}, [isDisplayedOnProfileCard, productPermissions, productPermissionsOld, filteredTeamContainers, filteredTeamLinks, maxNumberOfContainersToShow]);
|
|
175
|
+
}, [isDisplayedOnProfileCard, productPermissions, productPermissionsOld, filteredTeamContainers, filteredTeamLinks, maxNumberOfContainersToShow, requestedContainers]);
|
|
167
176
|
var handleShowMore = function handleShowMore() {
|
|
168
177
|
setShowMore(!showMore);
|
|
169
178
|
};
|
|
@@ -238,13 +247,33 @@ var TeamContainers = exports.TeamContainers = function TeamContainers(_ref) {
|
|
|
238
247
|
};
|
|
239
248
|
}(), [actions, createAnalyticsEvent, fireOperationalEvent, filteredTeamContainers, filteredTeamLinks, removeTeamLink, teamId, unlinkError]);
|
|
240
249
|
var TeamContainersSkeletonComponent = (components === null || components === void 0 ? void 0 : components.TeamContainersSkeleton) || _teamContainersSkeleton.TeamContainersSkeleton;
|
|
241
|
-
|
|
250
|
+
var hasNoPermissions = (0, _react.useMemo)(function () {
|
|
251
|
+
if ((0, _platformFeatureFlags.fg)('migrate-product-permissions')) {
|
|
252
|
+
return productPermissions && !(0, _teamsAppInternalProductPermissions.hasProductPermission)(productPermissions, 'jira') && !(0, _teamsAppInternalProductPermissions.hasProductPermission)(productPermissions, 'confluence') && !(0, _teamsAppInternalProductPermissions.hasProductPermission)(productPermissions, 'loom');
|
|
253
|
+
}
|
|
254
|
+
return productPermissionsOld && !(0, _controllers.hasProductPermission)(productPermissionsOld, 'jira') && !(0, _controllers.hasProductPermission)(productPermissionsOld, 'confluence') && !(0, _controllers.hasProductPermission)(productPermissionsOld, 'loom');
|
|
255
|
+
}, [productPermissions, productPermissionsOld]);
|
|
256
|
+
var hasNoContainers = (0, _react.useMemo)(function () {
|
|
257
|
+
if ((0, _platformFeatureFlags.fg)('enable_web_links_in_team_containers')) {
|
|
258
|
+
return filteredTeamLinks.length === 0;
|
|
259
|
+
}
|
|
260
|
+
return filteredTeamContainers.length === 0;
|
|
261
|
+
}, [filteredTeamLinks, filteredTeamContainers]);
|
|
262
|
+
var isLoading = (0, _react.useMemo)(function () {
|
|
263
|
+
if (loading) {
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
if ((0, _platformFeatureFlags.fg)('migrate-product-permissions')) {
|
|
267
|
+
return productPermissionIsLoading;
|
|
268
|
+
}
|
|
269
|
+
return productPermissionIsLoadingOld;
|
|
270
|
+
}, [loading, productPermissionIsLoading, productPermissionIsLoadingOld]);
|
|
271
|
+
if (isLoading) {
|
|
242
272
|
return /*#__PURE__*/_react.default.createElement(TeamContainersSkeletonComponent, {
|
|
243
273
|
numberOfContainers: maxNumberOfContainersToShow
|
|
244
274
|
});
|
|
245
275
|
}
|
|
246
|
-
|
|
247
|
-
if (((0, _platformFeatureFlags.fg)('enable_web_links_in_team_containers') ? filteredTeamLinks.length === 0 : filteredTeamContainers.length === 0) && !isDisplayedOnProfileCard && !hasAnyProductPermission) {
|
|
276
|
+
if (hasNoContainers && !isDisplayedOnProfileCard && hasNoPermissions) {
|
|
248
277
|
return /*#__PURE__*/_react.default.createElement(_noProductAccessEmptyState.NoProductAccessState, null);
|
|
249
278
|
}
|
|
250
279
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_primitives.Stack, {
|
|
@@ -252,7 +281,12 @@ var TeamContainers = exports.TeamContainers = function TeamContainers(_ref) {
|
|
|
252
281
|
}, /*#__PURE__*/_react.default.createElement(_primitives.Grid, {
|
|
253
282
|
templateColumns: "repeat(auto-fill, minmax(300px, 1fr))",
|
|
254
283
|
gap: isDisplayedOnProfileCard ? 'space.0' : 'space.100'
|
|
255
|
-
},
|
|
284
|
+
}, requestedContainers.map(function (containerType) {
|
|
285
|
+
return /*#__PURE__*/_react.default.createElement(_linkedContainerCardSkeleton.LinkedContainerCardSkeleton, {
|
|
286
|
+
key: containerType,
|
|
287
|
+
containerType: containerType
|
|
288
|
+
});
|
|
289
|
+
}), (0, _platformFeatureFlags.fg)('enable_web_links_in_team_containers') ? filteredTeamLinks.slice(0, maxNumberOfContainersToShow).map(function (container) {
|
|
256
290
|
return /*#__PURE__*/_react.default.createElement(LinkedContainerCardComponent, {
|
|
257
291
|
key: container.id,
|
|
258
292
|
containerType: container.type,
|
package/dist/cjs/ui/team-containers/team-containers-skeleton/linked-container-card-skeleton/index.js
CHANGED
|
@@ -10,13 +10,15 @@ require("./index.compiled.css");
|
|
|
10
10
|
var _runtime = require("@compiled/react/runtime");
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
12
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
13
|
+
var _getContainerProperties = require("../../../../common/utils/get-container-properties");
|
|
13
14
|
var styles = {
|
|
14
15
|
container: "_2rkoiti9 _1h6dz9xs _12y3e4h9 _12jimuej _1qu2nqa1 _syaz1fxt _ca0qpxbi _u5f3pxbi _n3tdpxbi _19bvpxbi",
|
|
15
16
|
avatarSkeleton: "_2rkoglpi _ca0qpxbi _u5f3pxbi _n3tdpxbi _19bvpxbi",
|
|
16
17
|
firstLineSkeleton: "_2rko1q77 _1rjc1b66",
|
|
17
18
|
secondLineSkeleton: "_2rko1q77 _1rjc1b66 _1bsbqkoa"
|
|
18
19
|
};
|
|
19
|
-
var LinkedContainerCardSkeleton = exports.LinkedContainerCardSkeleton = function LinkedContainerCardSkeleton() {
|
|
20
|
+
var LinkedContainerCardSkeleton = exports.LinkedContainerCardSkeleton = function LinkedContainerCardSkeleton(_ref) {
|
|
21
|
+
var containerType = _ref.containerType;
|
|
20
22
|
return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
21
23
|
xcss: styles.container
|
|
22
24
|
}, /*#__PURE__*/_react.default.createElement(_compiled.Inline, {
|
|
@@ -31,8 +33,32 @@ var LinkedContainerCardSkeleton = exports.LinkedContainerCardSkeleton = function
|
|
|
31
33
|
}, /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
32
34
|
backgroundColor: "color.background.neutral",
|
|
33
35
|
xcss: styles.firstLineSkeleton
|
|
34
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
36
|
+
}), containerType ? /*#__PURE__*/_react.default.createElement(ContainerIcon, {
|
|
37
|
+
containerType: containerType
|
|
38
|
+
}) : /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
35
39
|
backgroundColor: "color.background.neutral",
|
|
36
40
|
xcss: styles.secondLineSkeleton
|
|
37
41
|
}))));
|
|
38
|
-
};
|
|
42
|
+
};
|
|
43
|
+
function ContainerIcon(_ref2) {
|
|
44
|
+
var containerType = _ref2.containerType;
|
|
45
|
+
var _getContainerProperti = (0, _getContainerProperties.getContainerProperties)({
|
|
46
|
+
containerType: containerType,
|
|
47
|
+
iconSize: 'medium'
|
|
48
|
+
}),
|
|
49
|
+
description = _getContainerProperti.description,
|
|
50
|
+
icon = _getContainerProperti.icon,
|
|
51
|
+
containerTypeText = _getContainerProperti.containerTypeText;
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement(_compiled.Flex, {
|
|
53
|
+
gap: "space.050",
|
|
54
|
+
alignItems: "center"
|
|
55
|
+
}, icon, /*#__PURE__*/_react.default.createElement(_compiled.Inline, {
|
|
56
|
+
space: "space.050"
|
|
57
|
+
}, /*#__PURE__*/_react.default.createElement(_compiled.Text, {
|
|
58
|
+
size: "small",
|
|
59
|
+
color: "color.text.subtle"
|
|
60
|
+
}, description), /*#__PURE__*/_react.default.createElement(_compiled.Text, {
|
|
61
|
+
size: "small",
|
|
62
|
+
color: "color.text.subtle"
|
|
63
|
+
}, containerTypeText)));
|
|
64
|
+
}
|
|
@@ -52,7 +52,8 @@ var TeamLinkCard = exports.TeamLinkCard = function TeamLinkCard(_ref) {
|
|
|
52
52
|
_onDisconnectButtonClick = _ref.onDisconnectButtonClick,
|
|
53
53
|
_onEditLinkClick = _ref.onEditLinkClick,
|
|
54
54
|
iconsLoading = _ref.iconsLoading,
|
|
55
|
-
iconHasLoaded = _ref.iconHasLoaded
|
|
55
|
+
iconHasLoaded = _ref.iconHasLoaded,
|
|
56
|
+
openInNewTab = _ref.openInNewTab;
|
|
56
57
|
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
57
58
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
58
59
|
var _getContainerProperti = (0, _getContainerProperties.getContainerProperties)({
|
|
@@ -121,7 +122,7 @@ var TeamLinkCard = exports.TeamLinkCard = function TeamLinkCard(_ref) {
|
|
|
121
122
|
setShowKeyboardFocus(true);
|
|
122
123
|
}
|
|
123
124
|
};
|
|
124
|
-
var handleLinkClick = function handleLinkClick() {
|
|
125
|
+
var handleLinkClick = function handleLinkClick(e) {
|
|
125
126
|
var baseAttributes = {
|
|
126
127
|
container: containerType,
|
|
127
128
|
containerId: containerId
|
|
@@ -139,6 +140,10 @@ var TeamLinkCard = exports.TeamLinkCard = function TeamLinkCard(_ref) {
|
|
|
139
140
|
actionSubjectId: 'teamContainer',
|
|
140
141
|
attributes: attributes
|
|
141
142
|
});
|
|
143
|
+
if (openInNewTab) {
|
|
144
|
+
e.preventDefault();
|
|
145
|
+
window.open(link || '#', '_blank', 'noopener, noreferrer');
|
|
146
|
+
}
|
|
142
147
|
};
|
|
143
148
|
return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
144
149
|
backgroundColor: hovered ? 'color.background.input.hovered' : 'color.background.input',
|