@gingkoo/pandora-metabase 1.0.158-alpha.2 → 1.0.158-alpha.21
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/lib/cjs/common/SplitView/index.js +2 -2
- package/lib/cjs/components/dialog/column-type-label/index.d.ts +8 -0
- package/lib/cjs/components/dialog/column-type-label/index.js +22 -0
- package/lib/cjs/components/dialog/column-type-label/index.less +17 -0
- package/lib/cjs/components/dialog/custom-column/config.js +2 -2
- package/lib/cjs/components/dialog/custom-column/expression-editor.js +1 -1
- package/lib/cjs/components/dialog/custom-column/expressions/suggest.js +2 -2
- package/lib/cjs/components/dialog/custom-column/expressions/tokenizer.js +2 -2
- package/lib/cjs/components/dialog/custom-column/index.js +2 -2
- package/lib/cjs/components/dialog/custom-column/tokenized-expression.js +6 -6
- package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +8 -8
- package/lib/cjs/components/dialog/custom-editor/index.js +4 -4
- package/lib/cjs/components/dialog/expression/date-format-picker.js +1 -1
- package/lib/cjs/components/dialog/expression/index.js +4 -4
- package/lib/cjs/components/dialog/formula/index.js +55 -14
- package/lib/cjs/components/dialog/formula/index.less +7 -0
- package/lib/cjs/components/dialog/formula/utils.js +5 -1
- package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.d.ts +3 -4
- package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.js +138 -214
- package/lib/cjs/components/dialog/formula-list/LogicGroup.js +55 -39
- package/lib/cjs/components/dialog/formula-list/index.d.ts +3 -0
- package/lib/cjs/components/dialog/formula-list/index.js +414 -321
- package/lib/cjs/components/dialog/formula-list/index.less +1012 -1105
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +16 -2
- package/lib/cjs/components/dialog/formula-list/utils.js +650 -131
- package/lib/cjs/components/dialog/select-column/index.js +10 -4
- package/lib/cjs/components/dialog/select-column/index.less +6 -1
- package/lib/cjs/components/dialog/select-column-multiple/index.js +12 -9
- package/lib/cjs/components/dialog/select-column-multiple/index.less +10 -0
- package/lib/cjs/components/dialog/select-join-column/index.js +9 -5
- package/lib/cjs/components/dialog/select-join-column/index.less +10 -0
- package/lib/cjs/components/dialog/select-join-column-multiple/index.js +10 -6
- package/lib/cjs/components/dialog/select-join-column-multiple/index.less +10 -0
- package/lib/cjs/components/dialog/select-permission-table/index.js +1 -1
- package/lib/cjs/components/dialog/select-summarize/index.js +2 -2
- package/lib/cjs/components/dialog/select-table/index.js +5 -5
- package/lib/cjs/components/icons.js +1 -1
- package/lib/cjs/components/metabase/index.js +129 -60
- package/lib/cjs/components/metabase/index.less +28 -29
- package/lib/cjs/components/modules/components/Wrapper.js +2 -2
- package/lib/cjs/components/modules/components/header.d.ts +2 -1
- package/lib/cjs/components/modules/components/header.js +7 -3
- package/lib/cjs/components/modules/components/item-wrapper.js +1 -1
- package/lib/cjs/components/modules/components/meta-icon.js +3 -5
- package/lib/cjs/components/modules/custom-column.js +7 -4
- package/lib/cjs/components/modules/filter.js +2 -2
- package/lib/cjs/components/modules/join-data.js +100 -21
- package/lib/cjs/components/modules/sort.js +6 -3
- package/lib/cjs/components/modules/summarize/group-by.js +10 -6
- package/lib/cjs/components/modules/summarize/select-index.js +12 -5
- package/lib/cjs/components/modules/table-data.js +50 -16
- package/lib/cjs/components/popup.js +7 -7
- package/lib/cjs/components/right-click-menu.js +3 -3
- package/lib/cjs/components/sql-syntax-confirm.d.ts +14 -0
- package/lib/cjs/components/sql-syntax-confirm.js +149 -0
- package/lib/cjs/enum.d.ts +1 -0
- package/lib/cjs/enum.js +16 -0
- package/lib/cjs/hooks/patch.js +1 -1
- package/lib/cjs/hooks/patch2.js +1 -1
- package/lib/cjs/hooks/use-state.js +118 -111
- package/lib/cjs/hooks/winsize.js +1 -1
- package/lib/cjs/index.d.ts +4 -2
- package/lib/cjs/index.js +14 -6
- package/lib/cjs/locale/en.js +35 -0
- package/lib/cjs/locale/zh.js +35 -0
- package/lib/cjs/prompt.d.ts +3 -0
- package/lib/cjs/prompt.js +262 -0
- package/lib/cjs/store/enum.d.ts +50 -0
- package/lib/cjs/store/enum.js +56 -2
- package/lib/cjs/store/helper.js +2 -2
- package/lib/cjs/store/types.d.ts +9 -52
- package/lib/cjs/store/types.js +25 -54
- package/lib/cjs/types.d.ts +6 -0
- package/lib/cjs/utils/event.js +3 -3
- package/lib/cjs/utils/helper.js +1 -1
- package/lib/cjs/utils/keydown.js +2 -2
- package/lib/cjs/utils/selection.js +1 -1
- package/lib/cjs/utils/storage.js +2 -2
- package/lib/cjs/utils/transformSql.d.ts +44 -1
- package/lib/cjs/utils/transformSql.js +1042 -29
- package/lib/cjs/utils.d.ts +3 -1
- package/lib/cjs/utils.js +82 -43
- package/lib/cjs/validate.d.ts +2 -0
- package/lib/cjs/validate.js +42 -0
- package/lib/es/components/dialog/column-type-label/index.d.ts +8 -0
- package/lib/es/components/dialog/column-type-label/index.js +16 -0
- package/lib/es/components/dialog/column-type-label/index.less +17 -0
- package/lib/es/components/dialog/expression/index.js +1 -1
- package/lib/es/components/dialog/formula/index.js +53 -12
- package/lib/es/components/dialog/formula/index.less +7 -0
- package/lib/es/components/dialog/formula/utils.js +5 -1
- package/lib/es/components/dialog/formula-list/CaseWhenGroup.d.ts +3 -4
- package/lib/es/components/dialog/formula-list/CaseWhenGroup.js +141 -217
- package/lib/es/components/dialog/formula-list/LogicGroup.js +54 -38
- package/lib/es/components/dialog/formula-list/index.d.ts +3 -0
- package/lib/es/components/dialog/formula-list/index.js +409 -316
- package/lib/es/components/dialog/formula-list/index.less +1012 -1105
- package/lib/es/components/dialog/formula-list/utils.d.ts +16 -2
- package/lib/es/components/dialog/formula-list/utils.js +646 -126
- package/lib/es/components/dialog/select-column/index.js +7 -1
- package/lib/es/components/dialog/select-column/index.less +6 -1
- package/lib/es/components/dialog/select-column-multiple/index.js +9 -6
- package/lib/es/components/dialog/select-column-multiple/index.less +10 -0
- package/lib/es/components/dialog/select-join-column/index.js +7 -3
- package/lib/es/components/dialog/select-join-column/index.less +10 -0
- package/lib/es/components/dialog/select-join-column-multiple/index.js +7 -3
- package/lib/es/components/dialog/select-join-column-multiple/index.less +10 -0
- package/lib/es/components/metabase/index.js +126 -57
- package/lib/es/components/metabase/index.less +28 -29
- package/lib/es/components/modules/components/header.d.ts +2 -1
- package/lib/es/components/modules/components/header.js +6 -2
- package/lib/es/components/modules/components/meta-icon.js +2 -4
- package/lib/es/components/modules/custom-column.js +4 -1
- package/lib/es/components/modules/join-data.js +98 -19
- package/lib/es/components/modules/sort.js +4 -1
- package/lib/es/components/modules/summarize/group-by.js +5 -1
- package/lib/es/components/modules/summarize/select-index.js +8 -1
- package/lib/es/components/modules/table-data.js +47 -13
- package/lib/es/components/sql-syntax-confirm.d.ts +14 -0
- package/lib/es/components/sql-syntax-confirm.js +142 -0
- package/lib/es/enum.d.ts +1 -0
- package/lib/es/enum.js +1 -0
- package/lib/es/hooks/use-state.js +112 -105
- package/lib/es/index.d.ts +4 -2
- package/lib/es/index.js +8 -6
- package/lib/es/locale/en.js +35 -0
- package/lib/es/locale/zh.js +35 -0
- package/lib/es/prompt.d.ts +3 -0
- package/lib/es/prompt.js +3 -0
- package/lib/es/store/enum.d.ts +50 -0
- package/lib/es/store/enum.js +55 -1
- package/lib/es/store/types.d.ts +9 -52
- package/lib/es/store/types.js +2 -53
- package/lib/es/types.d.ts +6 -0
- package/lib/es/utils/transformSql.d.ts +44 -1
- package/lib/es/utils/transformSql.js +1038 -25
- package/lib/es/utils.d.ts +3 -1
- package/lib/es/utils.js +76 -37
- package/lib/es/validate.d.ts +2 -0
- package/lib/es/validate.js +1 -0
- package/package.json +31 -1
- package/lib/cjs/components/dialog/diff-viewer/index copy.d.ts +0 -10
- package/lib/cjs/components/dialog/diff-viewer/index copy.js +0 -139
- package/lib/es/components/dialog/diff-viewer/index copy.d.ts +0 -10
- package/lib/es/components/dialog/diff-viewer/index copy.js +0 -132
|
@@ -6,15 +6,15 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
6
6
|
var _excluded = ["subToolbar", "notExistsColumns", "isExit", "toolbar"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { useEffect, useState } from 'react';
|
|
9
|
+
import { useEffect, useRef, useState } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import { Button, Tooltip, Input, Modal2, Modal, Toast, Dropdown, InputNumber } from '@gingkoo/pandora';
|
|
12
12
|
import { FfPlus, FfLine, Repeat, RelatedWork } from '@gingkoo/pandora-icons';
|
|
13
13
|
import Metabase from '../../index';
|
|
14
14
|
import cloneDeep from 'lodash/cloneDeep';
|
|
15
|
-
import { uuidv4, getAlias, mergeNameAlias, isSameTableByIdName } from '../../utils/helper';
|
|
15
|
+
import { uuidv4, getAlias, mergeNameAlias, isSameTableByIdFirst, isSameTableByIdName } from '../../utils/helper';
|
|
16
16
|
import { getTopLayerZIndex } from '../../utils/helper-dom';
|
|
17
|
-
import { getConstantLabel } from '../dialog/formula-list/utils';
|
|
17
|
+
import { getConstantLabel, findNestedMetaIssue } from '../dialog/formula-list/utils';
|
|
18
18
|
import { __ } from '../../locale';
|
|
19
19
|
import { findIndex, getSubColumns, mergeSubQueryColumns, syncSubQueryFieldReferences } from '../../utils';
|
|
20
20
|
import { TypeEnum, ColumnsPopupThemeEnum, JoinEnum, SQL_COLUMN_TYPE } from '../../store/enum';
|
|
@@ -82,18 +82,27 @@ var JoinData = function JoinData(props) {
|
|
|
82
82
|
var columnsSelected = meta.table1.name && meta.table2.name;
|
|
83
83
|
var _getHelper = getHelper(store.metaList[groupIndex].list, meta),
|
|
84
84
|
prevTables = _getHelper.prevTables,
|
|
85
|
-
prevGroupBy = _getHelper.prevGroupBy
|
|
85
|
+
prevGroupBy = _getHelper.prevGroupBy,
|
|
86
|
+
prevList = _getHelper.prevList;
|
|
87
|
+
var previousLayerItems = prevGroupBy ? prevList : store.metaList[groupIndex].list.slice(0, index);
|
|
88
|
+
var joinIndex = previousLayerItems.filter(function (item) {
|
|
89
|
+
return item.type === TypeEnum.joinData;
|
|
90
|
+
}).length + 1;
|
|
86
91
|
var _useState = useState(false),
|
|
87
92
|
_useState2 = _slicedToArray(_useState, 2),
|
|
88
93
|
isDel = _useState2[0],
|
|
89
94
|
setIsDel = _useState2[1];
|
|
95
|
+
var tableCheckId = useRef(0);
|
|
96
|
+
var tableSelectionId = useRef(0);
|
|
97
|
+
var tableMetaVersion = useRef(0);
|
|
90
98
|
var tableIsDel = function () {
|
|
91
99
|
var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
|
|
92
100
|
var _meta$table;
|
|
93
|
-
var tableInfo, tables;
|
|
101
|
+
var checkId, tableInfo, tables, _t;
|
|
94
102
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
95
103
|
while (1) switch (_context.prev = _context.next) {
|
|
96
104
|
case 0:
|
|
105
|
+
checkId = ++tableCheckId.current;
|
|
97
106
|
tableInfo = meta.table2;
|
|
98
107
|
if ((_meta$table = meta.table2) !== null && _meta$table !== void 0 && _meta$table.datasourceId) {
|
|
99
108
|
_context.next = 1;
|
|
@@ -102,31 +111,55 @@ var JoinData = function JoinData(props) {
|
|
|
102
111
|
setIsDel(false);
|
|
103
112
|
return _context.abrupt("return");
|
|
104
113
|
case 1:
|
|
114
|
+
_context.prev = 1;
|
|
105
115
|
_context.next = 2;
|
|
106
116
|
return store === null || store === void 0 ? void 0 : store.fetchDataset(meta.table2.datasourceId);
|
|
107
117
|
case 2:
|
|
108
118
|
tables = _context.sent;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
119
|
+
_context.next = 4;
|
|
120
|
+
break;
|
|
121
|
+
case 3:
|
|
122
|
+
_context.prev = 3;
|
|
123
|
+
_t = _context["catch"](1);
|
|
124
|
+
return _context.abrupt("return");
|
|
125
|
+
case 4:
|
|
126
|
+
if (!(!tables || !Array.isArray(tables))) {
|
|
127
|
+
_context.next = 5;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
return _context.abrupt("return");
|
|
131
|
+
case 5:
|
|
132
|
+
if (!(checkId !== tableCheckId.current)) {
|
|
133
|
+
_context.next = 6;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
return _context.abrupt("return");
|
|
137
|
+
case 6:
|
|
138
|
+
if (!tables.some(function (v) {
|
|
139
|
+
return isSameTableByIdFirst(tableInfo, v) || isSameTableByIdName(tableInfo, v);
|
|
140
|
+
})) {
|
|
112
141
|
setIsDel(true);
|
|
113
142
|
} else {
|
|
114
143
|
setIsDel(false);
|
|
115
144
|
}
|
|
116
|
-
case
|
|
145
|
+
case 7:
|
|
117
146
|
case "end":
|
|
118
147
|
return _context.stop();
|
|
119
148
|
}
|
|
120
|
-
}, _callee);
|
|
149
|
+
}, _callee, null, [[1, 3]]);
|
|
121
150
|
}));
|
|
122
151
|
return function tableIsDel() {
|
|
123
152
|
return _ref.apply(this, arguments);
|
|
124
153
|
};
|
|
125
154
|
}();
|
|
126
155
|
useEffect(function () {
|
|
156
|
+
tableMetaVersion.current += 1;
|
|
127
157
|
setTimeout(function () {
|
|
128
158
|
tableIsDel();
|
|
129
159
|
}, 0);
|
|
160
|
+
return function () {
|
|
161
|
+
tableMetaVersion.current += 1;
|
|
162
|
+
};
|
|
130
163
|
}, [meta]);
|
|
131
164
|
useEffect(function () {
|
|
132
165
|
var expressions = meta.expressions || [];
|
|
@@ -480,6 +513,7 @@ var JoinData = function JoinData(props) {
|
|
|
480
513
|
});
|
|
481
514
|
}
|
|
482
515
|
function selectTable(e) {
|
|
516
|
+
var selectionHandled = false;
|
|
483
517
|
var value = {
|
|
484
518
|
name: meta.table2.name,
|
|
485
519
|
name_zh: meta.table2.name_zh,
|
|
@@ -498,8 +532,14 @@ var JoinData = function JoinData(props) {
|
|
|
498
532
|
data: store.sourceList,
|
|
499
533
|
value: value,
|
|
500
534
|
onChange: function onChange(data) {
|
|
535
|
+
if (selectionHandled) return;
|
|
536
|
+
selectionHandled = true;
|
|
537
|
+
var selectionId = ++tableSelectionId.current;
|
|
538
|
+
var selectionMetaVersion = tableMetaVersion.current;
|
|
539
|
+
var selectionEditRequestId = store.getMetaEditRequestId();
|
|
501
540
|
var tableName = data.name;
|
|
502
|
-
|
|
541
|
+
var isSameTable = isSameTableByIdName(meta.table2, data);
|
|
542
|
+
if (!isSameTable) {
|
|
503
543
|
var _store$preProps;
|
|
504
544
|
var newMeta = cloneDeep(store.metaList[groupIndex].list);
|
|
505
545
|
var aliasMetaList = newMeta.filter(function (_, i) {
|
|
@@ -519,14 +559,18 @@ var JoinData = function JoinData(props) {
|
|
|
519
559
|
newMeta[index].table2 = _table2;
|
|
520
560
|
initExpressions(newMeta);
|
|
521
561
|
store.fetchColumns(_table2, data.datasourceId, [], function (columns) {
|
|
562
|
+
if (selectionId !== tableSelectionId.current) return;
|
|
563
|
+
if (selectionMetaVersion !== tableMetaVersion.current) return;
|
|
564
|
+
if (selectionEditRequestId !== store.getMetaEditRequestId()) return;
|
|
522
565
|
newMeta[index].columns = columns;
|
|
523
566
|
store.setMeta(newMeta, groupIndex, {
|
|
524
567
|
obj: data,
|
|
525
568
|
type: ChangeType.table2
|
|
526
569
|
});
|
|
527
570
|
});
|
|
571
|
+
} else {
|
|
572
|
+
tableIsDel();
|
|
528
573
|
}
|
|
529
|
-
setIsDel(false);
|
|
530
574
|
store.setPopup({
|
|
531
575
|
visible: false
|
|
532
576
|
});
|
|
@@ -572,7 +616,6 @@ var JoinData = function JoinData(props) {
|
|
|
572
616
|
}],
|
|
573
617
|
type: AtomsTypeEnum.JOIN_DEFAULT
|
|
574
618
|
}];
|
|
575
|
-
store.setMeta(newMeta, groupIndex);
|
|
576
619
|
}
|
|
577
620
|
function selectJoin(e) {
|
|
578
621
|
var newMeta = store.metaList[groupIndex].list.slice();
|
|
@@ -986,7 +1029,11 @@ var JoinData = function JoinData(props) {
|
|
|
986
1029
|
children: _jsx(Metabase, _objectSpread(_objectSpread({}, other), {}, {
|
|
987
1030
|
popupZIndex: childModalZIndex + 1,
|
|
988
1031
|
showSubquery: store._showSubquery,
|
|
1032
|
+
isExit: isExit,
|
|
1033
|
+
isSubquery: true,
|
|
989
1034
|
toolbar: _toolbar,
|
|
1035
|
+
subToolbar: subToolbar,
|
|
1036
|
+
sqlValidationQueryKind: 'query',
|
|
990
1037
|
btnText: __('SqlQueryBuilder.confirm'),
|
|
991
1038
|
value: cloneDeep(val),
|
|
992
1039
|
onOk: function onOk(newList) {
|
|
@@ -1133,6 +1180,7 @@ var JoinData = function JoinData(props) {
|
|
|
1133
1180
|
};
|
|
1134
1181
|
var addExpression = function addExpression(type) {
|
|
1135
1182
|
var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
|
|
1183
|
+
var before = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1136
1184
|
var index = findIndex(store.metaList[groupIndex].list, meta);
|
|
1137
1185
|
var newMeta = store.metaList[groupIndex].list.slice();
|
|
1138
1186
|
var item = getTemplateItem(type);
|
|
@@ -1175,7 +1223,12 @@ var JoinData = function JoinData(props) {
|
|
|
1175
1223
|
if (!item) {
|
|
1176
1224
|
return;
|
|
1177
1225
|
}
|
|
1178
|
-
if (i >= 0) {
|
|
1226
|
+
if (before && i >= 0) {
|
|
1227
|
+
newMeta[index].expressions.splice(i, 0, item, {
|
|
1228
|
+
val: 'AND',
|
|
1229
|
+
type: AtomsTypeEnum.OPERATOR
|
|
1230
|
+
});
|
|
1231
|
+
} else if (i >= 0) {
|
|
1179
1232
|
newMeta[index].expressions.splice(i + 1, 0, {
|
|
1180
1233
|
val: 'AND',
|
|
1181
1234
|
type: AtomsTypeEnum.OPERATOR
|
|
@@ -1329,6 +1382,31 @@ var JoinData = function JoinData(props) {
|
|
|
1329
1382
|
})
|
|
1330
1383
|
});
|
|
1331
1384
|
};
|
|
1385
|
+
var renderPrependExpressionButton = function renderPrependExpressionButton(expressionIndex) {
|
|
1386
|
+
if (expressionIndex !== 0 || store.snapshotMode) {
|
|
1387
|
+
return null;
|
|
1388
|
+
}
|
|
1389
|
+
return _jsx(Tooltip, {
|
|
1390
|
+
title: __('SqlQueryBuilder.add'),
|
|
1391
|
+
children: _jsx(Dropdown, {
|
|
1392
|
+
trigger: ['click'],
|
|
1393
|
+
onChange: function onChange(key) {
|
|
1394
|
+
addExpression(key, expressionIndex, true);
|
|
1395
|
+
},
|
|
1396
|
+
droplist: menuTypes,
|
|
1397
|
+
children: _jsx(Button, {
|
|
1398
|
+
disabled: meta.readonly,
|
|
1399
|
+
primary: true,
|
|
1400
|
+
ghost: true,
|
|
1401
|
+
className: 'ml-2 mr-2 operator-icon',
|
|
1402
|
+
icon: _jsx(FfPlus, {})
|
|
1403
|
+
})
|
|
1404
|
+
})
|
|
1405
|
+
});
|
|
1406
|
+
};
|
|
1407
|
+
var nestedSubqueryIssue = meta.isSubquery ? findNestedMetaIssue(meta.subquery, 0, {
|
|
1408
|
+
requireOutputFields: true
|
|
1409
|
+
}) : null;
|
|
1332
1410
|
return _jsx(Wrapper, {
|
|
1333
1411
|
className: cx("Sqb-item"),
|
|
1334
1412
|
children: _jsxs("div", {
|
|
@@ -1337,6 +1415,7 @@ var JoinData = function JoinData(props) {
|
|
|
1337
1415
|
meta: meta,
|
|
1338
1416
|
groupIndex: groupIndex,
|
|
1339
1417
|
title: __('SqlQueryBuilder.joinData'),
|
|
1418
|
+
index: joinIndex,
|
|
1340
1419
|
onClose: function onClose() {
|
|
1341
1420
|
return store.delMeta(meta, groupIndex);
|
|
1342
1421
|
}
|
|
@@ -1384,8 +1463,8 @@ var JoinData = function JoinData(props) {
|
|
|
1384
1463
|
}
|
|
1385
1464
|
})
|
|
1386
1465
|
}), meta.isSubquery ? _jsx(ItemName, {
|
|
1387
|
-
isError: !store.tableEnableAlias && tableIsError(),
|
|
1388
|
-
message: __(isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias'),
|
|
1466
|
+
isError: Boolean(nestedSubqueryIssue === null || nestedSubqueryIssue === void 0 ? void 0 : nestedSubqueryIssue.isError) || !store.tableEnableAlias && tableIsError(),
|
|
1467
|
+
message: nestedSubqueryIssue !== null && nestedSubqueryIssue !== void 0 && nestedSubqueryIssue.isError ? __('metabase.sqlErrorOpenNested') : __(isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias'),
|
|
1389
1468
|
children: _jsx(RightClickValue, {
|
|
1390
1469
|
value: meta,
|
|
1391
1470
|
children: _jsxs("div", {
|
|
@@ -1479,7 +1558,7 @@ var JoinData = function JoinData(props) {
|
|
|
1479
1558
|
children: [i == 0 && _jsx("span", {
|
|
1480
1559
|
className: 'ml-2 mr-4 text-gray-500',
|
|
1481
1560
|
children: "on"
|
|
1482
|
-
}), renderItem(v.lhs, ExpressionsEnum.LEFT, i), renderSwitchTypeButton(ExpressionsEnum.LEFT, i), _jsx("span", {
|
|
1561
|
+
}), renderPrependExpressionButton(i), renderItem(v.lhs, ExpressionsEnum.LEFT, i), renderSwitchTypeButton(ExpressionsEnum.LEFT, i), _jsx("span", {
|
|
1483
1562
|
className: 'mr-2 text-gray-500',
|
|
1484
1563
|
children: "="
|
|
1485
1564
|
}), renderItem(v.rhs, ExpressionsEnum.RIGHT, i), renderSwitchTypeButton(ExpressionsEnum.RIGHT, i), !store.snapshotMode && _jsx(Tooltip, {
|
|
@@ -1540,7 +1619,7 @@ var JoinData = function JoinData(props) {
|
|
|
1540
1619
|
children: [i == 0 && _jsx("span", {
|
|
1541
1620
|
className: 'ml-2 mr-4 text-gray-500',
|
|
1542
1621
|
children: "on"
|
|
1543
|
-
}), _jsx(ItemName, {
|
|
1622
|
+
}), renderPrependExpressionButton(i), _jsx(ItemName, {
|
|
1544
1623
|
isError: isError(v, getTableColumns()),
|
|
1545
1624
|
children: _jsx(RightClickValue, {
|
|
1546
1625
|
value: v,
|
|
@@ -1591,7 +1670,7 @@ var JoinData = function JoinData(props) {
|
|
|
1591
1670
|
children: [i == 0 && _jsx("span", {
|
|
1592
1671
|
className: 'ml-2 mr-4 text-gray-500',
|
|
1593
1672
|
children: "on"
|
|
1594
|
-
}), _jsx(FormulaList, {
|
|
1673
|
+
}), renderPrependExpressionButton(i), _jsx(FormulaList, {
|
|
1595
1674
|
_type: FormulaTypeEnum.JOIN_DATA,
|
|
1596
1675
|
otherTypes: (_store$preProps5 = store.preProps) === null || _store$preProps5 === void 0 ? void 0 : _store$preProps5.otherTypes,
|
|
1597
1676
|
value: v.list,
|
|
@@ -4,6 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
import cx from 'classnames';
|
|
5
5
|
import { __ } from '../../locale';
|
|
6
6
|
import { findIndex, getHelper, isError } from '../../utils';
|
|
7
|
+
import { getAtomListIssue } from '../dialog/formula-list/utils';
|
|
7
8
|
import { ColumnsPopupThemeEnum, TypeEnum, SortEnum, SQL_COLUMN_TYPE } from '../../store/enum';
|
|
8
9
|
import { AtomsTypeEnum } from '../../store/types';
|
|
9
10
|
import { uuidv4 } from '../../utils/helper';
|
|
@@ -191,8 +192,10 @@ var Sort = function Sort(props) {
|
|
|
191
192
|
children: _jsxs("div", {
|
|
192
193
|
className: cx("Sqb-NotebookCell gray-bg"),
|
|
193
194
|
children: [sort.map(function (v, i) {
|
|
195
|
+
var atomIssue = getAtomListIssue(v.expression);
|
|
194
196
|
return _jsx(ItemName, {
|
|
195
|
-
isError: isError(v.expression, getColumns()),
|
|
197
|
+
isError: atomIssue.isError || isError(v.expression, getColumns()),
|
|
198
|
+
message: atomIssue.isError ? __('metabase.sqlErrorOpenNested') : undefined,
|
|
196
199
|
children: _jsx(RightClickValue, {
|
|
197
200
|
value: v,
|
|
198
201
|
children: _jsxs("div", {
|
|
@@ -18,6 +18,7 @@ import ItemName from '../components/item-name';
|
|
|
18
18
|
import RightClickValue from '../../right-click-value';
|
|
19
19
|
import { AddIcon, CloseIcon } from '../../icons';
|
|
20
20
|
import FormulaList from '../../dialog/formula-list';
|
|
21
|
+
import { getAtomListIssue } from '../../dialog/formula-list/utils';
|
|
21
22
|
import { useStore } from '../../../hooks/use-provider';
|
|
22
23
|
import cloneDeep from 'lodash/cloneDeep';
|
|
23
24
|
import { summarizeByToSql } from '../../../store/helper';
|
|
@@ -519,8 +520,11 @@ var GroupBy = function GroupBy(props) {
|
|
|
519
520
|
children: [meta.by.map(function (v, i) {
|
|
520
521
|
var existsError = isExistsError([getErrorCheckField(v)], store.existsError);
|
|
521
522
|
var aliasError = !isValidSQLAlias(v === null || v === void 0 ? void 0 : v.fieldAlias);
|
|
523
|
+
var atomIssue = getAtomListIssue(getAtomsValue(v));
|
|
524
|
+
var chipError = atomIssue.isError || existsError && !store.groupByEnableAlias;
|
|
522
525
|
return _jsx(ItemName, {
|
|
523
|
-
isError:
|
|
526
|
+
isError: chipError,
|
|
527
|
+
message: atomIssue.isError ? atomIssue.error || __('metabase.sqlErrorOpenNested') : undefined,
|
|
524
528
|
children: _jsx(RightClickValue, {
|
|
525
529
|
value: v,
|
|
526
530
|
children: _jsxs("div", {
|
|
@@ -13,6 +13,7 @@ import { Tooltip, Button, Modal, Input, Toast } from '@gingkoo/pandora';
|
|
|
13
13
|
import { uuidv4 } from '../../../utils/helper';
|
|
14
14
|
import { MetaSummarize_Enum, AtomsTypeEnum, ChangeType } from '../../../store/types';
|
|
15
15
|
import { changeFieldAlias, isExistsError, isValidSQLAlias } from '../../../utils';
|
|
16
|
+
import { getAtomListIssue } from '../../dialog/formula-list/utils';
|
|
16
17
|
import ItemName from '../components/item-name';
|
|
17
18
|
import RightClickValue from '../../right-click-value';
|
|
18
19
|
import { AddIcon, CloseIcon } from '../../icons';
|
|
@@ -413,8 +414,14 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
413
414
|
children: [meta.group.map(function (v, i) {
|
|
414
415
|
var existsError = isExistsError([getErrorCheckField(v)], store.existsError);
|
|
415
416
|
var aliasError = !isValidSQLAlias(v === null || v === void 0 ? void 0 : v.fieldAlias);
|
|
417
|
+
var atomIssue = isFormulaMetric(v) ? getAtomListIssue(getAtomsValue(v)) : {
|
|
418
|
+
isError: false,
|
|
419
|
+
error: undefined
|
|
420
|
+
};
|
|
421
|
+
var chipError = atomIssue.isError || existsError && !store.groupByEnableAlias;
|
|
416
422
|
return _jsx(ItemName, {
|
|
417
|
-
isError:
|
|
423
|
+
isError: chipError,
|
|
424
|
+
message: atomIssue.isError ? __('metabase.sqlErrorOpenNested') : undefined,
|
|
418
425
|
children: _jsx(RightClickValue, {
|
|
419
426
|
value: v,
|
|
420
427
|
children: _jsxs("div", {
|
|
@@ -6,13 +6,13 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
6
6
|
var _excluded = ["subToolbar", "notExistsColumns", "isExit", "toolbar"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { useEffect, useState } from 'react';
|
|
9
|
+
import { useEffect, useRef, useState } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import { __ } from '../../locale';
|
|
12
12
|
import { ChangeType } from '../../store/types';
|
|
13
13
|
import { Tooltip, Button, Modal, Modal2, Input, Toast } from '@gingkoo/pandora';
|
|
14
14
|
import Metabase from '../../index';
|
|
15
|
-
import { uuidv4, getAlias, isSameTableByIdName } from '../../utils/helper';
|
|
15
|
+
import { uuidv4, getAlias, isSameTableByIdFirst, isSameTableByIdName } from '../../utils/helper';
|
|
16
16
|
import { getTopLayerZIndex } from '../../utils/helper-dom';
|
|
17
17
|
import { changeTableAlias, getSubColumns, mergeSubQueryColumns, isValidSQLAlias, isExistsError, syncSubQueryFieldReferences } from '../../utils';
|
|
18
18
|
import { RelatedWork } from '@gingkoo/pandora-icons';
|
|
@@ -20,6 +20,7 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
20
20
|
import ItemName from './components/item-name';
|
|
21
21
|
import RightClickValue from '../right-click-value';
|
|
22
22
|
import { SelectTable, SelectColumn } from '../dialog';
|
|
23
|
+
import { findNestedMetaIssue } from '../dialog/formula-list/utils';
|
|
23
24
|
import Wrapper from './components/Wrapper';
|
|
24
25
|
import NextDom from './components/meta-icon';
|
|
25
26
|
import Header from './components/header';
|
|
@@ -36,13 +37,15 @@ var TableData = function TableData(props) {
|
|
|
36
37
|
_useState2 = _slicedToArray(_useState, 2),
|
|
37
38
|
isDel = _useState2[0],
|
|
38
39
|
setIsDel = _useState2[1];
|
|
40
|
+
var tableCheckId = useRef(0);
|
|
39
41
|
var tableIsDel = function () {
|
|
40
42
|
var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
|
|
41
43
|
var _meta$table;
|
|
42
|
-
var tableInfo, tables;
|
|
44
|
+
var checkId, tableInfo, tables;
|
|
43
45
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
44
46
|
while (1) switch (_context.prev = _context.next) {
|
|
45
47
|
case 0:
|
|
48
|
+
checkId = ++tableCheckId.current;
|
|
46
49
|
tableInfo = meta.table;
|
|
47
50
|
if (meta !== null && meta !== void 0 && (_meta$table = meta.table) !== null && _meta$table !== void 0 && _meta$table.datasourceId) {
|
|
48
51
|
_context.next = 1;
|
|
@@ -55,14 +58,26 @@ var TableData = function TableData(props) {
|
|
|
55
58
|
return store === null || store === void 0 ? void 0 : store.fetchDataset(meta.table.datasourceId);
|
|
56
59
|
case 2:
|
|
57
60
|
tables = _context.sent;
|
|
58
|
-
if (!(tables
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
if (!(!tables || !Array.isArray(tables))) {
|
|
62
|
+
_context.next = 3;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
return _context.abrupt("return");
|
|
66
|
+
case 3:
|
|
67
|
+
if (!(checkId !== tableCheckId.current)) {
|
|
68
|
+
_context.next = 4;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
return _context.abrupt("return");
|
|
72
|
+
case 4:
|
|
73
|
+
if (!tables.some(function (v) {
|
|
74
|
+
return isSameTableByIdFirst(tableInfo, v) || isSameTableByIdName(tableInfo, v);
|
|
75
|
+
})) {
|
|
61
76
|
setIsDel(true);
|
|
62
77
|
} else {
|
|
63
78
|
setIsDel(false);
|
|
64
79
|
}
|
|
65
|
-
case
|
|
80
|
+
case 5:
|
|
66
81
|
case "end":
|
|
67
82
|
return _context.stop();
|
|
68
83
|
}
|
|
@@ -87,7 +102,8 @@ var TableData = function TableData(props) {
|
|
|
87
102
|
sourceTable: store.sourceTable || [],
|
|
88
103
|
value: meta.table,
|
|
89
104
|
onChange: function onChange(data) {
|
|
90
|
-
|
|
105
|
+
var isSameTable = isSameTableByIdName(meta.table, data);
|
|
106
|
+
if (!isSameTable) {
|
|
91
107
|
var _store$preProps;
|
|
92
108
|
var newMetaList = store.metaList[groupIndex].list.slice()[0];
|
|
93
109
|
newMetaList.table = _objectSpread(_objectSpread({}, data), {}, {
|
|
@@ -103,11 +119,12 @@ var TableData = function TableData(props) {
|
|
|
103
119
|
type: ChangeType.datasource
|
|
104
120
|
});
|
|
105
121
|
});
|
|
122
|
+
} else {
|
|
123
|
+
tableIsDel();
|
|
106
124
|
}
|
|
107
125
|
store.setPopup({
|
|
108
126
|
visible: false
|
|
109
127
|
});
|
|
110
|
-
setIsDel(false);
|
|
111
128
|
}
|
|
112
129
|
})
|
|
113
130
|
});
|
|
@@ -200,7 +217,11 @@ var TableData = function TableData(props) {
|
|
|
200
217
|
children: _jsx(Metabase, _objectSpread(_objectSpread({}, other), {}, {
|
|
201
218
|
popupZIndex: childModalZIndex + 1,
|
|
202
219
|
showSubquery: store._showSubquery,
|
|
220
|
+
isExit: isExit,
|
|
221
|
+
isSubquery: true,
|
|
203
222
|
toolbar: _toolbar,
|
|
223
|
+
subToolbar: subToolbar,
|
|
224
|
+
sqlValidationQueryKind: 'query',
|
|
204
225
|
btnText: __('SqlQueryBuilder.confirm'),
|
|
205
226
|
value: cloneDeep(val),
|
|
206
227
|
onOk: function onOk(newList) {
|
|
@@ -275,6 +296,9 @@ var TableData = function TableData(props) {
|
|
|
275
296
|
}
|
|
276
297
|
return false;
|
|
277
298
|
};
|
|
299
|
+
var nestedSubqueryIssue = meta.isSubquery ? findNestedMetaIssue(meta.subquery, 0, {
|
|
300
|
+
requireOutputFields: true
|
|
301
|
+
}) : null;
|
|
278
302
|
return _jsx(Wrapper, {
|
|
279
303
|
className: "Sqb-item",
|
|
280
304
|
children: _jsxs("div", {
|
|
@@ -292,8 +316,8 @@ var TableData = function TableData(props) {
|
|
|
292
316
|
children: _jsxs("div", {
|
|
293
317
|
className: "Sqb-NotebookCell",
|
|
294
318
|
children: [meta.isSubquery ? _jsx(ItemName, {
|
|
295
|
-
isError: isExistsError(meta.subquery || [], store.existsError) || !store.tableEnableAlias && tableIsError(),
|
|
296
|
-
message: !store.tableEnableAlias && tableIsError() ? __(isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias') : undefined,
|
|
319
|
+
isError: Boolean(nestedSubqueryIssue === null || nestedSubqueryIssue === void 0 ? void 0 : nestedSubqueryIssue.isError) || isExistsError(meta.subquery || [], store.existsError) || !store.tableEnableAlias && tableIsError(),
|
|
320
|
+
message: nestedSubqueryIssue !== null && nestedSubqueryIssue !== void 0 && nestedSubqueryIssue.isError ? __('metabase.sqlErrorOpenNested') : !store.tableEnableAlias && tableIsError() ? __(isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias') : undefined,
|
|
297
321
|
children: _jsx(RightClickValue, {
|
|
298
322
|
value: meta,
|
|
299
323
|
children: _jsxs("div", {
|
|
@@ -381,10 +405,20 @@ var TableData = function TableData(props) {
|
|
|
381
405
|
onClick: switchSubQuery
|
|
382
406
|
})
|
|
383
407
|
}), selected && store.showFields && (!store.isExit || store.isSubquery) && ((_store$showMainColumn = store.showMainColumn[groupIndex]) === null || _store$showMainColumn === void 0 ? void 0 : _store$showMainColumn.showColumn) && _jsx("div", {
|
|
384
|
-
className:
|
|
408
|
+
className: cx('Sqb-TableColumns', {
|
|
409
|
+
isError: !(meta.columns || []).some(function (column) {
|
|
410
|
+
return column.select;
|
|
411
|
+
})
|
|
412
|
+
}),
|
|
385
413
|
"data-sqb-snapshot-allow": 'true',
|
|
386
414
|
onClick: selectColumns,
|
|
387
|
-
children:
|
|
415
|
+
children: _jsx(ItemName, {
|
|
416
|
+
isError: !(meta.columns || []).some(function (column) {
|
|
417
|
+
return column.select;
|
|
418
|
+
}),
|
|
419
|
+
message: __('metabase.sqlErrorEmptyOutputFields'),
|
|
420
|
+
children: __('SqlQueryBuilder.columns')
|
|
421
|
+
})
|
|
388
422
|
})]
|
|
389
423
|
})
|
|
390
424
|
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SqlValidationIssue } from '../utils/transformSql';
|
|
2
|
+
export declare const confirmSyntaxIssues: (issues: SqlValidationIssue[] | undefined, onOk: () => void | Promise<void>, descriptionKey?: string, extraMessages?: string[]) => void | Promise<void>;
|
|
3
|
+
export declare const toSyntaxIssues: (result?: {
|
|
4
|
+
isError?: boolean;
|
|
5
|
+
issues?: SqlValidationIssue[];
|
|
6
|
+
code?: string;
|
|
7
|
+
error?: string;
|
|
8
|
+
}) => SqlValidationIssue[];
|
|
9
|
+
export declare const mergeSyntaxIssues: (...results: Array<{
|
|
10
|
+
isError?: boolean;
|
|
11
|
+
issues?: SqlValidationIssue[];
|
|
12
|
+
code?: string;
|
|
13
|
+
error?: string;
|
|
14
|
+
} | undefined>) => SqlValidationIssue[];
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Modal } from '@gingkoo/pandora';
|
|
4
|
+
import { __ } from '../locale';
|
|
5
|
+
import { SQL_VALIDATION_I18N_KEYS } from '../utils/transformSql';
|
|
6
|
+
var getIssueMessage = function getIssueMessage(code) {
|
|
7
|
+
return __(SQL_VALIDATION_I18N_KEYS[code] || code);
|
|
8
|
+
};
|
|
9
|
+
var ISSUE_PATH_I18N_KEYS = {
|
|
10
|
+
data: 'SqlQueryBuilder.data',
|
|
11
|
+
joinData: 'SqlQueryBuilder.joinData',
|
|
12
|
+
customColumn: 'SqlQueryBuilder.customColumn',
|
|
13
|
+
filter: 'SqlQueryBuilder.filter',
|
|
14
|
+
summarize: 'SqlQueryBuilder.summarize',
|
|
15
|
+
sort: 'SqlQueryBuilder.sort',
|
|
16
|
+
rowLimit: 'SqlQueryBuilder.rowLimit',
|
|
17
|
+
union: 'SqlQueryBuilder.union',
|
|
18
|
+
subquery: 'SqlQueryBuilder.subquery'
|
|
19
|
+
};
|
|
20
|
+
var getIssuePath = function getIssuePath(issue) {
|
|
21
|
+
return (issue.path || []).filter(function (item) {
|
|
22
|
+
return item.type !== 'group';
|
|
23
|
+
}).map(function (item) {
|
|
24
|
+
var label = item.type === 'exists' ? 'EXISTS' : item.type === 'notExists' ? 'NOT EXISTS' : __(ISSUE_PATH_I18N_KEYS[item.type] || item.type);
|
|
25
|
+
return label;
|
|
26
|
+
}).join(' > ');
|
|
27
|
+
};
|
|
28
|
+
var UNCERTAIN_CODES = new Set(['clause', 'dangling-operator', 'generation']);
|
|
29
|
+
var POPUP_PATH_TYPES = new Set(['subquery', 'exists', 'notExists']);
|
|
30
|
+
var collapsePopupIssues = function collapsePopupIssues(issues) {
|
|
31
|
+
var collapsed = issues.map(function (issue) {
|
|
32
|
+
var path = issue.path || [];
|
|
33
|
+
var popupIndex = path.findIndex(function (item) {
|
|
34
|
+
return POPUP_PATH_TYPES.has(item.type);
|
|
35
|
+
});
|
|
36
|
+
if (popupIndex < 0) return issue;
|
|
37
|
+
return _objectSpread(_objectSpread({}, issue), {}, {
|
|
38
|
+
path: path.slice(0, popupIndex + 1),
|
|
39
|
+
code: 'open-nested'
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
var seen = new Set();
|
|
43
|
+
return collapsed.filter(function (issue) {
|
|
44
|
+
var key = "".concat(issue.code, "|").concat((issue.path || []).map(function (item) {
|
|
45
|
+
var _item$metaKey;
|
|
46
|
+
return "".concat(item.type, ":").concat((_item$metaKey = item.metaKey) !== null && _item$metaKey !== void 0 ? _item$metaKey : '');
|
|
47
|
+
}).join('/'));
|
|
48
|
+
if (seen.has(key)) return false;
|
|
49
|
+
seen.add(key);
|
|
50
|
+
return true;
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
var filterDisplayIssues = function filterDisplayIssues(issues) {
|
|
54
|
+
var collapsed = collapsePopupIssues(issues);
|
|
55
|
+
var hasLocatedIssue = collapsed.some(function (issue) {
|
|
56
|
+
var _issue$path;
|
|
57
|
+
return (_issue$path = issue.path) === null || _issue$path === void 0 ? void 0 : _issue$path.length;
|
|
58
|
+
});
|
|
59
|
+
var hasEmptyOutputFields = collapsed.some(function (issue) {
|
|
60
|
+
return issue.code === 'empty-output-fields';
|
|
61
|
+
});
|
|
62
|
+
return collapsed.filter(function (issue) {
|
|
63
|
+
var _issue$path2;
|
|
64
|
+
if (UNCERTAIN_CODES.has(issue.code)) return false;
|
|
65
|
+
if (hasLocatedIssue && !((_issue$path2 = issue.path) !== null && _issue$path2 !== void 0 && _issue$path2.length)) return false;
|
|
66
|
+
if (issue.code === 'select-list' && hasEmptyOutputFields) return false;
|
|
67
|
+
return true;
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
var renderIssues = function renderIssues(issues, descriptionKey) {
|
|
71
|
+
var extraMessages = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
72
|
+
return _jsxs("div", {
|
|
73
|
+
children: [_jsx("div", {
|
|
74
|
+
children: __(descriptionKey)
|
|
75
|
+
}), issues.length || extraMessages.length ? _jsxs("ul", {
|
|
76
|
+
style: {
|
|
77
|
+
margin: '8px 0 0',
|
|
78
|
+
paddingLeft: 20
|
|
79
|
+
},
|
|
80
|
+
children: [issues.map(function (issue) {
|
|
81
|
+
var issuePath = getIssuePath(issue);
|
|
82
|
+
var key = "".concat(issue.code, "-").concat((issue.path || []).map(function (item) {
|
|
83
|
+
var _item$metaKey2, _item$index;
|
|
84
|
+
return "".concat(item.type, "-").concat((_item$metaKey2 = item.metaKey) !== null && _item$metaKey2 !== void 0 ? _item$metaKey2 : '', "-").concat((_item$index = item.index) !== null && _item$index !== void 0 ? _item$index : '');
|
|
85
|
+
}).join('-'));
|
|
86
|
+
return _jsxs("li", {
|
|
87
|
+
children: [issuePath ? "".concat(issuePath, "\uFF1A") : '', getIssueMessage(issue.code)]
|
|
88
|
+
}, key);
|
|
89
|
+
}), extraMessages.map(function (message, index) {
|
|
90
|
+
return _jsx("li", {
|
|
91
|
+
children: message
|
|
92
|
+
}, "extra-".concat(index));
|
|
93
|
+
})]
|
|
94
|
+
}) : null]
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
export var confirmSyntaxIssues = function confirmSyntaxIssues() {
|
|
98
|
+
var issues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
99
|
+
var onOk = arguments.length > 1 ? arguments[1] : undefined;
|
|
100
|
+
var descriptionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'metabase.validationSqlSave';
|
|
101
|
+
var extraMessages = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
102
|
+
var displayIssues = filterDisplayIssues(issues);
|
|
103
|
+
var displayExtras = displayIssues.length ? [] : extraMessages;
|
|
104
|
+
if (!displayIssues.length && !displayExtras.length) {
|
|
105
|
+
return onOk();
|
|
106
|
+
}
|
|
107
|
+
Modal.confirm({
|
|
108
|
+
title: __('metabase.prompt'),
|
|
109
|
+
content: renderIssues(displayIssues, descriptionKey, displayExtras),
|
|
110
|
+
onOk: onOk
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
export var toSyntaxIssues = function toSyntaxIssues(result) {
|
|
114
|
+
var _result$issues;
|
|
115
|
+
if (result !== null && result !== void 0 && (_result$issues = result.issues) !== null && _result$issues !== void 0 && _result$issues.length) return result.issues;
|
|
116
|
+
if (result !== null && result !== void 0 && result.isError && result.code) {
|
|
117
|
+
return [{
|
|
118
|
+
code: result.code,
|
|
119
|
+
severity: 'warning'
|
|
120
|
+
}];
|
|
121
|
+
}
|
|
122
|
+
return [];
|
|
123
|
+
};
|
|
124
|
+
export var mergeSyntaxIssues = function mergeSyntaxIssues() {
|
|
125
|
+
for (var _len = arguments.length, results = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
126
|
+
results[_key] = arguments[_key];
|
|
127
|
+
}
|
|
128
|
+
var issues = results.flatMap(function (result) {
|
|
129
|
+
return toSyntaxIssues(result);
|
|
130
|
+
});
|
|
131
|
+
var getIssueKey = function getIssueKey(issue) {
|
|
132
|
+
return "".concat(issue.code, "|").concat((issue.path || []).map(function (item) {
|
|
133
|
+
var _item$metaKey3, _item$index2;
|
|
134
|
+
return "".concat(item.type, ":").concat((_item$metaKey3 = item.metaKey) !== null && _item$metaKey3 !== void 0 ? _item$metaKey3 : '', ":").concat((_item$index2 = item.index) !== null && _item$index2 !== void 0 ? _item$index2 : '');
|
|
135
|
+
}).join('/'));
|
|
136
|
+
};
|
|
137
|
+
return issues.filter(function (issue, index, list) {
|
|
138
|
+
return list.findIndex(function (item) {
|
|
139
|
+
return getIssueKey(item) === getIssueKey(issue);
|
|
140
|
+
}) === index;
|
|
141
|
+
});
|
|
142
|
+
};
|
package/lib/es/enum.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './store/enum';
|
package/lib/es/enum.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './store/enum';
|