@atlaskit/link-datasource 3.15.13 → 3.16.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 +16 -0
- package/dist/cjs/hooks/useDatasourceTableState.js +37 -39
- package/dist/cjs/state/index.js +3 -7
- package/dist/cjs/ui/issue-like-table/edit-type/icon/index.js +8 -2
- package/dist/cjs/ui/issue-like-table/index.js +44 -111
- package/dist/cjs/ui/issue-like-table/styled.js +1 -24
- package/dist/cjs/ui/issue-like-table/table-cell-content/inline-edit.js +54 -2
- package/dist/es2019/hooks/useDatasourceTableState.js +24 -26
- package/dist/es2019/state/index.js +3 -7
- package/dist/es2019/ui/issue-like-table/edit-type/icon/index.js +6 -2
- package/dist/es2019/ui/issue-like-table/index.js +5 -65
- package/dist/es2019/ui/issue-like-table/styled.js +0 -34
- package/dist/es2019/ui/issue-like-table/table-cell-content/inline-edit.js +59 -1
- package/dist/esm/hooks/useDatasourceTableState.js +37 -39
- package/dist/esm/state/index.js +3 -7
- package/dist/esm/ui/issue-like-table/edit-type/icon/index.js +8 -2
- package/dist/esm/ui/issue-like-table/index.js +46 -113
- package/dist/esm/ui/issue-like-table/styled.js +0 -23
- package/dist/esm/ui/issue-like-table/table-cell-content/inline-edit.js +53 -1
- package/dist/types/ui/issue-like-table/styled.d.ts +0 -4
- package/dist/types/ui/issue-like-table/table-cell-content/inline-edit.d.ts +5 -0
- package/dist/types-ts4.5/ui/issue-like-table/styled.d.ts +0 -4
- package/dist/types-ts4.5/ui/issue-like-table/table-cell-content/inline-edit.d.ts +5 -0
- package/package.json +7 -7
|
@@ -9,11 +9,9 @@ import { css, jsx } from '@emotion/react';
|
|
|
9
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
10
|
import styled from '@emotion/styled';
|
|
11
11
|
import debounce from 'lodash/debounce';
|
|
12
|
-
import { useIntl } from 'react-intl-next';
|
|
13
12
|
import invariant from 'tiny-invariant';
|
|
14
13
|
import { FlagsProvider } from '@atlaskit/flag';
|
|
15
14
|
import { Skeleton } from '@atlaskit/linking-common';
|
|
16
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
15
|
import { extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
18
16
|
import { reorderWithEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge';
|
|
19
17
|
import { autoScroller } from '@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll';
|
|
@@ -31,10 +29,9 @@ import { ColumnPicker } from './column-picker';
|
|
|
31
29
|
import { DragColumnPreview } from './drag-column-preview';
|
|
32
30
|
import { DraggableTableHeading } from './draggable-table-heading';
|
|
33
31
|
import TableEmptyState from './empty-state';
|
|
34
|
-
import { renderType
|
|
35
|
-
import { InlineEditableTableCell, Table,
|
|
32
|
+
import { renderType } from './render-type';
|
|
33
|
+
import { InlineEditableTableCell, Table, TableHeading, withTablePluginHeaderPrefix } from './styled';
|
|
36
34
|
import { TableCellContent } from './table-cell-content';
|
|
37
|
-
import { TruncateTextTag } from './truncate-text-tag';
|
|
38
35
|
import { useIsOnScreen } from './useIsOnScreen';
|
|
39
36
|
import { COLUMN_BASE_WIDTH, getFieldLabelById, getWidthCss } from './utils';
|
|
40
37
|
const tableSidePadding = "var(--ds-space-200, 16px)";
|
|
@@ -300,7 +297,6 @@ export const IssueLikeDataTableView = ({
|
|
|
300
297
|
extensionKey
|
|
301
298
|
}) => {
|
|
302
299
|
const tableId = useMemo(() => Symbol('unique-id'), []);
|
|
303
|
-
const intl = useIntl();
|
|
304
300
|
const experienceId = useDatasourceExperienceId();
|
|
305
301
|
const tableHeaderRowRef = useRef(null);
|
|
306
302
|
const [lastRowElement, setLastRowElement] = useState(null);
|
|
@@ -339,8 +335,6 @@ export const IssueLikeDataTableView = ({
|
|
|
339
335
|
// TODO seems like this component can't handle some combination of incremental data retrieval.
|
|
340
336
|
// If data comes first, then columns and then visibleColumnKeys it blows up,
|
|
341
337
|
// or some other combination.
|
|
342
|
-
|
|
343
|
-
const identityColumnKey = 'id';
|
|
344
338
|
const columnsWidthsSum = useMemo(() => visibleSortedColumns.map(({
|
|
345
339
|
key,
|
|
346
340
|
type
|
|
@@ -461,9 +455,7 @@ export const IssueLikeDataTableView = ({
|
|
|
461
455
|
}
|
|
462
456
|
}));
|
|
463
457
|
}, [visibleColumnKeys, onVisibleColumnKeysChange, tableId, hasData]);
|
|
464
|
-
const tableRows = useMemo(() =>
|
|
465
|
-
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
466
|
-
fg('enable_datasource_react_sweet_state') ? itemIds.map((id, rowIndex) => {
|
|
458
|
+
const tableRows = useMemo(() => itemIds.map((id, rowIndex) => {
|
|
467
459
|
return {
|
|
468
460
|
key: id,
|
|
469
461
|
cells: visibleSortedColumns.map(({
|
|
@@ -488,39 +480,7 @@ export const IssueLikeDataTableView = ({
|
|
|
488
480
|
}),
|
|
489
481
|
ref: rowIndex === items.length - 1 ? el => setLastRowElement(el) : undefined
|
|
490
482
|
};
|
|
491
|
-
})
|
|
492
|
-
key: `${identityColumnKey && newRowData[identityColumnKey] && newRowData[identityColumnKey].data || rowIndex}`,
|
|
493
|
-
cells: visibleSortedColumns.map(({
|
|
494
|
-
key,
|
|
495
|
-
type
|
|
496
|
-
}, cellIndex) => {
|
|
497
|
-
var _newRowData$key;
|
|
498
|
-
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
499
|
-
const value = (_newRowData$key = newRowData[key]) === null || _newRowData$key === void 0 ? void 0 : _newRowData$key.data;
|
|
500
|
-
const values = Array.isArray(value) ? value : [value];
|
|
501
|
-
const renderedValues = renderItem({
|
|
502
|
-
type,
|
|
503
|
-
values
|
|
504
|
-
});
|
|
505
|
-
const stringifiedContent = values.map(value => stringifyType({
|
|
506
|
-
type,
|
|
507
|
-
value
|
|
508
|
-
}, intl.formatMessage, intl.formatDate)).filter(value => value !== '').join(', ');
|
|
509
|
-
const contentComponent = stringifiedContent && !(wrappedColumnKeys !== null && wrappedColumnKeys !== void 0 && wrappedColumnKeys.includes(key)) ? jsx(Tooltip
|
|
510
|
-
// @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
|
|
511
|
-
, {
|
|
512
|
-
tag: TruncateTextTag,
|
|
513
|
-
content: stringifiedContent,
|
|
514
|
-
testId: "issues-table-cell-tooltip"
|
|
515
|
-
}, renderedValues) : renderedValues;
|
|
516
|
-
return {
|
|
517
|
-
key,
|
|
518
|
-
content: contentComponent,
|
|
519
|
-
width: getColumnWidth(key, type, cellIndex === visibleSortedColumns.length - 1)
|
|
520
|
-
};
|
|
521
|
-
}),
|
|
522
|
-
ref: rowIndex === items.length - 1 ? el => setLastRowElement(el) : undefined
|
|
523
|
-
})), [items, itemIds, renderItem, wrappedColumnKeys, visibleSortedColumns, getColumnWidth, intl.formatMessage, intl.formatDate]);
|
|
483
|
+
}), [items, itemIds, renderItem, wrappedColumnKeys, visibleSortedColumns, getColumnWidth]);
|
|
524
484
|
const rows = useMemo(() => {
|
|
525
485
|
if (status !== 'loading') {
|
|
526
486
|
return tableRows;
|
|
@@ -683,27 +643,7 @@ export const IssueLikeDataTableView = ({
|
|
|
683
643
|
shouldUseWidth,
|
|
684
644
|
width
|
|
685
645
|
});
|
|
686
|
-
|
|
687
|
-
if (fg('enable_datasource_react_sweet_state')) {
|
|
688
|
-
return jsx(InlineEditableTableCell, {
|
|
689
|
-
key: cellKey,
|
|
690
|
-
"data-testid": testId && `${testId}--cell-${cellIndex}`,
|
|
691
|
-
colSpan: isEditable && isLastCell ? 2 : undefined
|
|
692
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
693
|
-
,
|
|
694
|
-
style: loadingRowStyle,
|
|
695
|
-
css: [wrappedColumnKeys !== null && wrappedColumnKeys !== void 0 && wrappedColumnKeys.includes(cellKey) ? null : truncateStyles]
|
|
696
|
-
}, content);
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
// extra padding is required around skeleton loader to avoid vertical jumps when data loads
|
|
700
|
-
if (key !== null && key !== void 0 && key.includes('loading')) {
|
|
701
|
-
loadingRowStyle = {
|
|
702
|
-
...loadingRowStyle,
|
|
703
|
-
paddingBlock: "var(--ds-space-100, 8px)"
|
|
704
|
-
};
|
|
705
|
-
}
|
|
706
|
-
return jsx(TableCell, {
|
|
646
|
+
return jsx(InlineEditableTableCell, {
|
|
707
647
|
key: cellKey,
|
|
708
648
|
"data-testid": testId && `${testId}--cell-${cellIndex}`,
|
|
709
649
|
colSpan: isEditable && isLastCell ? 2 : undefined
|
|
@@ -77,40 +77,6 @@ export const TableHeading = styled.th({
|
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/ui-styling-standard/no-styled -- To migrate as part of go/ui-styling-standard
|
|
81
|
-
export const TableCell = styled.td({
|
|
82
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
83
|
-
[`${withTablePluginBodyPrefix()}`]: {
|
|
84
|
-
/* First section here is to override things editor table plugin css defines */
|
|
85
|
-
font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
86
|
-
padding: `${"var(--ds-space-050, 4px)"} ${"var(--ds-space-100, 8px)"}`,
|
|
87
|
-
border: 0,
|
|
88
|
-
minWidth: 'auto',
|
|
89
|
-
height: '32px',
|
|
90
|
-
verticalAlign: 'inherit',
|
|
91
|
-
boxSizing: 'content-box',
|
|
92
|
-
// Due to padding, content-box makes td height 40px equal to InlineEdit on height of 32px
|
|
93
|
-
borderRight: `${"var(--ds-border-width, 1px)"} solid ${`var(--ds-border, ${N40})`}`,
|
|
94
|
-
borderBottom: `${"var(--ds-border-width, 1px)"} solid ${`var(--ds-border, ${N40})`}`,
|
|
95
|
-
overflow: 'hidden'
|
|
96
|
-
},
|
|
97
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
98
|
-
[`${withTablePluginBodyPrefix('&:first-child')}`]: {
|
|
99
|
-
paddingLeft: "var(--ds-space-100, 8px)"
|
|
100
|
-
},
|
|
101
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
102
|
-
[`${withTablePluginBodyPrefix('&:last-child')}`]: {
|
|
103
|
-
borderRight: 0,
|
|
104
|
-
paddingRight: "var(--ds-space-100, 8px)"
|
|
105
|
-
},
|
|
106
|
-
// Inline smart links are pretty opinionated about word-wrapping.
|
|
107
|
-
// We want it to be controlled by user, so we make it overflow and truncate by default.
|
|
108
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
109
|
-
["& [data-testid='inline-card-icon-and-title'], " + "& [data-testid='button-connect-account'] > span"]: {
|
|
110
|
-
whiteSpace: 'unset'
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
80
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-styled, @atlaskit/ui-styling-standard/no-exported-styles -- To migrate as part of go/ui-styling-standard
|
|
115
81
|
export const InlineEditableTableCell = styled.td({
|
|
116
82
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
3
3
|
import { useIntl } from 'react-intl-next';
|
|
4
4
|
import AKInlineEdit from '@atlaskit/inline-edit';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
6
7
|
import { useSmartLinkReload } from '@atlaskit/smart-card/hooks';
|
|
7
8
|
import { useDatasourceAnalyticsEvents } from '../../../analytics';
|
|
@@ -17,6 +18,44 @@ export const InlineEditUFOExperience = 'inline-edit-rendered';
|
|
|
17
18
|
const editContainerStyles = xcss({
|
|
18
19
|
marginBlockStart: 'space.negative.100'
|
|
19
20
|
});
|
|
21
|
+
/**
|
|
22
|
+
* @returns String of the new field value, or ID of status transition / atlassian user ID / priority ID.
|
|
23
|
+
* @throws Error if the value is not supplied.
|
|
24
|
+
*/
|
|
25
|
+
export const newGetBackendUpdateValue = typedNewValue => {
|
|
26
|
+
if (typedNewValue.values.length === 0) {
|
|
27
|
+
throw new Error(`Datasource 2 way sync: Backend update value or value ID not supplied for type ${typedNewValue.type}`);
|
|
28
|
+
}
|
|
29
|
+
switch (typedNewValue.type) {
|
|
30
|
+
case 'string':
|
|
31
|
+
return typedNewValue.values[0];
|
|
32
|
+
case 'status':
|
|
33
|
+
const {
|
|
34
|
+
transitionId
|
|
35
|
+
} = typedNewValue.values[0];
|
|
36
|
+
if (transitionId === undefined || transitionId === '') {
|
|
37
|
+
throw new Error(`Datasource 2 way sync: Backend status transition ID not supplied for type transition`);
|
|
38
|
+
}
|
|
39
|
+
return transitionId;
|
|
40
|
+
case 'user':
|
|
41
|
+
const {
|
|
42
|
+
atlassianUserId
|
|
43
|
+
} = typedNewValue.values[0];
|
|
44
|
+
if (atlassianUserId === undefined || atlassianUserId === '') {
|
|
45
|
+
throw new Error(`Datasource 2 way sync: Backend atlasian user ID not supplied for type user`);
|
|
46
|
+
}
|
|
47
|
+
return atlassianUserId;
|
|
48
|
+
case 'icon':
|
|
49
|
+
const {
|
|
50
|
+
id
|
|
51
|
+
} = typedNewValue.values[0];
|
|
52
|
+
if (id === undefined || id === '') {
|
|
53
|
+
throw new Error(`Datasource 2 way sync: Backend update ID not supplied for type icon`);
|
|
54
|
+
}
|
|
55
|
+
return id;
|
|
56
|
+
}
|
|
57
|
+
throw new Error(`Datasource 2 way sync Backend update value not implemented for type ${typedNewValue.type}`);
|
|
58
|
+
};
|
|
20
59
|
const getBackendUpdateValue = typedNewValue => {
|
|
21
60
|
var _typedNewValue$values, _typedNewValue$values2, _typedNewValue$values3;
|
|
22
61
|
switch (typedNewValue.type) {
|
|
@@ -128,7 +167,26 @@ export const InlineEdit = ({
|
|
|
128
167
|
}
|
|
129
168
|
onUpdateItem(ari, newItem);
|
|
130
169
|
fireEvent('ui.form.submitted.inlineEdit', {});
|
|
131
|
-
|
|
170
|
+
let updateValue;
|
|
171
|
+
if (fg('platform-datasources-inline-edit-id-checks')) {
|
|
172
|
+
try {
|
|
173
|
+
// TODO: Refactor types so that valid update values are guaranteed for
|
|
174
|
+
// all object types. Invalid options should be filtered out of options -
|
|
175
|
+
// this frontend error flag is a last resort.
|
|
176
|
+
updateValue = newGetBackendUpdateValue(newValue);
|
|
177
|
+
} catch {
|
|
178
|
+
// Show an error as the new value that was going to be sent to the
|
|
179
|
+
// backend is invalid (and would have failed anyway, silently to the user)
|
|
180
|
+
showErrorFlag({});
|
|
181
|
+
onUpdateItem(ari, existingData);
|
|
182
|
+
setIsEditing(false);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
execute(updateValue !== undefined && fg('platform-datasources-inline-edit-id-checks') ? updateValue :
|
|
187
|
+
// Old behaviour is preserved in non-FFed path: errors thrown by getBackendUpdateValue are caught by
|
|
188
|
+
// the error boundary, _not_ by the catch block & frontend flag here.
|
|
189
|
+
getBackendUpdateValue(newValue)).then(refreshDatasourceItem).catch(error => {
|
|
132
190
|
const status = error && typeof error === 'object' ? error.status : undefined;
|
|
133
191
|
showErrorFlag({
|
|
134
192
|
status
|
|
@@ -6,7 +6,6 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
6
6
|
import isEqual from 'lodash/isEqual';
|
|
7
7
|
import { isFedRamp } from '@atlaskit/atlassian-context';
|
|
8
8
|
import { DEFAULT_GET_DATASOURCE_DATA_PAGE_SIZE, useDatasourceClientExtension } from '@atlaskit/link-client-extension';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
9
|
import { useDatasourceAnalyticsEvents } from '../analytics';
|
|
11
10
|
import { useDatasourceActions } from '../state';
|
|
12
11
|
import { useDiscoverActions } from '../state/actions';
|
|
@@ -305,33 +304,32 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
305
304
|
}
|
|
306
305
|
return [].concat(_toConsumableArray(currentResponseItems), _toConsumableArray(items));
|
|
307
306
|
});
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Product is typed as any.
|
|
310
|
+
*/
|
|
311
|
+
integrationKey = product;
|
|
312
|
+
/**
|
|
313
|
+
* When `entityType` is undefined, we should not discover actions it prevents unnecessary requests to Actions service
|
|
314
|
+
*/
|
|
315
|
+
entityType = objectTypesEntity;
|
|
316
|
+
newIds = onAddItems(items, typeof integrationKey === 'string' ? integrationKey : undefined, entityType);
|
|
317
|
+
setResponseItemIds(function (currentIds) {
|
|
318
|
+
return [].concat(_toConsumableArray(currentIds), _toConsumableArray(newIds));
|
|
319
|
+
});
|
|
320
|
+
if (!isFedRamp()) {
|
|
321
|
+
if (typeof integrationKey === 'string') {
|
|
322
|
+
aris = items.reduce(function (acc, item) {
|
|
323
|
+
var _item$ari;
|
|
324
|
+
return typeof ((_item$ari = item.ari) === null || _item$ari === void 0 ? void 0 : _item$ari.data) === 'string' ? [].concat(_toConsumableArray(acc), [item.ari.data]) : acc;
|
|
325
|
+
}, []);
|
|
326
|
+
if (aris.length && entityType) {
|
|
327
|
+
discoverActions({
|
|
328
|
+
aris: aris,
|
|
329
|
+
integrationKey: integrationKey,
|
|
330
|
+
fieldKeys: fieldKeys,
|
|
331
|
+
entityType: entityType
|
|
332
|
+
});
|
|
335
333
|
}
|
|
336
334
|
}
|
|
337
335
|
}
|
|
@@ -353,38 +351,38 @@ export var useDatasourceTableState = function useDatasourceTableState(_ref) {
|
|
|
353
351
|
});
|
|
354
352
|
}
|
|
355
353
|
setStatus('resolved');
|
|
356
|
-
_context2.next =
|
|
354
|
+
_context2.next = 64;
|
|
357
355
|
break;
|
|
358
|
-
case
|
|
359
|
-
_context2.prev =
|
|
356
|
+
case 52:
|
|
357
|
+
_context2.prev = 52;
|
|
360
358
|
_context2.t0 = _context2["catch"](10);
|
|
361
359
|
if (!(_context2.t0.message === 'Aborted')) {
|
|
362
|
-
_context2.next =
|
|
360
|
+
_context2.next = 56;
|
|
363
361
|
break;
|
|
364
362
|
}
|
|
365
363
|
return _context2.abrupt("return");
|
|
366
|
-
case
|
|
364
|
+
case 56:
|
|
367
365
|
captureError('onNextPage', _context2.t0);
|
|
368
366
|
if (!(_context2.t0 instanceof Response && _context2.t0.status === 401)) {
|
|
369
|
-
_context2.next =
|
|
367
|
+
_context2.next = 60;
|
|
370
368
|
break;
|
|
371
369
|
}
|
|
372
370
|
setStatus('unauthorized');
|
|
373
371
|
return _context2.abrupt("return");
|
|
374
|
-
case
|
|
372
|
+
case 60:
|
|
375
373
|
if (!(_context2.t0 instanceof Response && _context2.t0.status === 403)) {
|
|
376
|
-
_context2.next =
|
|
374
|
+
_context2.next = 63;
|
|
377
375
|
break;
|
|
378
376
|
}
|
|
379
377
|
setStatus('forbidden');
|
|
380
378
|
return _context2.abrupt("return");
|
|
381
|
-
case
|
|
379
|
+
case 63:
|
|
382
380
|
setStatus('rejected');
|
|
383
|
-
case
|
|
381
|
+
case 64:
|
|
384
382
|
case "end":
|
|
385
383
|
return _context2.stop();
|
|
386
384
|
}
|
|
387
|
-
}, _callee2, null, [[10,
|
|
385
|
+
}, _callee2, null, [[10, 52]]);
|
|
388
386
|
})), [captureError, parameters, fieldKeys, nextCursor, responseItems, setResponseItemIds, onAddItems, getDatasourceData, datasourceId, applySchemaProperties, fireEvent, fullSchema, initialEmptyArray, discoverActions]);
|
|
389
387
|
var reset = useCallback(function (options) {
|
|
390
388
|
setResponseItems(initialEmptyArray);
|
package/dist/esm/state/index.js
CHANGED
|
@@ -6,7 +6,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { createActionsHook, createContainer, createStateHook, createStore } from 'react-sweet-state';
|
|
8
8
|
import { v4 as uuidv4 } from 'uuid';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
9
|
var getInitialState = function getInitialState() {
|
|
11
10
|
return {
|
|
12
11
|
items: {}
|
|
@@ -75,10 +74,7 @@ export var useDatasourceActions = createActionsHook(Store);
|
|
|
75
74
|
var Container = createContainer(Store);
|
|
76
75
|
export var StoreContainer = function StoreContainer(_ref6) {
|
|
77
76
|
var children = _ref6.children;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}, children);
|
|
82
|
-
}
|
|
83
|
-
return children;
|
|
77
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
78
|
+
scope: "datasource"
|
|
79
|
+
}, children);
|
|
84
80
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useEffect } from 'react';
|
|
3
3
|
import { Layering } from '@atlaskit/layering';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import Select from '@atlaskit/select';
|
|
5
6
|
import Tooltip from '@atlaskit/tooltip';
|
|
6
7
|
import { failUfoExperience, succeedUfoExperience } from '../../../../analytics/ufoExperiences';
|
|
@@ -43,8 +44,13 @@ var IconEditType = function IconEditType(props) {
|
|
|
43
44
|
}, /*#__PURE__*/React.createElement(Select, _extends({}, getCleanedSelectProps(props), {
|
|
44
45
|
autoFocus: true,
|
|
45
46
|
blurInputOnSelect: true,
|
|
46
|
-
defaultMenuIsOpen: true
|
|
47
|
-
|
|
47
|
+
defaultMenuIsOpen: true
|
|
48
|
+
// We can't update the status if we don't have an ID - however the ID
|
|
49
|
+
// is typed optional.
|
|
50
|
+
,
|
|
51
|
+
options: fg('platform-datasources-inline-edit-id-checks') ? options.filter(function (option) {
|
|
52
|
+
return option.id;
|
|
53
|
+
}) : options,
|
|
48
54
|
menuPlacement: "auto",
|
|
49
55
|
isLoading: isLoading,
|
|
50
56
|
filterOption: filterOption,
|
|
@@ -16,11 +16,9 @@ import { css, jsx } from '@emotion/react';
|
|
|
16
16
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
17
17
|
import styled from '@emotion/styled';
|
|
18
18
|
import debounce from 'lodash/debounce';
|
|
19
|
-
import { useIntl } from 'react-intl-next';
|
|
20
19
|
import invariant from 'tiny-invariant';
|
|
21
20
|
import { FlagsProvider } from '@atlaskit/flag';
|
|
22
21
|
import { Skeleton } from '@atlaskit/linking-common';
|
|
23
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
24
22
|
import { extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
25
23
|
import { reorderWithEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge';
|
|
26
24
|
import { autoScroller } from '@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-autoscroll';
|
|
@@ -38,10 +36,9 @@ import { ColumnPicker } from './column-picker';
|
|
|
38
36
|
import { DragColumnPreview } from './drag-column-preview';
|
|
39
37
|
import { DraggableTableHeading } from './draggable-table-heading';
|
|
40
38
|
import TableEmptyState from './empty-state';
|
|
41
|
-
import { renderType
|
|
42
|
-
import { InlineEditableTableCell, Table,
|
|
39
|
+
import { renderType } from './render-type';
|
|
40
|
+
import { InlineEditableTableCell, Table, TableHeading, withTablePluginHeaderPrefix } from './styled';
|
|
43
41
|
import { TableCellContent } from './table-cell-content';
|
|
44
|
-
import { TruncateTextTag } from './truncate-text-tag';
|
|
45
42
|
import { useIsOnScreen } from './useIsOnScreen';
|
|
46
43
|
import { COLUMN_BASE_WIDTH, getFieldLabelById, getWidthCss } from './utils';
|
|
47
44
|
var tableSidePadding = "var(--ds-space-200, 16px)";
|
|
@@ -272,7 +269,6 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
272
269
|
var tableId = useMemo(function () {
|
|
273
270
|
return Symbol('unique-id');
|
|
274
271
|
}, []);
|
|
275
|
-
var intl = useIntl();
|
|
276
272
|
var experienceId = useDatasourceExperienceId();
|
|
277
273
|
var tableHeaderRowRef = useRef(null);
|
|
278
274
|
var _useState = useState(null),
|
|
@@ -328,8 +324,6 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
328
324
|
// TODO seems like this component can't handle some combination of incremental data retrieval.
|
|
329
325
|
// If data comes first, then columns and then visibleColumnKeys it blows up,
|
|
330
326
|
// or some other combination.
|
|
331
|
-
|
|
332
|
-
var identityColumnKey = 'id';
|
|
333
327
|
var columnsWidthsSum = useMemo(function () {
|
|
334
328
|
return visibleSortedColumns.map(function (_ref7) {
|
|
335
329
|
var key = _ref7.key,
|
|
@@ -460,76 +454,34 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
460
454
|
}));
|
|
461
455
|
}, [visibleColumnKeys, onVisibleColumnKeysChange, tableId, hasData]);
|
|
462
456
|
var tableRows = useMemo(function () {
|
|
463
|
-
return (
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
key
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
457
|
+
return itemIds.map(function (id, rowIndex) {
|
|
458
|
+
return {
|
|
459
|
+
key: id,
|
|
460
|
+
cells: visibleSortedColumns.map(function (_ref12, cellIndex) {
|
|
461
|
+
var key = _ref12.key,
|
|
462
|
+
type = _ref12.type,
|
|
463
|
+
title = _ref12.title;
|
|
464
|
+
return {
|
|
465
|
+
key: key,
|
|
466
|
+
columnKey: key,
|
|
467
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
468
|
+
content: jsx(TableCellContent, {
|
|
469
|
+
id: id,
|
|
474
470
|
columnKey: key,
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
} : undefined
|
|
490
|
-
};
|
|
491
|
-
}) : items.map(function (newRowData, rowIndex) {
|
|
492
|
-
return {
|
|
493
|
-
key: "".concat(identityColumnKey && newRowData[identityColumnKey] && newRowData[identityColumnKey].data || rowIndex),
|
|
494
|
-
cells: visibleSortedColumns.map(function (_ref13, cellIndex) {
|
|
495
|
-
var _newRowData$key;
|
|
496
|
-
var key = _ref13.key,
|
|
497
|
-
type = _ref13.type;
|
|
498
|
-
// Need to make sure we keep falsy values like 0 and '', as well as the boolean false.
|
|
499
|
-
var value = (_newRowData$key = newRowData[key]) === null || _newRowData$key === void 0 ? void 0 : _newRowData$key.data;
|
|
500
|
-
var values = Array.isArray(value) ? value : [value];
|
|
501
|
-
var renderedValues = renderItem({
|
|
502
|
-
type: type,
|
|
503
|
-
values: values
|
|
504
|
-
});
|
|
505
|
-
var stringifiedContent = values.map(function (value) {
|
|
506
|
-
return stringifyType({
|
|
507
|
-
type: type,
|
|
508
|
-
value: value
|
|
509
|
-
}, intl.formatMessage, intl.formatDate);
|
|
510
|
-
}).filter(function (value) {
|
|
511
|
-
return value !== '';
|
|
512
|
-
}).join(', ');
|
|
513
|
-
var contentComponent = stringifiedContent && !(wrappedColumnKeys !== null && wrappedColumnKeys !== void 0 && wrappedColumnKeys.includes(key)) ? jsx(Tooltip
|
|
514
|
-
// @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
|
|
515
|
-
, {
|
|
516
|
-
tag: TruncateTextTag,
|
|
517
|
-
content: stringifiedContent,
|
|
518
|
-
testId: "issues-table-cell-tooltip"
|
|
519
|
-
}, renderedValues) : renderedValues;
|
|
520
|
-
return {
|
|
521
|
-
key: key,
|
|
522
|
-
content: contentComponent,
|
|
523
|
-
width: getColumnWidth(key, type, cellIndex === visibleSortedColumns.length - 1)
|
|
524
|
-
};
|
|
525
|
-
}),
|
|
526
|
-
ref: rowIndex === items.length - 1 ? function (el) {
|
|
527
|
-
return setLastRowElement(el);
|
|
528
|
-
} : undefined
|
|
529
|
-
};
|
|
530
|
-
})
|
|
531
|
-
);
|
|
532
|
-
}, [items, itemIds, renderItem, wrappedColumnKeys, visibleSortedColumns, getColumnWidth, intl.formatMessage, intl.formatDate]);
|
|
471
|
+
columnType: type,
|
|
472
|
+
columnTitle: title,
|
|
473
|
+
wrappedColumnKeys: wrappedColumnKeys,
|
|
474
|
+
renderItem: renderItem
|
|
475
|
+
}),
|
|
476
|
+
width: getColumnWidth(key, type, cellIndex === visibleSortedColumns.length - 1)
|
|
477
|
+
};
|
|
478
|
+
}),
|
|
479
|
+
ref: rowIndex === items.length - 1 ? function (el) {
|
|
480
|
+
return setLastRowElement(el);
|
|
481
|
+
} : undefined
|
|
482
|
+
};
|
|
483
|
+
});
|
|
484
|
+
}, [items, itemIds, renderItem, wrappedColumnKeys, visibleSortedColumns, getColumnWidth]);
|
|
533
485
|
var rows = useMemo(function () {
|
|
534
486
|
if (status !== 'loading') {
|
|
535
487
|
return tableRows;
|
|
@@ -622,10 +574,10 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
622
574
|
className: !!onVisibleColumnKeysChange ? 'has-column-picker' : ''
|
|
623
575
|
}, jsx("tr", {
|
|
624
576
|
ref: tableHeaderRowRef
|
|
625
|
-
}, headerColumns.map(function (
|
|
626
|
-
var key =
|
|
627
|
-
content =
|
|
628
|
-
width =
|
|
577
|
+
}, headerColumns.map(function (_ref14, cellIndex) {
|
|
578
|
+
var key = _ref14.key,
|
|
579
|
+
content = _ref14.content,
|
|
580
|
+
width = _ref14.width;
|
|
629
581
|
var heading = jsx(Tooltip, {
|
|
630
582
|
content: content,
|
|
631
583
|
tag: "span",
|
|
@@ -643,10 +595,10 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
643
595
|
}
|
|
644
596
|
if (isEditable) {
|
|
645
597
|
var _containerRef$current3;
|
|
646
|
-
var previewRows = tableRows.map(function (
|
|
647
|
-
var cells =
|
|
648
|
-
var cell = cells.find(function (
|
|
649
|
-
var cellKey =
|
|
598
|
+
var previewRows = tableRows.map(function (_ref15) {
|
|
599
|
+
var cells = _ref15.cells;
|
|
600
|
+
var cell = cells.find(function (_ref16) {
|
|
601
|
+
var cellKey = _ref16.key;
|
|
650
602
|
return cellKey === key;
|
|
651
603
|
});
|
|
652
604
|
if (cell) {
|
|
@@ -689,43 +641,24 @@ export var IssueLikeDataTableView = function IssueLikeDataTableView(_ref5) {
|
|
|
689
641
|
})))), jsx("tbody", {
|
|
690
642
|
css: noDefaultBorderStyles,
|
|
691
643
|
"data-testid": testId && "".concat(testId, "--body")
|
|
692
|
-
}, rows.map(function (
|
|
693
|
-
var key =
|
|
694
|
-
cells =
|
|
695
|
-
ref =
|
|
644
|
+
}, rows.map(function (_ref17) {
|
|
645
|
+
var key = _ref17.key,
|
|
646
|
+
cells = _ref17.cells,
|
|
647
|
+
ref = _ref17.ref;
|
|
696
648
|
return jsx("tr", {
|
|
697
649
|
key: key,
|
|
698
650
|
"data-testid": testId && "".concat(testId, "--row-").concat(key),
|
|
699
651
|
ref: ref
|
|
700
|
-
}, cells.map(function (
|
|
701
|
-
var cellKey =
|
|
702
|
-
content =
|
|
703
|
-
width =
|
|
652
|
+
}, cells.map(function (_ref18, cellIndex) {
|
|
653
|
+
var cellKey = _ref18.key,
|
|
654
|
+
content = _ref18.content,
|
|
655
|
+
width = _ref18.width;
|
|
704
656
|
var isLastCell = cellIndex === cells.length - 1;
|
|
705
657
|
var loadingRowStyle = getWidthCss({
|
|
706
658
|
shouldUseWidth: shouldUseWidth,
|
|
707
659
|
width: width
|
|
708
660
|
});
|
|
709
|
-
|
|
710
|
-
if (fg('enable_datasource_react_sweet_state')) {
|
|
711
|
-
return jsx(InlineEditableTableCell, {
|
|
712
|
-
key: cellKey,
|
|
713
|
-
"data-testid": testId && "".concat(testId, "--cell-").concat(cellIndex),
|
|
714
|
-
colSpan: isEditable && isLastCell ? 2 : undefined
|
|
715
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
716
|
-
,
|
|
717
|
-
style: loadingRowStyle,
|
|
718
|
-
css: [wrappedColumnKeys !== null && wrappedColumnKeys !== void 0 && wrappedColumnKeys.includes(cellKey) ? null : truncateStyles]
|
|
719
|
-
}, content);
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
// extra padding is required around skeleton loader to avoid vertical jumps when data loads
|
|
723
|
-
if (key !== null && key !== void 0 && key.includes('loading')) {
|
|
724
|
-
loadingRowStyle = _objectSpread(_objectSpread({}, loadingRowStyle), {}, {
|
|
725
|
-
paddingBlock: "var(--ds-space-100, 8px)"
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
return jsx(TableCell, {
|
|
661
|
+
return jsx(InlineEditableTableCell, {
|
|
729
662
|
key: cellKey,
|
|
730
663
|
"data-testid": testId && "".concat(testId, "--cell-").concat(cellIndex),
|
|
731
664
|
colSpan: isEditable && isLastCell ? 2 : undefined
|