@atlaskit/link-datasource 2.10.3 → 2.11.1

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.
Files changed (23) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/state/actions/index.js +1 -1
  3. package/dist/cjs/ui/issue-like-table/index.js +8 -1
  4. package/dist/cjs/ui/issue-like-table/table-cell-content/index.js +61 -48
  5. package/dist/cjs/ui/issue-like-table/table-cell-content/inline-edit.js +4 -11
  6. package/dist/es2019/state/actions/index.js +1 -1
  7. package/dist/es2019/ui/issue-like-table/index.js +9 -2
  8. package/dist/es2019/ui/issue-like-table/table-cell-content/index.js +61 -47
  9. package/dist/es2019/ui/issue-like-table/table-cell-content/inline-edit.js +4 -12
  10. package/dist/esm/state/actions/index.js +1 -1
  11. package/dist/esm/ui/issue-like-table/index.js +9 -2
  12. package/dist/esm/ui/issue-like-table/table-cell-content/index.js +60 -47
  13. package/dist/esm/ui/issue-like-table/table-cell-content/inline-edit.js +4 -11
  14. package/dist/types/ui/common/modal/cancel-button/index.d.ts +1 -1
  15. package/dist/types/ui/common/modal/insert-button/index.d.ts +1 -1
  16. package/dist/types/ui/issue-like-table/table-cell-content/index.d.ts +2 -1
  17. package/dist/types/ui/issue-like-table/table-cell-content/inline-edit.d.ts +4 -2
  18. package/dist/types-ts4.5/ui/common/modal/cancel-button/index.d.ts +1 -1
  19. package/dist/types-ts4.5/ui/common/modal/insert-button/index.d.ts +1 -1
  20. package/dist/types-ts4.5/ui/issue-like-table/table-cell-content/index.d.ts +2 -1
  21. package/dist/types-ts4.5/ui/issue-like-table/table-cell-content/inline-edit.d.ts +4 -2
  22. package/examples-helpers/buildAssetsIssuesTable.tsx +1 -8
  23. package/package.json +11 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/link-datasource
2
2
 
