@atlaskit/link-datasource 1.0.13 → 1.0.15

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,17 @@
1
1
  # @atlaskit/link-datasource
2
2
 
3
+ ## 1.0.15
4
+
5
+ ### Patch Changes
6
+
7
+ - [`50617191678`](https://bitbucket.org/atlassian/atlassian-frontend/commits/50617191678) - Added button clicked (sync) event into datasources
8
+
9
+ ## 1.0.14
10
+
11
+ ### Patch Changes
12
+
13
+ - [`d2172ba6e25`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d2172ba6e25) - Updated analytics spec with ui events for datasources
14
+
3
15
  ## 1.0.13
4
16
 
5
17
  ### Patch Changes
@@ -52,11 +52,19 @@ var useDatasourceTableState = function useDatasourceTableState(_ref) {
52
52
  _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
53
53
  shouldForceRequest = _useState18[0],
54
54
  setShouldForceRequest = _useState18[1];
55
+ var _useState19 = (0, _react.useState)([]),
56
+ _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
57
+ destinationObjectTypes = _useState20[0],
58
+ setDestinationObjectTypes = _useState20[1];
59
+ var _useState21 = (0, _react.useState)(),
60
+ _useState22 = (0, _slicedToArray2.default)(_useState21, 2),
61
+ extensionKey = _useState22[0],
62
+ setExtensionKey = _useState22[1];
55
63
  var _useDatasourceClientE = (0, _linkClientExtension.useDatasourceClientExtension)(),
56
64
  getDatasourceData = _useDatasourceClientE.getDatasourceData,
57
65
  getDatasourceDetails = _useDatasourceClientE.getDatasourceDetails;
58
66
  var loadDatasourceDetails = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
59
- var _yield$getDatasourceD, access, schema, isColumnNotPresentInCurrentColumnsList, allColumns, newColumns;
67
+ var _yield$getDatasourceD, _yield$getDatasourceD2, access, _destinationObjectTypes, _extensionKey, schema, isColumnNotPresentInCurrentColumnsList, allColumns, newColumns;
60
68
  return _regenerator.default.wrap(function _callee$(_context) {
61
69
  while (1) switch (_context.prev = _context.next) {
62
70
  case 0:
@@ -73,15 +81,20 @@ var useDatasourceTableState = function useDatasourceTableState(_ref) {
73
81
  });
74
82
  case 5:
75
83
  _yield$getDatasourceD = _context.sent;
76
- access = _yield$getDatasourceD.meta.access;
84
+ _yield$getDatasourceD2 = _yield$getDatasourceD.meta;
85
+ access = _yield$getDatasourceD2.access;
86
+ _destinationObjectTypes = _yield$getDatasourceD2.destinationObjectTypes;
87
+ _extensionKey = _yield$getDatasourceD2.extensionKey;
77
88
  schema = _yield$getDatasourceD.data.schema;
78
89
  if (!(access === 'forbidden' || access === 'unauthorized')) {
79
- _context.next = 11;
90
+ _context.next = 14;
80
91
  break;
81
92
  }
82
93
  setStatus('unauthorized');
83
94
  return _context.abrupt("return");
84
- case 11:
95
+ case 14:
96
+ setExtensionKey(_extensionKey);
97
+ setDestinationObjectTypes(_destinationObjectTypes);
85
98
  isColumnNotPresentInCurrentColumnsList = function isColumnNotPresentInCurrentColumnsList(col) {
86
99
  return !columns.find(function (column) {
87
100
  return column.key === col.key;
@@ -90,17 +103,17 @@ var useDatasourceTableState = function useDatasourceTableState(_ref) {
90
103
  allColumns = schema.properties;
91
104
  newColumns = allColumns.filter(isColumnNotPresentInCurrentColumnsList);
92
105
  newColumns.length > 0 && setColumns([].concat((0, _toConsumableArray2.default)(columns), (0, _toConsumableArray2.default)(newColumns)));
93
- _context.next = 20;
106
+ _context.next = 25;
94
107
  break;
95
- case 17:
96
- _context.prev = 17;
108
+ case 22:
109
+ _context.prev = 22;
97
110
  _context.t0 = _context["catch"](2);
98
111
  setStatus('rejected');
99
- case 20:
112
+ case 25:
100
113
  case "end":
101
114
  return _context.stop();
102
115
  }
103
- }, _callee, null, [[2, 17]]);
116
+ }, _callee, null, [[2, 22]]);
104
117
  })), [columns, datasourceId, getDatasourceDetails, parameters]);
