@atlaskit/link-datasource 3.11.1 → 3.12.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/link-datasource
2
2
 
3
+ ## 3.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#166988](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/166988)
8
+ [`0950f1f3c353f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0950f1f3c353f) -
9
+ [ux] EDM-11263 Add UFO metrics to inline-edit icon field
10
+
3
11
  ## 3.11.1
4
12
 
5
13
  ### Patch Changes
@@ -13,7 +13,11 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
13
13
  var _react = _interopRequireWildcard(require("react"));
14
14
  var _linkingTypes = require("@atlaskit/linking-types");
15
15
  var _select = _interopRequireDefault(require("@atlaskit/select"));
16
+ var _ufoExperiences = require("../../../../analytics/ufoExperiences");
17
+ var _datasourceExperienceId = require("../../../../contexts/datasource-experience-id");
18
+ var _useDatasourceTableFlag = require("../../../../hooks/useDatasourceTableFlag");
16
19
  var _icon = require("../../shared-components/icon");
20
+ var _inlineEdit = require("../../table-cell-content/inline-edit");
17
21
  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); }
18
22
  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; }
19
23
  // FilterOptionOption is used in the filterOption function which is part of the public API, but the type itself is not exported
@@ -28,7 +32,23 @@ var IconEditType = function IconEditType(props) {
28
32
  executeFetch = props.executeFetch;
29
33
  var _usePriorityOptions = usePriorityOptions(currentValue, executeFetch),
30
34
  options = _usePriorityOptions.options,
31
- isLoading = _usePriorityOptions.isLoading;
35
+ isLoading = _usePriorityOptions.isLoading,
36
+ hasFailed = _usePriorityOptions.hasFailed;
37
+ var experienceId = (0, _datasourceExperienceId.useDatasourceExperienceId)();
38
+ (0, _react.useEffect)(function () {
39
+ if (!experienceId) {
40
+ return;
41
+ }
42
+ if (hasFailed) {
43
+ (0, _ufoExperiences.failUfoExperience)({
44
+ name: _inlineEdit.InlineEditUFOExperience
45
+ }, experienceId);
46
+ } else if (!isLoading) {
47
+ (0, _ufoExperiences.succeedUfoExperience)({
48
+ name: _inlineEdit.InlineEditUFOExperience
49
+ }, experienceId);
50
+ }
51
+ }, [experienceId, isLoading, hasFailed]);
32
52
  return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_select.default, (0, _extends2.default)({}, props, {
33
53
  testId: "inline-edit-priority",
34
54
  autoFocus: true,
@@ -66,30 +86,45 @@ var filterOption = function filterOption(option, inputValue) {
66
86
  var usePriorityOptions = function usePriorityOptions(currentValue, executeFetch) {
67
87
  var _useState = (0, _react.useState)({
68
88
  isLoading: true,
69
- options: []
89
+ options: [],
90
+ hasFailed: false
70
91
  }),
71
92
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
72
93
  _useState2$ = _useState2[0],
73
94
  options = _useState2$.options,
74
95
  isLoading = _useState2$.isLoading,
96
+ hasFailed = _useState2$.hasFailed,
75
97
  setOptions = _useState2[1];
98
+ var _useDatasourceTableFl = (0, _useDatasourceTableFlag.useDatasourceTableFlag)({
99
+ isFetchAction: true
100
+ }),
101
+ showErrorFlag = _useDatasourceTableFl.showErrorFlag;
76
102
  (0, _react.useEffect)(function () {
77
103
  var isMounted = true;
78
104
  loadOptions(currentValue, executeFetch).then(function (options) {
79
105
  if (isMounted) {
80
106
  setOptions({
81
107
  isLoading: false,
82
- options: options
108
+ options: options,
109
+ hasFailed: false
83
110
  });
84
111
  }
112
+ }).catch(function (err) {
113
+ showErrorFlag();
114
+ setOptions({
115
+ isLoading: false,
116
+ options: [],
117
+ hasFailed: true
118
+ });
85
119
  });
86
120
  return function () {
87
121
  isMounted = false;
88
122
  };
89
- }, [currentValue, executeFetch]);
123
+ }, [currentValue, executeFetch, showErrorFlag]);
90
124
  return {
91
125
  options: options,
92
- isLoading: isLoading
126
+ isLoading: isLoading,
127
+ hasFailed: hasFailed
93
128
  };
94
129
  };
95
130
 
@@ -114,14 +149,20 @@ var loadOptions = /*#__PURE__*/function () {
114
149
  _yield$executeFetch = _context.sent;
115
150
  operationStatus = _yield$executeFetch.operationStatus;
116
151
  entities = _yield$executeFetch.entities;
117
- if (!(operationStatus === _linkingTypes.ActionOperationStatus.SUCCESS && entities)) {
152
+ if (!(operationStatus === _linkingTypes.ActionOperationStatus.FAILURE)) {
118
153
  _context.next = 9;
119
154
  break;
120
155
  }
121
- return _context.abrupt("return", entities);
156
+ throw new Error('Failed to fetch icon options');
122
157
  case 9:
158
+ if (!(operationStatus === _linkingTypes.ActionOperationStatus.SUCCESS && entities)) {
159
+ _context.next = 11;
160
+ break;
161
+ }
162
+ return _context.abrupt("return", entities);
163
+ case 11:
123
164
  return _context.abrupt("return", []);
124
- case 10:
165
+ case 12:
125
166
  case "end":
126
167
  return _context.stop();
127
168
  }
@@ -5,7 +5,11 @@ import { ActionOperationStatus } from '@atlaskit/linking-types';
5
5
  // eslint-disable-next-line import/no-extraneous-dependencies,no-restricted-imports
6
6
 
7
7
  import Select from '@atlaskit/select';
8
+ import { failUfoExperience, succeedUfoExperience } from '../../../../analytics/ufoExperiences';
9
+ import { useDatasourceExperienceId } from '../../../../contexts/datasource-experience-id';
10
+ import { useDatasourceTableFlag } from '../../../../hooks/useDatasourceTableFlag';
8
11
  import { SharedIconComponent } from '../../shared-components/icon';
12
+ import { InlineEditUFOExperience } from '../../table-cell-content/inline-edit';
9
13
  /**
10
14
  * Should be gated by FF rollout of platform-datasources-enable-two-way-sync-priority
11
15
  */
@@ -17,8 +21,24 @@ const IconEditType = props => {
17
21
  } = props;
18
22
  const {
19
23
  options,
20
- isLoading
24
+ isLoading,
25
+ hasFailed
21
26
  } = usePriorityOptions(currentValue, executeFetch);
27
+ const experienceId = useDatasourceExperienceId();
28
+ useEffect(() => {
29
+ if (!experienceId) {
30
+ return;
31
+ }
32
+ if (hasFailed) {
33
+ failUfoExperience({
34
+ name: InlineEditUFOExperience
35
+ }, experienceId);
36
+ } else if (!isLoading) {
37
+ succeedUfoExperience({
38
+ name: InlineEditUFOExperience
39
+ }, experienceId);
40
+ }
41
+ }, [experienceId, isLoading, hasFailed]);
22
42
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Select, _extends({}, props, {
23
43
  testId: "inline-edit-priority",
24
44
  autoFocus: true,
@@ -49,10 +69,17 @@ const filterOption = (option, inputValue) => option.label.toLowerCase().includes
49
69
  const usePriorityOptions = (currentValue, executeFetch) => {
50
70
  const [{
51
71
  options,
52
- isLoading
72
+ isLoading,
73
+ hasFailed
53
74
  }, setOptions] = useState({
54
75
  isLoading: true,
55
- options: []
76
+ options: [],
77
+ hasFailed: false
78
+ });
79
+ const {
80
+ showErrorFlag
81
+ } = useDatasourceTableFlag({
82
+ isFetchAction: true
56
83
  });
57
84
  useEffect(() => {
58
85
  let isMounted = true;
@@ -60,17 +87,26 @@ const usePriorityOptions = (currentValue, executeFetch) => {
60
87
  if (isMounted) {
61
88
  setOptions({
62
89
  isLoading: false,
63
- options
90
+ options,
91
+ hasFailed: false
64
92
  });
65
93
  }
94
+ }).catch(err => {
95
+ showErrorFlag();
96
+ setOptions({
97
+ isLoading: false,
98
+ options: [],
99
+ hasFailed: true
100
+ });
66
101
  });
67
102
  return () => {
68
103
  isMounted = false;
69
104
  };
70
- }, [currentValue, executeFetch]);
105
+ }, [currentValue, executeFetch, showErrorFlag]);
71
106
  return {
72
107
  options,
73
- isLoading
108
+ isLoading,
109
+ hasFailed
74
110
  };
75
111
  };
76
112
 
@@ -85,6 +121,9 @@ const loadOptions = async (_currentValue, executeFetch) => {
85
121
  operationStatus,
86
122
  entities
87
123
  } = await executeFetch({});
124
+ if (operationStatus === ActionOperationStatus.FAILURE) {
125
+ throw new Error('Failed to fetch icon options');
126
+ }
88
127
  if (operationStatus === ActionOperationStatus.SUCCESS && entities) {
89
128
  // Map entities here if the backend type is different from the type required by the select
90
129
  return entities;
@@ -8,7 +8,11 @@ import { ActionOperationStatus } from '@atlaskit/linking-types';
8
8
  // eslint-disable-next-line import/no-extraneous-dependencies,no-restricted-imports
9
9
 
10
10
  import Select from '@atlaskit/select';
11
+ import { failUfoExperience, succeedUfoExperience } from '../../../../analytics/ufoExperiences';
12
+ import { useDatasourceExperienceId } from '../../../../contexts/datasource-experience-id';
13
+ import { useDatasourceTableFlag } from '../../../../hooks/useDatasourceTableFlag';
11
14
  import { SharedIconComponent } from '../../shared-components/icon';
15
+ import { InlineEditUFOExperience } from '../../table-cell-content/inline-edit';
12
16
  /**
13
17
  * Should be gated by FF rollout of platform-datasources-enable-two-way-sync-priority
14
18
  */
@@ -18,7 +22,23 @@ var IconEditType = function IconEditType(props) {
18
22
  executeFetch = props.executeFetch;
19
23
  var _usePriorityOptions = usePriorityOptions(currentValue, executeFetch),
20
24
  options = _usePriorityOptions.options,
21
- isLoading = _usePriorityOptions.isLoading;
25
+ isLoading = _usePriorityOptions.isLoading,
26
+ hasFailed = _usePriorityOptions.hasFailed;
27
+ var experienceId = useDatasourceExperienceId();
28
+ useEffect(function () {
29
+ if (!experienceId) {
30
+ return;
31
+ }
32
+ if (hasFailed) {
33
+ failUfoExperience({
34
+ name: InlineEditUFOExperience
35
+ }, experienceId);
36
+ } else if (!isLoading) {
37
+ succeedUfoExperience({
38
+ name: InlineEditUFOExperience
39
+ }, experienceId);
40
+ }
41
+ }, [experienceId, isLoading, hasFailed]);
22
42
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Select, _extends({}, props, {
23
43
  testId: "inline-edit-priority",
24
44
  autoFocus: true,
@@ -56,30 +76,45 @@ var filterOption = function filterOption(option, inputValue) {
56
76
  var usePriorityOptions = function usePriorityOptions(currentValue, executeFetch) {
57
77
  var _useState = useState({
58
78
  isLoading: true,
59
- options: []
79
+ options: [],
80
+ hasFailed: false
60
81
  }),
61
82
  _useState2 = _slicedToArray(_useState, 2),
62
83
  _useState2$ = _useState2[0],
63
84
  options = _useState2$.options,
64
85
  isLoading = _useState2$.isLoading,
86
+ hasFailed = _useState2$.hasFailed,
65
87
  setOptions = _useState2[1];
88
+ var _useDatasourceTableFl = useDatasourceTableFlag({
89
+ isFetchAction: true
90
+ }),
91
+ showErrorFlag = _useDatasourceTableFl.showErrorFlag;
66
92
  useEffect(function () {
67
93
  var isMounted = true;
68
94
  loadOptions(currentValue, executeFetch).then(function (options) {
69
95
  if (isMounted) {
70
96
  setOptions({
71
97
  isLoading: false,
72
- options: options
98
+ options: options,
99
+ hasFailed: false
73
100
  });
74
101
  }
102
+ }).catch(function (err) {
103
+ showErrorFlag();
104
+ setOptions({
105
+ isLoading: false,
106
+ options: [],
107
+ hasFailed: true
108
+ });
75
109
  });
76
110
  return function () {
77
111
  isMounted = false;
78
112
  };
79
- }, [currentValue, executeFetch]);
113
+ }, [currentValue, executeFetch, showErrorFlag]);
80
114
  return {
81
115
  options: options,
82
- isLoading: isLoading
116
+ isLoading: isLoading,
117
+ hasFailed: hasFailed
83
118
  };
84
119
  };
85
120
 
@@ -104,14 +139,20 @@ var loadOptions = /*#__PURE__*/function () {
104
139
  _yield$executeFetch = _context.sent;
105
140
  operationStatus = _yield$executeFetch.operationStatus;
106
141
  entities = _yield$executeFetch.entities;
107
- if (!(operationStatus === ActionOperationStatus.SUCCESS && entities)) {
142
+ if (!(operationStatus === ActionOperationStatus.FAILURE)) {
108
143
  _context.next = 9;
109
144
  break;
110
145
  }
111
- return _context.abrupt("return", entities);
146
+ throw new Error('Failed to fetch icon options');
112
147
  case 9:
148
+ if (!(operationStatus === ActionOperationStatus.SUCCESS && entities)) {
149
+ _context.next = 11;
150
+ break;
151
+ }
152
+ return _context.abrupt("return", entities);
153
+ case 11:
113
154
  return _context.abrupt("return", []);
114
- case 10:
155
+ case 12:
115
156
  case "end":
116
157
  return _context.stop();
117
158
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "3.11.1",
3
+ "version": "3.12.0",
4
4
  "description": "UI Components to support linking platform dataset feature",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",