3
+ ## 2.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#125506](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/125506)
8
+ [`2c38223755a99`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2c38223755a99) -
9
+ Fix isEditable field validation behind FF
10
+
11
+ ## 2.11.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#129983](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/129983)
16
+ [`02069a897926b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/02069a897926b) -
17
+ Add React 18 to peer dependencies and upgrade react-dom dependency to same versions as well
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+
3
23
  ## 2.10.3
4
24
 
5
25
  ### Patch Changes
@@ -122,7 +122,7 @@ var getFieldUpdateActionByAri = function getFieldUpdateActionByAri(state, _ref3)
122
122
  fieldKey = _ref3.fieldKey,
123
123
  integrationKey = _ref3.integrationKey;
124
124
  var isEditable = (_state$permissions$ar = state.permissions[ari]) === null || _state$permissions$ar === void 0 || (_state$permissions$ar = _state$permissions$ar[fieldKey]) === null || _state$permissions$ar === void 0 ? void 0 : _state$permissions$ar.isEditable;
125
- if (isEditable === false) {
125
+ if (!isEditable) {
126
126
  return;
127
127
  }
128
128
  return (_state$actionsByInteg = state.actionsByIntegration[integrationKey]) === null || _state$actionsByInteg === void 0 ? void 0 : _state$actionsByInteg[fieldKey];
@@ -471,7 +471,14 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
471
471
  return {
472
472
  key: key,
473
473
  columnKey: key,
474
- content: (0, _react2.jsx)(_tableCellContent.TableCellContent, {
474
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
475
+ content: (0, _platformFeatureFlags.fg)('platform-datasources-enable-two-way-sync') ? (0, _react2.jsx)(_tableCellContent.TableCellContent, {
476
+ id: id,
477
+ columnKey: key,
478
+ columnType: type,
479
+ wrappedColumnKeys: wrappedColumnKeys,
480
+ renderItem: renderItem
481
+ }) : (0, _react2.jsx)(_tableCellContent.ReadOnlyCell, {
475
482
  id: id,
476
483
  columnKey: key,
477
484
  columnType: type,
@@ -4,13 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.TableCellContent = void 0;
7
+ exports.TableCellContent = exports.ReadOnlyCell = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _reactIntlNext = require("react-intl-next");
10
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
10
  var _primitives = require("@atlaskit/primitives");
12
11
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
13
12
  var _state = require("../../../state");
13
+ var _actions = require("../../../state/actions");
14
14
  var _editType = require("../edit-type");
15
15
  var _renderType = require("../render-type");
16
16
  var _truncateTextTag = require("../truncate-text-tag");
@@ -47,7 +47,7 @@ var TooltipWrapper = function TooltipWrapper(_ref) {
47
47
  }
48
48
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
49
49
  };
50
- var ReadOnlyCell = function ReadOnlyCell(_ref2) {
50
+ var ReadOnlyCell = exports.ReadOnlyCell = function ReadOnlyCell(_ref2) {
51
51
  var _useDatasourceItem, _rowData$columnKey;
52
52
  var id = _ref2.id,
53
53
  columnType = _ref2.columnType,
@@ -59,7 +59,7 @@ var ReadOnlyCell = function ReadOnlyCell(_ref2) {
59
59
  id: id
60
60
  })) === null || _useDatasourceItem === void 0 ? void 0 : _useDatasourceItem.data;
61
61
  if (!rowData || !columnKey || !rowData[columnKey]) {
62
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
62
+ return null;
63
63
  }
64
64
 
65
65
  // Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
@@ -76,71 +76,84 @@ var ReadOnlyCell = function ReadOnlyCell(_ref2) {
76
76
  }, renderItem(datasourceTypeWithValues));
77
77
  };
78
78
  var InlineEditableCell = function InlineEditableCell(_ref3) {
79
- var _rowData$columnKey2;
80
- var id = _ref3.id,
79
+ var ari = _ref3.ari,
80
+ values = _ref3.values,
81
81
  columnKey = _ref3.columnKey,
82
- columnType = _ref3.columnType,
83
82
  renderItem = _ref3.renderItem,
83
+ integrationKey = _ref3.integrationKey,
84
84
  wrappedColumnKeys = _ref3.wrappedColumnKeys;
85
- var item = (0, _state.useDatasourceItem)({
86
- id: id
87
- });
88
- if (!item) {
89
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
90
- }
91
- var rowData = item.data,
92
- integrationKey = item.integrationKey,
93
- ari = item.ari;
94
- if (!rowData || !columnKey || !rowData[columnKey]) {
95
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
96
- }
97
-
98
- // Check if field is editable
99
- var isEditable = !!ari && !!integrationKey && (0, _editType.isEditTypeSupported)(columnType);
100
-
101
- // Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
102
- var value = (_rowData$columnKey2 = rowData[columnKey]) === null || _rowData$columnKey2 === void 0 ? void 0 : _rowData$columnKey2.data;
103
- var values = Array.isArray(value) ? value : [value];
104
- var datasourceTypeWithValues = {
105
- type: columnType,
106
- values: values
107
- };
85
+ // Execute fn is only returned when the field is editable and the action schema exists
86
+ var _useExecuteAtomicActi = (0, _actions.useExecuteAtomicAction)({
87
+ ari: ari,
88
+ fieldKey: columnKey,
89
+ integrationKey: integrationKey
90
+ }),
91
+ execute = _useExecuteAtomicActi.execute;
92
+ var isEditable = !!execute;
108
93
  var readView = /*#__PURE__*/_react.default.createElement(TooltipWrapper, {
109
94
  columnKey: columnKey,
110
- datasourceTypeWithValues: datasourceTypeWithValues,
95
+ datasourceTypeWithValues: values,
111
96
  wrappedColumnKeys: wrappedColumnKeys
112
97
  }, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
113
98
  testId: "inline-edit-read-view",
114
99
  paddingInline: isEditable ? 'space.075' : 'space.100',
115
100
  paddingBlock: "space.050",
116
101
  xcss: truncateTextStyles
117
- }, renderItem(datasourceTypeWithValues)));
118
- return isEditable ? /*#__PURE__*/_react.default.createElement(_inlineEdit.InlineEdit, {
102
+ }, renderItem(values)));
103
+ if (!isEditable) {
104
+ return readView;
105
+ }
106
+ return /*#__PURE__*/_react.default.createElement(_inlineEdit.InlineEdit, {
119
107
  ari: ari,
108
+ execute: execute,
109
+ readView: readView,
120
110
  columnKey: columnKey,
121
- datasourceTypeWithValues: datasourceTypeWithValues,
122
- readView: readView
123
- }) : readView;
111
+ datasourceTypeWithValues: values
112
+ });
124
113
  };
125
114
  var TableCellContent = exports.TableCellContent = function TableCellContent(_ref4) {
126
- var columnKey = _ref4.columnKey,
115
+ var id = _ref4.id,
116
+ columnKey = _ref4.columnKey,
127
117
  columnType = _ref4.columnType,
128
- id = _ref4.id,
129
118
  renderItem = _ref4.renderItem,
130
119
  wrappedColumnKeys = _ref4.wrappedColumnKeys;
131
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
132
- var renderedContent = (0, _platformFeatureFlags.fg)('platform-datasources-enable-two-way-sync') ? /*#__PURE__*/_react.default.createElement(InlineEditableCell, {
133
- id: id,
134
- columnKey: columnKey,
135
- columnType: columnType,
136
- renderItem: renderItem,
137
- wrappedColumnKeys: wrappedColumnKeys
138
- }) : /*#__PURE__*/_react.default.createElement(ReadOnlyCell, {
120
+ var item = (0, _state.useDatasourceItem)({
121
+ id: id
122
+ });
123
+ if (item) {
124
+ var integrationKey = item.integrationKey,
125
+ ari = item.ari,
126
+ rowData = item.data;
127
+ var isEditType = !!ari && !!integrationKey && rowData[columnKey] && (0, _editType.isEditTypeSupported)(columnType);
128
+ if (isEditType) {
129
+ var _rowData$columnKey2;
130
+ // Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
131
+ var value = (_rowData$columnKey2 = rowData[columnKey]) === null || _rowData$columnKey2 === void 0 ? void 0 : _rowData$columnKey2.data;
132
+ var values = Array.isArray(value) ? value : [value];
133
+ var datasourceTypeWithValues = {
134
+ type: columnType,
135
+ values: values
136
+ };
137
+ return /*#__PURE__*/_react.default.createElement(InlineEditableCell, {
138
+ ari: ari,
139
+ columnKey: columnKey,
140
+ renderItem: renderItem,
141
+ integrationKey: integrationKey,
142
+ values: datasourceTypeWithValues,
143
+ wrappedColumnKeys: wrappedColumnKeys
144
+ });
145
+ }
146
+ }
147
+ return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
148
+ testId: "inline-edit-read-view",
149
+ paddingInline: "space.100",
150
+ paddingBlock: "space.050",
151
+ xcss: truncateTextStyles
152
+ }, /*#__PURE__*/_react.default.createElement(ReadOnlyCell, {
139
153
  id: id,
140
154
  columnKey: columnKey,
141
155
  columnType: columnType,
142
156
  wrappedColumnKeys: wrappedColumnKeys,
143
157
  renderItem: renderItem
144
- });
145
- return renderedContent;
158
+ }));
146
159
  };
@@ -13,7 +13,6 @@ var _react = _interopRequireWildcard(require("react"));
13
13
  var _inlineEdit = _interopRequireDefault(require("@atlaskit/inline-edit"));
14
14
  var _primitives = require("@atlaskit/primitives");
15
15
  var _state = require("../../../state");
16
- var _actions = require("../../../state/actions");
17
16
  var _editType = require("../edit-type");
18
17
  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); }
19
18
  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 && Object.prototype.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; }
@@ -33,11 +32,11 @@ var mapUpdatedItem = function mapUpdatedItem(type, existingItem, columnKey, newV
33
32
  return null;
34
33
  };
35
34
  var InlineEdit = exports.InlineEdit = function InlineEdit(_ref) {
36
- var _item$integrationKey;
37
35
  var ari = _ref.ari,
36
+ execute = _ref.execute,
37
+ _readView = _ref.readView,
38
38
  columnKey = _ref.columnKey,
39
- datasourceTypeWithValues = _ref.datasourceTypeWithValues,
40
- _readView = _ref.readView;
39
+ datasourceTypeWithValues = _ref.datasourceTypeWithValues;
41
40
  var _useState = (0, _react.useState)(false),
42
41
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
43
42
  isEditing = _useState2[0],
@@ -47,14 +46,8 @@ var InlineEdit = exports.InlineEdit = function InlineEdit(_ref) {
47
46
  });
48
47
  var _useDatasourceActions = (0, _state.useDatasourceActions)(),
49
48
  onUpdateItem = _useDatasourceActions.onUpdateItem;
50
- var _useExecuteAtomicActi = (0, _actions.useExecuteAtomicAction)({
51
- ari: ari,
52
- fieldKey: columnKey,
53
- integrationKey: (_item$integrationKey = item === null || item === void 0 ? void 0 : item.integrationKey) !== null && _item$integrationKey !== void 0 ? _item$integrationKey : ''
54
- }),
55
- execute = _useExecuteAtomicActi.execute;
56
49
  var onCommitUpdate = (0, _react.useCallback)(function (value) {
57
- if (!execute || !item) {
50
+ if (!item) {
58
51
  setIsEditing(false);
59
52
  return;
60
53
  }
@@ -103,7 +103,7 @@ const getFieldUpdateActionByAri = (state, {
103
103
  }) => {
104
104
  var _state$permissions$ar, _state$permissions$ar2, _state$actionsByInteg;
105
105
  const isEditable = (_state$permissions$ar = state.permissions[ari]) === null || _state$permissions$ar === void 0 ? void 0 : (_state$permissions$ar2 = _state$permissions$ar[fieldKey]) === null || _state$permissions$ar2 === void 0 ? void 0 : _state$permissions$ar2.isEditable;
106
- if (isEditable === false) {
106
+ if (!isEditable) {
107
107
  return;
108
108
  }
109
109
  return (_state$actionsByInteg = state.actionsByIntegration[integrationKey]) === null || _state$actionsByInteg === void 0 ? void 0 : _state$actionsByInteg[fieldKey];
@@ -31,7 +31,7 @@ import { DraggableTableHeading } from './draggable-table-heading';
31
31
  import TableEmptyState from './empty-state';
32
32
  import { renderType, stringifyType } from './render-type';
33
33
  import { InlineEditableTableCell, Table, TableCell, TableHeading, withTablePluginHeaderPrefix } from './styled';
34
- import { TableCellContent } from './table-cell-content';
34
+ import { ReadOnlyCell, TableCellContent } from './table-cell-content';
35
35
  import { TruncateTextTag } from './truncate-text-tag';
36
36
  import { useIsOnScreen } from './useIsOnScreen';
37
37
  import { COLUMN_BASE_WIDTH, getWidthCss } from './utils';
@@ -469,7 +469,14 @@ export const IssueLikeDataTableView = ({
469
469
  return {
470
470
  key,
471
471
  columnKey: key,
472
- content: jsx(TableCellContent, {
472
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
473
+ content: fg('platform-datasources-enable-two-way-sync') ? jsx(TableCellContent, {
474
+ id: id,
475
+ columnKey: key,
476
+ columnType: type,
477
+ wrappedColumnKeys: wrappedColumnKeys,
478
+ renderItem: renderItem
479
+ }) : jsx(ReadOnlyCell, {
473
480
  id: id,
474
481
  columnKey: key,
475
482
  columnType: type,
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  import { Box, xcss } from '@atlaskit/primitives';
5
4
  import Tooltip from '@atlaskit/tooltip';
6
5
  import { useDatasourceItem } from '../../../state';
6
+ import { useExecuteAtomicAction } from '../../../state/actions';
7
7
  import { isEditTypeSupported } from '../edit-type';
8
8
  import { stringifyType } from '../render-type';
9
9
  import { TruncateTextTag } from '../truncate-text-tag';
@@ -38,7 +38,7 @@ const TooltipWrapper = ({
38
38
  }
39
39
  return /*#__PURE__*/React.createElement(React.Fragment, null, children);
40
40
  };
41
- const ReadOnlyCell = ({
41
+ export const ReadOnlyCell = ({
42
42
  id,
43
43
  columnType,
44
44
  wrappedColumnKeys = [],
@@ -50,7 +50,7 @@ const ReadOnlyCell = ({
50
50
  id
51
51
  })) === null || _useDatasourceItem === void 0 ? void 0 : _useDatasourceItem.data;
52
52
  if (!rowData || !columnKey || !rowData[columnKey]) {
53
- return /*#__PURE__*/React.createElement(React.Fragment, null);
53
+ return null;
54
54
  }
55
55
 
56
56
  // Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
@@ -67,75 +67,89 @@ const ReadOnlyCell = ({
67
67
  }, renderItem(datasourceTypeWithValues));
68
68
  };
69
69
  const InlineEditableCell = ({
70
- id,
70
+ ari,
71
+ values,
71
72
  columnKey,
72
- columnType,
73
73
  renderItem,
74
+ integrationKey,
74
75
  wrappedColumnKeys
75
76
  }) => {
76
- var _rowData$columnKey2;
77
- const item = useDatasourceItem({
78
- id
79
- });
80
- if (!item) {
81
- return /*#__PURE__*/React.createElement(React.Fragment, null);
82
- }
77
+ // Execute fn is only returned when the field is editable and the action schema exists
83
78
  const {
84
- data: rowData,
85
- integrationKey,
86
- ari
87
- } = item;
88
- if (!rowData || !columnKey || !rowData[columnKey]) {
89
- return /*#__PURE__*/React.createElement(React.Fragment, null);
90
- }
91
-
92
- // Check if field is editable
93
- const isEditable = !!ari && !!integrationKey && isEditTypeSupported(columnType);
94
-
95
- // Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
96
- const value = (_rowData$columnKey2 = rowData[columnKey]) === null || _rowData$columnKey2 === void 0 ? void 0 : _rowData$columnKey2.data;
97
- const values = Array.isArray(value) ? value : [value];
98
- const datasourceTypeWithValues = {
99
- type: columnType,
100
- values
101
- };
79
+ execute
80
+ } = useExecuteAtomicAction({
81
+ ari,
82
+ fieldKey: columnKey,
83
+ integrationKey
84
+ });
85
+ const isEditable = !!execute;
102
86
  const readView = /*#__PURE__*/React.createElement(TooltipWrapper, {
103
87
  columnKey: columnKey,
104
- datasourceTypeWithValues: datasourceTypeWithValues,
88
+ datasourceTypeWithValues: values,
105
89
  wrappedColumnKeys: wrappedColumnKeys
106
90
  }, /*#__PURE__*/React.createElement(Box, {
107
91
  testId: "inline-edit-read-view",
108
92
  paddingInline: isEditable ? 'space.075' : 'space.100',
109
93
  paddingBlock: "space.050",
110
94
  xcss: truncateTextStyles
111
- }, renderItem(datasourceTypeWithValues)));
112
- return isEditable ? /*#__PURE__*/React.createElement(InlineEdit, {
95
+ }, renderItem(values)));
96
+ if (!isEditable) {
97
+ return readView;
98
+ }
99
+ return /*#__PURE__*/React.createElement(InlineEdit, {
113
100
  ari: ari,
101
+ execute: execute,
102
+ readView: readView,
114
103
  columnKey: columnKey,
115
- datasourceTypeWithValues: datasourceTypeWithValues,
116
- readView: readView
117
- }) : readView;
104
+ datasourceTypeWithValues: values
105
+ });
118
106
  };
119
107
  export const TableCellContent = ({
108
+ id,
120
109
  columnKey,
121
110
  columnType,
122
- id,
123
111
  renderItem,
124
112
  wrappedColumnKeys
125
113
  }) => {
126
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
127
- const renderedContent = fg('platform-datasources-enable-two-way-sync') ? /*#__PURE__*/React.createElement(InlineEditableCell, {
128
- id: id,
129
- columnKey: columnKey,
130
- columnType: columnType,
131
- renderItem: renderItem,
132
- wrappedColumnKeys: wrappedColumnKeys
133
- }) : /*#__PURE__*/React.createElement(ReadOnlyCell, {
114
+ const item = useDatasourceItem({
115
+ id
116
+ });
117
+ if (item) {
118
+ const {
119
+ integrationKey,
120
+ ari,
121
+ data: rowData
122
+ } = item;
123
+ const isEditType = !!ari && !!integrationKey && rowData[columnKey] && isEditTypeSupported(columnType);
124
+ if (isEditType) {
125
+ var _rowData$columnKey2;
126
+ // Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
127
+ const value = (_rowData$columnKey2 = rowData[columnKey]) === null || _rowData$columnKey2 === void 0 ? void 0 : _rowData$columnKey2.data;
128
+ const values = Array.isArray(value) ? value : [value];
129
+ const datasourceTypeWithValues = {
130
+ type: columnType,
131
+ values
132
+ };
133
+ return /*#__PURE__*/React.createElement(InlineEditableCell, {
134
+ ari: ari,
135
+ columnKey: columnKey,
136
+ renderItem: renderItem,
137
+ integrationKey: integrationKey,
138
+ values: datasourceTypeWithValues,
139
+ wrappedColumnKeys: wrappedColumnKeys
140
+ });
141
+ }
142
+ }
143
+ return /*#__PURE__*/React.createElement(Box, {
144
+ testId: "inline-edit-read-view",
145
+ paddingInline: "space.100",
146
+ paddingBlock: "space.050",
147
+ xcss: truncateTextStyles
148
+ }, /*#__PURE__*/React.createElement(ReadOnlyCell, {
134
149
  id: id,
135
150
  columnKey: columnKey,
136
151
  columnType: columnType,
137
152
  wrappedColumnKeys: wrappedColumnKeys,
138
153
  renderItem: renderItem
139
- });
140
- return renderedContent;
154
+ }));
141
155
  };
@@ -3,7 +3,6 @@ import React, { useCallback, useState } from 'react';
3
3
  import AKInlineEdit from '@atlaskit/inline-edit';
4
4
  import { Box, xcss } from '@atlaskit/primitives';
5
5
  import { useDatasourceActions, useDatasourceItem } from '../../../state';
6
- import { useExecuteAtomicAction } from '../../../state/actions';
7
6
  import { editType } from '../edit-type';
8
7
  const containerStyles = xcss({
9
8
  marginBlockStart: 'space.negative.100'
@@ -23,11 +22,11 @@ const mapUpdatedItem = (type, existingItem, columnKey, newValue) => {
23
22
  };
24
23
  export const InlineEdit = ({
25
24
  ari,
25
+ execute,
26
+ readView,
26
27
  columnKey,
27
- datasourceTypeWithValues,
28
- readView
28
+ datasourceTypeWithValues
29
29
  }) => {
30
- var _item$integrationKey;
31
30
  const [isEditing, setIsEditing] = useState(false);
32
31
  const item = useDatasourceItem({
33
32
  id: ari
@@ -35,15 +34,8 @@ export const InlineEdit = ({
35
34
  const {
36
35
  onUpdateItem
37
36
  } = useDatasourceActions();
38
- const {
39
- execute
40
- } = useExecuteAtomicAction({
41
- ari,
42
- fieldKey: columnKey,
43
- integrationKey: (_item$integrationKey = item === null || item === void 0 ? void 0 : item.integrationKey) !== null && _item$integrationKey !== void 0 ? _item$integrationKey : ''
44
- });
45
37
  const onCommitUpdate = useCallback(value => {
46
- if (!execute || !item) {
38
+ if (!item) {
47
39
  setIsEditing(false);
48
40
  return;
49
41
  }
@@ -116,7 +116,7 @@ var getFieldUpdateActionByAri = function getFieldUpdateActionByAri(state, _ref3)
116
116
  fieldKey = _ref3.fieldKey,
117
117
  integrationKey = _ref3.integrationKey;
118
118
  var isEditable = (_state$permissions$ar = state.permissions[ari]) === null || _state$permissions$ar === void 0 || (_state$permissions$ar = _state$permissions$ar[fieldKey]) === null || _state$permissions$ar === void 0 ? void 0 : _state$permissions$ar.isEditable;
119
- if (isEditable === false) {
119
+ if (!isEditable) {
120
120
  return;
121
121
  }
122
122
  return (_state$actionsByInteg = state.actionsByIntegration[integrationKey]) === null || _state$actionsByInteg === void 0 ? void 0 : _state$actionsByInteg[fieldKey];
@@ -38,7 +38,7 @@ import { DraggableTableHeading } from './draggable-table-heading';
38
38
  import TableEmptyState from './empty-state';
39
39
  import { renderType, stringifyType } from './render-type';
40
40
  import { InlineEditableTableCell, Table, TableCell, TableHeading, withTablePluginHeaderPrefix } from './styled';
41
- import { TableCellContent } from './table-cell-content';
41
+ import { ReadOnlyCell, TableCellContent } from './table-cell-content';
42
42
  import { TruncateTextTag } from './truncate-text-tag';
43
43
  import { useIsOnScreen } from './useIsOnScreen';
44
44
  import { COLUMN_BASE_WIDTH, getWidthCss } from './utils';
@@ -467,7 +467,14 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
467
467
  return {
468
468
  key: key,
469
469
  columnKey: key,
470
- content: jsx(TableCellContent, {
470
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
471
+ content: fg('platform-datasources-enable-two-way-sync') ? jsx(TableCellContent, {
472
+ id: id,
473
+ columnKey: key,
474
+ columnType: type,
475
+ wrappedColumnKeys: wrappedColumnKeys,
476
+ renderItem: renderItem
477
+ }) : jsx(ReadOnlyCell, {
471
478
  id: id,
472
479
  columnKey: key,
473
480
  columnType: type,
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  import { Box, xcss } from '@atlaskit/primitives';
5
4
  import Tooltip from '@atlaskit/tooltip';
6
5
  import { useDatasourceItem } from '../../../state';
6
+ import { useExecuteAtomicAction } from '../../../state/actions';
7
7
  import { isEditTypeSupported } from '../edit-type';
8
8
  import { stringifyType } from '../render-type';
9
9
  import { TruncateTextTag } from '../truncate-text-tag';
@@ -40,7 +40,7 @@ var TooltipWrapper = function TooltipWrapper(_ref) {
40
40
  }
41
41
  return /*#__PURE__*/React.createElement(React.Fragment, null, children);
42
42
  };
43
- var ReadOnlyCell = function ReadOnlyCell(_ref2) {
43
+ export var ReadOnlyCell = function ReadOnlyCell(_ref2) {
44
44
  var _useDatasourceItem, _rowData$columnKey;
45
45
  var id = _ref2.id,
46
46
  columnType = _ref2.columnType,
@@ -52,7 +52,7 @@ var ReadOnlyCell = function ReadOnlyCell(_ref2) {
52
52
  id: id
53
53
  })) === null || _useDatasourceItem === void 0 ? void 0 : _useDatasourceItem.data;
54
54
  if (!rowData || !columnKey || !rowData[columnKey]) {
55
- return /*#__PURE__*/React.createElement(React.Fragment, null);
55
+ return null;
56
56
  }
57
57
 
58
58
  // Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
@@ -69,71 +69,84 @@ var ReadOnlyCell = function ReadOnlyCell(_ref2) {
69
69
  }, renderItem(datasourceTypeWithValues));
70
70
  };
71
71
  var InlineEditableCell = function InlineEditableCell(_ref3) {
72
- var _rowData$columnKey2;
73
- var id = _ref3.id,
72
+ var ari = _ref3.ari,
73
+ values = _ref3.values,
74
74
  columnKey = _ref3.columnKey,
75
- columnType = _ref3.columnType,
76
75
  renderItem = _ref3.renderItem,
76
+ integrationKey = _ref3.integrationKey,
77
77
  wrappedColumnKeys = _ref3.wrappedColumnKeys;
78
- var item = useDatasourceItem({
79
- id: id
80
- });
81
- if (!item) {
82
- return /*#__PURE__*/React.createElement(React.Fragment, null);
83
- }
84
- var rowData = item.data,
85
- integrationKey = item.integrationKey,
86
- ari = item.ari;
87
- if (!rowData || !columnKey || !rowData[columnKey]) {
88
- return /*#__PURE__*/React.createElement(React.Fragment, null);
89
- }
90
-
91
- // Check if field is editable
92
- var isEditable = !!ari && !!integrationKey && isEditTypeSupported(columnType);
93
-
94
- // Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
95
- var value = (_rowData$columnKey2 = rowData[columnKey]) === null || _rowData$columnKey2 === void 0 ? void 0 : _rowData$columnKey2.data;
96
- var values = Array.isArray(value) ? value : [value];
97
- var datasourceTypeWithValues = {
98
- type: columnType,
99
- values: values
100
- };
78
+ // Execute fn is only returned when the field is editable and the action schema exists
79
+ var _useExecuteAtomicActi = useExecuteAtomicAction({
80
+ ari: ari,
81
+ fieldKey: columnKey,
82
+ integrationKey: integrationKey
83
+ }),
84
+ execute = _useExecuteAtomicActi.execute;
85
+ var isEditable = !!execute;
101
86
  var readView = /*#__PURE__*/React.createElement(TooltipWrapper, {
102
87
  columnKey: columnKey,
103
- datasourceTypeWithValues: datasourceTypeWithValues,
88
+ datasourceTypeWithValues: values,
104
89
  wrappedColumnKeys: wrappedColumnKeys
105
90
  }, /*#__PURE__*/React.createElement(Box, {
106
91
  testId: "inline-edit-read-view",
107
92
  paddingInline: isEditable ? 'space.075' : 'space.100',
108
93
  paddingBlock: "space.050",
109
94
  xcss: truncateTextStyles
110
- }, renderItem(datasourceTypeWithValues)));
111
- return isEditable ? /*#__PURE__*/React.createElement(InlineEdit, {
95
+ }, renderItem(values)));
96
+ if (!isEditable) {
97
+ return readView;
98
+ }
99
+ return /*#__PURE__*/React.createElement(InlineEdit, {
112
100
  ari: ari,
101
+ execute: execute,
102
+ readView: readView,
113
103
  columnKey: columnKey,
114
- datasourceTypeWithValues: datasourceTypeWithValues,
115
- readView: readView
116
- }) : readView;
104
+ datasourceTypeWithValues: values
105
+ });
117
106
  };
118
107
  export var TableCellContent = function TableCellContent(_ref4) {
119
- var columnKey = _ref4.columnKey,
108
+ var id = _ref4.id,
109
+ columnKey = _ref4.columnKey,
120
110
  columnType = _ref4.columnType,
121
- id = _ref4.id,
122
111
  renderItem = _ref4.renderItem,
123
112
  wrappedColumnKeys = _ref4.wrappedColumnKeys;
124
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
125
- var renderedContent = fg('platform-datasources-enable-two-way-sync') ? /*#__PURE__*/React.createElement(InlineEditableCell, {
126
- id: id,
127
- columnKey: columnKey,
128
- columnType: columnType,
129
- renderItem: renderItem,
130
- wrappedColumnKeys: wrappedColumnKeys
131
- }) : /*#__PURE__*/React.createElement(ReadOnlyCell, {
113
+ var item = useDatasourceItem({
114
+ id: id
115
+ });
116
+ if (item) {
117
+ var integrationKey = item.integrationKey,
118
+ ari = item.ari,
119
+ rowData = item.data;
120
+ var isEditType = !!ari && !!integrationKey && rowData[columnKey] && isEditTypeSupported(columnType);
121
+ if (isEditType) {
122
+ var _rowData$columnKey2;
123
+ // Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
124
+ var value = (_rowData$columnKey2 = rowData[columnKey]) === null || _rowData$columnKey2 === void 0 ? void 0 : _rowData$columnKey2.data;
125
+ var values = Array.isArray(value) ? value : [value];
126
+ var datasourceTypeWithValues = {
127
+ type: columnType,
128
+ values: values
129
+ };
130
+ return /*#__PURE__*/React.createElement(InlineEditableCell, {
131
+ ari: ari,
132
+ columnKey: columnKey,
133
+ renderItem: renderItem,
134
+ integrationKey: integrationKey,
135
+ values: datasourceTypeWithValues,
136
+ wrappedColumnKeys: wrappedColumnKeys
137
+ });
138
+ }
139
+ }
140
+ return /*#__PURE__*/React.createElement(Box, {
141
+ testId: "inline-edit-read-view",
142
+ paddingInline: "space.100",
143
+ paddingBlock: "space.050",
144
+ xcss: truncateTextStyles
145
+ }, /*#__PURE__*/React.createElement(ReadOnlyCell, {
132
146
  id: id,
133
147
  columnKey: columnKey,
134
148
  columnType: columnType,
135
149
  wrappedColumnKeys: wrappedColumnKeys,
136
150
  renderItem: renderItem
137
- });
138
- return renderedContent;
151
+ }));
139
152
  };
@@ -7,7 +7,6 @@ import React, { useCallback, useState } from 'react';
7
7
  import AKInlineEdit from '@atlaskit/inline-edit';
8
8
  import { Box, xcss } from '@atlaskit/primitives';
9
9
  import { useDatasourceActions, useDatasourceItem } from '../../../state';
10
- import { useExecuteAtomicAction } from '../../../state/actions';
11
10
  import { editType } from '../edit-type';
12
11
  var containerStyles = xcss({
13
12
  marginBlockStart: 'space.negative.100'
@@ -23,11 +22,11 @@ var mapUpdatedItem = function mapUpdatedItem(type, existingItem, columnKey, newV
23
22
  return null;
24
23
  };
25
24
  export var InlineEdit = function InlineEdit(_ref) {
26
- var _item$integrationKey;
27
25
  var ari = _ref.ari,
26
+ execute = _ref.execute,
27
+ _readView = _ref.readView,
28
28
  columnKey = _ref.columnKey,
29
- datasourceTypeWithValues = _ref.datasourceTypeWithValues,
30
- _readView = _ref.readView;
29
+ datasourceTypeWithValues = _ref.datasourceTypeWithValues;
31
30
  var _useState = useState(false),
32
31
  _useState2 = _slicedToArray(_useState, 2),
33
32
  isEditing = _useState2[0],
@@ -37,14 +36,8 @@ export var InlineEdit = function InlineEdit(_ref) {
37
36
  });
38
37
  var _useDatasourceActions = useDatasourceActions(),
39
38
  onUpdateItem = _useDatasourceActions.onUpdateItem;
40
- var _useExecuteAtomicActi = useExecuteAtomicAction({
41
- ari: ari,
42
- fieldKey: columnKey,
43
- integrationKey: (_item$integrationKey = item === null || item === void 0 ? void 0 : item.integrationKey) !== null && _item$integrationKey !== void 0 ? _item$integrationKey : ''
44
- }),
45
- execute = _useExecuteAtomicActi.execute;
46
39
  var onCommitUpdate = useCallback(function (value) {
47
- if (!execute || !item) {
40
+ if (!item) {
48
41
  setIsEditing(false);
49
42
  return;
50
43
  }
@@ -3,6 +3,6 @@ import { type ButtonClickedCancelAttributesType } from '../../../../analytics/ge
3
3
  export interface CancelButtonProps {
4
4
  getAnalyticsPayload: () => ButtonClickedCancelAttributesType;
5
5
  onCancel: () => void;
6
- testId: string;
6
+ testId?: string;
7
7
  }
8
8
  export declare const CancelButton: ({ getAnalyticsPayload, onCancel, testId }: CancelButtonProps) => jsx.JSX.Element;
@@ -6,7 +6,7 @@ import { type PropsWithChildren } from 'react';
6
6
  import { jsx } from '@emotion/react';
7
7
  import { type DatasourceParameters } from '@atlaskit/linking-types';
8
8
  export type InsertButtonProps<Parameters extends DatasourceParameters> = PropsWithChildren<{
9
- testId: string;
9
+ testId?: string;
10
10
  url: string | undefined;
11
11
  getAnalyticsPayload: () => Record<string, any>;
12
12
  overwriteParameters?: (parameters: Parameters) => Parameters;
@@ -9,5 +9,6 @@ interface TableCellContentProps {
9
9
  renderItem: TableViewPropsRenderType;
10
10
  wrappedColumnKeys: string[] | undefined;
11
11
  }
12
- export declare const TableCellContent: ({ columnKey, columnType, id, renderItem, wrappedColumnKeys, }: TableCellContentProps) => JSX.Element;
12
+ export declare const ReadOnlyCell: ({ id, columnType, wrappedColumnKeys, renderItem, columnKey, }: TableCellContentProps) => JSX.Element | null;
13
+ export declare const TableCellContent: ({ id, columnKey, columnType, renderItem, wrappedColumnKeys, }: TableCellContentProps) => JSX.Element;
13
14
  export {};
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
+ import { type AtomicActionExecuteResponse } from '@atlaskit/linking-types';
2
3
  import type { DatasourceTypeWithOnlyValues } from '../types';
3
4
  interface InlineEditProps {
4
5
  ari: string;
5
6
  columnKey: string;
6
- datasourceTypeWithValues: DatasourceTypeWithOnlyValues;
7
7
  readView: React.ReactNode;
8
+ datasourceTypeWithValues: DatasourceTypeWithOnlyValues;
9
+ execute: (value: string | number) => Promise<AtomicActionExecuteResponse>;
8
10
  }
9
- export declare const InlineEdit: ({ ari, columnKey, datasourceTypeWithValues, readView, }: InlineEditProps) => JSX.Element;
11
+ export declare const InlineEdit: ({ ari, execute, readView, columnKey, datasourceTypeWithValues, }: InlineEditProps) => JSX.Element;
10
12
  export {};
@@ -3,6 +3,6 @@ import { type ButtonClickedCancelAttributesType } from '../../../../analytics/ge
3
3
  export interface CancelButtonProps {
4
4
  getAnalyticsPayload: () => ButtonClickedCancelAttributesType;
5
5
  onCancel: () => void;
6
- testId: string;
6
+ testId?: string;
7
7
  }
8
8
  export declare const CancelButton: ({ getAnalyticsPayload, onCancel, testId }: CancelButtonProps) => jsx.JSX.Element;
@@ -6,7 +6,7 @@ import { type PropsWithChildren } from 'react';
6
6
  import { jsx } from '@emotion/react';
7
7
  import { type DatasourceParameters } from '@atlaskit/linking-types';
8
8
  export type InsertButtonProps<Parameters extends DatasourceParameters> = PropsWithChildren<{
9
- testId: string;
9
+ testId?: string;
10
10
  url: string | undefined;
11
11
  getAnalyticsPayload: () => Record<string, any>;
12
12
  overwriteParameters?: (parameters: Parameters) => Parameters;
@@ -9,5 +9,6 @@ interface TableCellContentProps {
9
9
  renderItem: TableViewPropsRenderType;
10
10
  wrappedColumnKeys: string[] | undefined;
11
11
  }
12
- export declare const TableCellContent: ({ columnKey, columnType, id, renderItem, wrappedColumnKeys, }: TableCellContentProps) => JSX.Element;
12
+ export declare const ReadOnlyCell: ({ id, columnType, wrappedColumnKeys, renderItem, columnKey, }: TableCellContentProps) => JSX.Element | null;
13
+ export declare const TableCellContent: ({ id, columnKey, columnType, renderItem, wrappedColumnKeys, }: TableCellContentProps) => JSX.Element;
13
14
  export {};
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
+ import { type AtomicActionExecuteResponse } from '@atlaskit/linking-types';
2
3
  import type { DatasourceTypeWithOnlyValues } from '../types';
3
4
  interface InlineEditProps {
4
5
  ari: string;
5
6
  columnKey: string;
6
- datasourceTypeWithValues: DatasourceTypeWithOnlyValues;
7
7
  readView: React.ReactNode;
8
+ datasourceTypeWithValues: DatasourceTypeWithOnlyValues;
9
+ execute: (value: string | number) => Promise<AtomicActionExecuteResponse>;
8
10
  }
9
- export declare const InlineEdit: ({ ari, columnKey, datasourceTypeWithValues, readView, }: InlineEditProps) => JSX.Element;
11
+ export declare const InlineEdit: ({ ari, execute, readView, columnKey, datasourceTypeWithValues, }: InlineEditProps) => JSX.Element;
10
12
  export {};
@@ -1,8 +1,7 @@
1
- import React, { useEffect } from 'react';
1
+ import React from 'react';
2
2
 
3
3
  import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
4
4
  import { SmartCardProvider } from '@atlaskit/link-provider';
5
- import { mockAssetsClientFetchRequests } from '@atlaskit/link-test-helpers/datasource';
6
5
  import { type DatasourceParameters } from '@atlaskit/linking-types';
7
6
 
8
7
  import { DatasourceTableView } from '../src';
@@ -55,12 +54,6 @@ const AssetsTableView = () => {
55
54
  export const ExampleAssetsIssuesTableView = ({
56
55
  mockDatasourceFetchRequest = true,
57
56
  }: AssetsTableViewProps) => {
58
- useEffect(() => {
59
- if (mockDatasourceFetchRequest) {
60
- mockAssetsClientFetchRequests();
61
- }
62
- }, [mockDatasourceFetchRequest]);
63
-
64
57
  return (
65
58
  <IntlMessagesProvider loaderFn={fetchMessagesForLocale}>
66
59
  <SmartCardProvider client={new SmartLinkClient()}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-datasource",
3
- "version": "2.10.3",
3
+ "version": "2.11.1",
4
4
  "description": "UI Components to support linking platform dataset feature",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,7 +29,8 @@
29
29
  "i18n": true,
30
30
  "website": {
31
31
  "name": "Link Datasource"
32
- }
32
+ },
33
+ "runReact18": true
33
34
  },
34
35
  "scripts": {
35
36
  "analytics:codegen": "yarn workspace @atlassian/analytics-tooling run analytics:codegen link-datasource --output ./src/analytics/generated"
@@ -37,17 +38,17 @@
37
38
  "dependencies": {
38
39
  "@atlaskit/adf-schema": "^40.8.1",
39
40
  "@atlaskit/analytics-next": "^10.1.0",
40
- "@atlaskit/avatar": "^21.14.0",
41
+ "@atlaskit/avatar": "^21.15.0",
41
42
  "@atlaskit/avatar-group": "^9.11.0",
42
43
  "@atlaskit/badge": "^16.4.0",
43
- "@atlaskit/button": "^19.2.0",
44
- "@atlaskit/datetime-picker": "^13.10.0",
44
+ "@atlaskit/button": "^20.0.0",
45
+ "@atlaskit/datetime-picker": "^13.11.0",
45
46
  "@atlaskit/dropdown-menu": "^12.17.0",
46
47
  "@atlaskit/editor-prosemirror": "5.0.1",
47
48
  "@atlaskit/empty-state": "^7.11.0",
48
49
  "@atlaskit/form": "^10.5.0",
49
50
  "@atlaskit/heading": "^2.4.0",
50
- "@atlaskit/icon": "^22.12.0",
51
+ "@atlaskit/icon": "^22.13.0",
51
52
  "@atlaskit/icon-object": "^6.5.0",
52
53
  "@atlaskit/image": "^1.3.0",
53
54
  "@atlaskit/inline-edit": "^13.6.0",
@@ -63,14 +64,14 @@
63
64
  "@atlaskit/modal-dialog": "^12.15.0",
64
65
  "@atlaskit/outbound-auth-flow-client": "^3.4.5",
65
66
  "@atlaskit/platform-feature-flags": "^0.3.0",
66
- "@atlaskit/popup": "^1.22.0",
67
+ "@atlaskit/popup": "^1.23.0",
67
68
  "@atlaskit/pragmatic-drag-and-drop": "^1.3.0",
68
69
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.0",
69
70
  "@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll": "^1.2.0",
70
71
  "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.0",
71
72
  "@atlaskit/primitives": "^12.0.0",
72
- "@atlaskit/select": "^17.13.0",
73
- "@atlaskit/smart-card": "^27.15.0",
73
+ "@atlaskit/select": "^17.15.0",
74
+ "@atlaskit/smart-card": "^27.16.0",
74
75
  "@atlaskit/smart-user-picker": "6.10.2",
75
76
  "@atlaskit/spinner": "^16.3.0",
76
77
  "@atlaskit/tag": "^12.5.0",
@@ -92,7 +93,7 @@
92
93
  "uuid": "^3.1.0"
93
94
  },
94
95
  "peerDependencies": {
95
- "react": "^16.8.0",
96
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
96
97
  "react-intl-next": "npm:react-intl@^5.18.1"
97
98
  },
98
99
  "devDependencies": {