@atlaskit/link-datasource 0.29.4 → 0.29.5
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 +7 -0
- package/dist/cjs/hooks/useAssetsClient.js +50 -31
- package/dist/cjs/hooks/useObjectSchemas.js +74 -0
- package/dist/cjs/hooks/useValidateAqlText.js +42 -13
- package/dist/cjs/services/cmdbService.js +17 -8
- package/dist/cjs/types/assets/types.js +7 -1
- package/dist/cjs/ui/assets-modal/modal/index.js +46 -10
- package/dist/cjs/ui/assets-modal/modal/messages.js +5 -0
- package/dist/cjs/ui/assets-modal/modal/styled.js +1 -1
- package/dist/cjs/ui/assets-modal/search-container/aql-search-input/index.js +161 -0
- package/dist/cjs/ui/assets-modal/search-container/aql-search-input/loading-state.js +18 -0
- package/dist/cjs/ui/assets-modal/search-container/aql-search-input/messages.js +15 -0
- package/dist/cjs/ui/assets-modal/search-container/index.js +50 -0
- package/dist/cjs/ui/assets-modal/search-container/loading-state.js +21 -0
- package/dist/cjs/ui/assets-modal/search-container/object-schema-select/index.js +103 -0
- package/dist/cjs/ui/assets-modal/search-container/object-schema-select/loading-state.js +18 -0
- package/dist/cjs/ui/assets-modal/search-container/object-schema-select/messages.js +25 -0
- package/dist/cjs/ui/assets-modal/search-container/object-schema-select/utils.js +13 -0
- package/dist/cjs/ui/assets-modal/search-container/styled.js +22 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/hooks/useAssetsClient.js +22 -13
- package/dist/es2019/hooks/useObjectSchemas.js +32 -0
- package/dist/es2019/hooks/useValidateAqlText.js +26 -9
- package/dist/es2019/services/cmdbService.js +14 -6
- package/dist/es2019/types/assets/types.js +3 -1
- package/dist/es2019/ui/assets-modal/modal/index.js +42 -8
- package/dist/es2019/ui/assets-modal/modal/messages.js +5 -0
- package/dist/es2019/ui/assets-modal/modal/styled.js +3 -3
- package/dist/es2019/ui/assets-modal/search-container/aql-search-input/index.js +129 -0
- package/dist/es2019/ui/assets-modal/search-container/aql-search-input/loading-state.js +8 -0
- package/dist/es2019/ui/assets-modal/search-container/aql-search-input/messages.js +8 -0
- package/dist/es2019/ui/assets-modal/search-container/index.js +46 -0
- package/dist/es2019/ui/assets-modal/search-container/loading-state.js +14 -0
- package/dist/es2019/ui/assets-modal/search-container/object-schema-select/index.js +65 -0
- package/dist/es2019/ui/assets-modal/search-container/object-schema-select/loading-state.js +8 -0
- package/dist/es2019/ui/assets-modal/search-container/object-schema-select/messages.js +18 -0
- package/dist/es2019/ui/assets-modal/search-container/object-schema-select/utils.js +4 -0
- package/dist/es2019/ui/assets-modal/search-container/styled.js +22 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/hooks/useAssetsClient.js +51 -32
- package/dist/esm/hooks/useObjectSchemas.js +66 -0
- package/dist/esm/hooks/useValidateAqlText.js +42 -13
- package/dist/esm/services/cmdbService.js +15 -7
- package/dist/esm/types/assets/types.js +3 -1
- package/dist/esm/ui/assets-modal/modal/index.js +46 -10
- package/dist/esm/ui/assets-modal/modal/messages.js +5 -0
- package/dist/esm/ui/assets-modal/modal/styled.js +1 -1
- package/dist/esm/ui/assets-modal/search-container/aql-search-input/index.js +152 -0
- package/dist/esm/ui/assets-modal/search-container/aql-search-input/loading-state.js +10 -0
- package/dist/esm/ui/assets-modal/search-container/aql-search-input/messages.js +8 -0
- package/dist/esm/ui/assets-modal/search-container/index.js +41 -0
- package/dist/esm/ui/assets-modal/search-container/loading-state.js +13 -0
- package/dist/esm/ui/assets-modal/search-container/object-schema-select/index.js +94 -0
- package/dist/esm/ui/assets-modal/search-container/object-schema-select/loading-state.js +10 -0
- package/dist/esm/ui/assets-modal/search-container/object-schema-select/messages.js +18 -0
- package/dist/esm/ui/assets-modal/search-container/object-schema-select/utils.js +6 -0
- package/dist/esm/ui/assets-modal/search-container/styled.js +11 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/hooks/useAssetsClient.d.ts +8 -6
- package/dist/types/hooks/useObjectSchemas.d.ts +8 -0
- package/dist/types/hooks/useValidateAqlText.d.ts +5 -2
- package/dist/types/services/cmdbService.d.ts +4 -3
- package/dist/types/types/assets/types.d.ts +21 -10
- package/dist/types/ui/assets-modal/modal/messages.d.ts +5 -0
- package/dist/types/ui/assets-modal/search-container/aql-search-input/index.d.ts +8 -0
- package/dist/types/ui/assets-modal/search-container/aql-search-input/loading-state.d.ts +3 -0
- package/dist/types/ui/assets-modal/search-container/aql-search-input/messages.d.ts +7 -0
- package/dist/types/ui/assets-modal/search-container/index.d.ts +16 -0
- package/dist/types/ui/assets-modal/search-container/loading-state.d.ts +8 -0
- package/dist/types/ui/assets-modal/search-container/object-schema-select/index.d.ts +10 -0
- package/dist/types/ui/assets-modal/search-container/object-schema-select/loading-state.d.ts +3 -0
- package/dist/types/ui/assets-modal/search-container/object-schema-select/messages.d.ts +17 -0
- package/dist/types/ui/assets-modal/search-container/object-schema-select/utils.d.ts +2 -0
- package/dist/types/ui/assets-modal/search-container/styled.d.ts +19 -0
- package/dist/types-ts4.5/hooks/useAssetsClient.d.ts +8 -6
- package/dist/types-ts4.5/hooks/useObjectSchemas.d.ts +8 -0
- package/dist/types-ts4.5/hooks/useValidateAqlText.d.ts +5 -2
- package/dist/types-ts4.5/services/cmdbService.d.ts +4 -3
- package/dist/types-ts4.5/types/assets/types.d.ts +21 -10
- package/dist/types-ts4.5/ui/assets-modal/modal/messages.d.ts +5 -0
- package/dist/types-ts4.5/ui/assets-modal/search-container/aql-search-input/index.d.ts +8 -0
- package/dist/types-ts4.5/ui/assets-modal/search-container/aql-search-input/loading-state.d.ts +3 -0
- package/dist/types-ts4.5/ui/assets-modal/search-container/aql-search-input/messages.d.ts +7 -0
- package/dist/types-ts4.5/ui/assets-modal/search-container/index.d.ts +16 -0
- package/dist/types-ts4.5/ui/assets-modal/search-container/loading-state.d.ts +8 -0
- package/dist/types-ts4.5/ui/assets-modal/search-container/object-schema-select/index.d.ts +10 -0
- package/dist/types-ts4.5/ui/assets-modal/search-container/object-schema-select/loading-state.d.ts +3 -0
- package/dist/types-ts4.5/ui/assets-modal/search-container/object-schema-select/messages.d.ts +17 -0
- package/dist/types-ts4.5/ui/assets-modal/search-container/object-schema-select/utils.d.ts +2 -0
- package/dist/types-ts4.5/ui/assets-modal/search-container/styled.d.ts +19 -0
- package/package.json +4 -2
|
@@ -7,9 +7,13 @@ import Button from '@atlaskit/button/standard-button';
|
|
|
7
7
|
import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
8
8
|
import { useAssetsClient } from '../../../hooks/useAssetsClient';
|
|
9
9
|
import { useDatasourceTableState } from '../../../hooks/useDatasourceTableState';
|
|
10
|
+
import { ModalLoadingError } from '../../common/error-state/modal-loading-error';
|
|
11
|
+
import { AssetsSearchContainer } from '../search-container';
|
|
12
|
+
import { AssetsSearchContainerLoading } from '../search-container/loading-state';
|
|
10
13
|
import { modalMessages } from './messages';
|
|
11
14
|
import { RenderAssetsContent } from './render-assets-content';
|
|
12
15
|
import { ModalContentContainer } from './styled';
|
|
16
|
+
var AssetsModalTitle = jsx(ModalTitle, null, jsx(FormattedMessage, modalMessages.insertObjectsTitle));
|
|
13
17
|
export var AssetsConfigModal = function AssetsConfigModal(props) {
|
|
14
18
|
var datasourceId = props.datasourceId,
|
|
15
19
|
initialParameters = props.parameters,
|
|
@@ -17,22 +21,30 @@ export var AssetsConfigModal = function AssetsConfigModal(props) {
|
|
|
17
21
|
onInsert = props.onInsert,
|
|
18
22
|
initialVisibleColumnKeys = props.visibleColumnKeys;
|
|
19
23
|
var _useState = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.aql),
|
|
20
|
-
_useState2 = _slicedToArray(_useState,
|
|
21
|
-
aql = _useState2[0]
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
aql = _useState2[0],
|
|
26
|
+
setAql = _useState2[1];
|
|
22
27
|
var _useState3 = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.schemaId),
|
|
23
|
-
_useState4 = _slicedToArray(_useState3,
|
|
24
|
-
schemaId = _useState4[0]
|
|
28
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
29
|
+
schemaId = _useState4[0],
|
|
30
|
+
setSchemaId = _useState4[1];
|
|
25
31
|
var _useState5 = useState(initialVisibleColumnKeys),
|
|
26
32
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
27
33
|
visibleColumnKeys = _useState6[0],
|
|
28
34
|
setVisibleColumnKeys = _useState6[1];
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
|
|
36
|
+
// If a workspaceError occurs this is a critical error
|
|
37
|
+
var _useAssetsClient = useAssetsClient(initialParameters),
|
|
38
|
+
workspaceId = _useAssetsClient.workspaceId,
|
|
39
|
+
workspaceError = _useAssetsClient.workspaceError,
|
|
40
|
+
objectSchema = _useAssetsClient.objectSchema,
|
|
41
|
+
assetsClientLoading = _useAssetsClient.assetsClientLoading;
|
|
31
42
|
var parameters = useMemo(function () {
|
|
32
43
|
return {
|
|
33
44
|
aql: aql || '',
|
|
34
45
|
schemaId: schemaId || '',
|
|
35
|
-
workspaceId: ''
|
|
46
|
+
workspaceId: '',
|
|
47
|
+
cloudId: ''
|
|
36
48
|
};
|
|
37
49
|
}, [aql, schemaId]);
|
|
38
50
|
var _useDatasourceTableSt = useDatasourceTableState({
|
|
@@ -46,7 +58,7 @@ export var AssetsConfigModal = function AssetsConfigModal(props) {
|
|
|
46
58
|
var newVisibleColumnKeys = !initialVisibleColumnKeys || (initialVisibleColumnKeys || []).length === 0 ? defaultVisibleColumnKeys : initialVisibleColumnKeys;
|
|
47
59
|
setVisibleColumnKeys(newVisibleColumnKeys);
|
|
48
60
|
}, [initialVisibleColumnKeys, defaultVisibleColumnKeys]);
|
|
49
|
-
var isDisabled = status === 'rejected' || status === 'loading' || status === 'empty' ||
|
|
61
|
+
var isDisabled = status === 'rejected' || status === 'loading' || status === 'empty' || !!workspaceError || assetsClientLoading || !aql || !schemaId;
|
|
50
62
|
var retrieveUrlForSmartCardRender = useCallback(function () {
|
|
51
63
|
var _data$key, _data$key$data;
|
|
52
64
|
var _responseItems = _slicedToArray(responseItems, 1),
|
|
@@ -55,7 +67,7 @@ export var AssetsConfigModal = function AssetsConfigModal(props) {
|
|
|
55
67
|
return data === null || data === void 0 ? void 0 : (_data$key = data.key) === null || _data$key === void 0 ? void 0 : (_data$key$data = _data$key.data) === null || _data$key$data === void 0 ? void 0 : _data$key$data.url;
|
|
56
68
|
}, [responseItems]);
|
|
57
69
|
var onInsertPressed = useCallback(function () {
|
|
58
|
-
if (!aql) {
|
|
70
|
+
if (!aql || !schemaId) {
|
|
59
71
|
return;
|
|
60
72
|
}
|
|
61
73
|
var firstAssetUrl = retrieveUrlForSmartCardRender();
|
|
@@ -93,12 +105,36 @@ export var AssetsConfigModal = function AssetsConfigModal(props) {
|
|
|
93
105
|
});
|
|
94
106
|
}
|
|
95
107
|
}, [aql, datasourceId, onInsert, responseItems.length, retrieveUrlForSmartCardRender, schemaId, visibleColumnKeys]);
|
|
108
|
+
var handleOnSearch = useCallback(function (aql, schemaId) {
|
|
109
|
+
setAql(aql);
|
|
110
|
+
setSchemaId(schemaId);
|
|
111
|
+
}, []);
|
|
112
|
+
var renderModalTitleContent = useCallback(function () {
|
|
113
|
+
if (workspaceError) {
|
|
114
|
+
return undefined;
|
|
115
|
+
} else {
|
|
116
|
+
if (!workspaceId || assetsClientLoading) {
|
|
117
|
+
return jsx(AssetsSearchContainerLoading, {
|
|
118
|
+
modalTitle: AssetsModalTitle
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return jsx(AssetsSearchContainer, {
|
|
122
|
+
workspaceId: workspaceId,
|
|
123
|
+
initialSearchData: {
|
|
124
|
+
aql: aql,
|
|
125
|
+
objectSchema: objectSchema
|
|
126
|
+
},
|
|
127
|
+
onSearch: handleOnSearch,
|
|
128
|
+
modalTitle: AssetsModalTitle
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}, [aql, assetsClientLoading, handleOnSearch, objectSchema, workspaceError, workspaceId]);
|
|
96
132
|
return jsx(ModalTransition, null, jsx(Modal, {
|
|
97
133
|
testId: 'asset-datasource-modal',
|
|
98
134
|
onClose: onCancel,
|
|
99
135
|
width: "x-large",
|
|
100
136
|
shouldScrollInViewport: true
|
|
101
|
-
}, jsx(ModalHeader, null,
|
|
137
|
+
}, jsx(ModalHeader, null, renderModalTitleContent()), jsx(ModalBody, null, jsx(ModalContentContainer, null, workspaceError ? jsx(ModalLoadingError, null) : jsx(RenderAssetsContent, {
|
|
102
138
|
status: status,
|
|
103
139
|
responseItems: responseItems
|
|
104
140
|
}))), jsx(ModalFooter, null, jsx(Button, {
|
|
@@ -9,5 +9,10 @@ export var modalMessages = defineMessages({
|
|
|
9
9
|
id: 'linkDataSource.assets.configmodal.insertIssuesButtonText',
|
|
10
10
|
description: 'Button text to insert the displayed content',
|
|
11
11
|
defaultMessage: 'Insert objects'
|
|
12
|
+
},
|
|
13
|
+
insertObjectsTitle: {
|
|
14
|
+
id: 'linkDataSource.assets.configmodal.insertObjectsTitle',
|
|
15
|
+
description: 'Title for the Assets Objects Datasource config modal which prefixes a select picker',
|
|
16
|
+
defaultMessage: 'Insert objects from'
|
|
12
17
|
}
|
|
13
18
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
var _templateObject;
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
|
-
export var ModalContentContainer = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display:
|
|
4
|
+
export var ModalContentContainer = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: grid;\n height: 420px;\n overflow: auto;\n"])));
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
/** @jsx jsx */
|
|
5
|
+
import { useCallback, useRef } from 'react';
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import { useIntl } from 'react-intl-next';
|
|
8
|
+
import Button from '@atlaskit/button';
|
|
9
|
+
import { Field } from '@atlaskit/form';
|
|
10
|
+
import CheckCircleIcon from '@atlaskit/icon/glyph/check-circle';
|
|
11
|
+
import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
|
|
12
|
+
import SearchIcon from '@atlaskit/icon/glyph/editor/search';
|
|
13
|
+
import Spinner from '@atlaskit/spinner';
|
|
14
|
+
import Textfield from '@atlaskit/textfield';
|
|
15
|
+
import { useValidateAqlText } from '../../../../hooks/useValidateAqlText';
|
|
16
|
+
import { aqlKey } from '../../../../types/assets/types';
|
|
17
|
+
import { FieldContainer } from '../styled';
|
|
18
|
+
import { searchInputMessages } from './messages';
|
|
19
|
+
|
|
20
|
+
/* Meta isn't exported in @atlaskit/form
|
|
21
|
+
Taken from packages/design-system/form/src/field.tsx */
|
|
22
|
+
|
|
23
|
+
var searchButtonStyles = css({
|
|
24
|
+
marginRight: "var(--ds-space-075, 6px)"
|
|
25
|
+
});
|
|
26
|
+
export var SEARCH_DEBOUNCE_MS = 350;
|
|
27
|
+
var renderValidatorIcon = function renderValidatorIcon(value, error, meta) {
|
|
28
|
+
if (value && meta !== null && meta !== void 0 && meta.validating) {
|
|
29
|
+
return jsx(Spinner, {
|
|
30
|
+
size: "medium",
|
|
31
|
+
testId: "assets-datasource-modal--aql-validating"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (value && error) {
|
|
35
|
+
return jsx(CrossCircleIcon, {
|
|
36
|
+
label: "label",
|
|
37
|
+
primaryColor: "red",
|
|
38
|
+
size: "medium",
|
|
39
|
+
testId: "assets-datasource-modal--aql-invalid"
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (value && meta.valid) {
|
|
43
|
+
return jsx(CheckCircleIcon, {
|
|
44
|
+
label: "label",
|
|
45
|
+
primaryColor: "green",
|
|
46
|
+
size: "medium",
|
|
47
|
+
testId: "assets-datasource-modal--aql-valid"
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return jsx(SearchIcon, {
|
|
51
|
+
label: "label",
|
|
52
|
+
size: "medium",
|
|
53
|
+
testId: "assets-datasource-modal--aql-idle"
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
export var AqlSearchInput = function AqlSearchInput(_ref) {
|
|
57
|
+
var value = _ref.value,
|
|
58
|
+
workspaceId = _ref.workspaceId,
|
|
59
|
+
_ref$testId = _ref.testId,
|
|
60
|
+
testId = _ref$testId === void 0 ? 'assets-datasource-modal--aql-search-input' : _ref$testId;
|
|
61
|
+
var _useIntl = useIntl(),
|
|
62
|
+
formatMessage = _useIntl.formatMessage;
|
|
63
|
+
var timeout = useRef();
|
|
64
|
+
var lastValue = useRef(value);
|
|
65
|
+
var lastResult = useRef(Promise.resolve(undefined));
|
|
66
|
+
var _useValidateAqlText = useValidateAqlText(workspaceId),
|
|
67
|
+
validateAqlText = _useValidateAqlText.validateAqlText;
|
|
68
|
+
|
|
69
|
+
// Validation expects undefined when valid and a string as an error message when invalid
|
|
70
|
+
var handleValidation = useCallback( /*#__PURE__*/function () {
|
|
71
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(newUnvalidatedQlQuery) {
|
|
72
|
+
var isValid;
|
|
73
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
74
|
+
while (1) switch (_context.prev = _context.next) {
|
|
75
|
+
case 0:
|
|
76
|
+
if (newUnvalidatedQlQuery) {
|
|
77
|
+
_context.next = 2;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
return _context.abrupt("return", undefined);
|
|
81
|
+
case 2:
|
|
82
|
+
_context.next = 4;
|
|
83
|
+
return validateAqlText(newUnvalidatedQlQuery);
|
|
84
|
+
case 4:
|
|
85
|
+
isValid = _context.sent;
|
|
86
|
+
return _context.abrupt("return", isValid ? undefined : 'invalid');
|
|
87
|
+
case 6:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context.stop();
|
|
90
|
+
}
|
|
91
|
+
}, _callee);
|
|
92
|
+
}));
|
|
93
|
+
return function (_x) {
|
|
94
|
+
return _ref2.apply(this, arguments);
|
|
95
|
+
};
|
|
96
|
+
}(), [validateAqlText]);
|
|
97
|
+
|
|
98
|
+
/* Debounce async validation for input, validation is also called on every field change
|
|
99
|
+
in a form so we need to also memoize. The async validate function is expected to either:
|
|
100
|
+
Immediately return a promise (which is then collected into an array, every single time validation is run),
|
|
101
|
+
or immediately return either undefined or an error message */
|
|
102
|
+
var debouncedMemoizedValidation = function debouncedMemoizedValidation(value) {
|
|
103
|
+
return new Promise(function (resolve) {
|
|
104
|
+
if (timeout.current) {
|
|
105
|
+
timeout.current();
|
|
106
|
+
}
|
|
107
|
+
if (value !== lastValue.current) {
|
|
108
|
+
var timerId = setTimeout(function () {
|
|
109
|
+
lastValue.current = value;
|
|
110
|
+
lastResult.current = handleValidation(value);
|
|
111
|
+
resolve(lastResult.current);
|
|
112
|
+
}, SEARCH_DEBOUNCE_MS);
|
|
113
|
+
timeout.current = function () {
|
|
114
|
+
clearTimeout(timerId);
|
|
115
|
+
resolve('debouncing');
|
|
116
|
+
};
|
|
117
|
+
} else {
|
|
118
|
+
resolve(lastResult.current);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
return jsx(FieldContainer, null, jsx(Field, {
|
|
123
|
+
name: aqlKey,
|
|
124
|
+
defaultValue: value,
|
|
125
|
+
validate: debouncedMemoizedValidation
|
|
126
|
+
}, function (_ref3) {
|
|
127
|
+
var fieldProps = _ref3.fieldProps,
|
|
128
|
+
meta = _ref3.meta,
|
|
129
|
+
error = _ref3.error;
|
|
130
|
+
return jsx(Textfield, _extends({}, fieldProps, {
|
|
131
|
+
elemBeforeInput: jsx("span", {
|
|
132
|
+
style: {
|
|
133
|
+
paddingLeft: 6,
|
|
134
|
+
width: 24
|
|
135
|
+
}
|
|
136
|
+
}, renderValidatorIcon(fieldProps.value, error, meta)),
|
|
137
|
+
elemAfterInput: jsx(Button, {
|
|
138
|
+
appearance: "primary",
|
|
139
|
+
css: searchButtonStyles,
|
|
140
|
+
iconBefore: jsx(SearchIcon, {
|
|
141
|
+
label: formatMessage(searchInputMessages.placeholder),
|
|
142
|
+
size: "medium"
|
|
143
|
+
}),
|
|
144
|
+
spacing: "none",
|
|
145
|
+
testId: "assets-datasource-modal--aql-search-button",
|
|
146
|
+
type: "submit"
|
|
147
|
+
}),
|
|
148
|
+
placeholder: formatMessage(searchInputMessages.placeholder),
|
|
149
|
+
testId: testId
|
|
150
|
+
}));
|
|
151
|
+
}));
|
|
152
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { Skeleton } from '@atlaskit/linking-common';
|
|
4
|
+
export var AssetsAqlSearchInputSkeleton = function AssetsAqlSearchInputSkeleton() {
|
|
5
|
+
return jsx(Skeleton, {
|
|
6
|
+
width: "100%",
|
|
7
|
+
height: "40px",
|
|
8
|
+
testId: "assets-datasource-modal--aql-search-input-skeleton"
|
|
9
|
+
});
|
|
10
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export var searchInputMessages = defineMessages({
|
|
3
|
+
placeholder: {
|
|
4
|
+
id: 'linkDataSource.assets.configModal.aqlSearchInput.placeholder',
|
|
5
|
+
description: 'Display text for AQL search button',
|
|
6
|
+
defaultMessage: 'Search via AQL'
|
|
7
|
+
}
|
|
8
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import Form from '@atlaskit/form';
|
|
5
|
+
import { AqlSearchInput } from './aql-search-input';
|
|
6
|
+
import { AssetsObjectSchemaSelect } from './object-schema-select';
|
|
7
|
+
import { FormContainer, FormRowContainer, SchemaSelectContainer } from './styled';
|
|
8
|
+
var DEFAULT_AQL_QUERY = '';
|
|
9
|
+
var SEARCH_FORM_ID = 'linkDataSource.assets.configModal.searchContainer-form';
|
|
10
|
+
export var AssetsSearchContainer = function AssetsSearchContainer(props) {
|
|
11
|
+
var onSearch = props.onSearch,
|
|
12
|
+
workspaceId = props.workspaceId,
|
|
13
|
+
initialSearchData = props.initialSearchData,
|
|
14
|
+
modalTitle = props.modalTitle;
|
|
15
|
+
var onFormSubmit = function onFormSubmit(searchFormValues) {
|
|
16
|
+
var aql = searchFormValues.aql,
|
|
17
|
+
objectSchema = searchFormValues.objectSchema;
|
|
18
|
+
if (objectSchema) {
|
|
19
|
+
// Pass the validated aql and object schema back to modal
|
|
20
|
+
onSearch(aql, objectSchema.value);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return jsx(Form, {
|
|
24
|
+
onSubmit: onFormSubmit
|
|
25
|
+
}, function (_ref) {
|
|
26
|
+
var _initialSearchData$ob, _initialSearchData$aq;
|
|
27
|
+
var formProps = _ref.formProps;
|
|
28
|
+
return jsx(FormContainer, _extends({}, formProps, {
|
|
29
|
+
id: SEARCH_FORM_ID
|
|
30
|
+
}), jsx(FormRowContainer, {
|
|
31
|
+
isNarrowGap: true
|
|
32
|
+
}, modalTitle, jsx(SchemaSelectContainer, null, jsx(AssetsObjectSchemaSelect, {
|
|
33
|
+
value: (_initialSearchData$ob = initialSearchData.objectSchema) !== null && _initialSearchData$ob !== void 0 ? _initialSearchData$ob : undefined,
|
|
34
|
+
workspaceId: workspaceId,
|
|
35
|
+
classNamePrefix: "assets-datasource-modal--object-schema-select"
|
|
36
|
+
}))), jsx(FormRowContainer, null, jsx(AqlSearchInput, {
|
|
37
|
+
value: (_initialSearchData$aq = initialSearchData.aql) !== null && _initialSearchData$aq !== void 0 ? _initialSearchData$aq : DEFAULT_AQL_QUERY,
|
|
38
|
+
workspaceId: workspaceId
|
|
39
|
+
})));
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { AssetsAqlSearchInputSkeleton } from './aql-search-input/loading-state';
|
|
4
|
+
import { AssetsObjectSchemaSelectSkeleton } from './object-schema-select/loading-state';
|
|
5
|
+
import { FormContainer, FormRowContainer, SchemaSelectContainer } from './styled';
|
|
6
|
+
export var AssetsSearchContainerLoading = function AssetsSearchContainerLoading(_ref) {
|
|
7
|
+
var modalTitle = _ref.modalTitle;
|
|
8
|
+
return jsx(FormContainer, {
|
|
9
|
+
"data-testid": "assets-datasource-modal--search-container-skeleton"
|
|
10
|
+
}, jsx(FormRowContainer, {
|
|
11
|
+
isNarrowGap: true
|
|
12
|
+
}, modalTitle, jsx(SchemaSelectContainer, null, jsx(AssetsObjectSchemaSelectSkeleton, null))), jsx(FormRowContainer, null, jsx(AssetsAqlSearchInputSkeleton, null)));
|
|
13
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
|
+
var _excluded = ["onChange", "onFocus"];
|
|
6
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
+
/** @jsx jsx */
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
import { jsx } from '@emotion/react';
|
|
10
|
+
import debounce from 'debounce-promise';
|
|
11
|
+
import { useIntl } from 'react-intl-next';
|
|
12
|
+
import { Field } from '@atlaskit/form';
|
|
13
|
+
import { AsyncSelect } from '@atlaskit/select';
|
|
14
|
+
import { useObjectSchemas } from '../../../../hooks/useObjectSchemas';
|
|
15
|
+
import { objectSchemaKey } from '../../../../types/assets/types';
|
|
16
|
+
import { FieldContainer } from '../styled';
|
|
17
|
+
import { objectSchemaSelectMessages } from './messages';
|
|
18
|
+
import { objectSchemaToSelectOption } from './utils';
|
|
19
|
+
export var SEARCH_DEBOUNCE_MS = 350;
|
|
20
|
+
export var AssetsObjectSchemaSelect = function AssetsObjectSchemaSelect(_ref) {
|
|
21
|
+
var value = _ref.value,
|
|
22
|
+
workspaceId = _ref.workspaceId,
|
|
23
|
+
_ref$classNamePrefix = _ref.classNamePrefix,
|
|
24
|
+
classNamePrefix = _ref$classNamePrefix === void 0 ? 'assets-datasource-modal--object-schema-select' : _ref$classNamePrefix;
|
|
25
|
+
var _useIntl = useIntl(),
|
|
26
|
+
formatMessage = _useIntl.formatMessage;
|
|
27
|
+
var _useObjectSchemas = useObjectSchemas(workspaceId),
|
|
28
|
+
fetchObjectSchemas = _useObjectSchemas.fetchObjectSchemas,
|
|
29
|
+
objectSchemasLoading = _useObjectSchemas.objectSchemasLoading;
|
|
30
|
+
var _useState = useState(undefined),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
defaultOptions = _useState2[0],
|
|
33
|
+
setDefaultOptions = _useState2[1];
|
|
34
|
+
var selectedObjectSchema = value ? objectSchemaToSelectOption(value) : undefined;
|
|
35
|
+
var loadOptions = /*#__PURE__*/function () {
|
|
36
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(inputValue) {
|
|
37
|
+
var objectSchemas, options;
|
|
38
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
39
|
+
while (1) switch (_context.prev = _context.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
_context.next = 2;
|
|
42
|
+
return fetchObjectSchemas(inputValue);
|
|
43
|
+
case 2:
|
|
44
|
+
objectSchemas = _context.sent;
|
|
45
|
+
options = objectSchemas ? objectSchemas.map(function (objectSchema) {
|
|
46
|
+
return objectSchemaToSelectOption(objectSchema);
|
|
47
|
+
}) : [];
|
|
48
|
+
return _context.abrupt("return", options);
|
|
49
|
+
case 5:
|
|
50
|
+
case "end":
|
|
51
|
+
return _context.stop();
|
|
52
|
+
}
|
|
53
|
+
}, _callee);
|
|
54
|
+
}));
|
|
55
|
+
return function loadOptions(_x) {
|
|
56
|
+
return _ref2.apply(this, arguments);
|
|
57
|
+
};
|
|
58
|
+
}();
|
|
59
|
+
var debouncedLoadOptions = debounce(loadOptions, SEARCH_DEBOUNCE_MS);
|
|
60
|
+
var validateSchema = function validateSchema(value) {
|
|
61
|
+
if (!value || !value.value) {
|
|
62
|
+
return formatMessage(objectSchemaSelectMessages.schemaRequired);
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
};
|
|
66
|
+
return jsx(FieldContainer, null, jsx(Field, {
|
|
67
|
+
name: objectSchemaKey,
|
|
68
|
+
defaultValue: selectedObjectSchema,
|
|
69
|
+
validate: function validate(value) {
|
|
70
|
+
return validateSchema(value);
|
|
71
|
+
}
|
|
72
|
+
}, function (_ref3) {
|
|
73
|
+
var _ref3$fieldProps = _ref3.fieldProps,
|
|
74
|
+
_onChange = _ref3$fieldProps.onChange,
|
|
75
|
+
onFocus = _ref3$fieldProps.onFocus,
|
|
76
|
+
restFieldProps = _objectWithoutProperties(_ref3$fieldProps, _excluded);
|
|
77
|
+
return jsx(AsyncSelect, _extends({
|
|
78
|
+
classNamePrefix: classNamePrefix,
|
|
79
|
+
isLoading: objectSchemasLoading,
|
|
80
|
+
defaultOptions: defaultOptions || [],
|
|
81
|
+
isSearchable: true,
|
|
82
|
+
loadOptions: debouncedLoadOptions,
|
|
83
|
+
placeholder: formatMessage(objectSchemaSelectMessages.placeholder),
|
|
84
|
+
onChange: function onChange(newOption) {
|
|
85
|
+
return newOption && _onChange(newOption);
|
|
86
|
+
},
|
|
87
|
+
onFocus: function onFocus() {
|
|
88
|
+
if (!defaultOptions) {
|
|
89
|
+
loadOptions('').then(setDefaultOptions);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, restFieldProps));
|
|
93
|
+
}));
|
|
94
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { Skeleton } from '@atlaskit/linking-common';
|
|
4
|
+
export var AssetsObjectSchemaSelectSkeleton = function AssetsObjectSchemaSelectSkeleton() {
|
|
5
|
+
return jsx(Skeleton, {
|
|
6
|
+
width: "100%",
|
|
7
|
+
height: "40px",
|
|
8
|
+
testId: "assets-datasource-modal--object-schema-select-skeleton"
|
|
9
|
+
});
|
|
10
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export var objectSchemaSelectMessages = defineMessages({
|
|
3
|
+
label: {
|
|
4
|
+
id: 'linkDataSource.assets.configModal.objectSchemaSelect.label',
|
|
5
|
+
description: 'Label text for a select input where users can choose an Assets object schema to use',
|
|
6
|
+
defaultMessage: 'Select schema'
|
|
7
|
+
},
|
|
8
|
+
placeholder: {
|
|
9
|
+
id: 'linkDataSource.assets.configModal.objectSchemaSelect.placeholder',
|
|
10
|
+
description: 'Placeholder text for a select input where users can choose an Assets object schema to use',
|
|
11
|
+
defaultMessage: 'Select schema'
|
|
12
|
+
},
|
|
13
|
+
schemaRequired: {
|
|
14
|
+
id: 'linkDataSource.assets.configModal.objectSchemaSelect.schemaRequired',
|
|
15
|
+
description: 'Validation message displayed to the user when the select is blank',
|
|
16
|
+
defaultMessage: 'Schema is required'
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
3
|
+
import styled from '@emotion/styled';
|
|
4
|
+
export var FormRowContainer = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n align-items: center;\n display: flex;\n gap: ", ";\n flex-grow: 1;\n width: 100%;\n"])), function (props) {
|
|
5
|
+
return props.isNarrowGap ? "var(--ds-space-100, 8px)" : "var(--ds-space-200, 16px)";
|
|
6
|
+
});
|
|
7
|
+
export var FormContainer = styled.form(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: grid;\n row-gap: ", ";\n width: 100%;\n"])), "var(--ds-space-200, 16px)");
|
|
8
|
+
|
|
9
|
+
// Override the top margin of fields
|
|
10
|
+
export var FieldContainer = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n flex: 1;\n margin-top: calc(-1 * ", ");\n"])), "var(--ds-space-100, 8px)");
|
|
11
|
+
export var SchemaSelectContainer = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: 200px;\n"])));
|
package/dist/esm/version.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ObjectSchema } from '../types/assets/types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { AssetsDatasourceParameters } from '../ui/assets-modal/types';
|
|
3
|
+
export type UseAssetsClientState = {
|
|
4
|
+
workspaceId: string | undefined;
|
|
5
|
+
workspaceError: Error | undefined;
|
|
6
|
+
objectSchema: ObjectSchema | undefined;
|
|
7
|
+
assetsClientLoading: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const useAssetsClient: (initialParameters?: AssetsDatasourceParameters) => UseAssetsClientState;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ObjectSchema } from '../types/assets/types';
|
|
2
|
+
export type UseObjectSchemasState = {
|
|
3
|
+
objectSchemasLoading: boolean;
|
|
4
|
+
objectSchemasError: Error | undefined;
|
|
5
|
+
objectSchemas: ObjectSchema[] | undefined;
|
|
6
|
+
fetchObjectSchemas: (query: string) => Promise<ObjectSchema[] | undefined>;
|
|
7
|
+
};
|
|
8
|
+
export declare const useObjectSchemas: (workspaceId: string) => UseObjectSchemasState;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type UseValidateAqlTextState = {
|
|
2
|
+
validateAqlTextLoading: boolean;
|
|
3
|
+
validateAqlTextError: Error | undefined;
|
|
4
|
+
isValidAqlText: boolean;
|
|
2
5
|
validateAqlText: (aql: string) => Promise<boolean>;
|
|
3
|
-
isLoading: boolean;
|
|
4
6
|
};
|
|
7
|
+
export declare const useValidateAqlText: (workspaceId: string, hostname?: string) => UseValidateAqlTextState;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AqlValidateResponse, FetchObjectSchemasResponse } from '../types/assets/types';
|
|
2
|
-
export declare const getWorkspaceId: (
|
|
2
|
+
export declare const getWorkspaceId: () => Promise<string>;
|
|
3
3
|
export declare const validateAql: (workspaceId: string, data: {
|
|
4
4
|
qlQuery: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const
|
|
5
|
+
}) => Promise<AqlValidateResponse>;
|
|
6
|
+
export declare const fetchObjectSchema: (workspaceId: string, schemaId: string) => Promise<import("../types/assets/types").ObjectSchema>;
|
|
7
|
+
export declare const fetchObjectSchemas: (workspaceId: string, query?: string) => Promise<FetchObjectSchemasResponse>;
|
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type GetWorkspaceDetailsResponse = {
|
|
2
2
|
results: [
|
|
3
3
|
{
|
|
4
4
|
id: string;
|
|
5
5
|
}
|
|
6
6
|
];
|
|
7
|
-
}
|
|
8
|
-
export
|
|
9
|
-
id
|
|
10
|
-
name
|
|
11
|
-
}
|
|
12
|
-
export
|
|
7
|
+
};
|
|
8
|
+
export type ObjectSchema = {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export type ObjectSchemaOption = {
|
|
13
|
+
label: string;
|
|
14
|
+
value: string;
|
|
15
|
+
};
|
|
16
|
+
export type FetchObjectSchemaResponse = ObjectSchema;
|
|
17
|
+
export type FetchObjectSchemasResponse = {
|
|
13
18
|
startAt: number;
|
|
14
19
|
maxResults: number;
|
|
15
20
|
total: number;
|
|
16
21
|
values: ObjectSchema[];
|
|
17
22
|
isLast: boolean;
|
|
18
|
-
}
|
|
19
|
-
export
|
|
23
|
+
};
|
|
24
|
+
export type AqlValidateResponse = {
|
|
20
25
|
isValid: boolean;
|
|
21
26
|
errorMessages: string[];
|
|
22
27
|
errors: {};
|
|
23
|
-
}
|
|
28
|
+
};
|
|
29
|
+
export declare const objectSchemaKey: "objectSchema";
|
|
30
|
+
export declare const aqlKey: "aql";
|
|
31
|
+
export type SearchForm = {
|
|
32
|
+
[objectSchemaKey]: ObjectSchemaOption | undefined | null;
|
|
33
|
+
[aqlKey]: string;
|
|
34
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
export interface AqlSearchInputProps {
|
|
3
|
+
value: string;
|
|
4
|
+
workspaceId: string;
|
|
5
|
+
testId?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const SEARCH_DEBOUNCE_MS = 350;
|
|
8
|
+
export declare const AqlSearchInput: ({ value, workspaceId, testId, }: AqlSearchInputProps) => jsx.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { ObjectSchema } from '../../../types/assets/types';
|
|
5
|
+
type InitialSearchData = {
|
|
6
|
+
objectSchema?: ObjectSchema;
|
|
7
|
+
aql?: string;
|
|
8
|
+
};
|
|
9
|
+
export interface SearchContainerProps {
|
|
10
|
+
workspaceId: string;
|
|
11
|
+
initialSearchData: InitialSearchData;
|
|
12
|
+
onSearch: (aql: string, schemaId: string) => void;
|
|
13
|
+
modalTitle?: JSX.Element;
|
|
14
|
+
}
|
|
15
|
+
export declare const AssetsSearchContainer: (props: SearchContainerProps) => jsx.JSX.Element;
|
|
16
|
+
export {};
|