@atlaskit/link-datasource 3.6.12 → 3.6.13
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 +8 -0
- package/dist/cjs/ui/issue-like-table/edit-type/index.js +15 -12
- package/dist/cjs/ui/issue-like-table/edit-type/text/index.js +12 -1
- package/dist/cjs/ui/issue-like-table/table-cell-content/inline-edit.js +26 -9
- package/dist/es2019/ui/issue-like-table/edit-type/index.js +10 -8
- package/dist/es2019/ui/issue-like-table/edit-type/text/index.js +10 -1
- package/dist/es2019/ui/issue-like-table/table-cell-content/inline-edit.js +21 -9
- package/dist/esm/ui/issue-like-table/edit-type/index.js +12 -12
- package/dist/esm/ui/issue-like-table/edit-type/text/index.js +11 -0
- package/dist/esm/ui/issue-like-table/table-cell-content/inline-edit.js +26 -9
- package/dist/types/ui/issue-like-table/edit-type/index.d.ts +5 -1
- package/dist/types/ui/issue-like-table/edit-type/text/index.d.ts +6 -2
- package/dist/types-ts4.5/ui/issue-like-table/edit-type/index.d.ts +5 -1
- package/dist/types-ts4.5/ui/issue-like-table/edit-type/text/index.d.ts +6 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/link-datasource
|
|
2
2
|
|
|
3
|
+
## 3.6.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#153904](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/153904)
|
|
8
|
+
[`c08ee2802b968`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c08ee2802b968) -
|
|
9
|
+
Change inline-edit to be a controlled component
|
|
10
|
+
|
|
3
11
|
## 3.6.12
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.isEditTypeSupported = exports.editType = void 0;
|
|
9
|
+
var _objectDestructuringEmpty2 = _interopRequireDefault(require("@babel/runtime/helpers/objectDestructuringEmpty"));
|
|
8
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
11
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
var _text =
|
|
12
|
-
|
|
12
|
+
var _text = _interopRequireWildcard(require("./text"));
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
13
15
|
// This is used in editor-card-plugin to identify if any type of inline edit is active.
|
|
14
16
|
var ACTIVE_INLINE_EDIT_ID = 'sllv-active-inline-edit';
|
|
15
|
-
var editType = exports.editType = function editType(
|
|
16
|
-
var
|
|
17
|
-
|
|
17
|
+
var editType = exports.editType = function editType(_ref) {
|
|
18
|
+
var defaultValue = _ref.defaultValue,
|
|
19
|
+
currentValue = _ref.currentValue,
|
|
20
|
+
setEditValues = _ref.setEditValues;
|
|
21
|
+
switch (defaultValue.type) {
|
|
18
22
|
case 'string':
|
|
19
|
-
var stringValue = (_item$values$ = (_item$values = item.values) === null || _item$values === void 0 ? void 0 : _item$values[0]) !== null && _item$values$ !== void 0 ? _item$values$ : '';
|
|
20
23
|
return {
|
|
21
|
-
defaultValue:
|
|
22
|
-
editView: function editView(
|
|
23
|
-
var
|
|
24
|
-
fieldProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
24
|
+
defaultValue: (0, _text.toTextValue)(defaultValue),
|
|
25
|
+
editView: function editView(_ref2) {
|
|
26
|
+
var fieldProps = (0, _extends2.default)({}, ((0, _objectDestructuringEmpty2.default)(_ref2), _ref2));
|
|
25
27
|
return /*#__PURE__*/_react.default.createElement(_text.default, (0, _extends2.default)({}, fieldProps, {
|
|
26
|
-
|
|
28
|
+
currentValue: currentValue,
|
|
29
|
+
setEditValues: setEditValues,
|
|
27
30
|
id: ACTIVE_INLINE_EDIT_ID
|
|
28
31
|
}));
|
|
29
32
|
}
|
|
@@ -4,11 +4,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = void 0;
|
|
7
|
+
exports.toTextValue = exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _layering = require("@atlaskit/layering");
|
|
11
11
|
var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
|
|
12
|
+
var toTextValue = exports.toTextValue = function toTextValue(typeWithValues) {
|
|
13
|
+
var _ref, _typeWithValues$value;
|
|
14
|
+
return (_ref = (_typeWithValues$value = typeWithValues.values) === null || _typeWithValues$value === void 0 ? void 0 : _typeWithValues$value[0]) !== null && _ref !== void 0 ? _ref : '';
|
|
15
|
+
};
|
|
12
16
|
var TextEditType = function TextEditType(props) {
|
|
13
17
|
return /*#__PURE__*/_react.default.createElement(_layering.UNSAFE_LAYERING, {
|
|
14
18
|
isDisabled: false
|
|
@@ -19,6 +23,13 @@ var TextEditType = function TextEditType(props) {
|
|
|
19
23
|
style: {
|
|
20
24
|
// We need 8px left padding to match read only version, but there is already 1px of border
|
|
21
25
|
padding: "var(--ds-space-100, 8px)".concat(" calc(", "var(--ds-space-100, 8px)", " - 1px)")
|
|
26
|
+
},
|
|
27
|
+
value: toTextValue(props.currentValue),
|
|
28
|
+
onChange: function onChange(e) {
|
|
29
|
+
return props.setEditValues({
|
|
30
|
+
type: 'string',
|
|
31
|
+
values: [e.currentTarget.value]
|
|
32
|
+
});
|
|
22
33
|
}
|
|
23
34
|
})));
|
|
24
35
|
};
|
|
@@ -25,11 +25,18 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
25
25
|
var editContainerStyles = (0, _primitives.xcss)({
|
|
26
26
|
marginBlockStart: 'space.negative.100'
|
|
27
27
|
});
|
|
28
|
-
var
|
|
29
|
-
switch (type) {
|
|
28
|
+
var getBackendUpdateValue = function getBackendUpdateValue(typedNewValue) {
|
|
29
|
+
switch (typedNewValue.type) {
|
|
30
|
+
case 'string':
|
|
31
|
+
return typedNewValue.values[0] || '';
|
|
32
|
+
}
|
|
33
|
+
throw new Error("Datasource 2 way sync Backend update value not implemented for type ".concat(typedNewValue.type));
|
|
34
|
+
};
|
|
35
|
+
var mapUpdatedItem = function mapUpdatedItem(existingItem, columnKey, newValue) {
|
|
36
|
+
switch (newValue.type) {
|
|
30
37
|
case 'string':
|
|
31
38
|
return _objectSpread(_objectSpread({}, existingItem), {}, (0, _defineProperty2.default)({}, columnKey, {
|
|
32
|
-
data: newValue
|
|
39
|
+
data: newValue.values[0] || ''
|
|
33
40
|
}));
|
|
34
41
|
default:
|
|
35
42
|
}
|
|
@@ -62,6 +69,10 @@ var InlineEdit = exports.InlineEdit = function InlineEdit(_ref) {
|
|
|
62
69
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
63
70
|
isEditing = _useState2[0],
|
|
64
71
|
setIsEditing = _useState2[1];
|
|
72
|
+
var _useState3 = (0, _react.useState)(datasourceTypeWithValues),
|
|
73
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
74
|
+
editValues = _useState4[0],
|
|
75
|
+
setEditValues = _useState4[1];
|
|
65
76
|
var item = (0, _state.useDatasourceItem)({
|
|
66
77
|
id: ari
|
|
67
78
|
});
|
|
@@ -75,20 +86,20 @@ var InlineEdit = exports.InlineEdit = function InlineEdit(_ref) {
|
|
|
75
86
|
var _useDatasourceAnalyti = (0, _analytics.useDatasourceAnalyticsEvents)(),
|
|
76
87
|
fireEvent = _useDatasourceAnalyti.fireEvent;
|
|
77
88
|
var refreshDatasourceItem = useRefreshDatasourceItem(item);
|
|
78
|
-
var onCommitUpdate = (0, _react.useCallback)(function (
|
|
89
|
+
var onCommitUpdate = (0, _react.useCallback)(function (newValue) {
|
|
79
90
|
if (!item) {
|
|
80
91
|
setIsEditing(false);
|
|
81
92
|
return;
|
|
82
93
|
}
|
|
83
94
|
var existingData = item.data;
|
|
84
|
-
var newItem = mapUpdatedItem(
|
|
95
|
+
var newItem = mapUpdatedItem(item.data, columnKey, newValue);
|
|
85
96
|
if (!newItem || !isNewValue(columnKey, newItem, existingData)) {
|
|
86
97
|
setIsEditing(false);
|
|
87
98
|
return;
|
|
88
99
|
}
|
|
89
100
|
onUpdateItem(ari, newItem);
|
|
90
101
|
fireEvent('ui.form.submitted.inlineEdit', {});
|
|
91
|
-
execute(
|
|
102
|
+
execute(getBackendUpdateValue(newValue)).then(refreshDatasourceItem).catch(function (error) {
|
|
92
103
|
var status = error && (0, _typeof2.default)(error) === 'object' ? error.status : undefined;
|
|
93
104
|
showErrorFlag({
|
|
94
105
|
status: status
|
|
@@ -96,7 +107,7 @@ var InlineEdit = exports.InlineEdit = function InlineEdit(_ref) {
|
|
|
96
107
|
onUpdateItem(ari, existingData);
|
|
97
108
|
});
|
|
98
109
|
setIsEditing(false);
|
|
99
|
-
}, [item,
|
|
110
|
+
}, [item, columnKey, onUpdateItem, ari, refreshDatasourceItem, fireEvent, execute, showErrorFlag]);
|
|
100
111
|
var onEdit = (0, _react.useCallback)(function () {
|
|
101
112
|
setIsEditing(true);
|
|
102
113
|
if (integrationKey && entityType) {
|
|
@@ -119,7 +130,11 @@ var InlineEdit = exports.InlineEdit = function InlineEdit(_ref) {
|
|
|
119
130
|
}, [columnKey, entityType, fireEvent, integrationKey]);
|
|
120
131
|
return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
|
|
121
132
|
xcss: editContainerStyles
|
|
122
|
-
}, /*#__PURE__*/_react.default.createElement(_inlineEdit.default, (0, _extends2.default)({}, (0, _editType.editType)(
|
|
133
|
+
}, /*#__PURE__*/_react.default.createElement(_inlineEdit.default, (0, _extends2.default)({}, (0, _editType.editType)({
|
|
134
|
+
defaultValue: datasourceTypeWithValues,
|
|
135
|
+
currentValue: editValues,
|
|
136
|
+
setEditValues: setEditValues
|
|
137
|
+
}), {
|
|
123
138
|
hideActionButtons: true,
|
|
124
139
|
readView: function readView() {
|
|
125
140
|
return _readView;
|
|
@@ -128,6 +143,8 @@ var InlineEdit = exports.InlineEdit = function InlineEdit(_ref) {
|
|
|
128
143
|
isEditing: isEditing,
|
|
129
144
|
onEdit: onEdit,
|
|
130
145
|
onCancel: onCancelEdit,
|
|
131
|
-
onConfirm:
|
|
146
|
+
onConfirm: function onConfirm() {
|
|
147
|
+
return onCommitUpdate(editValues);
|
|
148
|
+
}
|
|
132
149
|
})));
|
|
133
150
|
};
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import TextEditType from './text';
|
|
3
|
+
import TextEditType, { toTextValue } from './text';
|
|
4
4
|
|
|
5
5
|
// This is used in editor-card-plugin to identify if any type of inline edit is active.
|
|
6
6
|
const ACTIVE_INLINE_EDIT_ID = 'sllv-active-inline-edit';
|
|
7
|
-
export const editType =
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export const editType = ({
|
|
8
|
+
defaultValue,
|
|
9
|
+
currentValue,
|
|
10
|
+
setEditValues
|
|
11
|
+
}) => {
|
|
12
|
+
switch (defaultValue.type) {
|
|
10
13
|
case 'string':
|
|
11
|
-
const stringValue = (_item$values$ = (_item$values = item.values) === null || _item$values === void 0 ? void 0 : _item$values[0]) !== null && _item$values$ !== void 0 ? _item$values$ : '';
|
|
12
14
|
return {
|
|
13
|
-
defaultValue:
|
|
15
|
+
defaultValue: toTextValue(defaultValue),
|
|
14
16
|
editView: ({
|
|
15
|
-
value,
|
|
16
17
|
...fieldProps
|
|
17
18
|
}) => /*#__PURE__*/React.createElement(TextEditType, _extends({}, fieldProps, {
|
|
18
|
-
|
|
19
|
+
currentValue: currentValue,
|
|
20
|
+
setEditValues: setEditValues,
|
|
19
21
|
id: ACTIVE_INLINE_EDIT_ID
|
|
20
22
|
}))
|
|
21
23
|
};
|
|
@@ -2,6 +2,10 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { UNSAFE_LAYERING } from '@atlaskit/layering';
|
|
4
4
|
import Textfield from '@atlaskit/textfield';
|
|
5
|
+
export const toTextValue = typeWithValues => {
|
|
6
|
+
var _ref, _typeWithValues$value;
|
|
7
|
+
return (_ref = (_typeWithValues$value = typeWithValues.values) === null || _typeWithValues$value === void 0 ? void 0 : _typeWithValues$value[0]) !== null && _ref !== void 0 ? _ref : '';
|
|
8
|
+
};
|
|
5
9
|
const TextEditType = props => {
|
|
6
10
|
return /*#__PURE__*/React.createElement(UNSAFE_LAYERING, {
|
|
7
11
|
isDisabled: false
|
|
@@ -12,7 +16,12 @@ const TextEditType = props => {
|
|
|
12
16
|
style: {
|
|
13
17
|
// We need 8px left padding to match read only version, but there is already 1px of border
|
|
14
18
|
padding: `${"var(--ds-space-100, 8px)"} calc(${"var(--ds-space-100, 8px)"} - 1px)`
|
|
15
|
-
}
|
|
19
|
+
},
|
|
20
|
+
value: toTextValue(props.currentValue),
|
|
21
|
+
onChange: e => props.setEditValues({
|
|
22
|
+
type: 'string',
|
|
23
|
+
values: [e.currentTarget.value]
|
|
24
|
+
})
|
|
16
25
|
})));
|
|
17
26
|
};
|
|
18
27
|
export default TextEditType;
|
|
@@ -10,13 +10,20 @@ import { editType } from '../edit-type';
|
|
|
10
10
|
const editContainerStyles = xcss({
|
|
11
11
|
marginBlockStart: 'space.negative.100'
|
|
12
12
|
});
|
|
13
|
-
const
|
|
14
|
-
switch (type) {
|
|
13
|
+
const getBackendUpdateValue = typedNewValue => {
|
|
14
|
+
switch (typedNewValue.type) {
|
|
15
|
+
case 'string':
|
|
16
|
+
return typedNewValue.values[0] || '';
|
|
17
|
+
}
|
|
18
|
+
throw new Error(`Datasource 2 way sync Backend update value not implemented for type ${typedNewValue.type}`);
|
|
19
|
+
};
|
|
20
|
+
const mapUpdatedItem = (existingItem, columnKey, newValue) => {
|
|
21
|
+
switch (newValue.type) {
|
|
15
22
|
case 'string':
|
|
16
23
|
return {
|
|
17
24
|
...existingItem,
|
|
18
25
|
[columnKey]: {
|
|
19
|
-
data: newValue
|
|
26
|
+
data: newValue.values[0] || ''
|
|
20
27
|
}
|
|
21
28
|
};
|
|
22
29
|
default:
|
|
@@ -48,6 +55,7 @@ export const InlineEdit = ({
|
|
|
48
55
|
datasourceTypeWithValues
|
|
49
56
|
}) => {
|
|
50
57
|
const [isEditing, setIsEditing] = useState(false);
|
|
58
|
+
const [editValues, setEditValues] = useState(datasourceTypeWithValues);
|
|
51
59
|
const item = useDatasourceItem({
|
|
52
60
|
id: ari
|
|
53
61
|
});
|
|
@@ -65,20 +73,20 @@ export const InlineEdit = ({
|
|
|
65
73
|
fireEvent
|
|
66
74
|
} = useDatasourceAnalyticsEvents();
|
|
67
75
|
const refreshDatasourceItem = useRefreshDatasourceItem(item);
|
|
68
|
-
const onCommitUpdate = useCallback(
|
|
76
|
+
const onCommitUpdate = useCallback(newValue => {
|
|
69
77
|
if (!item) {
|
|
70
78
|
setIsEditing(false);
|
|
71
79
|
return;
|
|
72
80
|
}
|
|
73
81
|
const existingData = item.data;
|
|
74
|
-
const newItem = mapUpdatedItem(
|
|
82
|
+
const newItem = mapUpdatedItem(item.data, columnKey, newValue);
|
|
75
83
|
if (!newItem || !isNewValue(columnKey, newItem, existingData)) {
|
|
76
84
|
setIsEditing(false);
|
|
77
85
|
return;
|
|
78
86
|
}
|
|
79
87
|
onUpdateItem(ari, newItem);
|
|
80
88
|
fireEvent('ui.form.submitted.inlineEdit', {});
|
|
81
|
-
execute(
|
|
89
|
+
execute(getBackendUpdateValue(newValue)).then(refreshDatasourceItem).catch(error => {
|
|
82
90
|
const status = error && typeof error === 'object' ? error.status : undefined;
|
|
83
91
|
showErrorFlag({
|
|
84
92
|
status
|
|
@@ -86,7 +94,7 @@ export const InlineEdit = ({
|
|
|
86
94
|
onUpdateItem(ari, existingData);
|
|
87
95
|
});
|
|
88
96
|
setIsEditing(false);
|
|
89
|
-
}, [item,
|
|
97
|
+
}, [item, columnKey, onUpdateItem, ari, refreshDatasourceItem, fireEvent, execute, showErrorFlag]);
|
|
90
98
|
const onEdit = useCallback(() => {
|
|
91
99
|
setIsEditing(true);
|
|
92
100
|
if (integrationKey && entityType) {
|
|
@@ -109,13 +117,17 @@ export const InlineEdit = ({
|
|
|
109
117
|
}, [columnKey, entityType, fireEvent, integrationKey]);
|
|
110
118
|
return /*#__PURE__*/React.createElement(Box, {
|
|
111
119
|
xcss: editContainerStyles
|
|
112
|
-
}, /*#__PURE__*/React.createElement(AKInlineEdit, _extends({}, editType(
|
|
120
|
+
}, /*#__PURE__*/React.createElement(AKInlineEdit, _extends({}, editType({
|
|
121
|
+
defaultValue: datasourceTypeWithValues,
|
|
122
|
+
currentValue: editValues,
|
|
123
|
+
setEditValues
|
|
124
|
+
}), {
|
|
113
125
|
hideActionButtons: true,
|
|
114
126
|
readView: () => readView,
|
|
115
127
|
readViewFitContainerWidth: true,
|
|
116
128
|
isEditing: isEditing,
|
|
117
129
|
onEdit: onEdit,
|
|
118
130
|
onCancel: onCancelEdit,
|
|
119
|
-
onConfirm: onCommitUpdate
|
|
131
|
+
onConfirm: () => onCommitUpdate(editValues)
|
|
120
132
|
})));
|
|
121
133
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
+
import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
|
|
1
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["value"];
|
|
4
3
|
import React from 'react';
|
|
5
|
-
import TextEditType from './text';
|
|
4
|
+
import TextEditType, { toTextValue } from './text';
|
|
6
5
|
|
|
7
6
|
// This is used in editor-card-plugin to identify if any type of inline edit is active.
|
|
8
7
|
var ACTIVE_INLINE_EDIT_ID = 'sllv-active-inline-edit';
|
|
9
|
-
export var editType = function editType(
|
|
10
|
-
var
|
|
11
|
-
|
|
8
|
+
export var editType = function editType(_ref) {
|
|
9
|
+
var defaultValue = _ref.defaultValue,
|
|
10
|
+
currentValue = _ref.currentValue,
|
|
11
|
+
setEditValues = _ref.setEditValues;
|
|
12
|
+
switch (defaultValue.type) {
|
|
12
13
|
case 'string':
|
|
13
|
-
var stringValue = (_item$values$ = (_item$values = item.values) === null || _item$values === void 0 ? void 0 : _item$values[0]) !== null && _item$values$ !== void 0 ? _item$values$ : '';
|
|
14
14
|
return {
|
|
15
|
-
defaultValue:
|
|
16
|
-
editView: function editView(
|
|
17
|
-
var
|
|
18
|
-
fieldProps = _objectWithoutProperties(_ref, _excluded);
|
|
15
|
+
defaultValue: toTextValue(defaultValue),
|
|
16
|
+
editView: function editView(_ref2) {
|
|
17
|
+
var fieldProps = _extends({}, (_objectDestructuringEmpty(_ref2), _ref2));
|
|
19
18
|
return /*#__PURE__*/React.createElement(TextEditType, _extends({}, fieldProps, {
|
|
20
|
-
|
|
19
|
+
currentValue: currentValue,
|
|
20
|
+
setEditValues: setEditValues,
|
|
21
21
|
id: ACTIVE_INLINE_EDIT_ID
|
|
22
22
|
}));
|
|
23
23
|
}
|
|
@@ -2,6 +2,10 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { UNSAFE_LAYERING } from '@atlaskit/layering';
|
|
4
4
|
import Textfield from '@atlaskit/textfield';
|
|
5
|
+
export var toTextValue = function toTextValue(typeWithValues) {
|
|
6
|
+
var _ref, _typeWithValues$value;
|
|
7
|
+
return (_ref = (_typeWithValues$value = typeWithValues.values) === null || _typeWithValues$value === void 0 ? void 0 : _typeWithValues$value[0]) !== null && _ref !== void 0 ? _ref : '';
|
|
8
|
+
};
|
|
5
9
|
var TextEditType = function TextEditType(props) {
|
|
6
10
|
return /*#__PURE__*/React.createElement(UNSAFE_LAYERING, {
|
|
7
11
|
isDisabled: false
|
|
@@ -12,6 +16,13 @@ var TextEditType = function TextEditType(props) {
|
|
|
12
16
|
style: {
|
|
13
17
|
// We need 8px left padding to match read only version, but there is already 1px of border
|
|
14
18
|
padding: "var(--ds-space-100, 8px)".concat(" calc(", "var(--ds-space-100, 8px)", " - 1px)")
|
|
19
|
+
},
|
|
20
|
+
value: toTextValue(props.currentValue),
|
|
21
|
+
onChange: function onChange(e) {
|
|
22
|
+
return props.setEditValues({
|
|
23
|
+
type: 'string',
|
|
24
|
+
values: [e.currentTarget.value]
|
|
25
|
+
});
|
|
15
26
|
}
|
|
16
27
|
})));
|
|
17
28
|
};
|
|
@@ -15,11 +15,18 @@ import { editType } from '../edit-type';
|
|
|
15
15
|
var editContainerStyles = xcss({
|
|
16
16
|
marginBlockStart: 'space.negative.100'
|
|
17
17
|
});
|
|
18
|
-
var
|
|
19
|
-
switch (type) {
|
|
18
|
+
var getBackendUpdateValue = function getBackendUpdateValue(typedNewValue) {
|
|
19
|
+
switch (typedNewValue.type) {
|
|
20
|
+
case 'string':
|
|
21
|
+
return typedNewValue.values[0] || '';
|
|
22
|
+
}
|
|
23
|
+
throw new Error("Datasource 2 way sync Backend update value not implemented for type ".concat(typedNewValue.type));
|
|
24
|
+
};
|
|
25
|
+
var mapUpdatedItem = function mapUpdatedItem(existingItem, columnKey, newValue) {
|
|
26
|
+
switch (newValue.type) {
|
|
20
27
|
case 'string':
|
|
21
28
|
return _objectSpread(_objectSpread({}, existingItem), {}, _defineProperty({}, columnKey, {
|
|
22
|
-
data: newValue
|
|
29
|
+
data: newValue.values[0] || ''
|
|
23
30
|
}));
|
|
24
31
|
default:
|
|
25
32
|
}
|
|
@@ -52,6 +59,10 @@ export var InlineEdit = function InlineEdit(_ref) {
|
|
|
52
59
|
_useState2 = _slicedToArray(_useState, 2),
|
|
53
60
|
isEditing = _useState2[0],
|
|
54
61
|
setIsEditing = _useState2[1];
|
|
62
|
+
var _useState3 = useState(datasourceTypeWithValues),
|
|
63
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
64
|
+
editValues = _useState4[0],
|
|
65
|
+
setEditValues = _useState4[1];
|
|
55
66
|
var item = useDatasourceItem({
|
|
56
67
|
id: ari
|
|
57
68
|
});
|
|
@@ -65,20 +76,20 @@ export var InlineEdit = function InlineEdit(_ref) {
|
|
|
65
76
|
var _useDatasourceAnalyti = useDatasourceAnalyticsEvents(),
|
|
66
77
|
fireEvent = _useDatasourceAnalyti.fireEvent;
|
|
67
78
|
var refreshDatasourceItem = useRefreshDatasourceItem(item);
|
|
68
|
-
var onCommitUpdate = useCallback(function (
|
|
79
|
+
var onCommitUpdate = useCallback(function (newValue) {
|
|
69
80
|
if (!item) {
|
|
70
81
|
setIsEditing(false);
|
|
71
82
|
return;
|
|
72
83
|
}
|
|
73
84
|
var existingData = item.data;
|
|
74
|
-
var newItem = mapUpdatedItem(
|
|
85
|
+
var newItem = mapUpdatedItem(item.data, columnKey, newValue);
|
|
75
86
|
if (!newItem || !isNewValue(columnKey, newItem, existingData)) {
|
|
76
87
|
setIsEditing(false);
|
|
77
88
|
return;
|
|
78
89
|
}
|
|
79
90
|
onUpdateItem(ari, newItem);
|
|
80
91
|
fireEvent('ui.form.submitted.inlineEdit', {});
|
|
81
|
-
execute(
|
|
92
|
+
execute(getBackendUpdateValue(newValue)).then(refreshDatasourceItem).catch(function (error) {
|
|
82
93
|
var status = error && _typeof(error) === 'object' ? error.status : undefined;
|
|
83
94
|
showErrorFlag({
|
|
84
95
|
status: status
|
|
@@ -86,7 +97,7 @@ export var InlineEdit = function InlineEdit(_ref) {
|
|
|
86
97
|
onUpdateItem(ari, existingData);
|
|
87
98
|
});
|
|
88
99
|
setIsEditing(false);
|
|
89
|
-
}, [item,
|
|
100
|
+
}, [item, columnKey, onUpdateItem, ari, refreshDatasourceItem, fireEvent, execute, showErrorFlag]);
|
|
90
101
|
var onEdit = useCallback(function () {
|
|
91
102
|
setIsEditing(true);
|
|
92
103
|
if (integrationKey && entityType) {
|
|
@@ -109,7 +120,11 @@ export var InlineEdit = function InlineEdit(_ref) {
|
|
|
109
120
|
}, [columnKey, entityType, fireEvent, integrationKey]);
|
|
110
121
|
return /*#__PURE__*/React.createElement(Box, {
|
|
111
122
|
xcss: editContainerStyles
|
|
112
|
-
}, /*#__PURE__*/React.createElement(AKInlineEdit, _extends({}, editType(
|
|
123
|
+
}, /*#__PURE__*/React.createElement(AKInlineEdit, _extends({}, editType({
|
|
124
|
+
defaultValue: datasourceTypeWithValues,
|
|
125
|
+
currentValue: editValues,
|
|
126
|
+
setEditValues: setEditValues
|
|
127
|
+
}), {
|
|
113
128
|
hideActionButtons: true,
|
|
114
129
|
readView: function readView() {
|
|
115
130
|
return _readView;
|
|
@@ -118,6 +133,8 @@ export var InlineEdit = function InlineEdit(_ref) {
|
|
|
118
133
|
isEditing: isEditing,
|
|
119
134
|
onEdit: onEdit,
|
|
120
135
|
onCancel: onCancelEdit,
|
|
121
|
-
onConfirm:
|
|
136
|
+
onConfirm: function onConfirm() {
|
|
137
|
+
return onCommitUpdate(editValues);
|
|
138
|
+
}
|
|
122
139
|
})));
|
|
123
140
|
};
|
|
@@ -2,5 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import type InlineEdit from '@atlaskit/inline-edit';
|
|
3
3
|
import type { DatasourceType } from '@atlaskit/linking-types';
|
|
4
4
|
import { type DatasourceTypeWithOnlyValues } from '../types';
|
|
5
|
-
export declare const editType: (
|
|
5
|
+
export declare const editType: ({ defaultValue, currentValue, setEditValues, }: {
|
|
6
|
+
defaultValue: DatasourceTypeWithOnlyValues;
|
|
7
|
+
currentValue: DatasourceTypeWithOnlyValues;
|
|
8
|
+
setEditValues: React.Dispatch<React.SetStateAction<DatasourceTypeWithOnlyValues>>;
|
|
9
|
+
}) => Pick<React.ComponentProps<typeof InlineEdit>, 'defaultValue' | 'editView'>;
|
|
6
10
|
export declare const isEditTypeSupported: (type: DatasourceType['type']) => boolean;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import { type FieldProps } from '@atlaskit/form';
|
|
3
|
+
import type { DatasourceTypeWithOnlyValues } from '../../types';
|
|
4
|
+
interface TextEditTypeProps extends Omit<FieldProps<string>, 'value'> {
|
|
5
|
+
currentValue: DatasourceTypeWithOnlyValues;
|
|
6
|
+
setEditValues: React.Dispatch<React.SetStateAction<DatasourceTypeWithOnlyValues>>;
|
|
4
7
|
}
|
|
8
|
+
export declare const toTextValue: (typeWithValues: DatasourceTypeWithOnlyValues) => string;
|
|
5
9
|
declare const TextEditType: (props: TextEditTypeProps) => JSX.Element;
|
|
6
10
|
export default TextEditType;
|
|
@@ -2,5 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import type InlineEdit from '@atlaskit/inline-edit';
|
|
3
3
|
import type { DatasourceType } from '@atlaskit/linking-types';
|
|
4
4
|
import { type DatasourceTypeWithOnlyValues } from '../types';
|
|
5
|
-
export declare const editType: (
|
|
5
|
+
export declare const editType: ({ defaultValue, currentValue, setEditValues, }: {
|
|
6
|
+
defaultValue: DatasourceTypeWithOnlyValues;
|
|
7
|
+
currentValue: DatasourceTypeWithOnlyValues;
|
|
8
|
+
setEditValues: React.Dispatch<React.SetStateAction<DatasourceTypeWithOnlyValues>>;
|
|
9
|
+
}) => Pick<React.ComponentProps<typeof InlineEdit>, 'defaultValue' | 'editView'>;
|
|
6
10
|
export declare const isEditTypeSupported: (type: DatasourceType['type']) => boolean;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import { type FieldProps } from '@atlaskit/form';
|
|
3
|
+
import type { DatasourceTypeWithOnlyValues } from '../../types';
|
|
4
|
+
interface TextEditTypeProps extends Omit<FieldProps<string>, 'value'> {
|
|
5
|
+
currentValue: DatasourceTypeWithOnlyValues;
|
|
6
|
+
setEditValues: React.Dispatch<React.SetStateAction<DatasourceTypeWithOnlyValues>>;
|
|
4
7
|
}
|
|
8
|
+
export declare const toTextValue: (typeWithValues: DatasourceTypeWithOnlyValues) => string;
|
|
5
9
|
declare const TextEditType: (props: TextEditTypeProps) => JSX.Element;
|
|
6
10
|
export default TextEditType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-datasource",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.13",
|
|
4
4
|
"description": "UI Components to support linking platform dataset feature",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@atlaskit/inline-edit": "^13.7.0",
|
|
55
55
|
"@atlaskit/intl-messages-provider": "^1.0.0",
|
|
56
56
|
"@atlaskit/jql-ast": "^3.3.0",
|
|
57
|
-
"@atlaskit/jql-editor": "^4.
|
|
57
|
+
"@atlaskit/jql-editor": "^4.9.0",
|
|
58
58
|
"@atlaskit/jql-editor-autocomplete-rest": "^2.1.0",
|
|
59
59
|
"@atlaskit/layering": "^0.7.0",
|
|
60
60
|
"@atlaskit/link-client-extension": "^2.4.0",
|