105
118
  var applySchemaProperties = (0, _react.useCallback)(function (properties) {
106
119
  if (columns.length === 0) {
@@ -128,9 +141,12 @@ var useDatasourceTableState = function useDatasourceTableState(_ref) {
128
141
  shouldForceRequest,
129
142
  sortedFieldKeys,
130
143
  datasourceDataRequest,
131
- _yield$getDatasourceD2,
132
- access,
133
144
  _yield$getDatasourceD3,
145
+ _yield$getDatasourceD4,
146
+ access,
147
+ _destinationObjectTypes2,
148
+ _extensionKey2,
149
+ _yield$getDatasourceD5,
134
150
  items,
135
151
  nextPageCursor,
136
152
  _totalCount,
@@ -161,20 +177,25 @@ var useDatasourceTableState = function useDatasourceTableState(_ref) {
161
177
  _context2.next = 11;
162
178
  return getDatasourceData(datasourceId, datasourceDataRequest, shouldForceRequest);
163
179
  case 11:
164
- _yield$getDatasourceD2 = _context2.sent;
165
- access = _yield$getDatasourceD2.meta.access;
166
- _yield$getDatasourceD3 = _yield$getDatasourceD2.data;
167
- items = _yield$getDatasourceD3.items;
168
- nextPageCursor = _yield$getDatasourceD3.nextPageCursor;
169
- _totalCount = _yield$getDatasourceD3.totalCount;
170
- schema = _yield$getDatasourceD3.schema;
180
+ _yield$getDatasourceD3 = _context2.sent;
181
+ _yield$getDatasourceD4 = _yield$getDatasourceD3.meta;
182
+ access = _yield$getDatasourceD4.access;
183
+ _destinationObjectTypes2 = _yield$getDatasourceD4.destinationObjectTypes;
184
+ _extensionKey2 = _yield$getDatasourceD4.extensionKey;
185
+ _yield$getDatasourceD5 = _yield$getDatasourceD3.data;
186
+ items = _yield$getDatasourceD5.items;
187
+ nextPageCursor = _yield$getDatasourceD5.nextPageCursor;
188
+ _totalCount = _yield$getDatasourceD5.totalCount;
189
+ schema = _yield$getDatasourceD5.schema;
171
190
  if (!(access === 'forbidden' || access === 'unauthorized')) {
172
- _context2.next = 21;
191
+ _context2.next = 24;
173
192
  break;
174
193
  }
175
194
  setStatus('unauthorized');
176
195
  return _context2.abrupt("return");
177
- case 21:
196
+ case 24:
197
+ setExtensionKey(_extensionKey2);
198
+ setDestinationObjectTypes(_destinationObjectTypes2);
178
199
  setTotalCount(_totalCount);
179
200
  setNextCursor(nextPageCursor);
180
201
  setResponseItems(function (currentResponseItems) {
@@ -191,17 +212,17 @@ var useDatasourceTableState = function useDatasourceTableState(_ref) {
191
212
  if (isSchemaFromData && schema && items.length > 0) {
192
213
  applySchemaProperties(schema.properties);
193
214
  }
194
- _context2.next = 33;
215
+ _context2.next = 38;
195
216
  break;
196
- case 30:
197
- _context2.prev = 30;
217
+ case 35:
218
+ _context2.prev = 35;
198
219
  _context2.t0 = _context2["catch"](8);
199
220
  setStatus('rejected');
200
- case 33:
221
+ case 38:
201
222
  case "end":
202
223
  return _context2.stop();
203
224
  }
204
- }, _callee2, null, [[8, 30]]);
225
+ }, _callee2, null, [[8, 35]]);
205
226
  })), [parameters, fieldKeys, getDatasourceData, datasourceId, nextCursor, applySchemaProperties]);
