@atlaskit/link-datasource 0.31.2 → 0.31.3
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 +6 -0
- package/dist/cjs/ui/datasource-table-view/datasourceTableView.js +7 -19
- package/dist/cjs/ui/issue-like-table/column-picker/index.js +2 -4
- package/dist/cjs/ui/issue-like-table/drag-column-preview.js +37 -0
- package/dist/cjs/ui/issue-like-table/draggable-table-heading.js +60 -25
- package/dist/cjs/ui/issue-like-table/empty-state/index.js +6 -1
- package/dist/cjs/ui/issue-like-table/index.js +102 -71
- package/dist/cjs/ui/issue-like-table/styled.js +2 -1
- package/dist/cjs/ui/jira-issues-modal/modal/index.js +12 -9
- package/dist/cjs/ui/table-footer/index.js +10 -7
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/ui/datasource-table-view/datasourceTableView.js +8 -20
- package/dist/es2019/ui/issue-like-table/column-picker/index.js +1 -3
- package/dist/es2019/ui/issue-like-table/drag-column-preview.js +46 -0
- package/dist/es2019/ui/issue-like-table/draggable-table-heading.js +53 -18
- package/dist/es2019/ui/issue-like-table/empty-state/index.js +6 -1
- package/dist/es2019/ui/issue-like-table/index.js +86 -43
- package/dist/es2019/ui/issue-like-table/styled.js +18 -0
- package/dist/es2019/ui/jira-issues-modal/modal/index.js +13 -10
- package/dist/es2019/ui/table-footer/index.js +11 -11
- package/dist/es2019/version.json +1 -1
- package/dist/esm/ui/datasource-table-view/datasourceTableView.js +8 -20
- package/dist/esm/ui/issue-like-table/column-picker/index.js +2 -4
- package/dist/esm/ui/issue-like-table/drag-column-preview.js +29 -0
- package/dist/esm/ui/issue-like-table/draggable-table-heading.js +60 -25
- package/dist/esm/ui/issue-like-table/empty-state/index.js +6 -1
- package/dist/esm/ui/issue-like-table/index.js +102 -71
- package/dist/esm/ui/issue-like-table/styled.js +2 -1
- package/dist/esm/ui/jira-issues-modal/modal/index.js +13 -10
- package/dist/esm/ui/table-footer/index.js +10 -7
- package/dist/esm/version.json +1 -1
- package/dist/types/ui/issue-like-table/column-picker/index.d.ts +1 -1
- package/dist/types/ui/issue-like-table/column-picker/types.d.ts +0 -1
- package/dist/types/ui/issue-like-table/drag-column-preview.d.ts +7 -0
- package/dist/types/ui/issue-like-table/draggable-table-heading.d.ts +2 -3
- package/dist/types/ui/issue-like-table/index.d.ts +1 -1
- package/dist/types/ui/issue-like-table/types.d.ts +5 -0
- package/dist/types-ts4.5/ui/issue-like-table/column-picker/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/issue-like-table/column-picker/types.d.ts +0 -1
- package/dist/types-ts4.5/ui/issue-like-table/drag-column-preview.d.ts +7 -0
- package/dist/types-ts4.5/ui/issue-like-table/draggable-table-heading.d.ts +2 -3
- package/dist/types-ts4.5/ui/issue-like-table/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/issue-like-table/types.d.ts +5 -0
- package/package.json +2 -2
|
@@ -37,8 +37,9 @@ var dropdownContainerStyles = (0, _react2.css)({
|
|
|
37
37
|
});
|
|
38
38
|
var contentContainerStyles = (0, _react2.css)({
|
|
39
39
|
display: 'grid',
|
|
40
|
-
|
|
41
|
-
overflow: 'auto'
|
|
40
|
+
maxHeight: '420px',
|
|
41
|
+
overflow: 'auto',
|
|
42
|
+
borderBottom: "2px solid ".concat("var(--ds-background-accent-gray-subtler, ".concat(_colors.N40, ")"))
|
|
42
43
|
});
|
|
43
44
|
var placeholderSmartLinkStyles = (0, _react2.css)({
|
|
44
45
|
backgroundColor: "var(--ds-surface-raised, ".concat(_colors.N0, ")"),
|
|
@@ -211,7 +212,9 @@ var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
|
|
|
211
212
|
setCurrentViewMode(selectedMode);
|
|
212
213
|
};
|
|
213
214
|
var issueLikeDataTableView = (0, _react.useMemo)(function () {
|
|
214
|
-
return (0, _react2.jsx)(
|
|
215
|
+
return (0, _react2.jsx)("div", {
|
|
216
|
+
css: contentContainerStyles
|
|
217
|
+
}, (0, _react2.jsx)(_issueLikeTable.IssueLikeDataTableView, {
|
|
215
218
|
testId: "jira-jql-datasource-table",
|
|
216
219
|
status: status,
|
|
217
220
|
columns: columns,
|
|
@@ -221,7 +224,7 @@ var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
|
|
|
221
224
|
onNextPage: onNextPage,
|
|
222
225
|
onLoadDatasourceDetails: loadDatasourceDetails,
|
|
223
226
|
onVisibleColumnKeysChange: setVisibleColumnKeys
|
|
224
|
-
});
|
|
227
|
+
}));
|
|
225
228
|
}, [columns, defaultVisibleColumnKeys, hasNextPage, loadDatasourceDetails, onNextPage, responseItems, status, visibleColumnKeys]);
|
|
226
229
|
var renderCountModeContent = (0, _react.useCallback)(function () {
|
|
227
230
|
var url = selectedJiraSite === null || selectedJiraSite === void 0 ? void 0 : selectedJiraSite.url;
|
|
@@ -258,9 +261,11 @@ var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
|
|
|
258
261
|
return (0, _react2.jsx)(_noResults.NoResults, null);
|
|
259
262
|
} else if (status === 'empty' || !columns.length) {
|
|
260
263
|
// persist the empty state when making the initial /data request which contains the columns
|
|
261
|
-
return (0, _react2.jsx)(
|
|
264
|
+
return (0, _react2.jsx)("div", {
|
|
265
|
+
css: contentContainerStyles
|
|
266
|
+
}, (0, _react2.jsx)(_issueLikeTable.EmptyState, {
|
|
262
267
|
testId: "jira-jql-datasource-modal--empty-state"
|
|
263
|
-
});
|
|
268
|
+
}));
|
|
264
269
|
}
|
|
265
270
|
var firstIssueUrl = retrieveUrlForSmartCardRender();
|
|
266
271
|
if (responseItems.length === 1 && firstIssueUrl) {
|
|
@@ -303,9 +308,7 @@ var JiraIssuesConfigModal = function JiraIssuesConfigModal(props) {
|
|
|
303
308
|
isSearching: status === 'loading',
|
|
304
309
|
parameters: parameters,
|
|
305
310
|
onSearch: onSearch
|
|
306
|
-
}), (0, _react2.jsx)("div", {
|
|
307
|
-
css: contentContainerStyles
|
|
308
|
-
}, currentViewMode === 'count' ? renderCountModeContent() : renderIssuesModeContent())), (0, _react2.jsx)(_modalDialog.ModalFooter, null, shouldShowIssueCount && (0, _react2.jsx)("div", {
|
|
311
|
+
}), currentViewMode === 'count' ? renderCountModeContent() : renderIssuesModeContent()), (0, _react2.jsx)(_modalDialog.ModalFooter, null, shouldShowIssueCount && (0, _react2.jsx)("div", {
|
|
309
312
|
"data-testid": "jira-jql-datasource-modal-total-issues-count",
|
|
310
313
|
css: issueCountStyles
|
|
311
314
|
}, (0, _react2.jsx)(_reactIntlNext.FormattedNumber, {
|
|
@@ -18,12 +18,13 @@ var _refresh = _interopRequireDefault(require("@atlaskit/icon/glyph/refresh"));
|
|
|
18
18
|
var _colors = require("@atlaskit/theme/colors");
|
|
19
19
|
var _messages = require("./messages");
|
|
20
20
|
var _syncInfo = require("./sync-info");
|
|
21
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
21
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
22
22
|
/** @jsx jsx */
|
|
23
|
-
var FooterWrapper = _styled.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
23
|
+
var FooterWrapper = _styled.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n padding: 0 ", ";\n box-sizing: border-box;\n background: ", ";\n"])), "var(--ds-space-200, 16px)", "var(--ds-background-input, ".concat(_colors.N0, ")"));
|
|
24
|
+
var TopBorderWrapper = _styled.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n box-sizing: border-box;\n justify-content: space-between;\n padding: ", " 0;\n border-top: 2px solid ", ";\n"])), "var(--ds-space-250, 20px)", "var(--ds-background-accent-gray-subtler, ".concat(_colors.N40, ")"));
|
|
25
|
+
var IssueCounterWrapper = _styled.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n align-self: center;\n color: ", ";\n"])), "var(--ds-text-accent-gray, ".concat(_colors.N800, ")"));
|
|
26
|
+
var SyncWrapper = _styled.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n align-items: center;\n color: ", ";\n"])), "var(--ds-text-accent-gray, ".concat(_colors.N90, ")"));
|
|
27
|
+
var SyncTextWrapper = _styled.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n margin-right: 5px;\n"])));
|
|
27
28
|
var TableFooter = function TableFooter(_ref) {
|
|
28
29
|
var issueCount = _ref.issueCount,
|
|
29
30
|
onRefresh = _ref.onRefresh,
|
|
@@ -44,7 +45,9 @@ var TableFooter = function TableFooter(_ref) {
|
|
|
44
45
|
// ensure correct positioning since 'justify-content: space-between' is used).
|
|
45
46
|
return onRefresh || showIssueCount ? (0, _react2.jsx)(FooterWrapper, {
|
|
46
47
|
"data-testid": "table-footer"
|
|
47
|
-
}, (0, _react2.jsx)(
|
|
48
|
+
}, (0, _react2.jsx)(TopBorderWrapper, null, (0, _react2.jsx)(IssueCounterWrapper, {
|
|
49
|
+
"data-testid": 'issue-count-wrapper'
|
|
50
|
+
}, showIssueCount && (0, _react2.jsx)(_heading.default, {
|
|
48
51
|
testId: "issue-count",
|
|
49
52
|
level: "h400"
|
|
50
53
|
}, (0, _react2.jsx)(_reactIntlNext.FormattedNumber, {
|
|
@@ -65,6 +68,6 @@ var TableFooter = function TableFooter(_ref) {
|
|
|
65
68
|
}),
|
|
66
69
|
isDisabled: isLoading,
|
|
67
70
|
testId: "refresh-button"
|
|
68
|
-
})))) : null;
|
|
71
|
+
}))))) : null;
|
|
69
72
|
};
|
|
70
73
|
exports.TableFooter = TableFooter;
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
4
|
import { useDatasourceTableState } from '../../hooks/useDatasourceTableState';
|
|
5
5
|
import { AccessRequired } from '../common/error-state/access-required';
|
|
6
6
|
import { LoadingError } from '../common/error-state/loading-error';
|
|
@@ -8,13 +8,6 @@ import { NoResults } from '../common/error-state/no-results';
|
|
|
8
8
|
import { IssueLikeDataTableView } from '../issue-like-table';
|
|
9
9
|
import EmptyState from '../issue-like-table/empty-state';
|
|
10
10
|
import { TableFooter } from '../table-footer';
|
|
11
|
-
const TableViewWrapperStyles = css({
|
|
12
|
-
display: 'grid',
|
|
13
|
-
position: 'relative',
|
|
14
|
-
padding: "var(--ds-space-200, 16px)",
|
|
15
|
-
paddingBottom: 0,
|
|
16
|
-
boxSizing: 'border-box'
|
|
17
|
-
});
|
|
18
11
|
export const DatasourceTableView = ({
|
|
19
12
|
datasourceId,
|
|
20
13
|
parameters,
|
|
@@ -59,9 +52,8 @@ export const DatasourceTableView = ({
|
|
|
59
52
|
onRefresh: reset
|
|
60
53
|
});
|
|
61
54
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}, jsx(IssueLikeDataTableView, {
|
|
55
|
+
const isDataReady = columns.length > 0;
|
|
56
|
+
return jsx("div", null, isDataReady ? jsx(IssueLikeDataTableView, {
|
|
65
57
|
testId: 'datasource-table-view',
|
|
66
58
|
hasNextPage: hasNextPage,
|
|
67
59
|
items: responseItems,
|
|
@@ -70,18 +62,14 @@ export const DatasourceTableView = ({
|
|
|
70
62
|
status: status,
|
|
71
63
|
columns: columns,
|
|
72
64
|
visibleColumnKeys: visibleColumnKeys || defaultVisibleColumnKeys,
|
|
73
|
-
onVisibleColumnKeysChange: onVisibleColumnKeysChange
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
onRefresh: reset,
|
|
77
|
-
isLoading: status === 'loading'
|
|
78
|
-
})) : jsx("div", {
|
|
79
|
-
css: TableViewWrapperStyles
|
|
80
|
-
}, jsx(EmptyState, {
|
|
65
|
+
onVisibleColumnKeysChange: onVisibleColumnKeysChange,
|
|
66
|
+
scrollableContainerHeight: 590
|
|
67
|
+
}) : jsx(EmptyState, {
|
|
81
68
|
testId: "datasource-table-view-skeleton",
|
|
82
69
|
isCompact: true
|
|
83
70
|
}), jsx(TableFooter, {
|
|
71
|
+
issueCount: isDataReady ? totalCount : undefined,
|
|
84
72
|
onRefresh: reset,
|
|
85
|
-
isLoading:
|
|
73
|
+
isLoading: !isDataReady || status === 'loading'
|
|
86
74
|
}));
|
|
87
75
|
};
|
|
@@ -9,7 +9,6 @@ import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
|
9
9
|
import { CheckboxOption, PopupSelect } from '@atlaskit/select';
|
|
10
10
|
import { columnPickerMessages } from './messages';
|
|
11
11
|
export const ColumnPicker = ({
|
|
12
|
-
isDatasourceLoading,
|
|
13
12
|
columns,
|
|
14
13
|
selectedColumnKeys,
|
|
15
14
|
onSelectedColumnKeysChange,
|
|
@@ -102,8 +101,7 @@ export const ColumnPicker = ({
|
|
|
102
101
|
})),
|
|
103
102
|
spacing: "compact",
|
|
104
103
|
appearance: "subtle",
|
|
105
|
-
testId: "column-picker-trigger-button"
|
|
106
|
-
isDisabled: isDatasourceLoading
|
|
104
|
+
testId: "column-picker-trigger-button"
|
|
107
105
|
}))
|
|
108
106
|
});
|
|
109
107
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
5
|
+
import { TableHeading } from './styled';
|
|
6
|
+
const maxWidth = '200px';
|
|
7
|
+
const firstLastChildOverride = `
|
|
8
|
+
&:first-of-type, &:last-of-type {
|
|
9
|
+
padding-left: ${"var(--ds-space-100, 8px)"};
|
|
10
|
+
padding-right: ${"var(--ds-space-100, 8px)"};
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
const TablePreviewHeading = styled(TableHeading)`
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
text-overflow: ellipsis;
|
|
16
|
+
white-space: nowrap;
|
|
17
|
+
background: ${"var(--ds-background-disabled, #091E4224)"};
|
|
18
|
+
color: ${"var(--ds-text-disabled, #091E424F)"};
|
|
19
|
+
max-width: ${maxWidth};
|
|
20
|
+
${firstLastChildOverride}
|
|
21
|
+
`;
|
|
22
|
+
const TablePreviewCell = styled.td`
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
text-overflow: ellipsis;
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
max-width: ${maxWidth};
|
|
27
|
+
padding: ${"var(--ds-space-050, 4px)"} ${"var(--ds-space-100, 8px)"};
|
|
28
|
+
${firstLastChildOverride}
|
|
29
|
+
`;
|
|
30
|
+
const tableStyles = css({
|
|
31
|
+
background: "var(--ds-surface, #FFF)",
|
|
32
|
+
borderCollapse: 'separate',
|
|
33
|
+
borderSpacing: 0,
|
|
34
|
+
fontSize: "var(--ds-font-size-200, 16px)",
|
|
35
|
+
maxWidth
|
|
36
|
+
});
|
|
37
|
+
export const DragColumnPreview = ({
|
|
38
|
+
title,
|
|
39
|
+
rows
|
|
40
|
+
}) => {
|
|
41
|
+
return jsx("table", {
|
|
42
|
+
css: tableStyles
|
|
43
|
+
}, jsx("thead", null, jsx("tr", null, jsx(TablePreviewHeading, null, title))), jsx("tbody", null, rows.map((data, i) => jsx("tr", {
|
|
44
|
+
key: i
|
|
45
|
+
}, jsx(TablePreviewCell, null, data))), jsx("tr", null, jsx(TablePreviewCell, null, "..."))));
|
|
46
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import ReactDOM from 'react-dom';
|
|
4
5
|
import invariant from 'tiny-invariant';
|
|
5
6
|
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
6
7
|
import { attachClosestEdge, extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
|
|
7
8
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-indicator/box-without-terminal';
|
|
8
9
|
import { draggable, dropTargetForElements, monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
9
10
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/util/combine';
|
|
11
|
+
import { offsetFromPointer } from '@atlaskit/pragmatic-drag-and-drop/util/offset-from-pointer';
|
|
12
|
+
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview';
|
|
10
13
|
import { TableHeading } from './styled';
|
|
11
|
-
const tableHeadingStyles = css({
|
|
12
|
-
cursor: 'grab'
|
|
13
|
-
});
|
|
14
14
|
const tableHeadingStatusStyles = {
|
|
15
15
|
idle: css({
|
|
16
16
|
':hover': {
|
|
@@ -30,7 +30,14 @@ const verticallyAlignedStyles = css({
|
|
|
30
30
|
const dragHandleStyles = css({
|
|
31
31
|
position: 'relative',
|
|
32
32
|
display: 'flex',
|
|
33
|
-
alignItems: 'center'
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
overflow: 'hidden',
|
|
35
|
+
width: 0,
|
|
36
|
+
transition: 'width 0.5s'
|
|
37
|
+
});
|
|
38
|
+
const dragHandleSpacerStyles = css({
|
|
39
|
+
width: 24,
|
|
40
|
+
transition: 'width 0.5s'
|
|
34
41
|
});
|
|
35
42
|
const dropTargetStyles = css({
|
|
36
43
|
position: 'absolute',
|
|
@@ -41,18 +48,23 @@ const dropTargetStyles = css({
|
|
|
41
48
|
const noPointerEventsStyles = css({
|
|
42
49
|
pointerEvents: 'none'
|
|
43
50
|
});
|
|
51
|
+
const idleState = {
|
|
52
|
+
type: 'idle'
|
|
53
|
+
};
|
|
54
|
+
const draggingState = {
|
|
55
|
+
type: 'dragging'
|
|
56
|
+
};
|
|
44
57
|
export const DraggableTableHeading = ({
|
|
45
58
|
children,
|
|
46
59
|
id,
|
|
47
60
|
index,
|
|
48
61
|
tableId,
|
|
49
62
|
dndPreviewHeight,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
onDragPreviewEnd
|
|
63
|
+
dragPreview,
|
|
64
|
+
maxWidth
|
|
53
65
|
}) => {
|
|
54
66
|
const ref = useRef(null);
|
|
55
|
-
const [
|
|
67
|
+
const [state, setState] = useState(idleState);
|
|
56
68
|
const [isDraggingAnyColumn, setIsDraggingAnyColumn] = useState(false);
|
|
57
69
|
const [closestEdge, setClosestEdge] = useState(null);
|
|
58
70
|
const dropTargetRef = useRef(null);
|
|
@@ -69,19 +81,38 @@ export const DraggableTableHeading = ({
|
|
|
69
81
|
tableId
|
|
70
82
|
};
|
|
71
83
|
},
|
|
72
|
-
onGenerateDragPreview(
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
onGenerateDragPreview({
|
|
85
|
+
nativeSetDragImage
|
|
86
|
+
}) {
|
|
87
|
+
setCustomNativeDragPreview({
|
|
88
|
+
getOffset: offsetFromPointer({
|
|
89
|
+
x: '18px',
|
|
90
|
+
y: '18px'
|
|
91
|
+
}),
|
|
92
|
+
render: ({
|
|
93
|
+
container
|
|
94
|
+
}) => {
|
|
95
|
+
// Cause a `react` re-render to create your portal synchronously
|
|
96
|
+
setState({
|
|
97
|
+
type: 'preview',
|
|
98
|
+
container
|
|
99
|
+
});
|
|
100
|
+
// In our cleanup function: cause a `react` re-render to create remove your portal
|
|
101
|
+
// Note: you can also remove the portal in `onDragStart`,
|
|
102
|
+
// which is when the cleanup function is called
|
|
103
|
+
return () => setState(draggingState);
|
|
104
|
+
},
|
|
105
|
+
nativeSetDragImage
|
|
106
|
+
});
|
|
75
107
|
},
|
|
76
108
|
onDragStart() {
|
|
77
|
-
|
|
78
|
-
onDragPreviewEnd();
|
|
109
|
+
setState(draggingState);
|
|
79
110
|
},
|
|
80
111
|
onDrop() {
|
|
81
|
-
|
|
112
|
+
setState(idleState);
|
|
82
113
|
}
|
|
83
114
|
}));
|
|
84
|
-
}, [id, index,
|
|
115
|
+
}, [id, index, tableId]);
|
|
85
116
|
|
|
86
117
|
// Here we handle drop target, that in our case is absolutely positioned div that covers full width and height
|
|
87
118
|
// of this column (has height of whole table). It sits on top of everything, but has `pointerEvents: 'none'` by default
|
|
@@ -145,7 +176,7 @@ export const DraggableTableHeading = ({
|
|
|
145
176
|
}, [tableId]);
|
|
146
177
|
return jsx(TableHeading, {
|
|
147
178
|
ref: ref,
|
|
148
|
-
css: [
|
|
179
|
+
css: [tableHeadingStatusStyles[state.type]],
|
|
149
180
|
"data-testid": `${id}-column-heading`,
|
|
150
181
|
style: {
|
|
151
182
|
maxWidth
|
|
@@ -162,9 +193,13 @@ export const DraggableTableHeading = ({
|
|
|
162
193
|
})), jsx("div", {
|
|
163
194
|
css: verticallyAlignedStyles
|
|
164
195
|
}, jsx("div", {
|
|
165
|
-
css: dragHandleStyles
|
|
196
|
+
css: dragHandleStyles,
|
|
197
|
+
className: "issue-like-table-drag-handle"
|
|
166
198
|
}, jsx(DragHandlerIcon, {
|
|
167
199
|
label: `${id}-drag-icon`,
|
|
168
200
|
size: "medium"
|
|
169
|
-
})), children
|
|
201
|
+
})), children, jsx("div", {
|
|
202
|
+
css: dragHandleSpacerStyles,
|
|
203
|
+
className: "issue-like-table-drag-handle-spacer"
|
|
204
|
+
})), state.type === 'preview' ? /*#__PURE__*/ReactDOM.createPortal(dragPreview, state.container) : null);
|
|
170
205
|
};
|
|
@@ -5,6 +5,9 @@ import UserType from '../render-type/user';
|
|
|
5
5
|
import { EmptyStateTableHeading } from '../styled';
|
|
6
6
|
import Priority from './priority';
|
|
7
7
|
import Type from './type';
|
|
8
|
+
const tableBodyStyles = css({
|
|
9
|
+
borderBottom: 0
|
|
10
|
+
});
|
|
8
11
|
const baseColumns = [{
|
|
9
12
|
key: 'type',
|
|
10
13
|
width: 50
|
|
@@ -118,7 +121,9 @@ export default (({
|
|
|
118
121
|
width: width,
|
|
119
122
|
height: 13,
|
|
120
123
|
borderRadius: 8
|
|
121
|
-
}))))), jsx("tbody",
|
|
124
|
+
}))))), jsx("tbody", {
|
|
125
|
+
css: tableBodyStyles
|
|
126
|
+
}, rows.map(row => jsx("tr", {
|
|
122
127
|
key: row.id
|
|
123
128
|
}, columnsToRender.map(column => jsx("td", {
|
|
124
129
|
css: cellStyles,
|
|
@@ -3,30 +3,42 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import styled from '@emotion/styled';
|
|
5
5
|
import invariant from 'tiny-invariant';
|
|
6
|
+
import Heading from '@atlaskit/heading';
|
|
6
7
|
import { Skeleton } from '@atlaskit/linking-common';
|
|
7
8
|
import { extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
|
|
8
9
|
import { reorderWithEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge';
|
|
9
10
|
import { autoScroller } from '@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll';
|
|
10
11
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
11
12
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/util/combine';
|
|
13
|
+
import { N40 } from '@atlaskit/theme/colors';
|
|
12
14
|
import { ColumnPicker } from './column-picker';
|
|
15
|
+
import { DragColumnPreview } from './drag-column-preview';
|
|
13
16
|
import { DraggableTableHeading } from './draggable-table-heading';
|
|
14
17
|
import TableEmptyState from './empty-state';
|
|
15
18
|
import { fallbackRenderType } from './render-type';
|
|
16
19
|
import { Table, TableHeading } from './styled';
|
|
17
20
|
import { useIsOnScreen } from './useIsOnScreen';
|
|
21
|
+
const tableSidePadding = "var(--ds-space-200, 16px)";
|
|
18
22
|
const tableHeadStyles = css({
|
|
19
23
|
background: "var(--ds-surface, #FFF)",
|
|
20
|
-
|
|
24
|
+
position: 'sticky',
|
|
25
|
+
top: 0,
|
|
26
|
+
zIndex: 10
|
|
21
27
|
});
|
|
22
|
-
const ColumnPickerHeader = styled.
|
|
28
|
+
const ColumnPickerHeader = styled.th`
|
|
23
29
|
width: 40px;
|
|
24
|
-
padding-block: ${"var(--ds-space-100, 8px)"};
|
|
25
30
|
position: sticky;
|
|
26
|
-
right:
|
|
31
|
+
right: calc(-1 * ${tableSidePadding});
|
|
27
32
|
background-color: ${"var(--ds-surface, #FFF)"};
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
border-bottom: 2px solid ${`var(--ds-background-accent-gray-subtler, ${N40})`}; /* It is required to have solid (not half-transparent) color because of this gradient business bellow */
|
|
34
|
+
background: linear-gradient(
|
|
35
|
+
90deg,
|
|
36
|
+
rgba(255, 255, 255, 0) 0%,
|
|
37
|
+
${"var(--ds-surface, #FFF)"} 10%
|
|
38
|
+
);
|
|
39
|
+
vertical-align: middle; /* Keeps dropdown button in the middle */
|
|
40
|
+
&:last-of-type {
|
|
41
|
+
padding-right: ${tableSidePadding};
|
|
30
42
|
}
|
|
31
43
|
`;
|
|
32
44
|
const truncatedCellStyles = css({
|
|
@@ -34,11 +46,22 @@ const truncatedCellStyles = css({
|
|
|
34
46
|
textOverflow: 'ellipsis',
|
|
35
47
|
whiteSpace: 'nowrap'
|
|
36
48
|
});
|
|
37
|
-
const
|
|
38
|
-
|
|
49
|
+
const scrollableContainerStyles = css({
|
|
50
|
+
overflow: 'auto',
|
|
51
|
+
padding: `0 ${tableSidePadding} 0 ${tableSidePadding}`,
|
|
52
|
+
boxSizing: 'border-box'
|
|
39
53
|
});
|
|
40
|
-
const
|
|
41
|
-
|
|
54
|
+
const tableStyles = css({
|
|
55
|
+
// These styles are needed to prevent thead bottom border from scrolling away.
|
|
56
|
+
// This happens because it is sticky. https://stackoverflow.com/questions/50361698/border-style-do-not-work-with-sticky-position-element
|
|
57
|
+
borderCollapse: 'separate',
|
|
58
|
+
borderSpacing: 0
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// By default tbody and thead have border-bottom: 2px ...
|
|
62
|
+
// This removes it, because for header we handle it via `th` styling and footer supply bottom border
|
|
63
|
+
const noDefaultBorderStyles = css({
|
|
64
|
+
borderBottom: 0
|
|
42
65
|
});
|
|
43
66
|
function extractIndex(data) {
|
|
44
67
|
const {
|
|
@@ -69,7 +92,6 @@ const BASE_WIDTH = 8;
|
|
|
69
92
|
function getColumnWidth(key, type) {
|
|
70
93
|
const keyBasedWidth = {
|
|
71
94
|
assignee: BASE_WIDTH * 22,
|
|
72
|
-
key: BASE_WIDTH * 10,
|
|
73
95
|
labels: BASE_WIDTH * 22,
|
|
74
96
|
priority: BASE_WIDTH * 8,
|
|
75
97
|
status: BASE_WIDTH * 18,
|
|
@@ -98,11 +120,11 @@ export const IssueLikeDataTableView = ({
|
|
|
98
120
|
visibleColumnKeys,
|
|
99
121
|
onVisibleColumnKeysChange,
|
|
100
122
|
status,
|
|
101
|
-
hasNextPage
|
|
123
|
+
hasNextPage,
|
|
124
|
+
scrollableContainerHeight
|
|
102
125
|
}) => {
|
|
103
126
|
const tableId = useMemo(() => Symbol('unique-id'), []);
|
|
104
127
|
const [lastRowElement, setLastRowElement] = useState(null);
|
|
105
|
-
const [isDragPreview, setIsDragPreview] = useState(false);
|
|
106
128
|
const [hasFullSchema, setHasFullSchema] = useState(false);
|
|
107
129
|
const isBottomOfTableVisibleRaw = useIsOnScreen(lastRowElement);
|
|
108
130
|
const containerRef = useRef(null);
|
|
@@ -135,7 +157,7 @@ export const IssueLikeDataTableView = ({
|
|
|
135
157
|
};
|
|
136
158
|
})
|
|
137
159
|
}), [visibleSortedColumns]);
|
|
138
|
-
const headColumns = visibleSortedColumns.map(({
|
|
160
|
+
const headColumns = useMemo(() => visibleSortedColumns.map(({
|
|
139
161
|
key,
|
|
140
162
|
title,
|
|
141
163
|
type
|
|
@@ -144,7 +166,7 @@ export const IssueLikeDataTableView = ({
|
|
|
144
166
|
content: title,
|
|
145
167
|
shouldTruncate: true,
|
|
146
168
|
maxWidth: getColumnWidth(key, type)
|
|
147
|
-
}));
|
|
169
|
+
})), [visibleSortedColumns]);
|
|
148
170
|
useEffect(() => {
|
|
149
171
|
if (isBottomOfTableVisibleRaw && hasNextPage && status === 'resolved') {
|
|
150
172
|
void onNextPage({
|
|
@@ -152,37 +174,41 @@ export const IssueLikeDataTableView = ({
|
|
|
152
174
|
});
|
|
153
175
|
}
|
|
154
176
|
}, [isBottomOfTableVisibleRaw, status, hasNextPage, onNextPage]);
|
|
155
|
-
|
|
156
|
-
if (items.length > 0 && containerRef.current) {
|
|
157
|
-
const containerEl = containerRef.current;
|
|
158
|
-
invariant(containerEl);
|
|
159
|
-
dndPreviewHeight = containerEl.offsetHeight;
|
|
160
|
-
}
|
|
177
|
+
const hasData = items.length > 0;
|
|
161
178
|
|
|
162
179
|
// This variable contains initial Y mouse coordinate, so we can restrict
|
|
163
180
|
// autoScroller in X axis only
|
|
164
181
|
const initialAutoScrollerClientY = useRef();
|
|
165
182
|
useEffect(() => {
|
|
166
|
-
if (!onVisibleColumnKeysChange) {
|
|
183
|
+
if (!onVisibleColumnKeysChange || !hasData) {
|
|
167
184
|
return;
|
|
168
185
|
}
|
|
169
186
|
return combine(monitorForElements({
|
|
170
187
|
onDragStart: ({
|
|
171
188
|
location
|
|
172
189
|
}) => {
|
|
190
|
+
var _containerRef$current;
|
|
173
191
|
initialAutoScrollerClientY.current = location.current.input.clientY;
|
|
174
192
|
autoScroller.start({
|
|
175
|
-
input:
|
|
193
|
+
input: {
|
|
194
|
+
...location.current.input,
|
|
195
|
+
clientY:
|
|
196
|
+
// The goal is to have clientY the same and in the middle of the scrollable area
|
|
197
|
+
// Since clientY is taken from to of the viewport we need to plus that in order to get
|
|
198
|
+
// middle of the scrollable area in reference to the viewport
|
|
199
|
+
(initialAutoScrollerClientY.current || 0) + (((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetHeight) || 0) / 2
|
|
200
|
+
},
|
|
176
201
|
behavior: 'container-only'
|
|
177
202
|
});
|
|
178
203
|
},
|
|
179
204
|
onDrag: ({
|
|
180
205
|
location
|
|
181
206
|
}) => {
|
|
207
|
+
var _containerRef$current2;
|
|
182
208
|
autoScroller.updateInput({
|
|
183
209
|
input: {
|
|
184
210
|
...location.current.input,
|
|
185
|
-
clientY: initialAutoScrollerClientY.current || 0
|
|
211
|
+
clientY: (initialAutoScrollerClientY.current || 0) + (((_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.offsetHeight) || 0) / 2
|
|
186
212
|
}
|
|
187
213
|
});
|
|
188
214
|
},
|
|
@@ -190,7 +216,6 @@ export const IssueLikeDataTableView = ({
|
|
|
190
216
|
source,
|
|
191
217
|
location
|
|
192
218
|
}) {
|
|
193
|
-
initialAutoScrollerClientY.current = null;
|
|
194
219
|
autoScroller.stop();
|
|
195
220
|
if (location.current.dropTargets.length === 0) {
|
|
196
221
|
return;
|
|
@@ -220,7 +245,7 @@ export const IssueLikeDataTableView = ({
|
|
|
220
245
|
}
|
|
221
246
|
}
|
|
222
247
|
}));
|
|
223
|
-
}, [visibleColumnKeys, onVisibleColumnKeysChange, tableId]);
|
|
248
|
+
}, [visibleColumnKeys, onVisibleColumnKeysChange, tableId, hasData]);
|
|
224
249
|
const tableRows = useMemo(() => items.map((newRowData, rowIndex) => ({
|
|
225
250
|
key: `${identityColumnKey && newRowData[identityColumnKey] && newRowData[identityColumnKey].data || rowIndex}`,
|
|
226
251
|
cells: visibleSortedColumns.map(({
|
|
@@ -242,9 +267,7 @@ export const IssueLikeDataTableView = ({
|
|
|
242
267
|
}),
|
|
243
268
|
ref: rowIndex === items.length - 1 ? el => setLastRowElement(el) : undefined
|
|
244
269
|
})), [identityColumnKey, renderItem, items, visibleSortedColumns]);
|
|
245
|
-
const rows = [...tableRows, ...(status === 'loading' ? [loadingRow] : [])];
|
|
246
|
-
const setIsDragPreviewOn = useCallback(() => setIsDragPreview(true), [setIsDragPreview]);
|
|
247
|
-
const setIsDragPreviewOff = useCallback(() => setIsDragPreview(false), [setIsDragPreview]);
|
|
270
|
+
const rows = useMemo(() => [...tableRows, ...(status === 'loading' ? [loadingRow] : [])], [loadingRow, status, tableRows]);
|
|
248
271
|
const onSelectedColumnKeysChange = useCallback(newSelectedColumnKeys => {
|
|
249
272
|
onVisibleColumnKeysChange === null || onVisibleColumnKeysChange === void 0 ? void 0 : onVisibleColumnKeysChange(newSelectedColumnKeys);
|
|
250
273
|
}, [onVisibleColumnKeysChange]);
|
|
@@ -261,32 +284,50 @@ export const IssueLikeDataTableView = ({
|
|
|
261
284
|
}, [hasFullSchema, onLoadDatasourceDetails]);
|
|
262
285
|
return jsx("div", {
|
|
263
286
|
ref: containerRef,
|
|
264
|
-
css:
|
|
287
|
+
css: scrollableContainerHeight ? scrollableContainerStyles : null,
|
|
288
|
+
style: scrollableContainerHeight ? {
|
|
289
|
+
maxHeight: `${scrollableContainerHeight}px`
|
|
290
|
+
} : undefined
|
|
265
291
|
}, jsx(Table, {
|
|
266
|
-
css:
|
|
292
|
+
css: tableStyles,
|
|
267
293
|
"data-testid": testId
|
|
268
294
|
}, jsx("thead", {
|
|
269
295
|
"data-testid": testId && `${testId}--head`,
|
|
270
|
-
css: tableHeadStyles
|
|
296
|
+
css: [noDefaultBorderStyles, tableHeadStyles]
|
|
271
297
|
}, jsx("tr", null, headColumns.map(({
|
|
272
298
|
key,
|
|
273
299
|
content,
|
|
274
300
|
maxWidth
|
|
275
301
|
}, cellIndex) => {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
302
|
+
if (onVisibleColumnKeysChange && hasData) {
|
|
303
|
+
var _containerRef$current3;
|
|
304
|
+
const previewRows = tableRows.map(({
|
|
305
|
+
cells
|
|
306
|
+
}) => {
|
|
307
|
+
const cell = cells.find(({
|
|
308
|
+
key: cellKey
|
|
309
|
+
}) => cellKey === key);
|
|
310
|
+
if (cell) {
|
|
311
|
+
return cell.content;
|
|
312
|
+
}
|
|
313
|
+
}).slice(0, 5);
|
|
314
|
+
const dragPreview = jsx(DragColumnPreview, {
|
|
315
|
+
title: jsx(Heading, {
|
|
316
|
+
level: "h400"
|
|
317
|
+
}, content),
|
|
318
|
+
rows: previewRows
|
|
319
|
+
});
|
|
280
320
|
return jsx(DraggableTableHeading, {
|
|
281
321
|
tableId: tableId,
|
|
282
322
|
key: key,
|
|
283
323
|
id: key,
|
|
284
324
|
index: cellIndex,
|
|
285
325
|
maxWidth: maxWidth,
|
|
286
|
-
dndPreviewHeight:
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
326
|
+
dndPreviewHeight: ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.offsetHeight) || 0,
|
|
327
|
+
dragPreview: dragPreview
|
|
328
|
+
}, jsx(Heading, {
|
|
329
|
+
level: "h400"
|
|
330
|
+
}, content));
|
|
290
331
|
} else {
|
|
291
332
|
return jsx(TableHeading, {
|
|
292
333
|
key: key,
|
|
@@ -294,15 +335,17 @@ export const IssueLikeDataTableView = ({
|
|
|
294
335
|
style: {
|
|
295
336
|
maxWidth
|
|
296
337
|
}
|
|
297
|
-
}, jsx(
|
|
338
|
+
}, jsx(Heading, {
|
|
339
|
+
level: "h400"
|
|
340
|
+
}, content));
|
|
298
341
|
}
|
|
299
|
-
}), onVisibleColumnKeysChange && jsx(ColumnPickerHeader, null, jsx(ColumnPicker, {
|
|
342
|
+
}), onVisibleColumnKeysChange && hasData && jsx(ColumnPickerHeader, null, jsx(ColumnPicker, {
|
|
300
343
|
columns: hasFullSchema ? orderedColumns : [],
|
|
301
344
|
selectedColumnKeys: hasFullSchema ? visibleColumnKeys : [],
|
|
302
|
-
isDatasourceLoading: status === 'loading',
|
|
303
345
|
onSelectedColumnKeysChange: onSelectedColumnKeysChange,
|
|
304
346
|
onOpen: handlePickerOpen
|
|
305
347
|
})))), jsx("tbody", {
|
|
348
|
+
css: noDefaultBorderStyles,
|
|
306
349
|
"data-testid": testId && `${testId}--body`
|
|
307
350
|
}, rows.map(({
|
|
308
351
|
key,
|