@atlaskit/teams-public 0.54.0 → 0.54.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/teams-public
2
2
 
3
+ ## 0.54.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`64db8286c7b8e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/64db8286c7b8e) -
8
+ Slightly tweak the design of create container button (hidden behind experiment)
9
+
10
+ ## 0.54.1
11
+
12
+ ### Patch Changes
13
+
14
+ - [`a16cf46ffdef0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a16cf46ffdef0) -
15
+ Optimise setting state in create containers store
16
+
3
17
  ## 0.54.0
4
18
 
5
19
  ### Minor Changes
@@ -15,7 +15,11 @@ var actions = {
15
15
  var setState = _ref.setState,
16
16
  getState = _ref.getState;
17
17
  var containers = getState();
18
- setState(_objectSpread(_objectSpread({}, containers), {}, (0, _defineProperty2.default)({}, product, _objectSpread(_objectSpread({}, containers[product]), {}, {
18
+ var current = containers[product];
19
+ if (current.isLoading === isLoading) {
20
+ return;
21
+ }
22
+ setState(_objectSpread(_objectSpread({}, containers), {}, (0, _defineProperty2.default)({}, product, _objectSpread(_objectSpread({}, current), {}, {
19
23
  isLoading: isLoading
20
24
  }))));
21
25
  };
@@ -25,8 +29,14 @@ var actions = {
25
29
  var setState = _ref2.setState,
26
30
  getState = _ref2.getState;
27
31
  var containers = getState();
28
- setState(_objectSpread(_objectSpread({}, containers), {}, (0, _defineProperty2.default)({}, product, _objectSpread(_objectSpread({}, containers[product]), {}, {
29
- isCreated: isCreated
32
+ var current = containers[product];
33
+ if (current.isCreated === isCreated) {
34
+ return;
35
+ }
36
+ var isLoading = isCreated ? false : current.isLoading;
37
+ setState(_objectSpread(_objectSpread({}, containers), {}, (0, _defineProperty2.default)({}, product, _objectSpread(_objectSpread({}, current), {}, {
38
+ isCreated: isCreated,
39
+ isLoading: isLoading
30
40
  }))));
31
41
  };
32
42
  }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.AddContainerCardButton = AddContainerCardButton;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactIntlNext = require("react-intl-next");
10
+ var _compiled = require("@atlaskit/primitives/compiled");
11
+ function AddContainerCardButton(_ref) {
12
+ var type = _ref.type;
13
+ var _getContainerProperti = getContainerProperties(type),
14
+ title = _getContainerProperti.title,
15
+ description = _getContainerProperti.description;
16
+ return /*#__PURE__*/_react.default.createElement(_compiled.Stack, null, /*#__PURE__*/_react.default.createElement(_compiled.Text, {
17
+ maxLines: 1,
18
+ weight: "medium",
19
+ color: "color.text"
20
+ }, title), /*#__PURE__*/_react.default.createElement(_compiled.Flex, {
21
+ gap: "space.050",
22
+ alignItems: "center"
23
+ }, /*#__PURE__*/_react.default.createElement(_compiled.Text, {
24
+ size: "small",
25
+ color: "color.text.subtle"
26
+ }, description)));
27
+ }
28
+ function getContainerProperties(type) {
29
+ switch (type) {
30
+ case 'ConfluenceSpace':
31
+ return {
32
+ description: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.confluenceContainerDescription),
33
+ title: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.addConfluenceContainerTitle)
34
+ };
35
+ case 'LoomSpace':
36
+ return {
37
+ description: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.loomSpaceDescription),
38
+ title: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.addLoomContainerTitle)
39
+ };
40
+ case 'JiraProject':
41
+ return {
42
+ description: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.jiraProjectDescription),
43
+ title: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.addJiraProjectTitle)
44
+ };
45
+ case 'WebLink':
46
+ return {
47
+ description: null,
48
+ title: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, messages.addWebLinkTitle)
49
+ };
50
+ default:
51
+ return {
52
+ description: null,
53
+ title: null
54
+ };
55
+ }
56
+ }
57
+ var messages = (0, _reactIntlNext.defineMessages)({
58
+ addConfluenceContainerTitle: {
59
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-confluence-space-title',
60
+ defaultMessage: 'Confluence space',
61
+ description: 'Title of the card to add a Confluence space to a team'
62
+ },
63
+ confluenceContainerDescription: {
64
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-confluence-space-description',
65
+ defaultMessage: 'Create a knowledge bank',
66
+ description: 'Description of the card to add a Confluence space to a team'
67
+ },
68
+ addLoomContainerTitle: {
69
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-loom-space-title',
70
+ defaultMessage: 'Loom space',
71
+ description: 'Title of the card to add a Loom space to a team'
72
+ },
73
+ loomSpaceDescription: {
74
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-loom-space-description',
75
+ defaultMessage: 'Share async updates',
76
+ description: 'Description of the card to add a Loom space to a team'
77
+ },
78
+ addJiraProjectTitle: {
79
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-jira-project-title',
80
+ defaultMessage: 'Jira project',
81
+ description: 'Title of the card to add a Jira project to a team'
82
+ },
83
+ jiraProjectDescription: {
84
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-jira-project-description',
85
+ defaultMessage: 'Plan out project tasks',
86
+ description: 'Description of the card to add a Jira project to a team'
87
+ },
88
+ addWebLinkTitle: {
89
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-web-link-title',
90
+ defaultMessage: 'Add any web link',
91
+ description: 'Title of the card to add a any web link to a team'
92
+ }
93
+ });
@@ -18,6 +18,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
18
  var _compiled = require("@atlaskit/primitives/compiled");
19
19
  var _linkedContainerCardSkeleton = require("../../../common/ui/team-containers-skeleton/linked-container-card-skeleton");
20
20
  var _getContainerProperties = require("../../../common/utils/get-container-properties");
21
+ var _addContainerCardButton = require("./add-container-card-button");
21
22
  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); }
22
23
  var styles = {
23
24
  card: "_4cvr1h6o _1bsb1osq",
@@ -49,7 +50,9 @@ var AddContainerCard = exports.AddContainerCard = function AddContainerCard(_ref
49
50
  var containerType = _ref2.containerType,
50
51
  onAddAContainerClick = _ref2.onAddAContainerClick,
51
52
  _ref2$isLoading = _ref2.isLoading,
52
- isLoading = _ref2$isLoading === void 0 ? false : _ref2$isLoading;
53
+ isLoading = _ref2$isLoading === void 0 ? false : _ref2$isLoading,
54
+ _ref2$showNewDesign = _ref2.showNewDesign,
55
+ showNewDesign = _ref2$showNewDesign === void 0 ? false : _ref2$showNewDesign;
53
56
  var _getContainerProperti = (0, _getContainerProperties.getContainerProperties)({
54
57
  containerType: containerType,
55
58
  iconSize: (0, _platformFeatureFlags.fg)('enable_medium_size_icons_for_team_link_cards') ? 'medium' : undefined,
@@ -83,7 +86,9 @@ var AddContainerCard = exports.AddContainerCard = function AddContainerCard(_ref
83
86
  onAddAContainerClick(e);
84
87
  e.stopPropagation();
85
88
  }
86
- })), /*#__PURE__*/_react.default.createElement(_compiled.Stack, (0, _platformFeatureFlags.fg)('enable_medium_size_icons_for_team_link_cards') ? {
89
+ })), showNewDesign ? /*#__PURE__*/_react.default.createElement(_addContainerCardButton.AddContainerCardButton, {
90
+ type: containerType
91
+ }) : /*#__PURE__*/_react.default.createElement(_compiled.Stack, (0, _platformFeatureFlags.fg)('enable_medium_size_icons_for_team_link_cards') ? {
87
92
  space: 'space.025'
88
93
  } : {}, /*#__PURE__*/_react.default.createElement(_compiled.Text, {
89
94
  maxLines: 1,
@@ -99,29 +104,34 @@ var AddContainerCard = exports.AddContainerCard = function AddContainerCard(_ref
99
104
  };
100
105
  var getAddContainerCards = exports.getAddContainerCards = function getAddContainerCards(_ref3) {
101
106
  var containers = _ref3.containers,
102
- _onAddAContainerClick = _ref3.onAddAContainerClick;
107
+ _onAddAContainerClick = _ref3.onAddAContainerClick,
108
+ showNewDesign = _ref3.showNewDesign;
103
109
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, containers.Jira.canAdd && /*#__PURE__*/_react.default.createElement(AddContainerCard, {
104
110
  onAddAContainerClick: function onAddAContainerClick(e) {
105
111
  return _onAddAContainerClick(e, 'Jira');
106
112
  },
107
113
  containerType: "JiraProject",
108
- isLoading: containers.Jira.isLoading
114
+ isLoading: containers.Jira.isLoading,
115
+ showNewDesign: showNewDesign
109
116
  }), containers.Confluence.canAdd && /*#__PURE__*/_react.default.createElement(AddContainerCard, {
110
117
  onAddAContainerClick: function onAddAContainerClick(e) {
111
118
  return _onAddAContainerClick(e, 'Confluence');
112
119
  },
113
120
  containerType: "ConfluenceSpace",
114
- isLoading: containers.Confluence.isLoading
121
+ isLoading: containers.Confluence.isLoading,
122
+ showNewDesign: showNewDesign
115
123
  }), containers.Loom.canAdd && (0, _platformFeatureFlags.fg)('loom_tab_in_container_linker_team_profile_page') && /*#__PURE__*/_react.default.createElement(AddContainerCard, {
116
124
  onAddAContainerClick: function onAddAContainerClick(e) {
117
125
  return _onAddAContainerClick(e, 'Loom');
118
126
  },
119
127
  containerType: "LoomSpace",
120
- isLoading: containers.Loom.isLoading
128
+ isLoading: containers.Loom.isLoading,
129
+ showNewDesign: showNewDesign
121
130
  }), containers.WebLink.canAdd && /*#__PURE__*/_react.default.createElement(AddContainerCard, {
122
131
  onAddAContainerClick: function onAddAContainerClick(e) {
123
132
  return _onAddAContainerClick(e, 'WebLink');
124
133
  },
125
- containerType: "WebLink"
134
+ containerType: "WebLink",
135
+ showNewDesign: showNewDesign
126
136
  }));
127
137
  };
@@ -14,6 +14,7 @@ var _react = _interopRequireWildcard(require("react"));
14
14
  var _reactIntlNext = require("react-intl-next");
15
15
  var _analyticsNext = require("@atlaskit/analytics-next");
16
16
  var _new = _interopRequireDefault(require("@atlaskit/button/new"));
17
+ var _featureGateJsClient = _interopRequireDefault(require("@atlaskit/feature-gate-js-client"));
17
18
  var _modalTransition = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-transition"));
18
19
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
20
  var _primitives = require("@atlaskit/primitives");
@@ -146,6 +147,16 @@ var TeamContainers = exports.TeamContainers = function TeamContainers(_ref) {
146
147
  productPermissionsOld = _useProductPermission2.data,
147
148
  productPermissionIsLoadingOld = _useProductPermission2.loading;
148
149
  useRefreshOnContainerCreated(teamId);
150
+ var hasPermissionToCreateContainer = (0, _react.useMemo)(function () {
151
+ if (!productPermissions) {
152
+ return {};
153
+ }
154
+ var getPermission = function getPermission(product, permission) {
155
+ return productPermissions && (0, _teamsAppInternalProductPermissions.hasProductPermission)(productPermissions, product, permission);
156
+ };
157
+ return getPermission('confluence', ['CREATE_SPACE']) || getPermission('jira', ['CREATE_PROJECT']) || getPermission('loom', ['write']);
158
+ }, [productPermissions]);
159
+ var createContainerExperimentEnabled = hasPermissionToCreateContainer && _featureGateJsClient.default.initializeCompleted() && _featureGateJsClient.default.getExperimentValue('teams_app_auto_container_creation', 'isEnabled', false);
149
160
  (0, _react.useEffect)(function () {
150
161
  if (isDisplayedOnProfileCard && filterContainerId) {
151
162
  setFilteredTeamLinks(teamLinks.filter(function (container) {
@@ -332,7 +343,8 @@ var TeamContainers = exports.TeamContainers = function TeamContainers(_ref) {
332
343
  });
333
344
  }), (0, _addContainerCard.getAddContainerCards)({
334
345
  containers: availableContainers,
335
- onAddAContainerClick: onAddAContainerClick
346
+ onAddAContainerClick: onAddAContainerClick,
347
+ showNewDesign: createContainerExperimentEnabled
336
348
  }), showMore && filteredTeamLinks.slice(maxNumberOfContainersToShow).map(function (container) {
337
349
  return /*#__PURE__*/_react.default.createElement(LinkedContainerCardComponent, {
338
350
  key: container.id,
@@ -5,10 +5,14 @@ const actions = {
5
5
  getState
6
6
  }) => {
7
7
  const containers = getState();
8
+ const current = containers[product];
9
+ if (current.isLoading === isLoading) {
10
+ return;
11
+ }
8
12
  setState({
9
13
  ...containers,
10
14
  [product]: {
11
- ...containers[product],
15
+ ...current,
12
16
  isLoading
13
17
  }
14
18
  });
@@ -18,11 +22,17 @@ const actions = {
18
22
  getState
19
23
  }) => {
20
24
  const containers = getState();
25
+ const current = containers[product];
26
+ if (current.isCreated === isCreated) {
27
+ return;
28
+ }
29
+ const isLoading = isCreated ? false : current.isLoading;
21
30
  setState({
22
31
  ...containers,
23
32
  [product]: {
24
- ...containers[product],
25
- isCreated
33
+ ...current,
34
+ isCreated,
35
+ isLoading
26
36
  }
27
37
  });
28
38
  }
@@ -0,0 +1,89 @@
1
+ import React from 'react';
2
+ import { defineMessages, FormattedMessage } from 'react-intl-next';
3
+ import { Flex, Stack, Text } from '@atlaskit/primitives/compiled';
4
+ function AddContainerCardButton({
5
+ type
6
+ }) {
7
+ const {
8
+ title,
9
+ description
10
+ } = getContainerProperties(type);
11
+ return /*#__PURE__*/React.createElement(Stack, null, /*#__PURE__*/React.createElement(Text, {
12
+ maxLines: 1,
13
+ weight: "medium",
14
+ color: "color.text"
15
+ }, title), /*#__PURE__*/React.createElement(Flex, {
16
+ gap: "space.050",
17
+ alignItems: "center"
18
+ }, /*#__PURE__*/React.createElement(Text, {
19
+ size: "small",
20
+ color: "color.text.subtle"
21
+ }, description)));
22
+ }
23
+ function getContainerProperties(type) {
24
+ switch (type) {
25
+ case 'ConfluenceSpace':
26
+ return {
27
+ description: /*#__PURE__*/React.createElement(FormattedMessage, messages.confluenceContainerDescription),
28
+ title: /*#__PURE__*/React.createElement(FormattedMessage, messages.addConfluenceContainerTitle)
29
+ };
30
+ case 'LoomSpace':
31
+ return {
32
+ description: /*#__PURE__*/React.createElement(FormattedMessage, messages.loomSpaceDescription),
33
+ title: /*#__PURE__*/React.createElement(FormattedMessage, messages.addLoomContainerTitle)
34
+ };
35
+ case 'JiraProject':
36
+ return {
37
+ description: /*#__PURE__*/React.createElement(FormattedMessage, messages.jiraProjectDescription),
38
+ title: /*#__PURE__*/React.createElement(FormattedMessage, messages.addJiraProjectTitle)
39
+ };
40
+ case 'WebLink':
41
+ return {
42
+ description: null,
43
+ title: /*#__PURE__*/React.createElement(FormattedMessage, messages.addWebLinkTitle)
44
+ };
45
+ default:
46
+ return {
47
+ description: null,
48
+ title: null
49
+ };
50
+ }
51
+ }
52
+ const messages = defineMessages({
53
+ addConfluenceContainerTitle: {
54
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-confluence-space-title',
55
+ defaultMessage: 'Confluence space',
56
+ description: 'Title of the card to add a Confluence space to a team'
57
+ },
58
+ confluenceContainerDescription: {
59
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-confluence-space-description',
60
+ defaultMessage: 'Create a knowledge bank',
61
+ description: 'Description of the card to add a Confluence space to a team'
62
+ },
63
+ addLoomContainerTitle: {
64
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-loom-space-title',
65
+ defaultMessage: 'Loom space',
66
+ description: 'Title of the card to add a Loom space to a team'
67
+ },
68
+ loomSpaceDescription: {
69
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-loom-space-description',
70
+ defaultMessage: 'Share async updates',
71
+ description: 'Description of the card to add a Loom space to a team'
72
+ },
73
+ addJiraProjectTitle: {
74
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-jira-project-title',
75
+ defaultMessage: 'Jira project',
76
+ description: 'Title of the card to add a Jira project to a team'
77
+ },
78
+ jiraProjectDescription: {
79
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-jira-project-description',
80
+ defaultMessage: 'Plan out project tasks',
81
+ description: 'Description of the card to add a Jira project to a team'
82
+ },
83
+ addWebLinkTitle: {
84
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-web-link-title',
85
+ defaultMessage: 'Add any web link',
86
+ description: 'Title of the card to add a any web link to a team'
87
+ }
88
+ });
89
+ export { AddContainerCardButton };
@@ -9,6 +9,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import { Box, Flex, Inline, Stack, Text } from '@atlaskit/primitives/compiled';
10
10
  import { LinkedContainerCardSkeleton } from '../../../common/ui/team-containers-skeleton/linked-container-card-skeleton';
11
11
  import { getContainerProperties } from '../../../common/utils/get-container-properties';
12
+ import { AddContainerCardButton } from './add-container-card-button';
12
13
  const styles = {
13
14
  card: "_4cvr1h6o _1bsb1osq",
14
15
  container: "_2rkoop52 _ca0qutpp _u5f3utpp _n3tdutpp _19bvutpp _d0altlke",
@@ -32,7 +33,8 @@ const AddContainerCardWrapper = ({
32
33
  export const AddContainerCard = ({
33
34
  containerType,
34
35
  onAddAContainerClick,
35
- isLoading = false
36
+ isLoading = false,
37
+ showNewDesign = false
36
38
  }) => {
37
39
  const {
38
40
  description,
@@ -66,7 +68,9 @@ export const AddContainerCard = ({
66
68
  onAddAContainerClick(e);
67
69
  e.stopPropagation();
68
70
  }
69
- })), /*#__PURE__*/React.createElement(Stack, fg('enable_medium_size_icons_for_team_link_cards') ? {
71
+ })), showNewDesign ? /*#__PURE__*/React.createElement(AddContainerCardButton, {
72
+ type: containerType
73
+ }) : /*#__PURE__*/React.createElement(Stack, fg('enable_medium_size_icons_for_team_link_cards') ? {
70
74
  space: 'space.025'
71
75
  } : {}, /*#__PURE__*/React.createElement(Text, {
72
76
  maxLines: 1,
@@ -82,22 +86,27 @@ export const AddContainerCard = ({
82
86
  };
83
87
  export const getAddContainerCards = ({
84
88
  containers,
85
- onAddAContainerClick
89
+ onAddAContainerClick,
90
+ showNewDesign
86
91
  }) => {
87
92
  return /*#__PURE__*/React.createElement(React.Fragment, null, containers.Jira.canAdd && /*#__PURE__*/React.createElement(AddContainerCard, {
88
93
  onAddAContainerClick: e => onAddAContainerClick(e, 'Jira'),
89
94
  containerType: "JiraProject",
90
- isLoading: containers.Jira.isLoading
95
+ isLoading: containers.Jira.isLoading,
96
+ showNewDesign: showNewDesign
91
97
  }), containers.Confluence.canAdd && /*#__PURE__*/React.createElement(AddContainerCard, {
92
98
  onAddAContainerClick: e => onAddAContainerClick(e, 'Confluence'),
93
99
  containerType: "ConfluenceSpace",
94
- isLoading: containers.Confluence.isLoading
100
+ isLoading: containers.Confluence.isLoading,
101
+ showNewDesign: showNewDesign
95
102
  }), containers.Loom.canAdd && fg('loom_tab_in_container_linker_team_profile_page') && /*#__PURE__*/React.createElement(AddContainerCard, {
96
103
  onAddAContainerClick: e => onAddAContainerClick(e, 'Loom'),
97
104
  containerType: "LoomSpace",
98
- isLoading: containers.Loom.isLoading
105
+ isLoading: containers.Loom.isLoading,
106
+ showNewDesign: showNewDesign
99
107
  }), containers.WebLink.canAdd && /*#__PURE__*/React.createElement(AddContainerCard, {
100
108
  onAddAContainerClick: e => onAddAContainerClick(e, 'WebLink'),
101
- containerType: "WebLink"
109
+ containerType: "WebLink",
110
+ showNewDesign: showNewDesign
102
111
  }));
103
112
  };
@@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import { defineMessages, FormattedMessage } from 'react-intl-next';
3
3
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
4
  import Button from '@atlaskit/button/new';
5
+ import FeatureGates from '@atlaskit/feature-gate-js-client';
5
6
  import ModalTransition from '@atlaskit/modal-dialog/modal-transition';
6
7
  import { fg } from '@atlaskit/platform-feature-flags';
7
8
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
@@ -115,6 +116,16 @@ export const TeamContainers = ({
115
116
  enabled: !fg('migrate-product-permissions')
116
117
  });
117
118
  useRefreshOnContainerCreated(teamId);
119
+ const hasPermissionToCreateContainer = useMemo(() => {
120
+ if (!productPermissions) {
121
+ return {};
122
+ }
123
+ const getPermission = (product, permission) => {
124
+ return productPermissions && hasProductPermission(productPermissions, product, permission);
125
+ };
126
+ return getPermission('confluence', ['CREATE_SPACE']) || getPermission('jira', ['CREATE_PROJECT']) || getPermission('loom', ['write']);
127
+ }, [productPermissions]);
128
+ const createContainerExperimentEnabled = hasPermissionToCreateContainer && FeatureGates.initializeCompleted() && FeatureGates.getExperimentValue('teams_app_auto_container_creation', 'isEnabled', false);
118
129
  useEffect(() => {
119
130
  if (isDisplayedOnProfileCard && filterContainerId) {
120
131
  setFilteredTeamLinks(teamLinks.filter(container => container.id !== filterContainerId && !requestedContainers.includes(container.type)));
@@ -265,7 +276,8 @@ export const TeamContainers = ({
265
276
  });
266
277
  }), getAddContainerCards({
267
278
  containers: availableContainers,
268
- onAddAContainerClick: onAddAContainerClick
279
+ onAddAContainerClick: onAddAContainerClick,
280
+ showNewDesign: createContainerExperimentEnabled
269
281
  }), showMore && filteredTeamLinks.slice(maxNumberOfContainersToShow).map(container => {
270
282
  return /*#__PURE__*/React.createElement(LinkedContainerCardComponent, {
271
283
  key: container.id,
@@ -8,7 +8,11 @@ var actions = {
8
8
  var setState = _ref.setState,
9
9
  getState = _ref.getState;
10
10
  var containers = getState();
11
- setState(_objectSpread(_objectSpread({}, containers), {}, _defineProperty({}, product, _objectSpread(_objectSpread({}, containers[product]), {}, {
11
+ var current = containers[product];
12
+ if (current.isLoading === isLoading) {
13
+ return;
14
+ }
15
+ setState(_objectSpread(_objectSpread({}, containers), {}, _defineProperty({}, product, _objectSpread(_objectSpread({}, current), {}, {
12
16
  isLoading: isLoading
13
17
  }))));
14
18
  };
@@ -18,8 +22,14 @@ var actions = {
18
22
  var setState = _ref2.setState,
19
23
  getState = _ref2.getState;
20
24
  var containers = getState();
21
- setState(_objectSpread(_objectSpread({}, containers), {}, _defineProperty({}, product, _objectSpread(_objectSpread({}, containers[product]), {}, {
22
- isCreated: isCreated
25
+ var current = containers[product];
26
+ if (current.isCreated === isCreated) {
27
+ return;
28
+ }
29
+ var isLoading = isCreated ? false : current.isLoading;
30
+ setState(_objectSpread(_objectSpread({}, containers), {}, _defineProperty({}, product, _objectSpread(_objectSpread({}, current), {}, {
31
+ isCreated: isCreated,
32
+ isLoading: isLoading
23
33
  }))));
24
34
  };
25
35
  }
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+ import { defineMessages, FormattedMessage } from 'react-intl-next';
3
+ import { Flex, Stack, Text } from '@atlaskit/primitives/compiled';
4
+ function AddContainerCardButton(_ref) {
5
+ var type = _ref.type;
6
+ var _getContainerProperti = getContainerProperties(type),
7
+ title = _getContainerProperti.title,
8
+ description = _getContainerProperti.description;
9
+ return /*#__PURE__*/React.createElement(Stack, null, /*#__PURE__*/React.createElement(Text, {
10
+ maxLines: 1,
11
+ weight: "medium",
12
+ color: "color.text"
13
+ }, title), /*#__PURE__*/React.createElement(Flex, {
14
+ gap: "space.050",
15
+ alignItems: "center"
16
+ }, /*#__PURE__*/React.createElement(Text, {
17
+ size: "small",
18
+ color: "color.text.subtle"
19
+ }, description)));
20
+ }
21
+ function getContainerProperties(type) {
22
+ switch (type) {
23
+ case 'ConfluenceSpace':
24
+ return {
25
+ description: /*#__PURE__*/React.createElement(FormattedMessage, messages.confluenceContainerDescription),
26
+ title: /*#__PURE__*/React.createElement(FormattedMessage, messages.addConfluenceContainerTitle)
27
+ };
28
+ case 'LoomSpace':
29
+ return {
30
+ description: /*#__PURE__*/React.createElement(FormattedMessage, messages.loomSpaceDescription),
31
+ title: /*#__PURE__*/React.createElement(FormattedMessage, messages.addLoomContainerTitle)
32
+ };
33
+ case 'JiraProject':
34
+ return {
35
+ description: /*#__PURE__*/React.createElement(FormattedMessage, messages.jiraProjectDescription),
36
+ title: /*#__PURE__*/React.createElement(FormattedMessage, messages.addJiraProjectTitle)
37
+ };
38
+ case 'WebLink':
39
+ return {
40
+ description: null,
41
+ title: /*#__PURE__*/React.createElement(FormattedMessage, messages.addWebLinkTitle)
42
+ };
43
+ default:
44
+ return {
45
+ description: null,
46
+ title: null
47
+ };
48
+ }
49
+ }
50
+ var messages = defineMessages({
51
+ addConfluenceContainerTitle: {
52
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-confluence-space-title',
53
+ defaultMessage: 'Confluence space',
54
+ description: 'Title of the card to add a Confluence space to a team'
55
+ },
56
+ confluenceContainerDescription: {
57
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-confluence-space-description',
58
+ defaultMessage: 'Create a knowledge bank',
59
+ description: 'Description of the card to add a Confluence space to a team'
60
+ },
61
+ addLoomContainerTitle: {
62
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-loom-space-title',
63
+ defaultMessage: 'Loom space',
64
+ description: 'Title of the card to add a Loom space to a team'
65
+ },
66
+ loomSpaceDescription: {
67
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-loom-space-description',
68
+ defaultMessage: 'Share async updates',
69
+ description: 'Description of the card to add a Loom space to a team'
70
+ },
71
+ addJiraProjectTitle: {
72
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-jira-project-title',
73
+ defaultMessage: 'Jira project',
74
+ description: 'Title of the card to add a Jira project to a team'
75
+ },
76
+ jiraProjectDescription: {
77
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-jira-project-description',
78
+ defaultMessage: 'Plan out project tasks',
79
+ description: 'Description of the card to add a Jira project to a team'
80
+ },
81
+ addWebLinkTitle: {
82
+ id: 'ptc-directory.team-profile-page.team-containers.create.add-web-link-title',
83
+ defaultMessage: 'Add any web link',
84
+ description: 'Title of the card to add a any web link to a team'
85
+ }
86
+ });
87
+ export { AddContainerCardButton };
@@ -10,6 +10,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
10
10
  import { Box, Flex, Inline, Stack, Text } from '@atlaskit/primitives/compiled';
11
11
  import { LinkedContainerCardSkeleton } from '../../../common/ui/team-containers-skeleton/linked-container-card-skeleton';
12
12
  import { getContainerProperties } from '../../../common/utils/get-container-properties';
13
+ import { AddContainerCardButton } from './add-container-card-button';
13
14
  var styles = {
14
15
  card: "_4cvr1h6o _1bsb1osq",
15
16
  container: "_2rkoop52 _ca0qutpp _u5f3utpp _n3tdutpp _19bvutpp _d0altlke",
@@ -40,7 +41,9 @@ export var AddContainerCard = function AddContainerCard(_ref2) {
40
41
  var containerType = _ref2.containerType,
41
42
  onAddAContainerClick = _ref2.onAddAContainerClick,
42
43
  _ref2$isLoading = _ref2.isLoading,
43
- isLoading = _ref2$isLoading === void 0 ? false : _ref2$isLoading;
44
+ isLoading = _ref2$isLoading === void 0 ? false : _ref2$isLoading,
45
+ _ref2$showNewDesign = _ref2.showNewDesign,
46
+ showNewDesign = _ref2$showNewDesign === void 0 ? false : _ref2$showNewDesign;
44
47
  var _getContainerProperti = getContainerProperties({
45
48
  containerType: containerType,
46
49
  iconSize: fg('enable_medium_size_icons_for_team_link_cards') ? 'medium' : undefined,
@@ -74,7 +77,9 @@ export var AddContainerCard = function AddContainerCard(_ref2) {
74
77
  onAddAContainerClick(e);
75
78
  e.stopPropagation();
76
79
  }
77
- })), /*#__PURE__*/React.createElement(Stack, fg('enable_medium_size_icons_for_team_link_cards') ? {
80
+ })), showNewDesign ? /*#__PURE__*/React.createElement(AddContainerCardButton, {
81
+ type: containerType
82
+ }) : /*#__PURE__*/React.createElement(Stack, fg('enable_medium_size_icons_for_team_link_cards') ? {
78
83
  space: 'space.025'
79
84
  } : {}, /*#__PURE__*/React.createElement(Text, {
80
85
  maxLines: 1,
@@ -90,29 +95,34 @@ export var AddContainerCard = function AddContainerCard(_ref2) {
90
95
  };
91
96
  export var getAddContainerCards = function getAddContainerCards(_ref3) {
92
97
  var containers = _ref3.containers,
93
- _onAddAContainerClick = _ref3.onAddAContainerClick;
98
+ _onAddAContainerClick = _ref3.onAddAContainerClick,
99
+ showNewDesign = _ref3.showNewDesign;
94
100
  return /*#__PURE__*/React.createElement(React.Fragment, null, containers.Jira.canAdd && /*#__PURE__*/React.createElement(AddContainerCard, {
95
101
  onAddAContainerClick: function onAddAContainerClick(e) {
96
102
  return _onAddAContainerClick(e, 'Jira');
97
103
  },
98
104
  containerType: "JiraProject",
99
- isLoading: containers.Jira.isLoading
105
+ isLoading: containers.Jira.isLoading,
106
+ showNewDesign: showNewDesign
100
107
  }), containers.Confluence.canAdd && /*#__PURE__*/React.createElement(AddContainerCard, {
101
108
  onAddAContainerClick: function onAddAContainerClick(e) {
102
109
  return _onAddAContainerClick(e, 'Confluence');
103
110
  },
104
111
  containerType: "ConfluenceSpace",
105
- isLoading: containers.Confluence.isLoading
112
+ isLoading: containers.Confluence.isLoading,
113
+ showNewDesign: showNewDesign
106
114
  }), containers.Loom.canAdd && fg('loom_tab_in_container_linker_team_profile_page') && /*#__PURE__*/React.createElement(AddContainerCard, {
107
115
  onAddAContainerClick: function onAddAContainerClick(e) {
108
116
  return _onAddAContainerClick(e, 'Loom');
109
117
  },
110
118
  containerType: "LoomSpace",
111
- isLoading: containers.Loom.isLoading
119
+ isLoading: containers.Loom.isLoading,
120
+ showNewDesign: showNewDesign
112
121
  }), containers.WebLink.canAdd && /*#__PURE__*/React.createElement(AddContainerCard, {
113
122
  onAddAContainerClick: function onAddAContainerClick(e) {
114
123
  return _onAddAContainerClick(e, 'WebLink');
115
124
  },
116
- containerType: "WebLink"
125
+ containerType: "WebLink",
126
+ showNewDesign: showNewDesign
117
127
  }));
118
128
  };
@@ -8,6 +8,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
8
8
  import { defineMessages, FormattedMessage } from 'react-intl-next';
9
9
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
10
10
  import Button from '@atlaskit/button/new';
11
+ import FeatureGates from '@atlaskit/feature-gate-js-client';
11
12
  import ModalTransition from '@atlaskit/modal-dialog/modal-transition';
12
13
  import { fg } from '@atlaskit/platform-feature-flags';
13
14
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
@@ -138,6 +139,16 @@ export var TeamContainers = function TeamContainers(_ref) {
138
139
  productPermissionsOld = _useProductPermission2.data,
139
140
  productPermissionIsLoadingOld = _useProductPermission2.loading;
140
141
  useRefreshOnContainerCreated(teamId);
142
+ var hasPermissionToCreateContainer = useMemo(function () {
143
+ if (!productPermissions) {
144
+ return {};
145
+ }
146
+ var getPermission = function getPermission(product, permission) {
147
+ return productPermissions && hasProductPermission(productPermissions, product, permission);
148
+ };
149
+ return getPermission('confluence', ['CREATE_SPACE']) || getPermission('jira', ['CREATE_PROJECT']) || getPermission('loom', ['write']);
150
+ }, [productPermissions]);
151
+ var createContainerExperimentEnabled = hasPermissionToCreateContainer && FeatureGates.initializeCompleted() && FeatureGates.getExperimentValue('teams_app_auto_container_creation', 'isEnabled', false);
141
152
  useEffect(function () {
142
153
  if (isDisplayedOnProfileCard && filterContainerId) {
143
154
  setFilteredTeamLinks(teamLinks.filter(function (container) {
@@ -324,7 +335,8 @@ export var TeamContainers = function TeamContainers(_ref) {
324
335
  });
325
336
  }), getAddContainerCards({
326
337
  containers: availableContainers,
327
- onAddAContainerClick: onAddAContainerClick
338
+ onAddAContainerClick: onAddAContainerClick,
339
+ showNewDesign: createContainerExperimentEnabled
328
340
  }), showMore && filteredTeamLinks.slice(maxNumberOfContainersToShow).map(function (container) {
329
341
  return /*#__PURE__*/React.createElement(LinkedContainerCardComponent, {
330
342
  key: container.id,
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { ContainerTypes } from '../../../../common/types';
3
+ declare function AddContainerCardButton({ type }: {
4
+ type: ContainerTypes;
5
+ }): React.JSX.Element;
6
+ export { AddContainerCardButton };
@@ -4,8 +4,9 @@ interface AddContainerCardProps {
4
4
  containerType: ContainerTypes;
5
5
  onAddAContainerClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
6
6
  isLoading?: boolean;
7
+ showNewDesign?: boolean;
7
8
  }
8
- export declare const AddContainerCard: ({ containerType, onAddAContainerClick, isLoading, }: AddContainerCardProps) => React.JSX.Element;
9
+ export declare const AddContainerCard: ({ containerType, onAddAContainerClick, isLoading, showNewDesign, }: AddContainerCardProps) => React.JSX.Element;
9
10
  type Container = {
10
11
  canAdd: boolean;
11
12
  isLoading: boolean;
@@ -18,6 +19,7 @@ type GetAddContainerCardsProps = {
18
19
  WebLink: Container;
19
20
  };
20
21
  onAddAContainerClick: (e: React.MouseEvent<HTMLButtonElement>, containerType: 'Confluence' | 'Jira' | 'Loom' | 'WebLink') => void;
22
+ showNewDesign?: boolean;
21
23
  };
22
- export declare const getAddContainerCards: ({ containers, onAddAContainerClick, }: GetAddContainerCardsProps) => React.JSX.Element;
24
+ export declare const getAddContainerCards: ({ containers, onAddAContainerClick, showNewDesign, }: GetAddContainerCardsProps) => React.JSX.Element;
23
25
  export {};
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { ContainerTypes } from '../../../../common/types';
3
+ declare function AddContainerCardButton({ type }: {
4
+ type: ContainerTypes;
5
+ }): React.JSX.Element;
6
+ export { AddContainerCardButton };
@@ -4,8 +4,9 @@ interface AddContainerCardProps {
4
4
  containerType: ContainerTypes;
5
5
  onAddAContainerClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
6
6
  isLoading?: boolean;
7
+ showNewDesign?: boolean;
7
8
  }
8
- export declare const AddContainerCard: ({ containerType, onAddAContainerClick, isLoading, }: AddContainerCardProps) => React.JSX.Element;
9
+ export declare const AddContainerCard: ({ containerType, onAddAContainerClick, isLoading, showNewDesign, }: AddContainerCardProps) => React.JSX.Element;
9
10
  type Container = {
10
11
  canAdd: boolean;
11
12
  isLoading: boolean;
@@ -18,6 +19,7 @@ type GetAddContainerCardsProps = {
18
19
  WebLink: Container;
19
20
  };
20
21
  onAddAContainerClick: (e: React.MouseEvent<HTMLButtonElement>, containerType: 'Confluence' | 'Jira' | 'Loom' | 'WebLink') => void;
22
+ showNewDesign?: boolean;
21
23
  };
22
- export declare const getAddContainerCards: ({ containers, onAddAContainerClick, }: GetAddContainerCardsProps) => React.JSX.Element;
24
+ export declare const getAddContainerCards: ({ containers, onAddAContainerClick, showNewDesign, }: GetAddContainerCardsProps) => React.JSX.Element;
23
25
  export {};
package/i18n/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "types": "../dist/types/i18n/index.d.ts",
10
10
  "typesVersions": {
11
- ">=4.5 <5.4": {
11
+ ">=4.5 <5.9": {
12
12
  "*": [
13
13
  "../dist/types-ts4.5/i18n/index.d.ts"
14
14
  ]
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "types": "../dist/types/common/ui/loom-avatar/index.d.ts",
10
10
  "typesVersions": {
11
- ">=4.5 <5.4": {
11
+ ">=4.5 <5.9": {
12
12
  "*": [
13
13
  "../dist/types-ts4.5/common/ui/loom-avatar/index.d.ts"
14
14
  ]
package/package.json CHANGED
@@ -117,7 +117,7 @@
117
117
  }
118
118
  },
119
119
  "name": "@atlaskit/teams-public",
120
- "version": "0.54.0",
120
+ "version": "0.54.2",
121
121
  "description": "Public components related to teams",
122
122
  "author": "Atlassian Pty Ltd",
123
123
  "license": "Apache-2.0",
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "types": "../dist/types/ui/team-containers/index.d.ts",
10
10
  "typesVersions": {
11
- ">=4.5 <5.4": {
11
+ ">=4.5 <5.9": {
12
12
  "*": [
13
13
  "../dist/types-ts4.5/ui/team-containers/index.d.ts"
14
14
  ]