@atlaskit/link-datasource 0.31.2 → 0.32.0
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 +12 -0
- package/dist/cjs/analytics/constants.js +8 -0
- package/dist/cjs/analytics/generated/analytics.types.js +5 -0
- package/dist/cjs/analytics/generated/create-event-payload.js +46 -0
- package/dist/cjs/analytics/generated/use-analytics-events.js +32 -0
- package/dist/cjs/analytics/index.js +18 -0
- package/dist/cjs/ui/common/error-state/access-required.js +12 -3
- package/dist/cjs/ui/common/error-state/loading-error.js +20 -11
- package/dist/cjs/ui/common/error-state/modal-loading-error.js +21 -12
- package/dist/cjs/ui/common/error-state/no-results.js +48 -41
- 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/jira-search-container/index.js +8 -0
- package/dist/cjs/ui/jira-issues-modal/modal/index.js +43 -15
- package/dist/cjs/ui/table-footer/index.js +10 -7
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/constants.js +1 -0
- package/dist/es2019/analytics/generated/analytics.types.js +1 -0
- package/dist/es2019/analytics/generated/create-event-payload.js +28 -0
- package/dist/es2019/analytics/generated/use-analytics-events.js +24 -0
- package/dist/es2019/analytics/index.js +3 -0
- package/dist/es2019/ui/common/error-state/access-required.js +10 -0
- package/dist/es2019/ui/common/error-state/loading-error.js +10 -0
- package/dist/es2019/ui/common/error-state/modal-loading-error.js +10 -0
- package/dist/es2019/ui/common/error-state/no-results.js +8 -0
- 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/jira-search-container/index.js +9 -0
- package/dist/es2019/ui/jira-issues-modal/modal/index.js +43 -13
- package/dist/es2019/ui/table-footer/index.js +11 -11
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/constants.js +1 -0
- package/dist/esm/analytics/generated/analytics.types.js +1 -0
- package/dist/esm/analytics/generated/create-event-payload.js +38 -0
- package/dist/esm/analytics/generated/use-analytics-events.js +23 -0
- package/dist/esm/analytics/index.js +5 -0
- package/dist/esm/ui/common/error-state/access-required.js +9 -0
- package/dist/esm/ui/common/error-state/loading-error.js +9 -0
- package/dist/esm/ui/common/error-state/modal-loading-error.js +9 -0
- package/dist/esm/ui/common/error-state/no-results.js +7 -0
- 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/jira-search-container/index.js +8 -0
- package/dist/esm/ui/jira-issues-modal/modal/index.js +43 -14
- package/dist/esm/ui/table-footer/index.js +10 -7
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/constants.d.ts +1 -0
- package/dist/types/analytics/generated/analytics.types.d.ts +49 -0
- package/dist/types/analytics/generated/create-event-payload.d.ts +27 -0
- package/dist/types/analytics/generated/use-analytics-events.d.ts +3 -0
- package/dist/types/analytics/index.d.ts +4 -0
- package/dist/types/ui/common/error-state/access-required.d.ts +0 -1
- package/dist/types/ui/common/error-state/loading-error.d.ts +0 -1
- package/dist/types/ui/common/error-state/modal-loading-error.d.ts +0 -1
- package/dist/types/ui/common/error-state/no-results.d.ts +0 -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/ui/jira-issues-modal/modal/index.d.ts +3 -1
- package/dist/types-ts4.5/analytics/constants.d.ts +1 -0
- package/dist/types-ts4.5/analytics/generated/analytics.types.d.ts +49 -0
- package/dist/types-ts4.5/analytics/generated/create-event-payload.d.ts +31 -0
- package/dist/types-ts4.5/analytics/generated/use-analytics-events.d.ts +7 -0
- package/dist/types-ts4.5/analytics/index.d.ts +8 -0
- package/dist/types-ts4.5/ui/common/error-state/access-required.d.ts +0 -1
- package/dist/types-ts4.5/ui/common/error-state/loading-error.d.ts +0 -1
- package/dist/types-ts4.5/ui/common/error-state/modal-loading-error.d.ts +0 -1
- package/dist/types-ts4.5/ui/common/error-state/no-results.d.ts +0 -1
- 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/dist/types-ts4.5/ui/jira-issues-modal/modal/index.d.ts +3 -1
- package/package.json +7 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
import { useEffect } from 'react';
|
|
2
3
|
import { css, jsx } from '@emotion/react';
|
|
3
4
|
import { FormattedMessage } from 'react-intl-next';
|
|
4
5
|
import Button from '@atlaskit/button/standard-button';
|
|
6
|
+
import { useDatasourceAnalyticsEvents } from '../../../analytics';
|
|
5
7
|
import { loadingErrorMessages } from './messages';
|
|
6
8
|
var noResultsContainerStyles = css({
|
|
7
9
|
display: 'grid',
|
|
@@ -20,6 +22,11 @@ var noResultsMessageStyles = css({
|
|
|
20
22
|
});
|
|
21
23
|
export var NoResults = function NoResults(_ref) {
|
|
22
24
|
var onRefresh = _ref.onRefresh;
|
|
25
|
+
var _useDatasourceAnalyti = useDatasourceAnalyticsEvents(),
|
|
26
|
+
fireEvent = _useDatasourceAnalyti.fireEvent;
|
|
27
|
+
useEffect(function () {
|
|
28
|
+
fireEvent('ui.emptyResult.shown.datasource', {});
|
|
29
|
+
}, [fireEvent]);
|
|
23
30
|
return jsx("div", {
|
|
24
31
|
css: noResultsContainerStyles,
|
|
25
32
|
"data-testid": "jira-jql-datasource-modal--no-results"
|
|
@@ -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
|
-
var 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 var DatasourceTableView = function DatasourceTableView(_ref) {
|
|
19
12
|
var datasourceId = _ref.datasourceId,
|
|
20
13
|
parameters = _ref.parameters,
|
|
@@ -57,9 +50,8 @@ export var DatasourceTableView = function DatasourceTableView(_ref) {
|
|
|
57
50
|
onRefresh: reset
|
|
58
51
|
});
|
|
59
52
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}, jsx(IssueLikeDataTableView, {
|
|
53
|
+
var isDataReady = columns.length > 0;
|
|
54
|
+
return jsx("div", null, isDataReady ? jsx(IssueLikeDataTableView, {
|
|
63
55
|
testId: 'datasource-table-view',
|
|
64
56
|
hasNextPage: hasNextPage,
|
|
65
57
|
items: responseItems,
|
|
@@ -68,18 +60,14 @@ export var DatasourceTableView = function DatasourceTableView(_ref) {
|
|
|
68
60
|
status: status,
|
|
69
61
|
columns: columns,
|
|
70
62
|
visibleColumnKeys: visibleColumnKeys || defaultVisibleColumnKeys,
|
|
71
|
-
onVisibleColumnKeysChange: onVisibleColumnKeysChange
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
onRefresh: reset,
|
|
75
|
-
isLoading: status === 'loading'
|
|
76
|
-
})) : jsx("div", {
|
|
77
|
-
css: TableViewWrapperStyles
|
|
78
|
-
}, jsx(EmptyState, {
|
|
63
|
+
onVisibleColumnKeysChange: onVisibleColumnKeysChange,
|
|
64
|
+
scrollableContainerHeight: 590
|
|
65
|
+
}) : jsx(EmptyState, {
|
|
79
66
|
testId: "datasource-table-view-skeleton",
|
|
80
67
|
isCompact: true
|
|
81
68
|
}), jsx(TableFooter, {
|
|
69
|
+
issueCount: isDataReady ? totalCount : undefined,
|
|
82
70
|
onRefresh: reset,
|
|
83
|
-
isLoading:
|
|
71
|
+
isLoading: !isDataReady || status === 'loading'
|
|
84
72
|
}));
|
|
85
73
|
};
|
|
@@ -13,8 +13,7 @@ import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
|
13
13
|
import { CheckboxOption, PopupSelect } from '@atlaskit/select';
|
|
14
14
|
import { columnPickerMessages } from './messages';
|
|
15
15
|
export var ColumnPicker = function ColumnPicker(_ref) {
|
|
16
|
-
var
|
|
17
|
-
columns = _ref.columns,
|
|
16
|
+
var columns = _ref.columns,
|
|
18
17
|
selectedColumnKeys = _ref.selectedColumnKeys,
|
|
19
18
|
onSelectedColumnKeysChange = _ref.onSelectedColumnKeysChange,
|
|
20
19
|
onOpen = _ref.onOpen;
|
|
@@ -120,8 +119,7 @@ export var ColumnPicker = function ColumnPicker(_ref) {
|
|
|
120
119
|
})),
|
|
121
120
|
spacing: "compact",
|
|
122
121
|
appearance: "subtle",
|
|
123
|
-
testId: "column-picker-trigger-button"
|
|
124
|
-
isDisabled: isDatasourceLoading
|
|
122
|
+
testId: "column-picker-trigger-button"
|
|
125
123
|
}));
|
|
126
124
|
}
|
|
127
125
|
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2;
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/react';
|
|
6
|
+
import styled from '@emotion/styled';
|
|
7
|
+
import { TableHeading } from './styled';
|
|
8
|
+
var maxWidth = '200px';
|
|
9
|
+
var firstLastChildOverride = "\n &:first-of-type, &:last-of-type {\n padding-left: ".concat("var(--ds-space-100, 8px)", ";\n padding-right: ", "var(--ds-space-100, 8px)", ";\n }\n");
|
|
10
|
+
var TablePreviewHeading = styled(TableHeading)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n background: ", ";\n color: ", ";\n max-width: ", ";\n ", "\n"])), "var(--ds-background-disabled, #091E4224)", "var(--ds-text-disabled, #091E424F)", maxWidth, firstLastChildOverride);
|
|
11
|
+
var TablePreviewCell = styled.td(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: ", ";\n padding: ", " ", ";\n ", "\n"])), maxWidth, "var(--ds-space-050, 4px)", "var(--ds-space-100, 8px)", firstLastChildOverride);
|
|
12
|
+
var tableStyles = css({
|
|
13
|
+
background: "var(--ds-surface, #FFF)",
|
|
14
|
+
borderCollapse: 'separate',
|
|
15
|
+
borderSpacing: 0,
|
|
16
|
+
fontSize: "var(--ds-font-size-200, 16px)",
|
|
17
|
+
maxWidth: maxWidth
|
|
18
|
+
});
|
|
19
|
+
export var DragColumnPreview = function DragColumnPreview(_ref) {
|
|
20
|
+
var title = _ref.title,
|
|
21
|
+
rows = _ref.rows;
|
|
22
|
+
return jsx("table", {
|
|
23
|
+
css: tableStyles
|
|
24
|
+
}, jsx("thead", null, jsx("tr", null, jsx(TablePreviewHeading, null, title))), jsx("tbody", null, rows.map(function (data, i) {
|
|
25
|
+
return jsx("tr", {
|
|
26
|
+
key: i
|
|
27
|
+
}, jsx(TablePreviewCell, null, data));
|
|
28
|
+
}), jsx("tr", null, jsx(TablePreviewCell, null, "..."))));
|
|
29
|
+
};
|
|
@@ -2,16 +2,16 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
|
+
import ReactDOM from 'react-dom';
|
|
5
6
|
import invariant from 'tiny-invariant';
|
|
6
7
|
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
7
8
|
import { attachClosestEdge, extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
|
|
8
9
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-indicator/box-without-terminal';
|
|
9
10
|
import { draggable, dropTargetForElements, monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
10
11
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/util/combine';
|
|
12
|
+
import { offsetFromPointer } from '@atlaskit/pragmatic-drag-and-drop/util/offset-from-pointer';
|
|
13
|
+
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview';
|
|
11
14
|
import { TableHeading } from './styled';
|
|
12
|
-
var tableHeadingStyles = css({
|
|
13
|
-
cursor: 'grab'
|
|
14
|
-
});
|
|
15
15
|
var tableHeadingStatusStyles = {
|
|
16
16
|
idle: css({
|
|
17
17
|
':hover': {
|
|
@@ -31,7 +31,14 @@ var verticallyAlignedStyles = css({
|
|
|
31
31
|
var dragHandleStyles = css({
|
|
32
32
|
position: 'relative',
|
|
33
33
|
display: 'flex',
|
|
34
|
-
alignItems: 'center'
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
overflow: 'hidden',
|
|
36
|
+
width: 0,
|
|
37
|
+
transition: 'width 0.5s'
|
|
38
|
+
});
|
|
39
|
+
var dragHandleSpacerStyles = css({
|
|
40
|
+
width: 24,
|
|
41
|
+
transition: 'width 0.5s'
|
|
35
42
|
});
|
|
36
43
|
var dropTargetStyles = css({
|
|
37
44
|
position: 'absolute',
|
|
@@ -42,20 +49,25 @@ var dropTargetStyles = css({
|
|
|
42
49
|
var noPointerEventsStyles = css({
|
|
43
50
|
pointerEvents: 'none'
|
|
44
51
|
});
|
|
52
|
+
var idleState = {
|
|
53
|
+
type: 'idle'
|
|
54
|
+
};
|
|
55
|
+
var draggingState = {
|
|
56
|
+
type: 'dragging'
|
|
57
|
+
};
|
|
45
58
|
export var DraggableTableHeading = function DraggableTableHeading(_ref) {
|
|
46
59
|
var children = _ref.children,
|
|
47
60
|
id = _ref.id,
|
|
48
61
|
index = _ref.index,
|
|
49
62
|
tableId = _ref.tableId,
|
|
50
63
|
dndPreviewHeight = _ref.dndPreviewHeight,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
onDragPreviewEnd = _ref.onDragPreviewEnd;
|
|
64
|
+
dragPreview = _ref.dragPreview,
|
|
65
|
+
maxWidth = _ref.maxWidth;
|
|
54
66
|
var ref = useRef(null);
|
|
55
|
-
var _useState = useState(
|
|
67
|
+
var _useState = useState(idleState),
|
|
56
68
|
_useState2 = _slicedToArray(_useState, 2),
|
|
57
|
-
|
|
58
|
-
|
|
69
|
+
state = _useState2[0],
|
|
70
|
+
setState = _useState2[1];
|
|
59
71
|
var _useState3 = useState(false),
|
|
60
72
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
61
73
|
isDraggingAnyColumn = _useState4[0],
|
|
@@ -78,19 +90,38 @@ export var DraggableTableHeading = function DraggableTableHeading(_ref) {
|
|
|
78
90
|
tableId: tableId
|
|
79
91
|
};
|
|
80
92
|
},
|
|
81
|
-
onGenerateDragPreview: function onGenerateDragPreview() {
|
|
82
|
-
|
|
83
|
-
|
|
93
|
+
onGenerateDragPreview: function onGenerateDragPreview(_ref2) {
|
|
94
|
+
var nativeSetDragImage = _ref2.nativeSetDragImage;
|
|
95
|
+
setCustomNativeDragPreview({
|
|
96
|
+
getOffset: offsetFromPointer({
|
|
97
|
+
x: '18px',
|
|
98
|
+
y: '18px'
|
|
99
|
+
}),
|
|
100
|
+
render: function render(_ref3) {
|
|
101
|
+
var container = _ref3.container;
|
|
102
|
+
// Cause a `react` re-render to create your portal synchronously
|
|
103
|
+
setState({
|
|
104
|
+
type: 'preview',
|
|
105
|
+
container: container
|
|
106
|
+
});
|
|
107
|
+
// In our cleanup function: cause a `react` re-render to create remove your portal
|
|
108
|
+
// Note: you can also remove the portal in `onDragStart`,
|
|
109
|
+
// which is when the cleanup function is called
|
|
110
|
+
return function () {
|
|
111
|
+
return setState(draggingState);
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
nativeSetDragImage: nativeSetDragImage
|
|
115
|
+
});
|
|
84
116
|
},
|
|
85
117
|
onDragStart: function onDragStart() {
|
|
86
|
-
|
|
87
|
-
onDragPreviewEnd();
|
|
118
|
+
setState(draggingState);
|
|
88
119
|
},
|
|
89
120
|
onDrop: function onDrop() {
|
|
90
|
-
|
|
121
|
+
setState(idleState);
|
|
91
122
|
}
|
|
92
123
|
}));
|
|
93
|
-
}, [id, index,
|
|
124
|
+
}, [id, index, tableId]);
|
|
94
125
|
|
|
95
126
|
// Here we handle drop target, that in our case is absolutely positioned div that covers full width and height
|
|
96
127
|
// of this column (has height of whole table). It sits on top of everything, but has `pointerEvents: 'none'` by default
|
|
@@ -102,9 +133,9 @@ export var DraggableTableHeading = function DraggableTableHeading(_ref) {
|
|
|
102
133
|
getIsSticky: function getIsSticky() {
|
|
103
134
|
return true;
|
|
104
135
|
},
|
|
105
|
-
getData: function getData(
|
|
106
|
-
var input =
|
|
107
|
-
element =
|
|
136
|
+
getData: function getData(_ref4) {
|
|
137
|
+
var input = _ref4.input,
|
|
138
|
+
element = _ref4.element;
|
|
108
139
|
var data = {
|
|
109
140
|
id: id,
|
|
110
141
|
index: index
|
|
@@ -135,8 +166,8 @@ export var DraggableTableHeading = function DraggableTableHeading(_ref) {
|
|
|
135
166
|
// During dragging anywhere we want to remove `pointerEvents: 'none'` from all the drop targets
|
|
136
167
|
useEffect(function () {
|
|
137
168
|
return monitorForElements({
|
|
138
|
-
canMonitor: function canMonitor(
|
|
139
|
-
var source =
|
|
169
|
+
canMonitor: function canMonitor(_ref5) {
|
|
170
|
+
var source = _ref5.source;
|
|
140
171
|
return source.data.type === 'table-header' && source.data.tableId === tableId;
|
|
141
172
|
},
|
|
142
173
|
onDragStart: function onDragStart() {
|
|
@@ -152,7 +183,7 @@ export var DraggableTableHeading = function DraggableTableHeading(_ref) {
|
|
|
152
183
|
}, [tableId]);
|
|
153
184
|
return jsx(TableHeading, {
|
|
154
185
|
ref: ref,
|
|
155
|
-
css: [
|
|
186
|
+
css: [tableHeadingStatusStyles[state.type]],
|
|
156
187
|
"data-testid": "".concat(id, "-column-heading"),
|
|
157
188
|
style: {
|
|
158
189
|
maxWidth: maxWidth
|
|
@@ -169,9 +200,13 @@ export var DraggableTableHeading = function DraggableTableHeading(_ref) {
|
|
|
169
200
|
})), jsx("div", {
|
|
170
201
|
css: verticallyAlignedStyles
|
|
171
202
|
}, jsx("div", {
|
|
172
|
-
css: dragHandleStyles
|
|
203
|
+
css: dragHandleStyles,
|
|
204
|
+
className: "issue-like-table-drag-handle"
|
|
173
205
|
}, jsx(DragHandlerIcon, {
|
|
174
206
|
label: "".concat(id, "-drag-icon"),
|
|
175
207
|
size: "medium"
|
|
176
|
-
})), children
|
|
208
|
+
})), children, jsx("div", {
|
|
209
|
+
css: dragHandleSpacerStyles,
|
|
210
|
+
className: "issue-like-table-drag-handle-spacer"
|
|
211
|
+
})), state.type === 'preview' ? /*#__PURE__*/ReactDOM.createPortal(dragPreview, state.container) : null);
|
|
177
212
|
};
|
|
@@ -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
|
+
var tableBodyStyles = css({
|
|
9
|
+
borderBottom: 0
|
|
10
|
+
});
|
|
8
11
|
var baseColumns = [{
|
|
9
12
|
key: 'type',
|
|
10
13
|
width: 50
|
|
@@ -118,7 +121,9 @@ export default (function (_ref3) {
|
|
|
118
121
|
height: 13,
|
|
119
122
|
borderRadius: 8
|
|
120
123
|
}));
|
|
121
|
-
}))), jsx("tbody",
|
|
124
|
+
}))), jsx("tbody", {
|
|
125
|
+
css: tableBodyStyles
|
|
126
|
+
}, rows.map(function (row) {
|
|
122
127
|
return jsx("tr", {
|
|
123
128
|
key: row.id
|
|
124
129
|
}, columnsToRender.map(function (column) {
|
|
@@ -12,33 +12,50 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
12
12
|
import { css, jsx } from '@emotion/react';
|
|
13
13
|
import styled from '@emotion/styled';
|
|
14
14
|
import invariant from 'tiny-invariant';
|
|
15
|
+
import Heading from '@atlaskit/heading';
|
|
15
16
|
import { Skeleton } from '@atlaskit/linking-common';
|
|
16
17
|
import { extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge';
|
|
17
18
|
import { reorderWithEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge';
|
|
18
19
|
import { autoScroller } from '@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll';
|
|
19
20
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/adapter/element';
|
|
20
21
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/util/combine';
|
|
22
|
+
import { N40 } from '@atlaskit/theme/colors';
|
|
21
23
|
import { ColumnPicker } from './column-picker';
|
|
24
|
+
import { DragColumnPreview } from './drag-column-preview';
|
|
22
25
|
import { DraggableTableHeading } from './draggable-table-heading';
|
|
23
26
|
import TableEmptyState from './empty-state';
|
|
24
27
|
import { fallbackRenderType } from './render-type';
|
|
25
28
|
import { Table, TableHeading } from './styled';
|
|
26
29
|
import { useIsOnScreen } from './useIsOnScreen';
|
|
30
|
+
var tableSidePadding = "var(--ds-space-200, 16px)";
|
|
27
31
|
var tableHeadStyles = css({
|
|
28
32
|
background: "var(--ds-surface, #FFF)",
|
|
29
|
-
|
|
33
|
+
position: 'sticky',
|
|
34
|
+
top: 0,
|
|
35
|
+
zIndex: 10
|
|
30
36
|
});
|
|
31
|
-
var ColumnPickerHeader = styled.
|
|
37
|
+
var ColumnPickerHeader = styled.th(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 40px;\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 bellow */\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"])), tableSidePadding, "var(--ds-surface, #FFF)", "var(--ds-background-accent-gray-subtler, ".concat(N40, ")"), "var(--ds-surface, #FFF)", tableSidePadding);
|
|
32
38
|
var truncatedCellStyles = css({
|
|
33
39
|
overflow: 'hidden',
|
|
34
40
|
textOverflow: 'ellipsis',
|
|
35
41
|
whiteSpace: 'nowrap'
|
|
36
42
|
});
|
|
37
|
-
var
|
|
38
|
-
|
|
43
|
+
var scrollableContainerStyles = css({
|
|
44
|
+
overflow: 'auto',
|
|
45
|
+
padding: "0 ".concat(tableSidePadding, " 0 ").concat(tableSidePadding),
|
|
46
|
+
boxSizing: 'border-box'
|
|
39
47
|
});
|
|
40
|
-
var
|
|
41
|
-
|
|
48
|
+
var tableStyles = css({
|
|
49
|
+
// These styles are needed to prevent thead bottom border from scrolling away.
|
|
50
|
+
// This happens because it is sticky. https://stackoverflow.com/questions/50361698/border-style-do-not-work-with-sticky-position-element
|
|
51
|
+
borderCollapse: 'separate',
|
|
52
|
+
borderSpacing: 0
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// By default tbody and thead have border-bottom: 2px ...
|
|
56
|
+
// This removes it, because for header we handle it via `th` styling and footer supply bottom border
|
|
57
|
+
var noDefaultBorderStyles = css({
|
|
58
|
+
borderBottom: 0
|
|
42
59
|
});
|
|
43
60
|
function extractIndex(data) {
|
|
44
61
|
var index = data.index;
|
|
@@ -66,7 +83,6 @@ var BASE_WIDTH = 8;
|
|
|
66
83
|
function getColumnWidth(key, type) {
|
|
67
84
|
var keyBasedWidth = {
|
|
68
85
|
assignee: BASE_WIDTH * 22,
|
|
69
|
-
key: BASE_WIDTH * 10,
|
|
70
86
|
labels: BASE_WIDTH * 22,
|
|
71
87
|
priority: BASE_WIDTH * 8,
|
|
72
88
|
status: BASE_WIDTH * 18,
|
|
@@ -96,7 +112,8 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
|
|
|
96
112
|
visibleColumnKeys = _ref2.visibleColumnKeys,
|
|
97
113
|
onVisibleColumnKeysChange = _ref2.onVisibleColumnKeysChange,
|
|
98
114
|
status = _ref2.status,
|
|
99
|
-
hasNextPage = _ref2.hasNextPage
|
|
115
|
+
hasNextPage = _ref2.hasNextPage,
|
|
116
|
+
scrollableContainerHeight = _ref2.scrollableContainerHeight;
|
|
100
117
|
var tableId = useMemo(function () {
|
|
101
118
|
return Symbol('unique-id');
|
|
102
119
|
}, []);
|
|
@@ -106,20 +123,16 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
|
|
|
106
123
|
setLastRowElement = _useState2[1];
|
|
107
124
|
var _useState3 = useState(false),
|
|
108
125
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
var _useState5 = useState(false),
|
|
112
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
113
|
-
hasFullSchema = _useState6[0],
|
|
114
|
-
setHasFullSchema = _useState6[1];
|
|
126
|
+
hasFullSchema = _useState4[0],
|
|
127
|
+
setHasFullSchema = _useState4[1];
|
|
115
128
|
var isBottomOfTableVisibleRaw = useIsOnScreen(lastRowElement);
|
|
116
129
|
var containerRef = useRef(null);
|
|
117
|
-
var
|
|
130
|
+
var _useState5 = useState(function () {
|
|
118
131
|
return orderColumns(_toConsumableArray(columns), _toConsumableArray(visibleColumnKeys));
|
|
119
132
|
}),
|
|
120
|
-
|
|
121
|
-
orderedColumns =
|
|
122
|
-
setOrderedColumns =
|
|
133
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
134
|
+
orderedColumns = _useState6[0],
|
|
135
|
+
setOrderedColumns = _useState6[1];
|
|
123
136
|
useEffect(function () {
|
|
124
137
|
setOrderedColumns(orderColumns(_toConsumableArray(columns), _toConsumableArray(visibleColumnKeys)));
|
|
125
138
|
}, [columns, visibleColumnKeys]);
|
|
@@ -154,17 +167,19 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
|
|
|
154
167
|
})
|
|
155
168
|
};
|
|
156
169
|
}, [visibleSortedColumns]);
|
|
157
|
-
var headColumns =
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
170
|
+
var headColumns = useMemo(function () {
|
|
171
|
+
return visibleSortedColumns.map(function (_ref5) {
|
|
172
|
+
var key = _ref5.key,
|
|
173
|
+
title = _ref5.title,
|
|
174
|
+
type = _ref5.type;
|
|
175
|
+
return {
|
|
176
|
+
key: key,
|
|
177
|
+
content: title,
|
|
178
|
+
shouldTruncate: true,
|
|
179
|
+
maxWidth: getColumnWidth(key, type)
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
}, [visibleSortedColumns]);
|
|
168
183
|
useEffect(function () {
|
|
169
184
|
if (isBottomOfTableVisibleRaw && hasNextPage && status === 'resolved') {
|
|
170
185
|
void onNextPage({
|
|
@@ -172,41 +187,43 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
|
|
|
172
187
|
});
|
|
173
188
|
}
|
|
174
189
|
}, [isBottomOfTableVisibleRaw, status, hasNextPage, onNextPage]);
|
|
175
|
-
var
|
|
176
|
-
if (items.length > 0 && containerRef.current) {
|
|
177
|
-
var containerEl = containerRef.current;
|
|
178
|
-
invariant(containerEl);
|
|
179
|
-
dndPreviewHeight = containerEl.offsetHeight;
|
|
180
|
-
}
|
|
190
|
+
var hasData = items.length > 0;
|
|
181
191
|
|
|
182
192
|
// This variable contains initial Y mouse coordinate, so we can restrict
|
|
183
193
|
// autoScroller in X axis only
|
|
184
194
|
var initialAutoScrollerClientY = useRef();
|
|
185
195
|
useEffect(function () {
|
|
186
|
-
if (!onVisibleColumnKeysChange) {
|
|
196
|
+
if (!onVisibleColumnKeysChange || !hasData) {
|
|
187
197
|
return;
|
|
188
198
|
}
|
|
189
199
|
return combine(monitorForElements({
|
|
190
200
|
onDragStart: function onDragStart(_ref6) {
|
|
201
|
+
var _containerRef$current;
|
|
191
202
|
var location = _ref6.location;
|
|
192
203
|
initialAutoScrollerClientY.current = location.current.input.clientY;
|
|
193
204
|
autoScroller.start({
|
|
194
|
-
input: location.current.input,
|
|
205
|
+
input: _objectSpread(_objectSpread({}, location.current.input), {}, {
|
|
206
|
+
clientY:
|
|
207
|
+
// The goal is to have clientY the same and in the middle of the scrollable area
|
|
208
|
+
// Since clientY is taken from to of the viewport we need to plus that in order to get
|
|
209
|
+
// middle of the scrollable area in reference to the viewport
|
|
210
|
+
(initialAutoScrollerClientY.current || 0) + (((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetHeight) || 0) / 2
|
|
211
|
+
}),
|
|
195
212
|
behavior: 'container-only'
|
|
196
213
|
});
|
|
197
214
|
},
|
|
198
215
|
onDrag: function onDrag(_ref7) {
|
|
216
|
+
var _containerRef$current2;
|
|
199
217
|
var location = _ref7.location;
|
|
200
218
|
autoScroller.updateInput({
|
|
201
219
|
input: _objectSpread(_objectSpread({}, location.current.input), {}, {
|
|
202
|
-
clientY: initialAutoScrollerClientY.current || 0
|
|
220
|
+
clientY: (initialAutoScrollerClientY.current || 0) + (((_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.offsetHeight) || 0) / 2
|
|
203
221
|
})
|
|
204
222
|
});
|
|
205
223
|
},
|
|
206
224
|
onDrop: function onDrop(_ref8) {
|
|
207
225
|
var source = _ref8.source,
|
|
208
226
|
location = _ref8.location;
|
|
209
|
-
initialAutoScrollerClientY.current = null;
|
|
210
227
|
autoScroller.stop();
|
|
211
228
|
if (location.current.dropTargets.length === 0) {
|
|
212
229
|
return;
|
|
@@ -236,7 +253,7 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
|
|
|
236
253
|
}
|
|
237
254
|
}
|
|
238
255
|
}));
|
|
239
|
-
}, [visibleColumnKeys, onVisibleColumnKeysChange, tableId]);
|
|
256
|
+
}, [visibleColumnKeys, onVisibleColumnKeysChange, tableId, hasData]);
|
|
240
257
|
var tableRows = useMemo(function () {
|
|
241
258
|
return items.map(function (newRowData, rowIndex) {
|
|
242
259
|
return {
|
|
@@ -265,13 +282,9 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
|
|
|
265
282
|
};
|
|
266
283
|
});
|
|
267
284
|
}, [identityColumnKey, renderItem, items, visibleSortedColumns]);
|
|
268
|
-
var rows =
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}, [setIsDragPreview]);
|
|
272
|
-
var setIsDragPreviewOff = useCallback(function () {
|
|
273
|
-
return setIsDragPreview(false);
|
|
274
|
-
}, [setIsDragPreview]);
|
|
285
|
+
var rows = useMemo(function () {
|
|
286
|
+
return [].concat(_toConsumableArray(tableRows), _toConsumableArray(status === 'loading' ? [loadingRow] : []));
|
|
287
|
+
}, [loadingRow, status, tableRows]);
|
|
275
288
|
var onSelectedColumnKeysChange = useCallback(function (newSelectedColumnKeys) {
|
|
276
289
|
onVisibleColumnKeysChange === null || onVisibleColumnKeysChange === void 0 ? void 0 : onVisibleColumnKeysChange(newSelectedColumnKeys);
|
|
277
290
|
}, [onVisibleColumnKeysChange]);
|
|
@@ -304,33 +317,49 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
|
|
|
304
317
|
})), [hasFullSchema, onLoadDatasourceDetails]);
|
|
305
318
|
return jsx("div", {
|
|
306
319
|
ref: containerRef,
|
|
307
|
-
css:
|
|
320
|
+
css: scrollableContainerHeight ? scrollableContainerStyles : null,
|
|
321
|
+
style: scrollableContainerHeight ? {
|
|
322
|
+
maxHeight: "".concat(scrollableContainerHeight, "px")
|
|
323
|
+
} : undefined
|
|
308
324
|
}, jsx(Table, {
|
|
309
|
-
css:
|
|
325
|
+
css: tableStyles,
|
|
310
326
|
"data-testid": testId
|
|
311
327
|
}, jsx("thead", {
|
|
312
328
|
"data-testid": testId && "".concat(testId, "--head"),
|
|
313
|
-
css: tableHeadStyles
|
|
329
|
+
css: [noDefaultBorderStyles, tableHeadStyles]
|
|
314
330
|
}, jsx("tr", null, headColumns.map(function (_ref11, cellIndex) {
|
|
315
331
|
var key = _ref11.key,
|
|
316
332
|
content = _ref11.content,
|
|
317
333
|
maxWidth = _ref11.maxWidth;
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
334
|
+
if (onVisibleColumnKeysChange && hasData) {
|
|
335
|
+
var _containerRef$current3;
|
|
336
|
+
var previewRows = tableRows.map(function (_ref12) {
|
|
337
|
+
var cells = _ref12.cells;
|
|
338
|
+
var cell = cells.find(function (_ref13) {
|
|
339
|
+
var cellKey = _ref13.key;
|
|
340
|
+
return cellKey === key;
|
|
341
|
+
});
|
|
342
|
+
if (cell) {
|
|
343
|
+
return cell.content;
|
|
344
|
+
}
|
|
345
|
+
}).slice(0, 5);
|
|
346
|
+
var dragPreview = jsx(DragColumnPreview, {
|
|
347
|
+
title: jsx(Heading, {
|
|
348
|
+
level: "h400"
|
|
349
|
+
}, content),
|
|
350
|
+
rows: previewRows
|
|
351
|
+
});
|
|
324
352
|
return jsx(DraggableTableHeading, {
|
|
325
353
|
tableId: tableId,
|
|
326
354
|
key: key,
|
|
327
355
|
id: key,
|
|
328
356
|
index: cellIndex,
|
|
329
357
|
maxWidth: maxWidth,
|
|
330
|
-
dndPreviewHeight:
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
358
|
+
dndPreviewHeight: ((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.offsetHeight) || 0,
|
|
359
|
+
dragPreview: dragPreview
|
|
360
|
+
}, jsx(Heading, {
|
|
361
|
+
level: "h400"
|
|
362
|
+
}, content));
|
|
334
363
|
} else {
|
|
335
364
|
return jsx(TableHeading, {
|
|
336
365
|
key: key,
|
|
@@ -338,28 +367,30 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref2) {
|
|
|
338
367
|
style: {
|
|
339
368
|
maxWidth: maxWidth
|
|
340
369
|
}
|
|
341
|
-
}, jsx(
|
|
370
|
+
}, jsx(Heading, {
|
|
371
|
+
level: "h400"
|
|
372
|
+
}, content));
|
|
342
373
|
}
|
|
343
|
-
}), onVisibleColumnKeysChange && jsx(ColumnPickerHeader, null, jsx(ColumnPicker, {
|
|
374
|
+
}), onVisibleColumnKeysChange && hasData && jsx(ColumnPickerHeader, null, jsx(ColumnPicker, {
|
|
344
375
|
columns: hasFullSchema ? orderedColumns : [],
|
|
345
376
|
selectedColumnKeys: hasFullSchema ? visibleColumnKeys : [],
|
|
346
|
-
isDatasourceLoading: status === 'loading',
|
|
347
377
|
onSelectedColumnKeysChange: onSelectedColumnKeysChange,
|
|
348
378
|
onOpen: handlePickerOpen
|
|
349
379
|
})))), jsx("tbody", {
|
|
380
|
+
css: noDefaultBorderStyles,
|
|
350
381
|
"data-testid": testId && "".concat(testId, "--body")
|
|
351
|
-
}, rows.map(function (
|
|
352
|
-
var key =
|
|
353
|
-
cells =
|
|
354
|
-
ref =
|
|
382
|
+
}, rows.map(function (_ref14) {
|
|
383
|
+
var key = _ref14.key,
|
|
384
|
+
cells = _ref14.cells,
|
|
385
|
+
ref = _ref14.ref;
|
|
355
386
|
return jsx("tr", {
|
|
356
387
|
key: key,
|
|
357
388
|
"data-testid": testId && "".concat(testId, "--row-").concat(key),
|
|
358
389
|
ref: ref
|
|
359
|
-
}, cells.map(function (
|
|
360
|
-
var cellKey =
|
|
361
|
-
content =
|
|
362
|
-
maxWidth =
|
|
390
|
+
}, cells.map(function (_ref15, cellIndex) {
|
|
391
|
+
var cellKey = _ref15.key,
|
|
392
|
+
content = _ref15.content,
|
|
393
|
+
maxWidth = _ref15.maxWidth;
|
|
363
394
|
return jsx("td", {
|
|
364
395
|
key: cellKey,
|
|
365
396
|
"data-testid": testId && "".concat(testId, "--cell-").concat(cellIndex),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
var _templateObject, _templateObject2, _templateObject3;
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
|
+
import { N40 } from '@atlaskit/theme/colors';
|
|
4
5
|
export var Table = styled.table(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 100%;\n"])));
|
|
5
|
-
export var TableHeading = styled.th(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n padding-block: ", ";\n line-height: ", ";\n"])), "var(--ds-space-100, 8px)", "var(--ds-font-lineHeight-300, 24px)");
|
|
6
|
+
export var TableHeading = styled.th(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n cursor: grab;\n position: relative;\n padding-block: ", ";\n line-height: ", ";\n border-bottom: 2px solid ", ";\n .ProseMirror & h5,\n & h5 {\n margin-top: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n line-height: 24px; /* Is needed to keep overall height consistent with or without drag handle icon present */\n }\n\n &:hover .issue-like-table-drag-handle {\n width: 24px;\n }\n &:hover .issue-like-table-drag-handle-spacer {\n width: 0px;\n }\n"])), "var(--ds-space-100, 8px)", "var(--ds-font-lineHeight-300, 24px)", "var(--ds-background-accent-gray-subtler, ".concat(N40, ")"));
|
|
6
7
|
export var EmptyStateTableHeading = styled(TableHeading)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n &:first-child {\n padding-left: ", ";\n }\n"])), "var(--ds-space-100, 8px)");
|