@atlaskit/link-datasource 2.3.0 → 2.3.2
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 +25 -0
- package/dist/cjs/hooks/useDatasourceTableState.js +26 -46
- package/dist/cjs/ui/issue-like-table/draggable-table-heading.js +12 -5
- package/dist/cjs/ui/issue-like-table/index.js +86 -48
- package/dist/cjs/ui/issue-like-table/render-type/richtext/index.js +2 -3
- package/dist/cjs/ui/issue-like-table/styled.js +11 -0
- package/dist/cjs/ui/issue-like-table/utils.js +13 -6
- package/dist/cjs/ui/jira-issues-modal/modal/index.js +2 -2
- package/dist/es2019/hooks/useDatasourceTableState.js +25 -40
- package/dist/es2019/ui/issue-like-table/draggable-table-heading.js +12 -5
- package/dist/es2019/ui/issue-like-table/index.js +50 -17
- package/dist/es2019/ui/issue-like-table/render-type/richtext/index.js +2 -3
- package/dist/es2019/ui/issue-like-table/styled.js +11 -0
- package/dist/es2019/ui/issue-like-table/utils.js +14 -5
- package/dist/es2019/ui/jira-issues-modal/modal/index.js +2 -2
- package/dist/esm/hooks/useDatasourceTableState.js +26 -46
- package/dist/esm/ui/issue-like-table/draggable-table-heading.js +12 -5
- package/dist/esm/ui/issue-like-table/index.js +86 -48
- package/dist/esm/ui/issue-like-table/render-type/richtext/index.js +2 -3
- package/dist/esm/ui/issue-like-table/styled.js +11 -0
- package/dist/esm/ui/issue-like-table/utils.js +13 -6
- package/dist/esm/ui/jira-issues-modal/modal/index.js +2 -2
- package/dist/types/common/utils/adf.d.ts +1 -1
- package/dist/types/hooks/useDatasourceTableState.d.ts +1 -1
- package/dist/types/ui/datasource-table-view/datasourceTableView.d.ts +0 -1
- package/dist/types/ui/datasource-table-view/types.d.ts +1 -2
- package/dist/types/ui/issue-like-table/draggable-table-heading.d.ts +2 -2
- package/dist/types/ui/issue-like-table/index.d.ts +1 -1
- package/dist/types/ui/issue-like-table/utils.d.ts +2 -2
- package/dist/types-ts4.5/common/utils/adf.d.ts +1 -1
- package/dist/types-ts4.5/hooks/useDatasourceTableState.d.ts +1 -1
- package/dist/types-ts4.5/ui/datasource-table-view/datasourceTableView.d.ts +0 -1
- package/dist/types-ts4.5/ui/datasource-table-view/types.d.ts +1 -2
- package/dist/types-ts4.5/ui/issue-like-table/draggable-table-heading.d.ts +2 -2
- package/dist/types-ts4.5/ui/issue-like-table/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/issue-like-table/utils.d.ts +2 -2
- package/package.json +14 -14
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import isEqual from 'lodash/isEqual';
|
|
3
3
|
import { DEFAULT_GET_DATASOURCE_DATA_PAGE_SIZE, useDatasourceClientExtension } from '@atlaskit/link-client-extension';
|
|
4
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { useDatasourceAnalyticsEvents } from '../analytics';
|
|
6
5
|
import useErrorLogger from './useErrorLogger';
|
|
7
6
|
export const useDatasourceTableState = ({
|
|
@@ -115,17 +114,15 @@ export const useDatasourceTableState = ({
|
|
|
115
114
|
}, [columns, defaultVisibleColumnKeys, lastRequestedFieldKeys]);
|
|
116
115
|
const onNextPage = useCallback(async (requestInfo = {}) => {
|
|
117
116
|
let currentAbortController;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
currentAbortController = abortController.current;
|
|
128
|
-
}
|
|
117
|
+
/**
|
|
118
|
+
* Abort whichever request was made before this one.
|
|
119
|
+
*/
|
|
120
|
+
abortController.current.abort();
|
|
121
|
+
/**
|
|
122
|
+
* Setup new abort controller for this request.
|
|
123
|
+
*/
|
|
124
|
+
abortController.current = new AbortController();
|
|
125
|
+
currentAbortController = abortController.current;
|
|
129
126
|
if (!parameters) {
|
|
130
127
|
return;
|
|
131
128
|
}
|
|
@@ -144,6 +141,7 @@ export const useDatasourceTableState = ({
|
|
|
144
141
|
};
|
|
145
142
|
setStatus('loading');
|
|
146
143
|
try {
|
|
144
|
+
var _currentAbortControll;
|
|
147
145
|
const {
|
|
148
146
|
meta: {
|
|
149
147
|
access,
|
|
@@ -159,14 +157,12 @@ export const useDatasourceTableState = ({
|
|
|
159
157
|
schema
|
|
160
158
|
}
|
|
161
159
|
} = await getDatasourceData(datasourceId, datasourceDataRequest, shouldForceRequest);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
throw new Error('Aborted');
|
|
169
|
-
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Let the response finish and store in cache, but throw error if signal is aborted
|
|
163
|
+
*/
|
|
164
|
+
if ((_currentAbortControll = currentAbortController) !== null && _currentAbortControll !== void 0 && _currentAbortControll.signal.aborted) {
|
|
165
|
+
throw new Error('Aborted');
|
|
170
166
|
}
|
|
171
167
|
setExtensionKey(extensionKey);
|
|
172
168
|
setProviderName(providerName);
|
|
@@ -179,13 +175,6 @@ export const useDatasourceTableState = ({
|
|
|
179
175
|
setTotalCount(totalCount);
|
|
180
176
|
setNextCursor(nextPageCursor);
|
|
181
177
|
setResponseItems(currentResponseItems => {
|
|
182
|
-
if (!getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
|
|
183
|
-
const hasIdenticalResponseItems = isEqual(currentResponseItems, items);
|
|
184
|
-
if (hasIdenticalResponseItems || shouldRequestFirstPage) {
|
|
185
|
-
return items;
|
|
186
|
-
}
|
|
187
|
-
return [...currentResponseItems, ...items];
|
|
188
|
-
}
|
|
189
178
|
if (shouldRequestFirstPage) {
|
|
190
179
|
return items;
|
|
191
180
|
}
|
|
@@ -210,16 +199,14 @@ export const useDatasourceTableState = ({
|
|
|
210
199
|
}
|
|
211
200
|
setStatus('resolved');
|
|
212
201
|
} catch (e) {
|
|
213
|
-
if (
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
202
|
+
if (e.message === 'Aborted') {
|
|
203
|
+
/**
|
|
204
|
+
* If the request was aborted, we don't want to change the status of the table
|
|
205
|
+
* as we are already loading the next request attempt
|
|
206
|
+
*
|
|
207
|
+
* Is not an exceptional state, do not need to captureError
|
|
208
|
+
*/
|
|
209
|
+
return;
|
|
223
210
|
}
|
|
224
211
|
captureError('onNextPage', e);
|
|
225
212
|
if (e instanceof Response && e.status === 401) {
|
|
@@ -288,9 +275,7 @@ export const useDatasourceTableState = ({
|
|
|
288
275
|
}
|
|
289
276
|
}, [fieldKeys, lastRequestedFieldKeys, responseItems, reset, onNextPage]);
|
|
290
277
|
useEffect(() => {
|
|
291
|
-
|
|
292
|
-
return () => abortController.current.abort();
|
|
293
|
-
}
|
|
278
|
+
return () => abortController.current.abort();
|
|
294
279
|
}, []);
|
|
295
280
|
return {
|
|
296
281
|
status,
|
|
@@ -100,6 +100,11 @@ export const DraggableTableHeading = ({
|
|
|
100
100
|
const [isDraggingAnyColumn, setIsDraggingAnyColumn] = useState(false);
|
|
101
101
|
const [closestEdge, setClosestEdge] = useState(null);
|
|
102
102
|
const dropTargetRef = useRef(null);
|
|
103
|
+
/**
|
|
104
|
+
* When width is not set (or callback is not set) we assume not resizing is needed.
|
|
105
|
+
* In our case width won't be set for last cell when table container is bigger than sum of all columns
|
|
106
|
+
*/
|
|
107
|
+
const resizeIsEnabled = !!onWidthChange && !!width;
|
|
103
108
|
useEffect(() => {
|
|
104
109
|
const cell = mainHeaderCellRef.current;
|
|
105
110
|
invariant(cell);
|
|
@@ -209,7 +214,7 @@ export const DraggableTableHeading = ({
|
|
|
209
214
|
|
|
210
215
|
// Handling column resizing
|
|
211
216
|
useEffect(() => {
|
|
212
|
-
if (!
|
|
217
|
+
if (!resizeIsEnabled) {
|
|
213
218
|
return;
|
|
214
219
|
}
|
|
215
220
|
const resizeHandle = columnResizeHandleRef.current;
|
|
@@ -269,10 +274,12 @@ export const DraggableTableHeading = ({
|
|
|
269
274
|
}
|
|
270
275
|
}
|
|
271
276
|
});
|
|
272
|
-
}, [id, index, onWidthChange, state, tableId, width]);
|
|
277
|
+
}, [id, index, onWidthChange, resizeIsEnabled, state, tableId, width]);
|
|
273
278
|
const [buttonHovered, setButtonHovered] = useState(false);
|
|
274
279
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
|
275
|
-
|
|
280
|
+
// Width is not set when it is a last cell in a wide table.
|
|
281
|
+
// We make assumption thus that there is enough width for chevron.
|
|
282
|
+
const isWideEnoughToHaveChevron = !width || width > 76;
|
|
276
283
|
const shouldShowTriggerIcon = (buttonHovered || isDropdownOpen) && isWideEnoughToHaveChevron;
|
|
277
284
|
const triggerIcon = useMemo(() => shouldShowTriggerIcon ? isDropdownOpen ? ChevronUp : ChevronDown : isWideEnoughToHaveChevron ? GlyphPlaceholder : undefined, [shouldShowTriggerIcon, isDropdownOpen, isWideEnoughToHaveChevron]);
|
|
278
285
|
const getTriggerButton = useCallback(({
|
|
@@ -300,11 +307,11 @@ export const DraggableTableHeading = ({
|
|
|
300
307
|
style: {
|
|
301
308
|
cursor: 'grab',
|
|
302
309
|
...getWidthCss({
|
|
303
|
-
shouldUseWidth:
|
|
310
|
+
shouldUseWidth: resizeIsEnabled,
|
|
304
311
|
width
|
|
305
312
|
})
|
|
306
313
|
}
|
|
307
|
-
},
|
|
314
|
+
}, resizeIsEnabled ? jsx("div", {
|
|
308
315
|
ref: columnResizeHandleRef,
|
|
309
316
|
css: [resizerStyles, state.type === 'resizing' && resizingStyles],
|
|
310
317
|
style: {
|
|
@@ -3,6 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
5
|
import styled from '@emotion/styled';
|
|
6
|
+
import debounce from 'lodash/debounce';
|
|
6
7
|
import { useIntl } from 'react-intl-next';
|
|
7
8
|
import invariant from 'tiny-invariant';
|
|
8
9
|
import { Skeleton } from '@atlaskit/linking-common';
|
|
@@ -14,6 +15,7 @@ import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/ad
|
|
|
14
15
|
import { N40 } from '@atlaskit/theme/colors';
|
|
15
16
|
import { fontFallback } from '@atlaskit/theme/typography';
|
|
16
17
|
import Tooltip from '@atlaskit/tooltip';
|
|
18
|
+
import { WidthObserver } from '@atlaskit/width-detector';
|
|
17
19
|
import { startUfoExperience, succeedUfoExperience } from '../../analytics/ufoExperiences';
|
|
18
20
|
import { stickyTableHeadersIndex } from '../../common/zindex';
|
|
19
21
|
import { ColumnPicker } from './column-picker';
|
|
@@ -36,23 +38,24 @@ const truncateTextStyles = css({
|
|
|
36
38
|
textOverflow: 'ellipsis',
|
|
37
39
|
whiteSpace: 'nowrap'
|
|
38
40
|
});
|
|
41
|
+
const columnPickerWidth = 80;
|
|
39
42
|
const ColumnPickerHeader = styled.th({
|
|
40
|
-
[`${withTablePluginHeaderPrefix()}`]: {
|
|
41
|
-
boxSizing: '
|
|
43
|
+
[`${withTablePluginHeaderPrefix('&:last-of-type')}`]: {
|
|
44
|
+
boxSizing: 'border-box',
|
|
42
45
|
border: 0,
|
|
43
|
-
width:
|
|
46
|
+
width: `${columnPickerWidth}px`,
|
|
44
47
|
zIndex: 10,
|
|
45
48
|
position: 'sticky',
|
|
46
49
|
right: `calc(-1 * ${tableSidePadding})`,
|
|
47
50
|
backgroundColor: "var(--ds-elevation-surface-current, #FFF)",
|
|
51
|
+
/* It is required to have solid (not half-transparent) color because of this gradient business below */
|
|
48
52
|
borderBottom: `2px solid ${`var(--ds-border, ${N40})`}`,
|
|
49
|
-
paddingRight:
|
|
53
|
+
paddingRight: tableSidePadding,
|
|
50
54
|
background: `linear-gradient( 90deg, rgba(255, 255, 255, 0) 0%, ${"var(--ds-elevation-surface-current, #FFF)"} 10% )`,
|
|
55
|
+
/* Keeps dropdown button in the middle */
|
|
51
56
|
verticalAlign: 'middle',
|
|
57
|
+
/* In case when TH itself is bigger we want to keep picker at the right side */
|
|
52
58
|
textAlign: 'right'
|
|
53
|
-
},
|
|
54
|
-
[`${withTablePluginHeaderPrefix('&:last-of-type')}`]: {
|
|
55
|
-
paddingRight: tableSidePadding
|
|
56
59
|
}
|
|
57
60
|
});
|
|
58
61
|
const truncateStyles = css({
|
|
@@ -61,6 +64,7 @@ const truncateStyles = css({
|
|
|
61
64
|
});
|
|
62
65
|
const TableCell = styled.td({
|
|
63
66
|
[`${withTablePluginBodyPrefix()}`]: {
|
|
67
|
+
/* First section here is to override things editor table plugin css defines */
|
|
64
68
|
font: fieldTextFontSize,
|
|
65
69
|
padding: `${"var(--ds-space-050, 4px)"} ${"var(--ds-space-100, 8px)"}`,
|
|
66
70
|
border: 0,
|
|
@@ -87,7 +91,8 @@ const TableCell = styled.td({
|
|
|
87
91
|
const tableContainerStyles = css({
|
|
88
92
|
borderRadius: 'inherit',
|
|
89
93
|
borderBottomLeftRadius: 0,
|
|
90
|
-
borderBottomRightRadius: 0
|
|
94
|
+
borderBottomRightRadius: 0,
|
|
95
|
+
position: 'relative'
|
|
91
96
|
});
|
|
92
97
|
|
|
93
98
|
/**
|
|
@@ -220,7 +225,10 @@ const tableStyles = css({
|
|
|
220
225
|
// These styles are needed to prevent thead bottom border from scrolling away.
|
|
221
226
|
// This happens because it is sticky. https://stackoverflow.com/questions/50361698/border-style-do-not-work-with-sticky-position-element
|
|
222
227
|
borderCollapse: 'separate',
|
|
223
|
-
borderSpacing: 0
|
|
228
|
+
borderSpacing: 0,
|
|
229
|
+
// There is a strange table:first-of-type rule that sets margin-top to 0 coming from container,
|
|
230
|
+
// but because our table is now not the first child (there is an empty div to measure width) we need to set it manually.
|
|
231
|
+
margin: 0
|
|
224
232
|
});
|
|
225
233
|
|
|
226
234
|
// By default tbody and thead have border-bottom: 2px ...
|
|
@@ -317,6 +325,18 @@ export const IssueLikeDataTableView = ({
|
|
|
317
325
|
const isBottomOfTableVisibleRaw = useIsOnScreen(lastRowElement);
|
|
318
326
|
const containerRef = useRef(null);
|
|
319
327
|
const [orderedColumns, setOrderedColumns] = useState(() => getOrderedColumns([...columns], [...visibleColumnKeys]));
|
|
328
|
+
|
|
329
|
+
// Table container width is used to know if sum of all column widths is bigger of container or not.
|
|
330
|
+
// When sum of all columns is less than container size we make last column stretchable (width: undefined)
|
|
331
|
+
const [tableContainerWidth, setTableContainerWidth] = useState();
|
|
332
|
+
useEffect(() => {
|
|
333
|
+
const {
|
|
334
|
+
current
|
|
335
|
+
} = containerRef;
|
|
336
|
+
if (containerRef && current) {
|
|
337
|
+
setTableContainerWidth(current.getBoundingClientRect().width);
|
|
338
|
+
}
|
|
339
|
+
}, [containerRef]);
|
|
320
340
|
useEffect(() => {
|
|
321
341
|
if (!hasFullSchema) {
|
|
322
342
|
setOrderedColumns(getOrderedColumns([...columns], [...visibleColumnKeys]));
|
|
@@ -338,16 +358,27 @@ export const IssueLikeDataTableView = ({
|
|
|
338
358
|
// or some other combination.
|
|
339
359
|
|
|
340
360
|
const identityColumnKey = 'id';
|
|
341
|
-
const
|
|
361
|
+
const columnsWidthsSum = useMemo(() => visibleSortedColumns.map(({
|
|
362
|
+
key,
|
|
363
|
+
type
|
|
364
|
+
}) => (columnCustomSizes === null || columnCustomSizes === void 0 ? void 0 : columnCustomSizes[key]) || getDefaultColumnWidth(key, type)).reduce((sum, width) => width + sum, 0) + (onVisibleColumnKeysChange ? columnPickerWidth : 0), [columnCustomSizes, onVisibleColumnKeysChange, visibleSortedColumns]);
|
|
365
|
+
const shouldUseWidth = !!(onColumnResize || columnCustomSizes);
|
|
366
|
+
const getColumnWidth = useCallback((key, type, isLastCell) => {
|
|
367
|
+
if (isLastCell && shouldUseWidth && (!tableContainerWidth || tableContainerWidth > columnsWidthsSum)) {
|
|
368
|
+
return undefined;
|
|
369
|
+
} else {
|
|
370
|
+
return (columnCustomSizes === null || columnCustomSizes === void 0 ? void 0 : columnCustomSizes[key]) || getDefaultColumnWidth(key, type);
|
|
371
|
+
}
|
|
372
|
+
}, [columnCustomSizes, columnsWidthsSum, shouldUseWidth, tableContainerWidth]);
|
|
342
373
|
const headerColumns = useMemo(() => visibleSortedColumns.map(({
|
|
343
374
|
key,
|
|
344
375
|
title,
|
|
345
376
|
type
|
|
346
|
-
}) => ({
|
|
377
|
+
}, index) => ({
|
|
347
378
|
key,
|
|
348
379
|
content: title,
|
|
349
380
|
shouldTruncate: true,
|
|
350
|
-
width: getColumnWidth(key, type)
|
|
381
|
+
width: getColumnWidth(key, type, index === visibleSortedColumns.length - 1)
|
|
351
382
|
})), [getColumnWidth, visibleSortedColumns]);
|
|
352
383
|
const loadingRow = useMemo(() => ({
|
|
353
384
|
key: 'loading',
|
|
@@ -450,7 +481,7 @@ export const IssueLikeDataTableView = ({
|
|
|
450
481
|
cells: visibleSortedColumns.map(({
|
|
451
482
|
key,
|
|
452
483
|
type
|
|
453
|
-
}) => {
|
|
484
|
+
}, cellIndex) => {
|
|
454
485
|
var _newRowData$key;
|
|
455
486
|
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
456
487
|
const value = (_newRowData$key = newRowData[key]) === null || _newRowData$key === void 0 ? void 0 : _newRowData$key.data;
|
|
@@ -471,7 +502,7 @@ export const IssueLikeDataTableView = ({
|
|
|
471
502
|
return {
|
|
472
503
|
key,
|
|
473
504
|
content: contentComponent,
|
|
474
|
-
width: getColumnWidth(key, type)
|
|
505
|
+
width: getColumnWidth(key, type, cellIndex === visibleSortedColumns.length - 1)
|
|
475
506
|
};
|
|
476
507
|
}),
|
|
477
508
|
ref: rowIndex === items.length - 1 ? el => setLastRowElement(el) : undefined
|
|
@@ -517,7 +548,6 @@ export const IssueLikeDataTableView = ({
|
|
|
517
548
|
setHasFullSchema(false);
|
|
518
549
|
}
|
|
519
550
|
}, [parentContainerRenderInstanceId, extensionKey, hasFullSchema, onLoadDatasourceDetails]);
|
|
520
|
-
const shouldUseWidth = !!(onColumnResize || columnCustomSizes);
|
|
521
551
|
const isEditable = onVisibleColumnKeysChange && hasData;
|
|
522
552
|
return jsx("div", {
|
|
523
553
|
/* There is required contentEditable={true} in editor-card-plugin
|
|
@@ -529,8 +559,11 @@ export const IssueLikeDataTableView = ({
|
|
|
529
559
|
css: [tableContainerStyles, scrollableContainerHeight && scrollableContainerStyles],
|
|
530
560
|
style: scrollableContainerHeight ? {
|
|
531
561
|
maxHeight: `${scrollableContainerHeight}px`
|
|
532
|
-
} : undefined
|
|
533
|
-
|
|
562
|
+
} : undefined,
|
|
563
|
+
"data-testid": 'issue-like-table-container'
|
|
564
|
+
}, jsx(WidthObserver, {
|
|
565
|
+
setWidth: debounce(setTableContainerWidth, 100)
|
|
566
|
+
}), jsx(Table, {
|
|
534
567
|
css: tableStyles,
|
|
535
568
|
"data-testid": testId,
|
|
536
569
|
style: shouldUseWidth ? {
|
|
@@ -4,8 +4,7 @@ import { css, jsx } from '@emotion/react';
|
|
|
4
4
|
import { defaultSchema } from '@atlaskit/adf-schema/schema-default';
|
|
5
5
|
import { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
const rootStyles = css({
|
|
7
|
-
position: 'relative'
|
|
8
|
-
display: 'block'
|
|
7
|
+
position: 'relative'
|
|
9
8
|
});
|
|
10
9
|
const smartLinkNodeToUrl = node => {
|
|
11
10
|
var _node$attrs$url;
|
|
@@ -45,7 +44,7 @@ const RichTextType = ({
|
|
|
45
44
|
}) => {
|
|
46
45
|
const adfPlainText = useMemo(() => parseRichText(value), [value]);
|
|
47
46
|
if (adfPlainText) {
|
|
48
|
-
return jsx("
|
|
47
|
+
return jsx("span", {
|
|
49
48
|
css: rootStyles,
|
|
50
49
|
"data-testid": "richtext-plaintext"
|
|
51
50
|
}, adfPlainText);
|
|
@@ -26,11 +26,19 @@ export const TableHeading = styled.th({
|
|
|
26
26
|
[`${withTablePluginHeaderPrefix()}`]: {
|
|
27
27
|
border: 0,
|
|
28
28
|
position: 'relative',
|
|
29
|
+
/* This makes resizing work with out jumping due to padding + changes overall width for same default values. */
|
|
29
30
|
boxSizing: 'border-box',
|
|
30
31
|
lineHeight: lineHeight,
|
|
31
32
|
padding: `${verticalPadding} ${"var(--ds-space-050, 4px)"}`,
|
|
32
33
|
borderRight: `0.5px solid ${`var(--ds-border, ${N40})`}`,
|
|
33
34
|
borderBottom: `2px solid ${`var(--ds-border, ${N40})`}`,
|
|
35
|
+
/*
|
|
36
|
+
lineHeight * 2 -> Max height of two lined header
|
|
37
|
+
verticalPadding * 2 -> padding for this component itself
|
|
38
|
+
verticalPadding * 2 -> padding inside span (--container)
|
|
39
|
+
2px -> Bottom border
|
|
40
|
+
Last two terms are needed because of border-box box sizing.
|
|
41
|
+
*/
|
|
34
42
|
height: `calc(${lineHeight} * 2 + ${verticalPadding} * 4 + 2px)`,
|
|
35
43
|
verticalAlign: 'bottom',
|
|
36
44
|
backgroundColor: "var(--ds-elevation-surface-current, #FFF)"
|
|
@@ -46,6 +54,9 @@ export const TableHeading = styled.th({
|
|
|
46
54
|
},
|
|
47
55
|
"& [data-testid='datasource-header-content--container']": {
|
|
48
56
|
width: '100%',
|
|
57
|
+
/* With Button now being a parent for this component it adds its lineHeight value and spoils
|
|
58
|
+
`height` calculation above. */
|
|
59
|
+
lineHeight: lineHeight,
|
|
49
60
|
padding: `${verticalPadding} ${"var(--ds-space-050, 4px)"}`,
|
|
50
61
|
display: '-webkit-box',
|
|
51
62
|
WebkitLineClamp: 2,
|
|
@@ -8,15 +8,24 @@ export const COLUMN_MIN_WIDTH = COLUMN_BASE_WIDTH * 3;
|
|
|
8
8
|
* or rather default width that should be treated as a maximum width. When table inserted initially
|
|
9
9
|
* and no user custom width defined we set this value to `false`. As soon as user changes any of the
|
|
10
10
|
* column widths we treat all width as custom hardcoded widths.
|
|
11
|
-
* @param width
|
|
11
|
+
* @param width Sometimes set to undefined for last column to make it occupy remainder of the table width
|
|
12
12
|
*/
|
|
13
13
|
export const getWidthCss = ({
|
|
14
14
|
shouldUseWidth,
|
|
15
15
|
width
|
|
16
|
-
}) =>
|
|
17
|
-
width
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
}) => {
|
|
17
|
+
if (!width) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
if (shouldUseWidth) {
|
|
21
|
+
return {
|
|
22
|
+
width
|
|
23
|
+
};
|
|
24
|
+
} else {
|
|
25
|
+
return {
|
|
26
|
+
maxWidth: width
|
|
27
|
+
};
|
|
28
|
+
}
|
|
20
29
|
};
|
|
21
30
|
|
|
22
31
|
/**
|
|
@@ -253,7 +253,7 @@ export const PlainJiraIssuesConfigModal = props => {
|
|
|
253
253
|
// During insertion, we want the JQL of the datasource to be whatever is in the search bar,
|
|
254
254
|
// even if the user didn't previously click search
|
|
255
255
|
const upToDateJql = searchBarJql !== null && searchBarJql !== void 0 ? searchBarJql : jql;
|
|
256
|
-
const upToDateJqlUrl = selectedJiraSite && jql && `${selectedJiraSite.url}/issues/?jql=${
|
|
256
|
+
const upToDateJqlUrl = selectedJiraSite && jql && `${selectedJiraSite.url}/issues/?jql=${encodeURIComponent(upToDateJql)}`;
|
|
257
257
|
const filterSelectionCount = availableBasicFilterTypes.reduce((current, filter) => {
|
|
258
258
|
var _basicFilterSelection;
|
|
259
259
|
return {
|
|
@@ -384,7 +384,7 @@ export const PlainJiraIssuesConfigModal = props => {
|
|
|
384
384
|
if (responseItems.length === 1 && retrieveUrlForSmartCardRender()) {
|
|
385
385
|
url = retrieveUrlForSmartCardRender();
|
|
386
386
|
} else {
|
|
387
|
-
url = `${selectedJiraSiteUrl}/issues/?jql=${
|
|
387
|
+
url = `${selectedJiraSiteUrl}/issues/?jql=${encodeURIComponent(jql)}`;
|
|
388
388
|
}
|
|
389
389
|
return jsx(SmartLink, {
|
|
390
390
|
url: url
|
|
@@ -5,7 +5,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
5
5
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
6
|
import isEqual from 'lodash/isEqual';
|
|
7
7
|
import { DEFAULT_GET_DATASOURCE_DATA_PAGE_SIZE, useDatasourceClientExtension } from '@atlaskit/link-client-extension';
|
|
8
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { useDatasourceAnalyticsEvents } from '../analytics';
|
|
10
9
|
import useErrorLogger from './useErrorLogger';
|
|
11
10
|
export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
@@ -196,6 +195,7 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
196
195
|
shouldForceRequest,
|
|
197
196
|
isFullSchemaLoaded,
|
|
198
197
|
datasourceDataRequest,
|
|
198
|
+
_currentAbortControll,
|
|
199
199
|
_yield$getDatasourceD3,
|
|
200
200
|
_yield$getDatasourceD4,
|
|
201
201
|
access,
|
|
@@ -208,7 +208,6 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
208
208
|
nextPageCursor,
|
|
209
209
|
_totalCount,
|
|
210
210
|
schema,
|
|
211
|
-
_currentAbortControll,
|
|
212
211
|
isUserLoadingNextPage,
|
|
213
212
|
currentLoadedItemCount,
|
|
214
213
|
newlyLoadedItemCount,
|
|
@@ -217,23 +216,21 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
217
216
|
while (1) switch (_context2.prev = _context2.next) {
|
|
218
217
|
case 0:
|
|
219
218
|
requestInfo = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
currentAbortController = abortController.current;
|
|
230
|
-
}
|
|
219
|
+
/**
|
|
220
|
+
* Abort whichever request was made before this one.
|
|
221
|
+
*/
|
|
222
|
+
abortController.current.abort();
|
|
223
|
+
/**
|
|
224
|
+
* Setup new abort controller for this request.
|
|
225
|
+
*/
|
|
226
|
+
abortController.current = new AbortController();
|
|
227
|
+
currentAbortController = abortController.current;
|
|
231
228
|
if (parameters) {
|
|
232
|
-
_context2.next =
|
|
229
|
+
_context2.next = 6;
|
|
233
230
|
break;
|
|
234
231
|
}
|
|
235
232
|
return _context2.abrupt("return");
|
|
236
|
-
case
|
|
233
|
+
case 6:
|
|
237
234
|
_requestInfo$isSchema = requestInfo.isSchemaFromData, isSchemaFromData = _requestInfo$isSchema === void 0 ? true : _requestInfo$isSchema, shouldRequestFirstPage = requestInfo.shouldRequestFirstPage, _requestInfo$shouldFo = requestInfo.shouldForceRequest, shouldForceRequest = _requestInfo$shouldFo === void 0 ? false : _requestInfo$shouldFo;
|
|
238
235
|
isFullSchemaLoaded = fullSchema.properties.length > 0;
|
|
239
236
|
datasourceDataRequest = {
|
|
@@ -244,10 +241,10 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
244
241
|
includeSchema: isFullSchemaLoaded ? false : isSchemaFromData
|
|
245
242
|
};
|
|
246
243
|
setStatus('loading');
|
|
247
|
-
_context2.prev =
|
|
248
|
-
_context2.next =
|
|
244
|
+
_context2.prev = 10;
|
|
245
|
+
_context2.next = 13;
|
|
249
246
|
return getDatasourceData(datasourceId, datasourceDataRequest, shouldForceRequest);
|
|
250
|
-
case
|
|
247
|
+
case 13:
|
|
251
248
|
_yield$getDatasourceD3 = _context2.sent;
|
|
252
249
|
_yield$getDatasourceD4 = _yield$getDatasourceD3.meta;
|
|
253
250
|
access = _yield$getDatasourceD4.access;
|
|
@@ -260,37 +257,26 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
260
257
|
nextPageCursor = _yield$getDatasourceD5.nextPageCursor;
|
|
261
258
|
_totalCount = _yield$getDatasourceD5.totalCount;
|
|
262
259
|
schema = _yield$getDatasourceD5.schema;
|
|
263
|
-
if (!getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
|
|
264
|
-
_context2.next = 26;
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
260
|
if (!((_currentAbortControll = currentAbortController) !== null && _currentAbortControll !== void 0 && _currentAbortControll.signal.aborted)) {
|
|
268
|
-
_context2.next =
|
|
261
|
+
_context2.next = 27;
|
|
269
262
|
break;
|
|
270
263
|
}
|
|
271
264
|
throw new Error('Aborted');
|
|
272
|
-
case
|
|
265
|
+
case 27:
|
|
273
266
|
setExtensionKey(_extensionKey);
|
|
274
267
|
setProviderName(_providerName);
|
|
275
268
|
if (!(access === 'unauthorized' || access === 'forbidden')) {
|
|
276
|
-
_context2.next =
|
|
269
|
+
_context2.next = 33;
|
|
277
270
|
break;
|
|
278
271
|
}
|
|
279
272
|
setStatus(access);
|
|
280
273
|
setAuthDetails(auth || initialEmptyArray);
|
|
281
274
|
return _context2.abrupt("return");
|
|
282
|
-
case
|
|
275
|
+
case 33:
|
|
283
276
|
setDestinationObjectTypes(_destinationObjectTypes);
|
|
284
277
|
setTotalCount(_totalCount);
|
|
285
278
|
setNextCursor(nextPageCursor);
|
|
286
279
|
setResponseItems(function (currentResponseItems) {
|
|
287
|
-
if (!getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
|
|
288
|
-
var hasIdenticalResponseItems = isEqual(currentResponseItems, items);
|
|
289
|
-
if (hasIdenticalResponseItems || shouldRequestFirstPage) {
|
|
290
|
-
return items;
|
|
291
|
-
}
|
|
292
|
-
return [].concat(_toConsumableArray(currentResponseItems), _toConsumableArray(items));
|
|
293
|
-
}
|
|
294
280
|
if (shouldRequestFirstPage) {
|
|
295
281
|
return items;
|
|
296
282
|
}
|
|
@@ -316,13 +302,9 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
316
302
|
setStatus('resolved');
|
|
317
303
|
_context2.next = 57;
|
|
318
304
|
break;
|
|
319
|
-
case
|
|
320
|
-
_context2.prev =
|
|
321
|
-
_context2.t0 = _context2["catch"](
|
|
322
|
-
if (!getBooleanFF('platform.linking-platform.datasource.enable-abort-controller')) {
|
|
323
|
-
_context2.next = 49;
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
305
|
+
case 45:
|
|
306
|
+
_context2.prev = 45;
|
|
307
|
+
_context2.t0 = _context2["catch"](10);
|
|
326
308
|
if (!(_context2.t0.message === 'Aborted')) {
|
|
327
309
|
_context2.next = 49;
|
|
328
310
|
break;
|
|
@@ -349,7 +331,7 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
349
331
|
case "end":
|
|
350
332
|
return _context2.stop();
|
|
351
333
|
}
|
|
352
|
-
}, _callee2, null, [[
|
|
334
|
+
}, _callee2, null, [[10, 45]]);
|
|
353
335
|
})), [captureError, parameters, fieldKeys, nextCursor, getDatasourceData, datasourceId, responseItems, applySchemaProperties, fireEvent, fullSchema, initialEmptyArray]);
|
|
354
336
|
var reset = useCallback(function (options) {
|
|
355
337
|
setResponseItems(initialEmptyArray);
|
|
@@ -410,11 +392,9 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
410
392
|
}
|
|
411
393
|
}, [fieldKeys, lastRequestedFieldKeys, responseItems, reset, onNextPage]);
|
|
412
394
|
useEffect(function () {
|
|
413
|
-
|
|
414
|
-
return
|
|
415
|
-
|
|
416
|
-
};
|
|
417
|
-
}
|
|
395
|
+
return function () {
|
|
396
|
+
return abortController.current.abort();
|
|
397
|
+
};
|
|
418
398
|
}, []);
|
|
419
399
|
return {
|
|
420
400
|
status: status,
|
|
@@ -114,6 +114,11 @@ export var DraggableTableHeading = function DraggableTableHeading(_ref) {
|
|
|
114
114
|
closestEdge = _useState6[0],
|
|
115
115
|
setClosestEdge = _useState6[1];
|
|
116
116
|
var dropTargetRef = useRef(null);
|
|
117
|
+
/**
|
|
118
|
+
* When width is not set (or callback is not set) we assume not resizing is needed.
|
|
119
|
+
* In our case width won't be set for last cell when table container is bigger than sum of all columns
|
|
120
|
+
*/
|
|
121
|
+
var resizeIsEnabled = !!onWidthChange && !!width;
|
|
117
122
|
useEffect(function () {
|
|
118
123
|
var cell = mainHeaderCellRef.current;
|
|
119
124
|
invariant(cell);
|
|
@@ -221,7 +226,7 @@ export var DraggableTableHeading = function DraggableTableHeading(_ref) {
|
|
|
221
226
|
|
|
222
227
|
// Handling column resizing
|
|
223
228
|
useEffect(function () {
|
|
224
|
-
if (!
|
|
229
|
+
if (!resizeIsEnabled) {
|
|
225
230
|
return;
|
|
226
231
|
}
|
|
227
232
|
var resizeHandle = columnResizeHandleRef.current;
|
|
@@ -277,7 +282,7 @@ export var DraggableTableHeading = function DraggableTableHeading(_ref) {
|
|
|
277
282
|
}
|
|
278
283
|
}
|
|
279
284
|
});
|
|
280
|
-
}, [id, index, onWidthChange, state, tableId, width]);
|
|
285
|
+
}, [id, index, onWidthChange, resizeIsEnabled, state, tableId, width]);
|
|
281
286
|
var _useState7 = useState(false),
|
|
282
287
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
283
288
|
buttonHovered = _useState8[0],
|
|
@@ -286,7 +291,9 @@ export var DraggableTableHeading = function DraggableTableHeading(_ref) {
|
|
|
286
291
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
287
292
|
isDropdownOpen = _useState10[0],
|
|
288
293
|
setIsDropdownOpen = _useState10[1];
|
|
289
|
-
|
|
294
|
+
// Width is not set when it is a last cell in a wide table.
|
|
295
|
+
// We make assumption thus that there is enough width for chevron.
|
|
296
|
+
var isWideEnoughToHaveChevron = !width || width > 76;
|
|
290
297
|
var shouldShowTriggerIcon = (buttonHovered || isDropdownOpen) && isWideEnoughToHaveChevron;
|
|
291
298
|
var triggerIcon = useMemo(function () {
|
|
292
299
|
return shouldShowTriggerIcon ? isDropdownOpen ? ChevronUp : ChevronDown : isWideEnoughToHaveChevron ? GlyphPlaceholder : undefined;
|
|
@@ -322,10 +329,10 @@ export var DraggableTableHeading = function DraggableTableHeading(_ref) {
|
|
|
322
329
|
style: _objectSpread({
|
|
323
330
|
cursor: 'grab'
|
|
324
331
|
}, getWidthCss({
|
|
325
|
-
shouldUseWidth:
|
|
332
|
+
shouldUseWidth: resizeIsEnabled,
|
|
326
333
|
width: width
|
|
327
334
|
}))
|
|
328
|
-
},
|
|
335
|
+
}, resizeIsEnabled ? jsx("div", {
|
|
329
336
|
ref: columnResizeHandleRef,
|
|
330
337
|
css: [resizerStyles, state.type === 'resizing' && resizingStyles],
|
|
331
338
|
style: {
|