@atlaskit/link-datasource 1.19.36 → 1.19.38
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 +13 -0
- package/dist/cjs/hooks/useDatasourceTableState.js +8 -17
- package/dist/cjs/ui/issue-like-table/index.js +32 -3
- package/dist/cjs/ui/issue-like-table/render-type/date-time/index.js +18 -9
- package/dist/cjs/ui/issue-like-table/render-type/index.js +38 -3
- package/dist/cjs/ui/issue-like-table/render-type/richtext/index.js +17 -14
- package/dist/es2019/hooks/useDatasourceTableState.js +8 -14
- package/dist/es2019/ui/issue-like-table/index.js +30 -5
- package/dist/es2019/ui/issue-like-table/render-type/date-time/index.js +14 -8
- package/dist/es2019/ui/issue-like-table/render-type/index.js +35 -2
- package/dist/es2019/ui/issue-like-table/render-type/richtext/index.js +17 -14
- package/dist/esm/hooks/useDatasourceTableState.js +8 -17
- package/dist/esm/ui/issue-like-table/index.js +34 -5
- package/dist/esm/ui/issue-like-table/render-type/date-time/index.js +17 -9
- package/dist/esm/ui/issue-like-table/render-type/index.js +34 -2
- package/dist/esm/ui/issue-like-table/render-type/richtext/index.js +16 -13
- package/dist/types/hooks/useDatasourceTableState.d.ts +0 -2
- package/dist/types/ui/issue-like-table/render-type/date-time/index.d.ts +2 -0
- package/dist/types/ui/issue-like-table/render-type/index.d.ts +3 -0
- package/dist/types/ui/issue-like-table/render-type/richtext/index.d.ts +1 -0
- package/dist/types-ts4.5/hooks/useDatasourceTableState.d.ts +0 -2
- package/dist/types-ts4.5/ui/issue-like-table/render-type/date-time/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/issue-like-table/render-type/index.d.ts +3 -0
- package/dist/types-ts4.5/ui/issue-like-table/render-type/richtext/index.d.ts +1 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/link-datasource
|
|
2
2
|
|
|
3
|
+
## 1.19.38
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#63865](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/63865) [`3626f73af8aa`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3626f73af8aa) - added tooltips to datasource table items
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 1.19.37
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#64237](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/64237) [`60749f37a107`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/60749f37a107) - [ux] Revert issue duplication in list of links due to infinite loop bug
|
|
15
|
+
|
|
3
16
|
## 1.19.36
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -308,26 +308,18 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
|
|
|
308
308
|
}
|
|
309
309
|
}, _callee2, null, [[7, 39]]);
|
|
310
310
|
})), [captureError, parameters, fieldKeys, nextCursor, getDatasourceData, datasourceId, responseItems === null || responseItems === void 0 ? void 0 : responseItems.length, applySchemaProperties, fireEvent, fullSchema]);
|
|
311
|
-
var reset = (0, _react.useCallback)(function () {
|
|
312
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
313
|
-
var _ref4 = options,
|
|
314
|
-
_ref4$shouldResetFull = _ref4.shouldResetFullSchema,
|
|
315
|
-
shouldResetFullSchema = _ref4$shouldResetFull === void 0 ? true : _ref4$shouldResetFull,
|
|
316
|
-
_ref4$shouldForceRequ = _ref4.shouldForceRequest,
|
|
317
|
-
shouldForceRequest = _ref4$shouldForceRequ === void 0 ? false : _ref4$shouldForceRequ,
|
|
318
|
-
_ref4$shouldResetColu = _ref4.shouldResetColumns,
|
|
319
|
-
shouldResetColumns = _ref4$shouldResetColu === void 0 ? false : _ref4$shouldResetColu;
|
|
311
|
+
var reset = (0, _react.useCallback)(function (options) {
|
|
320
312
|
setStatus('empty');
|
|
321
313
|
setResponseItems([]);
|
|
322
314
|
setHasNextPage(true);
|
|
323
315
|
setNextCursor(undefined);
|
|
324
316
|
setTotalCount(undefined);
|
|
325
317
|
setLastRequestedFieldKeys([]);
|
|
326
|
-
|
|
318
|
+
setFullSchema({
|
|
327
319
|
properties: []
|
|
328
320
|
});
|
|
329
|
-
setShouldForceRequest(shouldForceRequest);
|
|
330
|
-
if (shouldResetColumns) {
|
|
321
|
+
setShouldForceRequest((options === null || options === void 0 ? void 0 : options.shouldForceRequest) || false);
|
|
322
|
+
if (options !== null && options !== void 0 && options.shouldResetColumns) {
|
|
331
323
|
setColumns([]);
|
|
332
324
|
setDefaultVisibleColumnKeys([]);
|
|
333
325
|
}
|
|
@@ -362,12 +354,11 @@ var useDatasourceTableState = exports.useDatasourceTableState = function useData
|
|
|
362
354
|
return responseItemKeys.includes(key);
|
|
363
355
|
});
|
|
364
356
|
});
|
|
365
|
-
|
|
366
|
-
// if there is no data for the new columns, resetting the state triggers the request of new data (onNextPage)
|
|
367
|
-
// but the schema should not be reset as it is already loaded
|
|
368
357
|
if (!hasDataForColumns) {
|
|
369
|
-
reset(
|
|
370
|
-
|
|
358
|
+
reset();
|
|
359
|
+
void onNextPage({
|
|
360
|
+
isSchemaFromData: false,
|
|
361
|
+
shouldRequestFirstPage: true
|
|
371
362
|
});
|
|
372
363
|
}
|
|
373
364
|
}
|
|
@@ -9,11 +9,13 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
13
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
14
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
14
15
|
var _react = require("react");
|
|
15
16
|
var _react2 = require("@emotion/react");
|
|
16
17
|
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
18
|
+
var _reactIntlNext = require("react-intl-next");
|
|
17
19
|
var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
|
|
18
20
|
var _heading = _interopRequireDefault(require("@atlaskit/heading"));
|
|
19
21
|
var _linkingCommon = require("@atlaskit/linking-common");
|
|
@@ -44,6 +46,11 @@ var tableHeadStyles = (0, _react2.css)({
|
|
|
44
46
|
top: 0,
|
|
45
47
|
zIndex: _zindex.stickyTableHeadersIndex
|
|
46
48
|
});
|
|
49
|
+
var truncateTextStyles = (0, _react2.css)({
|
|
50
|
+
overflow: 'hidden',
|
|
51
|
+
textOverflow: 'ellipsis',
|
|
52
|
+
whiteSpace: 'nowrap'
|
|
53
|
+
});
|
|
47
54
|
var ColumnPickerHeader = _styled.default.th(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: 56px;\n z-index: 10;\n position: sticky;\n right: calc(-1 * ", ");\n background-color: ", ";\n border-bottom: 2px solid ", "; /* It is required to have solid (not half-transparent) color because of this gradient business below */\n\n padding-right: ", ";\n\n background: linear-gradient(\n 90deg,\n rgba(255, 255, 255, 0) 0%,\n ", " 10%\n );\n vertical-align: middle; /* Keeps dropdown button in the middle */\n &:last-of-type {\n padding-right: ", ";\n }\n text-align: right; /* In case when TH itself is bigger we want to keep picker at the right side */\n"])), tableSidePadding, "var(--ds-elevation-surface-current, #FFF)", "var(--ds-border, ".concat(_colors.N40, ")"), "var(--ds-space-100, 4px)", "var(--ds-elevation-surface-current, #FFF)", tableSidePadding);
|
|
48
55
|
var truncatedCellStyles = (0, _react2.css)({
|
|
49
56
|
overflow: 'hidden',
|
|
@@ -213,6 +220,13 @@ function getDefaultColumnWidth(key, type) {
|
|
|
213
220
|
return DEFAULT_WIDTH;
|
|
214
221
|
}
|
|
215
222
|
}
|
|
223
|
+
var TruncateTextTag = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
224
|
+
return (0, _react2.jsx)("span", (0, _extends2.default)({
|
|
225
|
+
css: truncateTextStyles
|
|
226
|
+
}, props, {
|
|
227
|
+
ref: ref
|
|
228
|
+
}), props.children);
|
|
229
|
+
});
|
|
216
230
|
var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
217
231
|
var testId = _ref5.testId,
|
|
218
232
|
onNextPage = _ref5.onNextPage,
|
|
@@ -233,6 +247,7 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
|
|
|
233
247
|
var tableId = (0, _react.useMemo)(function () {
|
|
234
248
|
return Symbol('unique-id');
|
|
235
249
|
}, []);
|
|
250
|
+
var intl = (0, _reactIntlNext.useIntl)();
|
|
236
251
|
var tableHeaderRowRef = (0, _react.useRef)(null);
|
|
237
252
|
var _useState = (0, _react.useState)(null),
|
|
238
253
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -398,15 +413,29 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
|
|
|
398
413
|
type = _ref11.type;
|
|
399
414
|
var value = ((_newRowData$key = newRowData[key]) === null || _newRowData$key === void 0 ? void 0 : _newRowData$key.data) || newRowData[key];
|
|
400
415
|
var values = Array.isArray(value) ? value : [value];
|
|
401
|
-
var
|
|
416
|
+
var renderedValues = values.map(function (value) {
|
|
402
417
|
return renderItem({
|
|
403
418
|
type: type,
|
|
404
419
|
value: value
|
|
405
420
|
});
|
|
406
421
|
});
|
|
422
|
+
var stringifiedContent = values.map(function (value) {
|
|
423
|
+
return (0, _renderType.stringifyType)({
|
|
424
|
+
type: type,
|
|
425
|
+
value: value
|
|
426
|
+
}, intl.formatMessage, intl.formatDate);
|
|
427
|
+
}).filter(function (value) {
|
|
428
|
+
return value !== '';
|
|
429
|
+
}).join(', ');
|
|
430
|
+
var content = renderedValues.length === 1 ? renderedValues[0] : renderedValues;
|
|
431
|
+
var contentComponent = stringifiedContent ? (0, _react2.jsx)(_tooltip.default, {
|
|
432
|
+
tag: TruncateTextTag,
|
|
433
|
+
content: stringifiedContent,
|
|
434
|
+
testId: "issues-table-cell-tooltip"
|
|
435
|
+
}, content) : content;
|
|
407
436
|
return {
|
|
408
437
|
key: key,
|
|
409
|
-
content:
|
|
438
|
+
content: contentComponent,
|
|
410
439
|
width: getColumnWidth(key, type)
|
|
411
440
|
};
|
|
412
441
|
}),
|
|
@@ -415,7 +444,7 @@ var IssueLikeDataTableView = exports.IssueLikeDataTableView = function IssueLike
|
|
|
415
444
|
} : undefined
|
|
416
445
|
};
|
|
417
446
|
});
|
|
418
|
-
}, [items, visibleSortedColumns, getColumnWidth, renderItem]);
|
|
447
|
+
}, [items, visibleSortedColumns, getColumnWidth, renderItem, intl]);
|
|
419
448
|
var rows = (0, _react.useMemo)(function () {
|
|
420
449
|
if (status !== 'loading') {
|
|
421
450
|
return tableRows;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.DATETIME_TYPE_TEST_ID = void 0;
|
|
8
|
+
exports.getFormattedDate = getFormattedDate;
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
10
11
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -26,13 +27,9 @@ var timeOptions = {
|
|
|
26
27
|
minute: '2-digit'
|
|
27
28
|
};
|
|
28
29
|
var DateTimeWrapper = _styled.default.span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n font-size: ", ";\n"])), _styled2.FieldTextFontSize);
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
testId = _ref$testId === void 0 ? DATETIME_TYPE_TEST_ID : _ref$testId,
|
|
33
|
-
_ref$display = _ref.display,
|
|
34
|
-
display = _ref$display === void 0 ? 'datetime' : _ref$display;
|
|
35
|
-
var intl = (0, _reactIntlNext.useIntl)();
|
|
30
|
+
function getFormattedDate(value) {
|
|
31
|
+
var display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'datetime';
|
|
32
|
+
var formatDate = arguments.length > 2 ? arguments[2] : undefined;
|
|
36
33
|
/* In some cases we get a value of `2023-12-20` which when parsed by JS assumes meantime timezone, causing the date
|
|
37
34
|
to be one day off in some timezones. We want it to display the date without converting timezones and a solution
|
|
38
35
|
is to replace the hyphens with slashes. So it should be 20th Dec regardless of the timezone in this case.
|
|
@@ -41,14 +38,26 @@ var DateTimeRenderType = function DateTimeRenderType(_ref) {
|
|
|
41
38
|
var dateValue = /^\d{4}-\d{2}-\d{2}$/.exec(value) ? value.replace(/-/g, '/') : value;
|
|
42
39
|
var date = new Date(dateValue);
|
|
43
40
|
if (!value || isNaN(date.getTime())) {
|
|
44
|
-
return
|
|
41
|
+
return '';
|
|
45
42
|
}
|
|
46
43
|
var options = {
|
|
47
44
|
date: dateOptions,
|
|
48
45
|
time: timeOptions,
|
|
49
46
|
datetime: _objectSpread(_objectSpread({}, dateOptions), timeOptions)
|
|
50
47
|
};
|
|
51
|
-
|
|
48
|
+
return formatDate(date, options[display] || options['date']);
|
|
49
|
+
}
|
|
50
|
+
var DateTimeRenderType = function DateTimeRenderType(_ref) {
|
|
51
|
+
var value = _ref.value,
|
|
52
|
+
_ref$testId = _ref.testId,
|
|
53
|
+
testId = _ref$testId === void 0 ? DATETIME_TYPE_TEST_ID : _ref$testId,
|
|
54
|
+
_ref$display = _ref.display,
|
|
55
|
+
display = _ref$display === void 0 ? 'datetime' : _ref$display;
|
|
56
|
+
var intl = (0, _reactIntlNext.useIntl)();
|
|
57
|
+
var formattedString = getFormattedDate(value, display, intl.formatDate);
|
|
58
|
+
if (formattedString === '') {
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
60
|
+
}
|
|
52
61
|
return /*#__PURE__*/_react.default.createElement(DateTimeWrapper, {
|
|
53
62
|
"data-testid": testId
|
|
54
63
|
}, formattedString);
|
|
@@ -1,22 +1,57 @@
|
|
|
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
|
-
exports.fallbackRenderType = void 0;
|
|
8
|
+
exports.stringifyType = exports.fallbackRenderType = void 0;
|
|
8
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var _react = _interopRequireDefault(require("react"));
|
|
10
11
|
var _boolean = _interopRequireDefault(require("./boolean"));
|
|
11
|
-
var _dateTime =
|
|
12
|
+
var _dateTime = _interopRequireWildcard(require("./date-time"));
|
|
12
13
|
var _icon = _interopRequireDefault(require("./icon"));
|
|
13
14
|
var _link = _interopRequireDefault(require("./link"));
|
|
14
15
|
var _number = _interopRequireDefault(require("./number"));
|
|
15
|
-
var _richtext =
|
|
16
|
+
var _richtext = _interopRequireWildcard(require("./richtext"));
|
|
16
17
|
var _status = _interopRequireDefault(require("./status"));
|
|
17
18
|
var _tag = _interopRequireDefault(require("./tag"));
|
|
18
19
|
var _text = _interopRequireDefault(require("./text"));
|
|
19
20
|
var _user = _interopRequireDefault(require("./user"));
|
|
21
|
+
var _messages = require("./user/messages");
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
|
+
var stringifyType = exports.stringifyType = function stringifyType(_ref, formatMessage, formatDate) {
|
|
25
|
+
var type = _ref.type,
|
|
26
|
+
value = _ref.value;
|
|
27
|
+
switch (type) {
|
|
28
|
+
case 'boolean':
|
|
29
|
+
case 'number':
|
|
30
|
+
return (value === null || value === void 0 ? void 0 : value.toString()) || '';
|
|
31
|
+
case 'date':
|
|
32
|
+
return (0, _dateTime.getFormattedDate)(value, 'date', formatDate);
|
|
33
|
+
case 'datetime':
|
|
34
|
+
return (0, _dateTime.getFormattedDate)(value, 'datetime', formatDate);
|
|
35
|
+
case 'time':
|
|
36
|
+
return (0, _dateTime.getFormattedDate)(value, 'time', formatDate);
|
|
37
|
+
case 'icon':
|
|
38
|
+
return (value === null || value === void 0 ? void 0 : value.label) || '';
|
|
39
|
+
case 'status':
|
|
40
|
+
return (value === null || value === void 0 ? void 0 : value.text.toString()) || '';
|
|
41
|
+
case 'string':
|
|
42
|
+
return value;
|
|
43
|
+
case 'tag':
|
|
44
|
+
return (value === null || value === void 0 ? void 0 : value.text) || '';
|
|
45
|
+
case 'user':
|
|
46
|
+
return (value === null || value === void 0 ? void 0 : value.displayName) || formatMessage(_messages.userTypeMessages.userDefaultdisplayNameValue);
|
|
47
|
+
case 'richtext':
|
|
48
|
+
var adfPlainText = (0, _richtext.parseRichText)(value);
|
|
49
|
+
return adfPlainText || '';
|
|
50
|
+
case 'link':
|
|
51
|
+
default:
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
};
|
|
20
55
|
var fallbackRenderType = exports.fallbackRenderType = function fallbackRenderType(item) {
|
|
21
56
|
var _item$value, _item$value2, _item$value3;
|
|
22
57
|
switch (item.type) {
|
|
@@ -4,7 +4,7 @@ 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.parseRichText = exports.default = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _react = require("react");
|
|
@@ -20,22 +20,25 @@ var rootStyles = (0, _react2.css)({
|
|
|
20
20
|
position: 'relative',
|
|
21
21
|
display: 'block'
|
|
22
22
|
});
|
|
23
|
+
var parseRichText = exports.parseRichText = function parseRichText(value) {
|
|
24
|
+
try {
|
|
25
|
+
if (value.type === 'adf') {
|
|
26
|
+
var adf = JSON.parse(value.text);
|
|
27
|
+
return _model.Node.fromJSON(_schemaDefault.defaultSchema, _objectSpread(_objectSpread({}, adf), {}, {
|
|
28
|
+
content: (0, _toConsumableArray2.default)(adf.content.slice(0, 2))
|
|
29
|
+
})).textContent;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.error('error parsing adf', e);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
23
38
|
var RichTextType = function RichTextType(_ref) {
|
|
24
39
|
var value = _ref.value;
|
|
25
40
|
var adfPlainText = (0, _react.useMemo)(function () {
|
|
26
|
-
|
|
27
|
-
if (value.type === 'adf') {
|
|
28
|
-
var adf = JSON.parse(value.text);
|
|
29
|
-
return _model.Node.fromJSON(_schemaDefault.defaultSchema, _objectSpread(_objectSpread({}, adf), {}, {
|
|
30
|
-
content: (0, _toConsumableArray2.default)(adf.content.slice(0, 2))
|
|
31
|
-
})).textContent;
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
} catch (e) {
|
|
35
|
-
// eslint-disable-next-line no-console
|
|
36
|
-
console.error('error parsing adf', e);
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
41
|
+
return parseRichText(value);
|
|
39
42
|
}, [value]);
|
|
40
43
|
if (adfPlainText) {
|
|
41
44
|
return (0, _react2.jsx)("div", {
|
|
@@ -189,23 +189,18 @@ export const useDatasourceTableState = ({
|
|
|
189
189
|
setStatus('rejected');
|
|
190
190
|
}
|
|
191
191
|
}, [captureError, parameters, fieldKeys, nextCursor, getDatasourceData, datasourceId, responseItems === null || responseItems === void 0 ? void 0 : responseItems.length, applySchemaProperties, fireEvent, fullSchema]);
|
|
192
|
-
const reset = useCallback(
|
|
193
|
-
const {
|
|
194
|
-
shouldResetFullSchema = true,
|
|
195
|
-
shouldForceRequest = false,
|
|
196
|
-
shouldResetColumns = false
|
|
197
|
-
} = options;
|
|
192
|
+
const reset = useCallback(options => {
|
|
198
193
|
setStatus('empty');
|
|
199
194
|
setResponseItems([]);
|
|
200
195
|
setHasNextPage(true);
|
|
201
196
|
setNextCursor(undefined);
|
|
202
197
|
setTotalCount(undefined);
|
|
203
198
|
setLastRequestedFieldKeys([]);
|
|
204
|
-
|
|
199
|
+
setFullSchema({
|
|
205
200
|
properties: []
|
|
206
201
|
});
|
|
207
|
-
setShouldForceRequest(shouldForceRequest);
|
|
208
|
-
if (shouldResetColumns) {
|
|
202
|
+
setShouldForceRequest((options === null || options === void 0 ? void 0 : options.shouldForceRequest) || false);
|
|
203
|
+
if (options !== null && options !== void 0 && options.shouldResetColumns) {
|
|
209
204
|
setColumns([]);
|
|
210
205
|
setDefaultVisibleColumnKeys([]);
|
|
211
206
|
}
|
|
@@ -236,12 +231,11 @@ export const useDatasourceTableState = ({
|
|
|
236
231
|
const responseItemKeys = Object.keys(responseItem);
|
|
237
232
|
return fieldKeys.every(key => responseItemKeys.includes(key));
|
|
238
233
|
});
|
|
239
|
-
|
|
240
|
-
// if there is no data for the new columns, resetting the state triggers the request of new data (onNextPage)
|
|
241
|
-
// but the schema should not be reset as it is already loaded
|
|
242
234
|
if (!hasDataForColumns) {
|
|
243
|
-
reset(
|
|
244
|
-
|
|
235
|
+
reset();
|
|
236
|
+
void onNextPage({
|
|
237
|
+
isSchemaFromData: false,
|
|
238
|
+
shouldRequestFirstPage: true
|
|
245
239
|
});
|
|
246
240
|
}
|
|
247
241
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
/** @jsx jsx */
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
4
|
import { css, jsx } from '@emotion/react';
|
|
4
5
|
import styled from '@emotion/styled';
|
|
6
|
+
import { useIntl } from 'react-intl-next';
|
|
5
7
|
import invariant from 'tiny-invariant';
|
|
6
8
|
import Heading from '@atlaskit/heading';
|
|
7
9
|
import { Skeleton } from '@atlaskit/linking-common';
|
|
@@ -18,7 +20,7 @@ import { ColumnPicker } from './column-picker';
|
|
|
18
20
|
import { DragColumnPreview } from './drag-column-preview';
|
|
19
21
|
import { DraggableTableHeading } from './draggable-table-heading';
|
|
20
22
|
import TableEmptyState from './empty-state';
|
|
21
|
-
import { fallbackRenderType } from './render-type';
|
|
23
|
+
import { fallbackRenderType, stringifyType } from './render-type';
|
|
22
24
|
import { Table, TableHeading } from './styled';
|
|
23
25
|
import { useIsOnScreen } from './useIsOnScreen';
|
|
24
26
|
const tableSidePadding = "var(--ds-space-200, 16px)";
|
|
@@ -28,6 +30,11 @@ const tableHeadStyles = css({
|
|
|
28
30
|
top: 0,
|
|
29
31
|
zIndex: stickyTableHeadersIndex
|
|
30
32
|
});
|
|
33
|
+
const truncateTextStyles = css({
|
|
34
|
+
overflow: 'hidden',
|
|
35
|
+
textOverflow: 'ellipsis',
|
|
36
|
+
whiteSpace: 'nowrap'
|
|
37
|
+
});
|
|
31
38
|
const ColumnPickerHeader = styled.th`
|
|
32
39
|
width: 56px;
|
|
33
40
|
z-index: 10;
|
|
@@ -251,6 +258,13 @@ function getDefaultColumnWidth(key, type) {
|
|
|
251
258
|
return DEFAULT_WIDTH;
|
|
252
259
|
}
|
|
253
260
|
}
|
|
261
|
+
const TruncateTextTag = /*#__PURE__*/forwardRef((props, ref) => {
|
|
262
|
+
return jsx("span", _extends({
|
|
263
|
+
css: truncateTextStyles
|
|
264
|
+
}, props, {
|
|
265
|
+
ref: ref
|
|
266
|
+
}), props.children);
|
|
267
|
+
});
|
|
254
268
|
export const IssueLikeDataTableView = ({
|
|
255
269
|
testId,
|
|
256
270
|
onNextPage,
|
|
@@ -269,6 +283,7 @@ export const IssueLikeDataTableView = ({
|
|
|
269
283
|
extensionKey
|
|
270
284
|
}) => {
|
|
271
285
|
const tableId = useMemo(() => Symbol('unique-id'), []);
|
|
286
|
+
const intl = useIntl();
|
|
272
287
|
const tableHeaderRowRef = useRef(null);
|
|
273
288
|
const [lastRowElement, setLastRowElement] = useState(null);
|
|
274
289
|
const [hasFullSchema, setHasFullSchema] = useState(false);
|
|
@@ -412,18 +427,28 @@ export const IssueLikeDataTableView = ({
|
|
|
412
427
|
var _newRowData$key;
|
|
413
428
|
const value = ((_newRowData$key = newRowData[key]) === null || _newRowData$key === void 0 ? void 0 : _newRowData$key.data) || newRowData[key];
|
|
414
429
|
const values = Array.isArray(value) ? value : [value];
|
|
415
|
-
const
|
|
430
|
+
const renderedValues = values.map(value => renderItem({
|
|
416
431
|
type,
|
|
417
432
|
value
|
|
418
433
|
}));
|
|
434
|
+
const stringifiedContent = values.map(value => stringifyType({
|
|
435
|
+
type,
|
|
436
|
+
value
|
|
437
|
+
}, intl.formatMessage, intl.formatDate)).filter(value => value !== '').join(', ');
|
|
438
|
+
const content = renderedValues.length === 1 ? renderedValues[0] : renderedValues;
|
|
439
|
+
const contentComponent = stringifiedContent ? jsx(Tooltip, {
|
|
440
|
+
tag: TruncateTextTag,
|
|
441
|
+
content: stringifiedContent,
|
|
442
|
+
testId: "issues-table-cell-tooltip"
|
|
443
|
+
}, content) : content;
|
|
419
444
|
return {
|
|
420
445
|
key,
|
|
421
|
-
content:
|
|
446
|
+
content: contentComponent,
|
|
422
447
|
width: getColumnWidth(key, type)
|
|
423
448
|
};
|
|
424
449
|
}),
|
|
425
450
|
ref: rowIndex === items.length - 1 ? el => setLastRowElement(el) : undefined
|
|
426
|
-
})), [items, visibleSortedColumns, getColumnWidth, renderItem]);
|
|
451
|
+
})), [items, visibleSortedColumns, getColumnWidth, renderItem, intl]);
|
|
427
452
|
const rows = useMemo(() => {
|
|
428
453
|
if (status !== 'loading') {
|
|
429
454
|
return tableRows;
|
|
@@ -16,12 +16,7 @@ const timeOptions = {
|
|
|
16
16
|
const DateTimeWrapper = styled.span`
|
|
17
17
|
font-size: ${FieldTextFontSize};
|
|
18
18
|
`;
|
|
19
|
-
|
|
20
|
-
value,
|
|
21
|
-
testId = DATETIME_TYPE_TEST_ID,
|
|
22
|
-
display = 'datetime'
|
|
23
|
-
}) => {
|
|
24
|
-
const intl = useIntl();
|
|
19
|
+
export function getFormattedDate(value, display = 'datetime', formatDate) {
|
|
25
20
|
/* In some cases we get a value of `2023-12-20` which when parsed by JS assumes meantime timezone, causing the date
|
|
26
21
|
to be one day off in some timezones. We want it to display the date without converting timezones and a solution
|
|
27
22
|
is to replace the hyphens with slashes. So it should be 20th Dec regardless of the timezone in this case.
|
|
@@ -30,7 +25,7 @@ const DateTimeRenderType = ({
|
|
|
30
25
|
const dateValue = /^\d{4}-\d{2}-\d{2}$/.exec(value) ? value.replace(/-/g, '/') : value;
|
|
31
26
|
const date = new Date(dateValue);
|
|
32
27
|
if (!value || isNaN(date.getTime())) {
|
|
33
|
-
return
|
|
28
|
+
return '';
|
|
34
29
|
}
|
|
35
30
|
const options = {
|
|
36
31
|
date: dateOptions,
|
|
@@ -40,7 +35,18 @@ const DateTimeRenderType = ({
|
|
|
40
35
|
...timeOptions
|
|
41
36
|
}
|
|
42
37
|
};
|
|
43
|
-
|
|
38
|
+
return formatDate(date, options[display] || options['date']);
|
|
39
|
+
}
|
|
40
|
+
const DateTimeRenderType = ({
|
|
41
|
+
value,
|
|
42
|
+
testId = DATETIME_TYPE_TEST_ID,
|
|
43
|
+
display = 'datetime'
|
|
44
|
+
}) => {
|
|
45
|
+
const intl = useIntl();
|
|
46
|
+
const formattedString = getFormattedDate(value, display, intl.formatDate);
|
|
47
|
+
if (formattedString === '') {
|
|
48
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
49
|
+
}
|
|
44
50
|
return /*#__PURE__*/React.createElement(DateTimeWrapper, {
|
|
45
51
|
"data-testid": testId
|
|
46
52
|
}, formattedString);
|
|
@@ -1,15 +1,48 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import BooleanRenderType from './boolean';
|
|
4
|
-
import DateTimeRenderType from './date-time';
|
|
4
|
+
import DateTimeRenderType, { getFormattedDate } from './date-time';
|
|
5
5
|
import IconRenderType from './icon';
|
|
6
6
|
import LinkRenderType from './link';
|
|
7
7
|
import NumberRenderType from './number';
|
|
8
|
-
import RichTextRenderType from './richtext';
|
|
8
|
+
import RichTextRenderType, { parseRichText } from './richtext';
|
|
9
9
|
import StatusRenderType from './status';
|
|
10
10
|
import TagRenderType from './tag';
|
|
11
11
|
import StringRenderType from './text';
|
|
12
12
|
import UserRenderType from './user';
|
|
13
|
+
import { userTypeMessages } from './user/messages';
|
|
14
|
+
export const stringifyType = ({
|
|
15
|
+
type,
|
|
16
|
+
value
|
|
17
|
+
}, formatMessage, formatDate) => {
|
|
18
|
+
switch (type) {
|
|
19
|
+
case 'boolean':
|
|
20
|
+
case 'number':
|
|
21
|
+
return (value === null || value === void 0 ? void 0 : value.toString()) || '';
|
|
22
|
+
case 'date':
|
|
23
|
+
return getFormattedDate(value, 'date', formatDate);
|
|
24
|
+
case 'datetime':
|
|
25
|
+
return getFormattedDate(value, 'datetime', formatDate);
|
|
26
|
+
case 'time':
|
|
27
|
+
return getFormattedDate(value, 'time', formatDate);
|
|
28
|
+
case 'icon':
|
|
29
|
+
return (value === null || value === void 0 ? void 0 : value.label) || '';
|
|
30
|
+
case 'status':
|
|
31
|
+
return (value === null || value === void 0 ? void 0 : value.text.toString()) || '';
|
|
32
|
+
case 'string':
|
|
33
|
+
return value;
|
|
34
|
+
case 'tag':
|
|
35
|
+
return (value === null || value === void 0 ? void 0 : value.text) || '';
|
|
36
|
+
case 'user':
|
|
37
|
+
return (value === null || value === void 0 ? void 0 : value.displayName) || formatMessage(userTypeMessages.userDefaultdisplayNameValue);
|
|
38
|
+
case 'richtext':
|
|
39
|
+
const adfPlainText = parseRichText(value);
|
|
40
|
+
return adfPlainText || '';
|
|
41
|
+
case 'link':
|
|
42
|
+
default:
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
};
|
|
13
46
|
export const fallbackRenderType = item => {
|
|
14
47
|
var _item$value, _item$value2, _item$value3;
|
|
15
48
|
switch (item.type) {
|
|
@@ -10,24 +10,27 @@ const rootStyles = css({
|
|
|
10
10
|
position: 'relative',
|
|
11
11
|
display: 'block'
|
|
12
12
|
});
|
|
13
|
+
export const parseRichText = value => {
|
|
14
|
+
try {
|
|
15
|
+
if (value.type === 'adf') {
|
|
16
|
+
const adf = JSON.parse(value.text);
|
|
17
|
+
return PMNode.fromJSON(defaultSchema, {
|
|
18
|
+
...adf,
|
|
19
|
+
content: [...adf.content.slice(0, 2)]
|
|
20
|
+
}).textContent;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
} catch (e) {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.error('error parsing adf', e);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
13
29
|
const RichTextType = ({
|
|
14
30
|
value
|
|
15
31
|
}) => {
|
|
16
32
|
const adfPlainText = useMemo(() => {
|
|
17
|
-
|
|
18
|
-
if (value.type === 'adf') {
|
|
19
|
-
const adf = JSON.parse(value.text);
|
|
20
|
-
return PMNode.fromJSON(defaultSchema, {
|
|
21
|
-
...adf,
|
|
22
|
-
content: [...adf.content.slice(0, 2)]
|
|
23
|
-
}).textContent;
|
|
24
|
-
}
|
|
25
|
-
return null;
|
|
26
|
-
} catch (e) {
|
|
27
|
-
// eslint-disable-next-line no-console
|
|
28
|
-
console.error('error parsing adf', e);
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
33
|
+
return parseRichText(value);
|
|
31
34
|
}, [value]);
|
|
32
35
|
if (adfPlainText) {
|
|
33
36
|
return jsx("div", {
|
|
@@ -301,26 +301,18 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
301
301
|
}
|
|
302
302
|
}, _callee2, null, [[7, 39]]);
|
|
303
303
|
})), [captureError, parameters, fieldKeys, nextCursor, getDatasourceData, datasourceId, responseItems === null || responseItems === void 0 ? void 0 : responseItems.length, applySchemaProperties, fireEvent, fullSchema]);
|
|
304
|
-
var reset = useCallback(function () {
|
|
305
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
306
|
-
var _ref4 = options,
|
|
307
|
-
_ref4$shouldResetFull = _ref4.shouldResetFullSchema,
|
|
308
|
-
shouldResetFullSchema = _ref4$shouldResetFull === void 0 ? true : _ref4$shouldResetFull,
|
|
309
|
-
_ref4$shouldForceRequ = _ref4.shouldForceRequest,
|
|
310
|
-
shouldForceRequest = _ref4$shouldForceRequ === void 0 ? false : _ref4$shouldForceRequ,
|
|
311
|
-
_ref4$shouldResetColu = _ref4.shouldResetColumns,
|
|
312
|
-
shouldResetColumns = _ref4$shouldResetColu === void 0 ? false : _ref4$shouldResetColu;
|
|
304
|
+
var reset = useCallback(function (options) {
|
|
313
305
|
setStatus('empty');
|
|
314
306
|
setResponseItems([]);
|
|
315
307
|
setHasNextPage(true);
|
|
316
308
|
setNextCursor(undefined);
|
|
317
309
|
setTotalCount(undefined);
|
|
318
310
|
setLastRequestedFieldKeys([]);
|
|
319
|
-
|
|
311
|
+
setFullSchema({
|
|
320
312
|
properties: []
|
|
321
313
|
});
|
|
322
|
-
setShouldForceRequest(shouldForceRequest);
|
|
323
|
-
if (shouldResetColumns) {
|
|
314
|
+
setShouldForceRequest((options === null || options === void 0 ? void 0 : options.shouldForceRequest) || false);
|
|
315
|
+
if (options !== null && options !== void 0 && options.shouldResetColumns) {
|
|
324
316
|
setColumns([]);
|
|
325
317
|
setDefaultVisibleColumnKeys([]);
|
|
326
318
|
}
|
|
@@ -355,12 +347,11 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
355
347
|
return responseItemKeys.includes(key);
|
|
356
348
|
});
|
|
357
349
|
});
|
|
358
|
-
|
|
359
|
-
// if there is no data for the new columns, resetting the state triggers the request of new data (onNextPage)
|
|
360
|
-
// but the schema should not be reset as it is already loaded
|
|
361
350
|
if (!hasDataForColumns) {
|
|
362
|
-
reset(
|
|
363
|
-
|
|
351
|
+
reset();
|
|
352
|
+
void onNextPage({
|
|
353
|
+
isSchemaFromData: false,
|
|
354
|
+
shouldRequestFirstPage: true
|
|
364
355
|
});
|
|
365
356
|
}
|
|
366
357
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
5
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
5
6
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
6
7
|
var _templateObject;
|
|
@@ -8,9 +9,10 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
8
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
11
|
/** @jsx jsx */
|
|
11
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
12
|
+
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
12
13
|
import { css, jsx } from '@emotion/react';
|
|
13
14
|
import styled from '@emotion/styled';
|
|
15
|
+
import { useIntl } from 'react-intl-next';
|
|
14
16
|
import invariant from 'tiny-invariant';
|
|
15
17
|
import Heading from '@atlaskit/heading';
|
|
16
18
|
import { Skeleton } from '@atlaskit/linking-common';
|
|
@@ -27,7 +29,7 @@ import { ColumnPicker } from './column-picker';
|
|
|
27
29
|
import { DragColumnPreview } from './drag-column-preview';
|
|
28
30
|
import { DraggableTableHeading } from './draggable-table-heading';
|
|
29
31
|
import TableEmptyState from './empty-state';
|
|
30
|
-
import { fallbackRenderType } from './render-type';
|
|
32
|
+
import { fallbackRenderType, stringifyType } from './render-type';
|
|
31
33
|
import { Table, TableHeading } from './styled';
|
|
32
34
|
import { useIsOnScreen } from './useIsOnScreen';
|
|
33
35
|
var tableSidePadding = "var(--ds-space-200, 16px)";
|
|
@@ -37,6 +39,11 @@ var tableHeadStyles = css({
|
|
|
37
39
|
top: 0,
|
|
38
40
|
zIndex: stickyTableHeadersIndex
|
|
39
41
|
});
|
|
42
|
+
var truncateTextStyles = css({
|
|
43
|
+
overflow: 'hidden',
|
|
44
|
+
textOverflow: 'ellipsis',
|
|
45
|
+
whiteSpace: 'nowrap'
|
|
46
|
+
});
|
|
40
47
|
var ColumnPickerHeader = styled.th(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 56px;\n z-index: 10;\n position: sticky;\n right: calc(-1 * ", ");\n background-color: ", ";\n border-bottom: 2px solid ", "; /* It is required to have solid (not half-transparent) color because of this gradient business below */\n\n padding-right: ", ";\n\n background: linear-gradient(\n 90deg,\n rgba(255, 255, 255, 0) 0%,\n ", " 10%\n );\n vertical-align: middle; /* Keeps dropdown button in the middle */\n &:last-of-type {\n padding-right: ", ";\n }\n text-align: right; /* In case when TH itself is bigger we want to keep picker at the right side */\n"])), tableSidePadding, "var(--ds-elevation-surface-current, #FFF)", "var(--ds-border, ".concat(N40, ")"), "var(--ds-space-100, 4px)", "var(--ds-elevation-surface-current, #FFF)", tableSidePadding);
|
|
41
48
|
var truncatedCellStyles = css({
|
|
42
49
|
overflow: 'hidden',
|
|
@@ -206,6 +213,13 @@ function getDefaultColumnWidth(key, type) {
|
|
|
206
213
|
return DEFAULT_WIDTH;
|
|
207
214
|
}
|
|
208
215
|
}
|
|
216
|
+
var TruncateTextTag = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
217
|
+
return jsx("span", _extends({
|
|
218
|
+
css: truncateTextStyles
|
|
219
|
+
}, props, {
|
|
220
|
+
ref: ref
|
|
221
|
+
}), props.children);
|
|
222
|
+
});
|
|
209
223
|
export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
210
224
|
var testId = _ref5.testId,
|
|
211
225
|
onNextPage = _ref5.onNextPage,
|
|
@@ -226,6 +240,7 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
226
240
|
var tableId = useMemo(function () {
|
|
227
241
|
return Symbol('unique-id');
|
|
228
242
|
}, []);
|
|
243
|
+
var intl = useIntl();
|
|
229
244
|
var tableHeaderRowRef = useRef(null);
|
|
230
245
|
var _useState = useState(null),
|
|
231
246
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -391,15 +406,29 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
391
406
|
type = _ref11.type;
|
|
392
407
|
var value = ((_newRowData$key = newRowData[key]) === null || _newRowData$key === void 0 ? void 0 : _newRowData$key.data) || newRowData[key];
|
|
393
408
|
var values = Array.isArray(value) ? value : [value];
|
|
394
|
-
var
|
|
409
|
+
var renderedValues = values.map(function (value) {
|
|
395
410
|
return renderItem({
|
|
396
411
|
type: type,
|
|
397
412
|
value: value
|
|
398
413
|
});
|
|
399
414
|
});
|
|
415
|
+
var stringifiedContent = values.map(function (value) {
|
|
416
|
+
return stringifyType({
|
|
417
|
+
type: type,
|
|
418
|
+
value: value
|
|
419
|
+
}, intl.formatMessage, intl.formatDate);
|
|
420
|
+
}).filter(function (value) {
|
|
421
|
+
return value !== '';
|
|
422
|
+
}).join(', ');
|
|
423
|
+
var content = renderedValues.length === 1 ? renderedValues[0] : renderedValues;
|
|
424
|
+
var contentComponent = stringifiedContent ? jsx(Tooltip, {
|
|
425
|
+
tag: TruncateTextTag,
|
|
426
|
+
content: stringifiedContent,
|
|
427
|
+
testId: "issues-table-cell-tooltip"
|
|
428
|
+
}, content) : content;
|
|
400
429
|
return {
|
|
401
430
|
key: key,
|
|
402
|
-
content:
|
|
431
|
+
content: contentComponent,
|
|
403
432
|
width: getColumnWidth(key, type)
|
|
404
433
|
};
|
|
405
434
|
}),
|
|
@@ -408,7 +437,7 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
408
437
|
} : undefined
|
|
409
438
|
};
|
|
410
439
|
});
|
|
411
|
-
}, [items, visibleSortedColumns, getColumnWidth, renderItem]);
|
|
440
|
+
}, [items, visibleSortedColumns, getColumnWidth, renderItem, intl]);
|
|
412
441
|
var rows = useMemo(function () {
|
|
413
442
|
if (status !== 'loading') {
|
|
414
443
|
return tableRows;
|
|
@@ -19,13 +19,9 @@ var timeOptions = {
|
|
|
19
19
|
minute: '2-digit'
|
|
20
20
|
};
|
|
21
21
|
var DateTimeWrapper = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-size: ", ";\n"])), FieldTextFontSize);
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
testId = _ref$testId === void 0 ? DATETIME_TYPE_TEST_ID : _ref$testId,
|
|
26
|
-
_ref$display = _ref.display,
|
|
27
|
-
display = _ref$display === void 0 ? 'datetime' : _ref$display;
|
|
28
|
-
var intl = useIntl();
|
|
22
|
+
export function getFormattedDate(value) {
|
|
23
|
+
var display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'datetime';
|
|
24
|
+
var formatDate = arguments.length > 2 ? arguments[2] : undefined;
|
|
29
25
|
/* In some cases we get a value of `2023-12-20` which when parsed by JS assumes meantime timezone, causing the date
|
|
30
26
|
to be one day off in some timezones. We want it to display the date without converting timezones and a solution
|
|
31
27
|
is to replace the hyphens with slashes. So it should be 20th Dec regardless of the timezone in this case.
|
|
@@ -34,14 +30,26 @@ var DateTimeRenderType = function DateTimeRenderType(_ref) {
|
|
|
34
30
|
var dateValue = /^\d{4}-\d{2}-\d{2}$/.exec(value) ? value.replace(/-/g, '/') : value;
|
|
35
31
|
var date = new Date(dateValue);
|
|
36
32
|
if (!value || isNaN(date.getTime())) {
|
|
37
|
-
return
|
|
33
|
+
return '';
|
|
38
34
|
}
|
|
39
35
|
var options = {
|
|
40
36
|
date: dateOptions,
|
|
41
37
|
time: timeOptions,
|
|
42
38
|
datetime: _objectSpread(_objectSpread({}, dateOptions), timeOptions)
|
|
43
39
|
};
|
|
44
|
-
|
|
40
|
+
return formatDate(date, options[display] || options['date']);
|
|
41
|
+
}
|
|
42
|
+
var DateTimeRenderType = function DateTimeRenderType(_ref) {
|
|
43
|
+
var value = _ref.value,
|
|
44
|
+
_ref$testId = _ref.testId,
|
|
45
|
+
testId = _ref$testId === void 0 ? DATETIME_TYPE_TEST_ID : _ref$testId,
|
|
46
|
+
_ref$display = _ref.display,
|
|
47
|
+
display = _ref$display === void 0 ? 'datetime' : _ref$display;
|
|
48
|
+
var intl = useIntl();
|
|
49
|
+
var formattedString = getFormattedDate(value, display, intl.formatDate);
|
|
50
|
+
if (formattedString === '') {
|
|
51
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
52
|
+
}
|
|
45
53
|
return /*#__PURE__*/React.createElement(DateTimeWrapper, {
|
|
46
54
|
"data-testid": testId
|
|
47
55
|
}, formattedString);
|
|
@@ -1,15 +1,47 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import BooleanRenderType from './boolean';
|
|
4
|
-
import DateTimeRenderType from './date-time';
|
|
4
|
+
import DateTimeRenderType, { getFormattedDate } from './date-time';
|
|
5
5
|
import IconRenderType from './icon';
|
|
6
6
|
import LinkRenderType from './link';
|
|
7
7
|
import NumberRenderType from './number';
|
|
8
|
-
import RichTextRenderType from './richtext';
|
|
8
|
+
import RichTextRenderType, { parseRichText } from './richtext';
|
|
9
9
|
import StatusRenderType from './status';
|
|
10
10
|
import TagRenderType from './tag';
|
|
11
11
|
import StringRenderType from './text';
|
|
12
12
|
import UserRenderType from './user';
|
|
13
|
+
import { userTypeMessages } from './user/messages';
|
|
14
|
+
export var stringifyType = function stringifyType(_ref, formatMessage, formatDate) {
|
|
15
|
+
var type = _ref.type,
|
|
16
|
+
value = _ref.value;
|
|
17
|
+
switch (type) {
|
|
18
|
+
case 'boolean':
|
|
19
|
+
case 'number':
|
|
20
|
+
return (value === null || value === void 0 ? void 0 : value.toString()) || '';
|
|
21
|
+
case 'date':
|
|
22
|
+
return getFormattedDate(value, 'date', formatDate);
|
|
23
|
+
case 'datetime':
|
|
24
|
+
return getFormattedDate(value, 'datetime', formatDate);
|
|
25
|
+
case 'time':
|
|
26
|
+
return getFormattedDate(value, 'time', formatDate);
|
|
27
|
+
case 'icon':
|
|
28
|
+
return (value === null || value === void 0 ? void 0 : value.label) || '';
|
|
29
|
+
case 'status':
|
|
30
|
+
return (value === null || value === void 0 ? void 0 : value.text.toString()) || '';
|
|
31
|
+
case 'string':
|
|
32
|
+
return value;
|
|
33
|
+
case 'tag':
|
|
34
|
+
return (value === null || value === void 0 ? void 0 : value.text) || '';
|
|
35
|
+
case 'user':
|
|
36
|
+
return (value === null || value === void 0 ? void 0 : value.displayName) || formatMessage(userTypeMessages.userDefaultdisplayNameValue);
|
|
37
|
+
case 'richtext':
|
|
38
|
+
var adfPlainText = parseRichText(value);
|
|
39
|
+
return adfPlainText || '';
|
|
40
|
+
case 'link':
|
|
41
|
+
default:
|
|
42
|
+
return '';
|
|
43
|
+
}
|
|
44
|
+
};
|
|
13
45
|
export var fallbackRenderType = function fallbackRenderType(item) {
|
|
14
46
|
var _item$value, _item$value2, _item$value3;
|
|
15
47
|
switch (item.type) {
|
|
@@ -14,22 +14,25 @@ var rootStyles = css({
|
|
|
14
14
|
position: 'relative',
|
|
15
15
|
display: 'block'
|
|
16
16
|
});
|
|
17
|
+
export var parseRichText = function parseRichText(value) {
|
|
18
|
+
try {
|
|
19
|
+
if (value.type === 'adf') {
|
|
20
|
+
var adf = JSON.parse(value.text);
|
|
21
|
+
return PMNode.fromJSON(defaultSchema, _objectSpread(_objectSpread({}, adf), {}, {
|
|
22
|
+
content: _toConsumableArray(adf.content.slice(0, 2))
|
|
23
|
+
})).textContent;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.error('error parsing adf', e);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
17
32
|
var RichTextType = function RichTextType(_ref) {
|
|
18
33
|
var value = _ref.value;
|
|
19
34
|
var adfPlainText = useMemo(function () {
|
|
20
|
-
|
|
21
|
-
if (value.type === 'adf') {
|
|
22
|
-
var adf = JSON.parse(value.text);
|
|
23
|
-
return PMNode.fromJSON(defaultSchema, _objectSpread(_objectSpread({}, adf), {}, {
|
|
24
|
-
content: _toConsumableArray(adf.content.slice(0, 2))
|
|
25
|
-
})).textContent;
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
28
|
-
} catch (e) {
|
|
29
|
-
// eslint-disable-next-line no-console
|
|
30
|
-
console.error('error parsing adf', e);
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
35
|
+
return parseRichText(value);
|
|
33
36
|
}, [value]);
|
|
34
37
|
if (adfPlainText) {
|
|
35
38
|
return jsx("div", {
|
|
@@ -10,8 +10,6 @@ interface ResetOptions {
|
|
|
10
10
|
shouldForceRequest?: boolean;
|
|
11
11
|
/** Resets current column data from a datasource table when issuing the new request */
|
|
12
12
|
shouldResetColumns?: boolean;
|
|
13
|
-
/** Resets current schema data from a datasource table when issuing the new request */
|
|
14
|
-
shouldResetFullSchema?: boolean;
|
|
15
13
|
}
|
|
16
14
|
export interface DatasourceTableState {
|
|
17
15
|
/** The current status of the table for rendering of the different UI states (e.g.: loading, error, etc). */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { IntlShape } from 'react-intl-next';
|
|
2
3
|
import { DateTimeType, DateType, TimeType } from '@atlaskit/linking-types';
|
|
3
4
|
export interface DateProps {
|
|
4
5
|
testId?: string;
|
|
@@ -6,5 +7,6 @@ export interface DateProps {
|
|
|
6
7
|
display: (DateType | TimeType | DateTimeType)['type'];
|
|
7
8
|
}
|
|
8
9
|
export declare const DATETIME_TYPE_TEST_ID = "link-datasource-render-type--datetime";
|
|
10
|
+
export declare function getFormattedDate(value: string, display: string | undefined, formatDate: IntlShape['formatDate']): string;
|
|
9
11
|
declare const DateTimeRenderType: ({ value, testId, display, }: DateProps) => JSX.Element;
|
|
10
12
|
export default DateTimeRenderType;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { IntlShape } from 'react-intl-next';
|
|
2
|
+
import { DatasourceType } from '@atlaskit/linking-types';
|
|
1
3
|
import { TableViewPropsRenderType } from '../types';
|
|
4
|
+
export declare const stringifyType: ({ type, value }: DatasourceType, formatMessage: IntlShape['formatMessage'], formatDate: IntlShape['formatDate']) => string;
|
|
2
5
|
export declare const fallbackRenderType: TableViewPropsRenderType;
|
|
@@ -10,8 +10,6 @@ interface ResetOptions {
|
|
|
10
10
|
shouldForceRequest?: boolean;
|
|
11
11
|
/** Resets current column data from a datasource table when issuing the new request */
|
|
12
12
|
shouldResetColumns?: boolean;
|
|
13
|
-
/** Resets current schema data from a datasource table when issuing the new request */
|
|
14
|
-
shouldResetFullSchema?: boolean;
|
|
15
13
|
}
|
|
16
14
|
export interface DatasourceTableState {
|
|
17
15
|
/** The current status of the table for rendering of the different UI states (e.g.: loading, error, etc). */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { IntlShape } from 'react-intl-next';
|
|
2
3
|
import { DateTimeType, DateType, TimeType } from '@atlaskit/linking-types';
|
|
3
4
|
export interface DateProps {
|
|
4
5
|
testId?: string;
|
|
@@ -6,5 +7,6 @@ export interface DateProps {
|
|
|
6
7
|
display: (DateType | TimeType | DateTimeType)['type'];
|
|
7
8
|
}
|
|
8
9
|
export declare const DATETIME_TYPE_TEST_ID = "link-datasource-render-type--datetime";
|
|
10
|
+
export declare function getFormattedDate(value: string, display: string | undefined, formatDate: IntlShape['formatDate']): string;
|
|
9
11
|
declare const DateTimeRenderType: ({ value, testId, display, }: DateProps) => JSX.Element;
|
|
10
12
|
export default DateTimeRenderType;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { IntlShape } from 'react-intl-next';
|
|
2
|
+
import { DatasourceType } from '@atlaskit/linking-types';
|
|
1
3
|
import { TableViewPropsRenderType } from '../types';
|
|
4
|
+
export declare const stringifyType: ({ type, value }: DatasourceType, formatMessage: IntlShape['formatMessage'], formatDate: IntlShape['formatDate']) => string;
|
|
2
5
|
export declare const fallbackRenderType: TableViewPropsRenderType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-datasource",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.38",
|
|
4
4
|
"description": "UI Components to support linking platform dataset feature",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@atlaskit/jql-ast": "^3.0.0",
|
|
47
47
|
"@atlaskit/jql-editor-autocomplete-rest": "^2.0.0",
|
|
48
48
|
"@atlaskit/link-client-extension": "^1.8.0",
|
|
49
|
-
"@atlaskit/linking-common": "^5.
|
|
49
|
+
"@atlaskit/linking-common": "^5.1.0",
|
|
50
50
|
"@atlaskit/linking-types": "^8.5.0",
|
|
51
51
|
"@atlaskit/lozenge": "^11.5.0",
|
|
52
52
|
"@atlaskit/modal-dialog": "^12.10.0",
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^0.12.0",
|
|
56
56
|
"@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll": "^0.6.0",
|
|
57
57
|
"@atlaskit/pragmatic-drag-and-drop-react-indicator": "^0.18.0",
|
|
58
|
-
"@atlaskit/primitives": "^1.
|
|
58
|
+
"@atlaskit/primitives": "^1.16.0",
|
|
59
59
|
"@atlaskit/select": "^17.0.3",
|
|
60
60
|
"@atlaskit/smart-card": "^26.43.0",
|
|
61
61
|
"@atlaskit/spinner": "^16.0.0",
|
|
62
62
|
"@atlaskit/tag": "^12.0.0",
|
|
63
63
|
"@atlaskit/textfield": "6.0.0",
|
|
64
64
|
"@atlaskit/theme": "^12.6.0",
|
|
65
|
-
"@atlaskit/tokens": "^1.
|
|
65
|
+
"@atlaskit/tokens": "^1.33.0",
|
|
66
66
|
"@atlaskit/tooltip": "^18.1.0",
|
|
67
67
|
"@atlaskit/ufo": "^0.2.4",
|
|
68
68
|
"@atlassianlabs/jql-editor": "^2.0.1",
|