206
227
  var reset = (0, _react.useCallback)(function (options) {
207
228
  setStatus('empty');
@@ -254,7 +275,9 @@ var useDatasourceTableState = function useDatasourceTableState(_ref) {
254
275
  hasNextPage: hasNextPage,
255
276
  columns: columns,
256
277
  defaultVisibleColumnKeys: defaultVisibleColumnKeys,
257
- totalCount: totalCount
278
+ totalCount: totalCount,
279
+ extensionKey: extensionKey,
280
+ destinationObjectTypes: destinationObjectTypes
258
281
  };
259
282
  };
260
283
  exports.useDatasourceTableState = useDatasourceTableState;
@@ -231,7 +231,7 @@ var analyticsContextAttributes = {
231
231
  };
232
232
  var analyticsContextData = {
233
233
  packageName: "@atlaskit/link-datasource",
234
- packageVersion: "1.0.13",
234
+ packageVersion: "1.0.15",
235
235
  source: 'datasourceConfigModal'
236
236
  };
237
237
  var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.DatasourceTableView = void 0;
8
8
  var _react = require("react");
9
9
  var _react2 = require("@emotion/react");
10
+ var _analyticsNext = require("@atlaskit/analytics-next");
11
+ var _analytics = require("../../analytics");
10
12
  var _useDatasourceTableState = require("../../hooks/useDatasourceTableState");
11
13
  var _accessRequired = require("../common/error-state/access-required");
12
14
  var _loadingError = require("../common/error-state/loading-error");
@@ -16,7 +18,7 @@ var _emptyState = _interopRequireDefault(require("../issue-like-table/empty-stat
16
18
  var _tableFooter = require("../table-footer");
17
19
  /** @jsx jsx */
18
20
 
19
- var DatasourceTableView = function DatasourceTableView(_ref) {
21
+ var DatasourceTableViewWithoutAnalytics = function DatasourceTableViewWithoutAnalytics(_ref) {
20
22
  var datasourceId = _ref.datasourceId,
21
23
  parameters = _ref.parameters,
22
24
  visibleColumnKeys = _ref.visibleColumnKeys,
@@ -34,7 +36,12 @@ var DatasourceTableView = function DatasourceTableView(_ref) {
34
36
  columns = _useDatasourceTableSt.columns,
35
37
  defaultVisibleColumnKeys = _useDatasourceTableSt.defaultVisibleColumnKeys,
36
38
  totalCount = _useDatasourceTableSt.totalCount,
37
- loadDatasourceDetails = _useDatasourceTableSt.loadDatasourceDetails;
39
+ loadDatasourceDetails = _useDatasourceTableSt.loadDatasourceDetails,
40
+ _useDatasourceTableSt2 = _useDatasourceTableSt.extensionKey,
41
+ extensionKey = _useDatasourceTableSt2 === void 0 ? null : _useDatasourceTableSt2,
42
+ destinationObjectTypes = _useDatasourceTableSt.destinationObjectTypes;
43
+ var _useDatasourceAnalyti = (0, _analytics.useDatasourceAnalyticsEvents)(),
44
+ fireEvent = _useDatasourceAnalyti.fireEvent;
38
45
 
39
46
  /* Need this to make sure that the datasource in the editor gets updated new info if any edits are made in the modal
40
47
  But we don't want to call it on initial load. This screws up useDatasourceTableState's internal
@@ -53,10 +60,14 @@ var DatasourceTableView = function DatasourceTableView(_ref) {
53
60
  }
54
61
  }, [visibleColumnKeys, defaultVisibleColumnKeys, onVisibleColumnKeysChange]);
55
62
  var forcedReset = (0, _react.useCallback)(function () {
63
+ fireEvent('ui.button.clicked.sync', {
64
+ extensionKey: extensionKey,
65
+ destinationObjectTypes: destinationObjectTypes
66
+ });
56
67
  reset({
57
68
  shouldForceRequest: true
58
69
  });
59
- }, [reset]);
70
+ }, [destinationObjectTypes, extensionKey, fireEvent, reset]);
60
71
  if (status === 'resolved' && !responseItems.length) {
61
72
  return (0, _react2.jsx)(_noResults.NoResults, {
62
73
  onRefresh: reset
@@ -97,4 +108,9 @@ var DatasourceTableView = function DatasourceTableView(_ref) {
97
108
  }))
98
109
  );
99
110
  };
111
+ var analyticsContextData = {
112
+ packageName: "@atlaskit/link-datasource",
113
+ packageVersion: "1.0.15"
114
+ };
115
+ var DatasourceTableView = (0, _analyticsNext.withAnalyticsContext)(analyticsContextData)(DatasourceTableViewWithoutAnalytics);
100
116
  exports.DatasourceTableView = DatasourceTableView;
@@ -348,7 +348,7 @@ var analyticsContextAttributes = {
348
348
  };
349
349
  var analyticsContextData = {
350
350
  packageName: "@atlaskit/link-datasource",
351
- packageVersion: "1.0.13",
351
+ packageVersion: "1.0.15",
352
352
  source: 'datasourceConfigModal'
353
353
  };
354
354
  var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
@@ -14,6 +14,8 @@ export const useDatasourceTableState = ({
14
14
  const [columns, setColumns] = useState([]);
15
15
  const [totalCount, setTotalCount] = useState(undefined);
16
16
  const [shouldForceRequest, setShouldForceRequest] = useState(false);
17
+ const [destinationObjectTypes, setDestinationObjectTypes] = useState([]);
18
+ const [extensionKey, setExtensionKey] = useState();
17
19
  const {
18
20
  getDatasourceData,
19
21
  getDatasourceDetails
@@ -25,7 +27,9 @@ export const useDatasourceTableState = ({
25
27
  try {
26
28
  const {
27
29
  meta: {
28
- access
30
+ access,
31
+ destinationObjectTypes,
32
+ extensionKey
29
33
  },
30
34
  data: {
31
35
  schema
@@ -37,6 +41,8 @@ export const useDatasourceTableState = ({
37
41
  setStatus('unauthorized');
38
42
  return;
39
43
  }
44
+ setExtensionKey(extensionKey);
45
+ setDestinationObjectTypes(destinationObjectTypes);
40
46
  const isColumnNotPresentInCurrentColumnsList = col => !columns.find(column => column.key === col.key);
41
47
  const allColumns = schema.properties;
42
48
  const newColumns = allColumns.filter(isColumnNotPresentInCurrentColumnsList);
@@ -83,7 +89,9 @@ export const useDatasourceTableState = ({
83
89
  try {
84
90
  const {
85
91
  meta: {
86
- access
92
+ access,
93
+ destinationObjectTypes,
94
+ extensionKey
87
95
  },
88
96
  data: {
89
97
  items,
@@ -96,6 +104,8 @@ export const useDatasourceTableState = ({
96
104
  setStatus('unauthorized');
97
105
  return;
98
106
  }
107
+ setExtensionKey(extensionKey);
108
+ setDestinationObjectTypes(destinationObjectTypes);
99
109
  setTotalCount(totalCount);
100
110
  setNextCursor(nextPageCursor);
101
111
  setResponseItems(currentResponseItems => {
@@ -165,6 +175,8 @@ export const useDatasourceTableState = ({
165
175
  hasNextPage,
166
176
  columns,
167
177
  defaultVisibleColumnKeys,
168
- totalCount
178
+ totalCount,
179
+ extensionKey,
180
+ destinationObjectTypes
169
181
  };
170
182
  };
@@ -205,7 +205,7 @@ const analyticsContextAttributes = {
205
205
  };
206
206
  const analyticsContextData = {
207
207
  packageName: "@atlaskit/link-datasource",
208
- packageVersion: "1.0.13",
208
+ packageVersion: "1.0.15",
209
209
  source: 'datasourceConfigModal'
210
210
  };
211
211
  const contextData = {
@@ -1,6 +1,8 @@
1
1
  /** @jsx jsx */
2
2
  import { useCallback, useEffect, useRef } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
+ import { withAnalyticsContext } from '@atlaskit/analytics-next';
5
+ import { useDatasourceAnalyticsEvents } from '../../analytics';
4
6
  import { useDatasourceTableState } from '../../hooks/useDatasourceTableState';
5
7
  import { AccessRequired } from '../common/error-state/access-required';
6
8
  import { LoadingError } from '../common/error-state/loading-error';
@@ -8,7 +10,7 @@ import { NoResults } from '../common/error-state/no-results';
8
10
  import { IssueLikeDataTableView } from '../issue-like-table';
9
11
  import EmptyState from '../issue-like-table/empty-state';
10
12
  import { TableFooter } from '../table-footer';
11
- export const DatasourceTableView = ({
13
+ const DatasourceTableViewWithoutAnalytics = ({
12
14
  datasourceId,
13
15
  parameters,
14
16
  visibleColumnKeys,
@@ -23,12 +25,17 @@ export const DatasourceTableView = ({
23
25
  columns,
24
26
  defaultVisibleColumnKeys,
25
27
  totalCount,
26
- loadDatasourceDetails
28
+ loadDatasourceDetails,
29
+ extensionKey = null,
30
+ destinationObjectTypes
27
31
  } = useDatasourceTableState({
28
32
  datasourceId,
29
33
  parameters,
30
34
  fieldKeys: visibleColumnKeys
31
35
  });
36
+ const {
37
+ fireEvent
38
+ } = useDatasourceAnalyticsEvents();
32
39
 
33
40
  /* Need this to make sure that the datasource in the editor gets updated new info if any edits are made in the modal
34
41
  But we don't want to call it on initial load. This screws up useDatasourceTableState's internal
@@ -47,10 +54,14 @@ export const DatasourceTableView = ({
47
54
  }
48
55
  }, [visibleColumnKeys, defaultVisibleColumnKeys, onVisibleColumnKeysChange]);
49
56
  const forcedReset = useCallback(() => {
57
+ fireEvent('ui.button.clicked.sync', {
58
+ extensionKey,
59
+ destinationObjectTypes
60
+ });
50
61
  reset({
51
62
  shouldForceRequest: true
52
63
  });
53
- }, [reset]);
64
+ }, [destinationObjectTypes, extensionKey, fireEvent, reset]);
54
65
  if (status === 'resolved' && !responseItems.length) {
55
66
  return jsx(NoResults, {
56
67
  onRefresh: reset
@@ -90,4 +101,9 @@ export const DatasourceTableView = ({
90
101
  isLoading: !isDataReady || status === 'loading'
91
102
  }))
92
103
  );
93
- };
104
+ };
105
+ const analyticsContextData = {
106
+ packageName: "@atlaskit/link-datasource",
107
+ packageVersion: "1.0.15"
108
+ };
109
+ export const DatasourceTableView = withAnalyticsContext(analyticsContextData)(DatasourceTableViewWithoutAnalytics);
@@ -294,7 +294,7 @@ const analyticsContextAttributes = {
294
294
  };
295
295
  const analyticsContextData = {
296
296
  packageName: "@atlaskit/link-datasource",
297
- packageVersion: "1.0.13",
297
+ packageVersion: "1.0.15",
298
298
  source: 'datasourceConfigModal'
299
299
  };
300
300
  const contextData = {
@@ -45,11 +45,19 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
45
45
  _useState18 = _slicedToArray(_useState17, 2),
46
46
  shouldForceRequest = _useState18[0],
47
47
  setShouldForceRequest = _useState18[1];
48
+ var _useState19 = useState([]),
49
+ _useState20 = _slicedToArray(_useState19, 2),
50
+ destinationObjectTypes = _useState20[0],
51
+ setDestinationObjectTypes = _useState20[1];
52
+ var _useState21 = useState(),
53
+ _useState22 = _slicedToArray(_useState21, 2),
54
+ extensionKey = _useState22[0],
55
+ setExtensionKey = _useState22[1];
48
56
  var _useDatasourceClientE = useDatasourceClientExtension(),
49
57
  getDatasourceData = _useDatasourceClientE.getDatasourceData,
50
58
  getDatasourceDetails = _useDatasourceClientE.getDatasourceDetails;
51
59
  var loadDatasourceDetails = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
52
- var _yield$getDatasourceD, access, schema, isColumnNotPresentInCurrentColumnsList, allColumns, newColumns;
60
+ var _yield$getDatasourceD, _yield$getDatasourceD2, access, _destinationObjectTypes, _extensionKey, schema, isColumnNotPresentInCurrentColumnsList, allColumns, newColumns;
53
61
  return _regeneratorRuntime.wrap(function _callee$(_context) {
54
62
  while (1) switch (_context.prev = _context.next) {
55
63
  case 0:
@@ -66,15 +74,20 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
66
74
  });
67
75
  case 5:
68
76
  _yield$getDatasourceD = _context.sent;
69
- access = _yield$getDatasourceD.meta.access;
77
+ _yield$getDatasourceD2 = _yield$getDatasourceD.meta;
78
+ access = _yield$getDatasourceD2.access;
79
+ _destinationObjectTypes = _yield$getDatasourceD2.destinationObjectTypes;
80
+ _extensionKey = _yield$getDatasourceD2.extensionKey;
70
81
  schema = _yield$getDatasourceD.data.schema;
71
82
  if (!(access === 'forbidden' || access === 'unauthorized')) {
72
- _context.next = 11;
83
+ _context.next = 14;
73
84
  break;
74
85
  }
75
86
  setStatus('unauthorized');
76
87
  return _context.abrupt("return");
77
- case 11:
88
+ case 14:
89
+ setExtensionKey(_extensionKey);
90
+ setDestinationObjectTypes(_destinationObjectTypes);
78
91
  isColumnNotPresentInCurrentColumnsList = function isColumnNotPresentInCurrentColumnsList(col) {
79
92
  return !columns.find(function (column) {
80
93
  return column.key === col.key;
@@ -83,17 +96,17 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
83
96
  allColumns = schema.properties;
84
97
  newColumns = allColumns.filter(isColumnNotPresentInCurrentColumnsList);
85
98
  newColumns.length > 0 && setColumns([].concat(_toConsumableArray(columns), _toConsumableArray(newColumns)));
86
- _context.next = 20;
99
+ _context.next = 25;
87
100
  break;
88
- case 17:
89
- _context.prev = 17;
101
+ case 22:
102
+ _context.prev = 22;
90
103
  _context.t0 = _context["catch"](2);
91
104
  setStatus('rejected');
92
- case 20:
105
+ case 25:
93
106
  case "end":
94
107
  return _context.stop();
95
108
  }
96
- }, _callee, null, [[2, 17]]);
109
+ }, _callee, null, [[2, 22]]);
97
110
  })), [columns, datasourceId, getDatasourceDetails, parameters]);
98
111
  var applySchemaProperties = useCallback(function (properties) {
99
112
  if (columns.length === 0) {
@@ -121,9 +134,12 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
121
134
  shouldForceRequest,
122
135
  sortedFieldKeys,
123
136
  datasourceDataRequest,
124
- _yield$getDatasourceD2,
125
- access,
126
137
  _yield$getDatasourceD3,
138
+ _yield$getDatasourceD4,
139
+ access,
140
+ _destinationObjectTypes2,
141
+ _extensionKey2,
142
+ _yield$getDatasourceD5,
127
143
  items,
128
144
  nextPageCursor,
129
145
  _totalCount,
@@ -154,20 +170,25 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
154
170
  _context2.next = 11;
155
171
  return getDatasourceData(datasourceId, datasourceDataRequest, shouldForceRequest);
156
172
  case 11:
157
- _yield$getDatasourceD2 = _context2.sent;
158
- access = _yield$getDatasourceD2.meta.access;
159
- _yield$getDatasourceD3 = _yield$getDatasourceD2.data;
160
- items = _yield$getDatasourceD3.items;
161
- nextPageCursor = _yield$getDatasourceD3.nextPageCursor;
162
- _totalCount = _yield$getDatasourceD3.totalCount;
163
- schema = _yield$getDatasourceD3.schema;
173
+ _yield$getDatasourceD3 = _context2.sent;
174
+ _yield$getDatasourceD4 = _yield$getDatasourceD3.meta;
175
+ access = _yield$getDatasourceD4.access;
176
+ _destinationObjectTypes2 = _yield$getDatasourceD4.destinationObjectTypes;
177
+ _extensionKey2 = _yield$getDatasourceD4.extensionKey;
178
+ _yield$getDatasourceD5 = _yield$getDatasourceD3.data;
179
+ items = _yield$getDatasourceD5.items;
180
+ nextPageCursor = _yield$getDatasourceD5.nextPageCursor;
181
+ _totalCount = _yield$getDatasourceD5.totalCount;
182
+ schema = _yield$getDatasourceD5.schema;
164
183
  if (!(access === 'forbidden' || access === 'unauthorized')) {
165
- _context2.next = 21;
184
+ _context2.next = 24;
166
185
  break;
167
186
  }
168
187
  setStatus('unauthorized');
169
188
  return _context2.abrupt("return");
170
- case 21:
189
+ case 24:
190
+ setExtensionKey(_extensionKey2);
191
+ setDestinationObjectTypes(_destinationObjectTypes2);
171
192
  setTotalCount(_totalCount);
172
193
  setNextCursor(nextPageCursor);
173
194
  setResponseItems(function (currentResponseItems) {
@@ -184,17 +205,17 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
184
205
  if (isSchemaFromData && schema && items.length > 0) {
185
206
  applySchemaProperties(schema.properties);
186
207
  }
187
- _context2.next = 33;
208
+ _context2.next = 38;
188
209
  break;
189
- case 30:
190
- _context2.prev = 30;
210
+ case 35:
211
+ _context2.prev = 35;
191
212
  _context2.t0 = _context2["catch"](8);
192
213
  setStatus('rejected');
193
- case 33:
214
+ case 38:
194
215
  case "end":
195
216
  return _context2.stop();
196
217
  }
197
- }, _callee2, null, [[8, 30]]);
218
+ }, _callee2, null, [[8, 35]]);
198
219
  })), [parameters, fieldKeys, getDatasourceData, datasourceId, nextCursor, applySchemaProperties]);
199
220
  var reset = useCallback(function (options) {
200
221
  setStatus('empty');
@@ -247,6 +268,8 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
247
268
  hasNextPage: hasNextPage,
248
269
  columns: columns,
249
270
  defaultVisibleColumnKeys: defaultVisibleColumnKeys,
250
- totalCount: totalCount
271
+ totalCount: totalCount,
272
+ extensionKey: extensionKey,
273
+ destinationObjectTypes: destinationObjectTypes
251
274
  };
252
275
  };
@@ -222,7 +222,7 @@ var analyticsContextAttributes = {
222
222
  };
223
223
  var analyticsContextData = {
224
224
  packageName: "@atlaskit/link-datasource",
225
- packageVersion: "1.0.13",
225
+ packageVersion: "1.0.15",
226
226
  source: 'datasourceConfigModal'
227
227
  };
228
228
  var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
@@ -1,6 +1,8 @@
1
1
  /** @jsx jsx */
2
2
  import { useCallback, useEffect, useRef } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
+ import { withAnalyticsContext } from '@atlaskit/analytics-next';
5
+ import { useDatasourceAnalyticsEvents } from '../../analytics';
4
6
  import { useDatasourceTableState } from '../../hooks/useDatasourceTableState';
5
7
  import { AccessRequired } from '../common/error-state/access-required';
6
8
  import { LoadingError } from '../common/error-state/loading-error';
@@ -8,7 +10,7 @@ import { NoResults } from '../common/error-state/no-results';
8
10
  import { IssueLikeDataTableView } from '../issue-like-table';
9
11
  import EmptyState from '../issue-like-table/empty-state';
10
12
  import { TableFooter } from '../table-footer';
11
- export var DatasourceTableView = function DatasourceTableView(_ref) {
13
+ var DatasourceTableViewWithoutAnalytics = function DatasourceTableViewWithoutAnalytics(_ref) {
12
14
  var datasourceId = _ref.datasourceId,
13
15
  parameters = _ref.parameters,
14
16
  visibleColumnKeys = _ref.visibleColumnKeys,
@@ -26,7 +28,12 @@ export var DatasourceTableView = function DatasourceTableView(_ref) {
26
28
  columns = _useDatasourceTableSt.columns,
27
29
  defaultVisibleColumnKeys = _useDatasourceTableSt.defaultVisibleColumnKeys,
28
30
  totalCount = _useDatasourceTableSt.totalCount,
29
- loadDatasourceDetails = _useDatasourceTableSt.loadDatasourceDetails;
31
+ loadDatasourceDetails = _useDatasourceTableSt.loadDatasourceDetails,
32
+ _useDatasourceTableSt2 = _useDatasourceTableSt.extensionKey,
33
+ extensionKey = _useDatasourceTableSt2 === void 0 ? null : _useDatasourceTableSt2,
34
+ destinationObjectTypes = _useDatasourceTableSt.destinationObjectTypes;
35
+ var _useDatasourceAnalyti = useDatasourceAnalyticsEvents(),
36
+ fireEvent = _useDatasourceAnalyti.fireEvent;
30
37
 
31
38
  /* Need this to make sure that the datasource in the editor gets updated new info if any edits are made in the modal
32
39
  But we don't want to call it on initial load. This screws up useDatasourceTableState's internal
@@ -45,10 +52,14 @@ export var DatasourceTableView = function DatasourceTableView(_ref) {
45
52
  }
46
53
  }, [visibleColumnKeys, defaultVisibleColumnKeys, onVisibleColumnKeysChange]);
47
54
  var forcedReset = useCallback(function () {
55
+ fireEvent('ui.button.clicked.sync', {
56
+ extensionKey: extensionKey,
57
+ destinationObjectTypes: destinationObjectTypes
58
+ });
48
59
  reset({
49
60
  shouldForceRequest: true
50
61
  });
51
- }, [reset]);
62
+ }, [destinationObjectTypes, extensionKey, fireEvent, reset]);
52
63
  if (status === 'resolved' && !responseItems.length) {
53
64
  return jsx(NoResults, {
54
65
  onRefresh: reset
@@ -88,4 +99,9 @@ export var DatasourceTableView = function DatasourceTableView(_ref) {
88
99
  isLoading: !isDataReady || status === 'loading'
89
100
  }))
90
101
  );
91
- };
102
+ };
103
+ var analyticsContextData = {
104
+ packageName: "@atlaskit/link-datasource",
105
+ packageVersion: "1.0.15"
106
+ };
107
+ export var DatasourceTableView = withAnalyticsContext(analyticsContextData)(DatasourceTableViewWithoutAnalytics);
@@ -338,7 +338,7 @@ var analyticsContextAttributes = {
338
338
  };
339
339
  var analyticsContextData = {
340
340
  packageName: "@atlaskit/link-datasource",
341
- packageVersion: "1.0.13",
341
+ packageVersion: "1.0.15",
342
342
  source: 'datasourceConfigModal'
343
343
  };
344
344
  var contextData = _objectSpread(_objectSpread({}, analyticsContextData), {}, {
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::7dd648157e3329a0b94f96c5f039ac2d>>
6
+ * @codegen <<SignedSource::62501952dd8f62a9009c28acb74a64b4>>
7
7
  * @codegenCommand yarn workspace @atlassian/analytics-tooling run analytics:codegen link-datasource
8
8
  */
9
9
  export type PackageMetaDataType = {
@@ -11,7 +11,7 @@ export type PackageMetaDataType = {
11
11
  packageVersion: string;
12
12
  };
13
13
  export type AnalyticsContextType = {
14
- source: 'datasourceConfigModal' | 'datasourceConfluenceEditor';
14
+ source: 'datasourceConfigModal';
15
15
  };
16
16
  export type AnalyticsContextAttributesType = {
17
17
  dataProvider: 'jira-issues' | 'jsm-assets';
@@ -26,6 +26,53 @@ export type EmptyResultShownDatasourceAttributesType = {};
26
26
  export type ErrorShownAttributesType = {
27
27
  reason: 'network' | 'access';
28
28
  };
29
+ export type ButtonClickedSyncAttributesType = {
30
+ extensionKey: string | null;
31
+ destinationObjectTypes: unknown[];
32
+ };
33
+ export type ButtonClickedInsertAttributesType = {
34
+ searchCount: number;
35
+ totalItemCount: number;
36
+ displayedColumnCount: number | null;
37
+ display: 'datasource_inline' | 'datasource_table' | 'inline';
38
+ destinationObjectTypes: unknown[];
39
+ searchMethod: 'datasource_search_query' | 'datasource_basic_filter' | 'datasource_saved_filter' | null;
40
+ };
41
+ export type ButtonClickedCancelAttributesType = {
42
+ searchCount: number;
43
+ };
44
+ export type LinkClickedSingleItemAttributesType = {
45
+ extensionKey: string | null;
46
+ destinationObjectTypes: unknown[];
47
+ };
48
+ export type DatasourceRenderedAttributesType = {
49
+ totalItemCount: number;
50
+ destinationObjectTypes: unknown[];
51
+ displayedColumnCount: number | null;
52
+ extensionKey: string | null;
53
+ display: 'datasource_inline' | 'datasource_table' | 'inline';
54
+ status: 'resolved' | 'unauthorized' | 'forbidden' | 'not_found' | 'errored';
55
+ };
56
+ export type NextItemLoadedAttributesType = {
57
+ destinationObjectTypes: unknown[];
58
+ extensionKey: string | null;
59
+ loadedItemCount: number;
60
+ };
61
+ export type TableViewedDatasourceAttributesType = {
62
+ destinationObjectTypes: unknown[];
63
+ totalItemCount: number;
64
+ displayedColumnCount: number | null;
65
+ searchMethod: 'datasource_search_query' | 'datasource_basic_filter' | 'datasource_saved_filter' | null;
66
+ };
67
+ export type LinkViewedSingleItemAttributesType = {
68
+ destinationObjectTypes: unknown[];
69
+ searchMethod: 'datasource_search_query' | 'datasource_basic_filter' | 'datasource_saved_filter' | null;
70
+ };
71
+ export type LinkViewedCountAttributesType = {
72
+ destinationObjectTypes: unknown[];
73
+ searchMethod: 'datasource_search_query' | 'datasource_basic_filter' | 'datasource_saved_filter' | null;
74
+ totalItemCount: number;
75
+ };
29
76
  export type AnalyticsEventAttributes = {
30
77
  /**
31
78
  * Fires when user sees modal dialog. */
@@ -45,5 +92,32 @@ export type AnalyticsEventAttributes = {
45
92
  /**
46
93
  * Fires when datasource errors state is shown. */
47
94
  'ui.error.shown': ErrorShownAttributesType;
95
+ /**
96
+ * Fired when user clicks on datasource table sync button */
97
+ 'ui.button.clicked.sync': ButtonClickedSyncAttributesType;
98
+ /**
99
+ * Fired on insert button click */
100
+ 'ui.button.clicked.insert': ButtonClickedInsertAttributesType;
101
+ /**
102
+ * Fired on cancel button click */
103
+ 'ui.button.clicked.cancel': ButtonClickedCancelAttributesType;
104
+ /**
105
+ * Fired when user clicks on datasource items */
106
+ 'ui.link.clicked.singleItem': LinkClickedSingleItemAttributesType;
107
+ /**
108
+ * Fired when an inserted datasource resolves / renders. */
109
+ 'ui.datasource.rendered': DatasourceRenderedAttributesType;
110
+ /**
111
+ * Fired when user scrolls to the next page/list of the objects */
112
+ 'ui.nextItem.loaded': NextItemLoadedAttributesType;
113
+ /**
114
+ * Fired when the datasource results are displayed as table */
115
+ 'ui.table.viewed.datasource': TableViewedDatasourceAttributesType;
116
+ /**
117
+ * Fired when the datasource results are displayed as link(may be smart-link) for a single item */
118
+ 'ui.link.viewed.singleItem': LinkViewedSingleItemAttributesType;
119
+ /**
120
+ * Fired when the datasource results are displayed as link( smart-link) in count mode. */
121
+ 'ui.link.viewed.count': LinkViewedCountAttributesType;
48
122
  };
49
123
  export type EventKey = keyof AnalyticsEventAttributes;
@@ -19,6 +19,8 @@ export interface DatasourceTableState {
19
19
  columns: DatasourceResponseSchemaProperty[];
20
20
  defaultVisibleColumnKeys: string[];
21
21
  totalCount?: number;
22
+ destinationObjectTypes: string[];
23
+ extensionKey?: string;
22
24
  }
23
25
  export interface DatasourceTableStateProps {
24
26
  datasourceId: string;
@@ -1,3 +1,3 @@
1
- import { jsx } from '@emotion/react';
1
+ /// <reference types="react" />
2
2
  import { DatasourceTableViewProps } from './types';
3
- export declare const DatasourceTableView: ({ datasourceId, parameters, visibleColumnKeys, onVisibleColumnKeysChange, }: DatasourceTableViewProps) => jsx.JSX.Element;
3
+ export declare const DatasourceTableView: import("react").ForwardRefExoticComponent<DatasourceTableViewProps & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::7dd648157e3329a0b94f96c5f039ac2d>>
6
+ * @codegen <<SignedSource::62501952dd8f62a9009c28acb74a64b4>>
7
7
  * @codegenCommand yarn workspace @atlassian/analytics-tooling run analytics:codegen link-datasource
8
8
  */
9
9
  export type PackageMetaDataType = {
@@ -11,7 +11,7 @@ export type PackageMetaDataType = {
11
11
  packageVersion: string;
12
12
  };
13
13
  export type AnalyticsContextType = {
14
- source: 'datasourceConfigModal' | 'datasourceConfluenceEditor';
14
+ source: 'datasourceConfigModal';
15
15
  };
16
16
  export type AnalyticsContextAttributesType = {
17
17
  dataProvider: 'jira-issues' | 'jsm-assets';
@@ -26,6 +26,53 @@ export type EmptyResultShownDatasourceAttributesType = {};
26
26
  export type ErrorShownAttributesType = {
27
27
  reason: 'network' | 'access';
28
28
  };
29
+ export type ButtonClickedSyncAttributesType = {
30
+ extensionKey: string | null;
31
+ destinationObjectTypes: unknown[];
32
+ };
33
+ export type ButtonClickedInsertAttributesType = {
34
+ searchCount: number;
35
+ totalItemCount: number;
36
+ displayedColumnCount: number | null;
37
+ display: 'datasource_inline' | 'datasource_table' | 'inline';
38
+ destinationObjectTypes: unknown[];
39
+ searchMethod: 'datasource_search_query' | 'datasource_basic_filter' | 'datasource_saved_filter' | null;
40
+ };
41
+ export type ButtonClickedCancelAttributesType = {
42
+ searchCount: number;
43
+ };
44
+ export type LinkClickedSingleItemAttributesType = {
45
+ extensionKey: string | null;
46
+ destinationObjectTypes: unknown[];
47
+ };
48
+ export type DatasourceRenderedAttributesType = {
49
+ totalItemCount: number;
50
+ destinationObjectTypes: unknown[];
51
+ displayedColumnCount: number | null;
52
+ extensionKey: string | null;
53
+ display: 'datasource_inline' | 'datasource_table' | 'inline';
54
+ status: 'resolved' | 'unauthorized' | 'forbidden' | 'not_found' | 'errored';
55
+ };
56
+ export type NextItemLoadedAttributesType = {
57
+ destinationObjectTypes: unknown[];
58
+ extensionKey: string | null;
59
+ loadedItemCount: number;
60
+ };
61
+ export type TableViewedDatasourceAttributesType = {
62
+ destinationObjectTypes: unknown[];
63
+ totalItemCount: number;
64
+ displayedColumnCount: number | null;
65
+ searchMethod: 'datasource_search_query' | 'datasource_basic_filter' | 'datasource_saved_filter' | null;
66
+ };
67
+ export type LinkViewedSingleItemAttributesType = {
68
+ destinationObjectTypes: unknown[];
69
+ searchMethod: 'datasource_search_query' | 'datasource_basic_filter' | 'datasource_saved_filter' | null;
70
+ };
71
+ export type LinkViewedCountAttributesType = {
72
+ destinationObjectTypes: unknown[];
73
+ searchMethod: 'datasource_search_query' | 'datasource_basic_filter' | 'datasource_saved_filter' | null;
74
+ totalItemCount: number;
75
+ };
29
76
  export type AnalyticsEventAttributes = {
30
77
  /**
31
78
  * Fires when user sees modal dialog. */
@@ -45,5 +92,32 @@ export type AnalyticsEventAttributes = {
45
92
  /**
46
93
  * Fires when datasource errors state is shown. */
47
94
  'ui.error.shown': ErrorShownAttributesType;
95
+ /**
96
+ * Fired when user clicks on datasource table sync button */
97
+ 'ui.button.clicked.sync': ButtonClickedSyncAttributesType;
98
+ /**
99
+ * Fired on insert button click */
100
+ 'ui.button.clicked.insert': ButtonClickedInsertAttributesType;
101
+ /**
102
+ * Fired on cancel button click */
103
+ 'ui.button.clicked.cancel': ButtonClickedCancelAttributesType;
104
+ /**
105
+ * Fired when user clicks on datasource items */
106
+ 'ui.link.clicked.singleItem': LinkClickedSingleItemAttributesType;
107
+ /**
108
+ * Fired when an inserted datasource resolves / renders. */
109
+ 'ui.datasource.rendered': DatasourceRenderedAttributesType;
110
+ /**
111
+ * Fired when user scrolls to the next page/list of the objects */
112
+ 'ui.nextItem.loaded': NextItemLoadedAttributesType;
113
+ /**
114
+ * Fired when the datasource results are displayed as table */
115
+ 'ui.table.viewed.datasource': TableViewedDatasourceAttributesType;
116
+ /**
117
+ * Fired when the datasource results are displayed as link(may be smart-link) for a single item */
118
+ 'ui.link.viewed.singleItem': LinkViewedSingleItemAttributesType;
119
+ /**
120
+ * Fired when the datasource results are displayed as link( smart-link) in count mode. */
121
+ 'ui.link.viewed.count': LinkViewedCountAttributesType;
48
122
  };
49
123
  export type EventKey = keyof AnalyticsEventAttributes;
@@ -19,6 +19,8 @@ export interface DatasourceTableState {
19
19
  columns: DatasourceResponseSchemaProperty[];
20
20
  defaultVisibleColumnKeys: string[];
21
21
  totalCount?: number;
22
+ destinationObjectTypes: string[];
23
+ extensionKey?: string;
22
24
  }
23
25
  export interface DatasourceTableStateProps {
24
26
  datasourceId: string;
@@ -1,3 +1,3 @@
1
- import { jsx } from '@emotion/react';
1
+ /// <reference types="react" />
2
2
  import { DatasourceTableViewProps } from './types';
3
- export declare const DatasourceTableView: ({ datasourceId, parameters, visibleColumnKeys, onVisibleColumnKeysChange, }: DatasourceTableViewProps) => jsx.JSX.Element;
3
+ export declare const DatasourceTableView: import("react").ForwardRefExoticComponent<DatasourceTableViewProps & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "UI Components to support linking platform dataset feature",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"