@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
|
@@ -16,6 +16,7 @@ import { useStore } from '../../../hooks/use-provider';
|
|
|
16
16
|
import { getColumnIdFirstKey, isSameColumnByIdFirst, uuidv4 } from '../../../utils/helper';
|
|
17
17
|
import { changeFieldAlias, isValidSQLAlias } from '../../../utils';
|
|
18
18
|
import { SearchIcon } from '../../icons';
|
|
19
|
+
import ColumnTypeLabel from '../column-type-label';
|
|
19
20
|
var SelectColumn = function SelectColumn(_ref) {
|
|
20
21
|
var _ref$data = _ref.data,
|
|
21
22
|
data = _ref$data === void 0 ? [] : _ref$data,
|
|
@@ -227,7 +228,12 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
227
228
|
children: _jsx(SelectIcon, {})
|
|
228
229
|
}) : _jsx("div", {
|
|
229
230
|
className: 'no-select mr-2'
|
|
230
|
-
}),
|
|
231
|
+
}), _jsxs("span", {
|
|
232
|
+
className: 'Sqb-SelectColumn-name',
|
|
233
|
+
children: [v.name, v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
|
|
234
|
+
}), _jsx(ColumnTypeLabel, {
|
|
235
|
+
column: v
|
|
236
|
+
}), store.fieldEnableAlias && !readonly && _jsx(Tooltip, {
|
|
231
237
|
title: __('SqlQueryBuilder.alias'),
|
|
232
238
|
children: _jsx(Button, {
|
|
233
239
|
className: ':Sqb-TableName-as',
|
|
@@ -37,9 +37,14 @@
|
|
|
37
37
|
}
|
|
38
38
|
.Sqb-TableName-as {
|
|
39
39
|
// font-size: 16px;
|
|
40
|
-
margin-left:
|
|
40
|
+
margin-left: 8px;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
.Sqb-SelectColumn-name {
|
|
44
|
+
flex: 1 1 auto;
|
|
45
|
+
min-width: 0;
|
|
46
|
+
overflow-wrap: anywhere;
|
|
47
|
+
}
|
|
43
48
|
.Sqb-SelectColumn--header {
|
|
44
49
|
position: sticky;
|
|
45
50
|
top: 0;
|
|
@@ -14,6 +14,7 @@ import { SummarizeAlias } from '../../../store/helper';
|
|
|
14
14
|
import { AtomsTypeEnum } from '../../../store/types';
|
|
15
15
|
import { __ } from '../../../locale';
|
|
16
16
|
import { NUMBER_GROUP, DATE_GROUP } from '../const';
|
|
17
|
+
import ColumnTypeLabel from '../column-type-label';
|
|
17
18
|
import { useStore } from '../../../hooks/use-provider';
|
|
18
19
|
import { replaceTpl, mergeNameAlias, uuidv4 } from '../../../utils/helper';
|
|
19
20
|
import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2 } from '../../icons';
|
|
@@ -265,9 +266,8 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
265
266
|
return matchedColumn ? syncSelectedFieldByColumn(field, matchedColumn, tableItem) : field;
|
|
266
267
|
});
|
|
267
268
|
setValue(syncedValue);
|
|
268
|
-
if (!readonly && !isEqual(syncedValue, _value || [])) {
|
|
269
|
-
|
|
270
|
-
(_ref2 = onValueSync || onSelect) === null || _ref2 === void 0 || _ref2(syncedValue, getQuotes(syncedValue));
|
|
269
|
+
if (!readonly && onValueSync && !isEqual(syncedValue, _value || [])) {
|
|
270
|
+
onValueSync(syncedValue, getQuotes(syncedValue));
|
|
271
271
|
}
|
|
272
272
|
}, [data, _value, onValueSync]);
|
|
273
273
|
var changeValue = function changeValue(tableUuid, val) {
|
|
@@ -503,11 +503,14 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
503
503
|
children: [_jsx("span", {
|
|
504
504
|
className: 'List-item-icon',
|
|
505
505
|
children: IconMap[special_type || database_type] || _jsx(LetterAaIcon, {})
|
|
506
|
-
}),
|
|
507
|
-
|
|
506
|
+
}), _jsxs("div", {
|
|
507
|
+
className: 'List-item-content',
|
|
508
|
+
children: [_jsxs("h4", {
|
|
508
509
|
className: 'List-item-title ml-2',
|
|
509
510
|
children: [replaceTpl(store.fieldNameTpl, v), v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
|
|
510
|
-
})
|
|
511
|
+
}), _jsx(ColumnTypeLabel, {
|
|
512
|
+
column: v
|
|
513
|
+
})]
|
|
511
514
|
})]
|
|
512
515
|
})
|
|
513
516
|
})
|
|
@@ -23,6 +23,16 @@
|
|
|
23
23
|
align-items: center;
|
|
24
24
|
color: #b8bbc3;
|
|
25
25
|
}
|
|
26
|
+
.List-item-content {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
min-width: 0;
|
|
30
|
+
width: 100%;
|
|
31
|
+
.List-item-title {
|
|
32
|
+
flex: 1 1 auto;
|
|
33
|
+
min-width: 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
26
36
|
.List-item-title {
|
|
27
37
|
word-break: break-word;
|
|
28
38
|
word-wrap: anywhere;
|
|
@@ -10,6 +10,7 @@ import { ColumnsPopupThemeEnum, SQL_GROUP_TYPE } from '../../../store/enum';
|
|
|
10
10
|
import { SummarizeAlias } from '../../../store/helper';
|
|
11
11
|
import { __ } from '../../../locale';
|
|
12
12
|
import { NUMBER_GROUP, DATE_GROUP } from '../const';
|
|
13
|
+
import ColumnTypeLabel from '../column-type-label';
|
|
13
14
|
import { useStore } from '../../../hooks/use-provider';
|
|
14
15
|
import { getColumnIdFirstKey, isSameColumnByIdName, replaceTpl, mergeNameAlias } from '../../../utils/helper';
|
|
15
16
|
import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2, RightArrowIcon } from '../../icons';
|
|
@@ -308,11 +309,14 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
308
309
|
children: [_jsx("span", {
|
|
309
310
|
className: 'List-item-icon',
|
|
310
311
|
children: IconMap[special_type || database_type] || _jsx(LetterAaIcon, {})
|
|
311
|
-
}),
|
|
312
|
-
|
|
312
|
+
}), _jsxs("div", {
|
|
313
|
+
className: 'List-item-content',
|
|
314
|
+
children: [_jsx("h4", {
|
|
313
315
|
className: 'List-item-title ml-2',
|
|
314
316
|
children: replaceTpl(store.fieldNameTpl, v)
|
|
315
|
-
})
|
|
317
|
+
}), _jsx(ColumnTypeLabel, {
|
|
318
|
+
column: v
|
|
319
|
+
})]
|
|
316
320
|
})]
|
|
317
321
|
}), OPEN_GROUP && isGroup && groupe !== SQL_GROUP_TYPE.STRING && _jsx(Popover, {
|
|
318
322
|
placement: 'rt',
|
|
@@ -23,6 +23,16 @@
|
|
|
23
23
|
align-items: center;
|
|
24
24
|
color: #b8bbc3;
|
|
25
25
|
}
|
|
26
|
+
.List-item-content {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
min-width: 0;
|
|
30
|
+
width: 100%;
|
|
31
|
+
.List-item-title {
|
|
32
|
+
flex: 1 1 auto;
|
|
33
|
+
min-width: 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
26
36
|
.List-item-title {
|
|
27
37
|
word-break: break-word;
|
|
28
38
|
word-wrap: anywhere;
|
|
@@ -10,6 +10,7 @@ import { ColumnsPopupThemeEnum, SQL_GROUP_TYPE } from '../../../store/enum';
|
|
|
10
10
|
import { SummarizeAlias } from '../../../store/helper';
|
|
11
11
|
import { __ } from '../../../locale';
|
|
12
12
|
import { NUMBER_GROUP, DATE_GROUP } from '../const';
|
|
13
|
+
import ColumnTypeLabel from '../column-type-label';
|
|
13
14
|
import { useStore } from '../../../hooks/use-provider';
|
|
14
15
|
import { getColumnIdFirstKey, isSameColumnByIdName, replaceTpl, mergeNameAlias } from '../../../utils/helper';
|
|
15
16
|
import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2 } from '../../icons';
|
|
@@ -244,11 +245,14 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
244
245
|
children: [_jsx("span", {
|
|
245
246
|
className: 'List-item-icon',
|
|
246
247
|
children: IconMap[special_type || database_type] || _jsx(LetterAaIcon, {})
|
|
247
|
-
}),
|
|
248
|
-
|
|
248
|
+
}), _jsxs("div", {
|
|
249
|
+
className: 'List-item-content',
|
|
250
|
+
children: [_jsx("h4", {
|
|
249
251
|
className: 'List-item-title ml-2',
|
|
250
252
|
children: replaceTpl(store.fieldNameTpl, v)
|
|
251
|
-
})
|
|
253
|
+
}), _jsx(ColumnTypeLabel, {
|
|
254
|
+
column: v
|
|
255
|
+
})]
|
|
252
256
|
})]
|
|
253
257
|
})
|
|
254
258
|
})
|
|
@@ -23,6 +23,16 @@
|
|
|
23
23
|
align-items: center;
|
|
24
24
|
color: #b8bbc3;
|
|
25
25
|
}
|
|
26
|
+
.List-item-content {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
min-width: 0;
|
|
30
|
+
width: 100%;
|
|
31
|
+
.List-item-title {
|
|
32
|
+
flex: 1 1 auto;
|
|
33
|
+
min-width: 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
26
36
|
.List-item-title {
|
|
27
37
|
word-break: break-word;
|
|
28
38
|
word-wrap: anywhere;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
3
4
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
4
5
|
var _templateObject;
|
|
5
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
@@ -17,10 +18,55 @@ import Popup from '../popup';
|
|
|
17
18
|
import { useStore } from '../../hooks/use-provider';
|
|
18
19
|
import storage from '../../utils/storage';
|
|
19
20
|
import SqbRightClickMenu, { openSqbRightClickMenu } from '../right-click-menu';
|
|
21
|
+
import { validateMetabaseConfig } from '../../utils/transformSql';
|
|
22
|
+
import { confirmSyntaxIssues } from '../sql-syntax-confirm';
|
|
20
23
|
var VisualBox = Styled.div.attrs({
|
|
21
24
|
className: 'visual-box scroller'
|
|
22
25
|
})(_templateObject || (_templateObject = _taggedTemplateLiteral([""])));
|
|
23
26
|
var EMPTY_ARRAY = [];
|
|
27
|
+
var findJoinRelationConflict = function findJoinRelationConflict(metaList) {
|
|
28
|
+
var _iterator = _createForOfIteratorHelper(metaList),
|
|
29
|
+
_step;
|
|
30
|
+
try {
|
|
31
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
32
|
+
var group = _step.value;
|
|
33
|
+
if (group.type !== 'group') continue;
|
|
34
|
+
var joinKeys = new Set();
|
|
35
|
+
var _iterator2 = _createForOfIteratorHelper(group.list || []),
|
|
36
|
+
_step2;
|
|
37
|
+
try {
|
|
38
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
39
|
+
var item = _step2.value;
|
|
40
|
+
if (item.type !== 'joinData' || !item.table1 || !item.table2) continue;
|
|
41
|
+
var key = "".concat(item.table1.id || '', "_").concat(item.table2.id || '', "_").concat(item.table2.name || '');
|
|
42
|
+
if (joinKeys.has(key)) {
|
|
43
|
+
return {
|
|
44
|
+
table1: item.table1,
|
|
45
|
+
table2: item.table2
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
joinKeys.add(key);
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
_iterator2.e(err);
|
|
52
|
+
} finally {
|
|
53
|
+
_iterator2.f();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} catch (err) {
|
|
57
|
+
_iterator.e(err);
|
|
58
|
+
} finally {
|
|
59
|
+
_iterator.f();
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
};
|
|
63
|
+
var formatTableName = function formatTableName(table) {
|
|
64
|
+
var _table$name, _table$name_zh;
|
|
65
|
+
var name = (_table$name = table.name) === null || _table$name === void 0 ? void 0 : _table$name.trim();
|
|
66
|
+
var nameZh = (_table$name_zh = table.name_zh) === null || _table$name_zh === void 0 ? void 0 : _table$name_zh.trim();
|
|
67
|
+
if (nameZh && name && nameZh !== name) return "".concat(nameZh, "\uFF08").concat(name, "\uFF09");
|
|
68
|
+
return nameZh || name || '未命名表';
|
|
69
|
+
};
|
|
24
70
|
var Metabase = function Metabase(props) {
|
|
25
71
|
var _props$btnText = props.btnText,
|
|
26
72
|
btnText = _props$btnText === void 0 ? '' : _props$btnText,
|
|
@@ -32,7 +78,13 @@ var Metabase = function Metabase(props) {
|
|
|
32
78
|
popupZIndex = props.popupZIndex,
|
|
33
79
|
_props$rightClickMenu = props.rightClickMenu,
|
|
34
80
|
rightClickMenu = _props$rightClickMenu === void 0 ? EMPTY_ARRAY : _props$rightClickMenu,
|
|
35
|
-
onRightClickMenuClick = props.onRightClickMenuClick
|
|
81
|
+
onRightClickMenuClick = props.onRightClickMenuClick,
|
|
82
|
+
_props$sqlDialect = props.sqlDialect,
|
|
83
|
+
sqlDialect = _props$sqlDialect === void 0 ? 'mysql' : _props$sqlDialect,
|
|
84
|
+
_props$sqlValidationE = props.sqlValidationEnabled,
|
|
85
|
+
sqlValidationEnabled = _props$sqlValidationE === void 0 ? true : _props$sqlValidationE,
|
|
86
|
+
_props$sqlValidationQ = props.sqlValidationQueryKind,
|
|
87
|
+
sqlValidationQueryKind = _props$sqlValidationQ === void 0 ? 'query' : _props$sqlValidationQ;
|
|
36
88
|
var store = useStore();
|
|
37
89
|
var readonlyMode = readonly || store.snapshotMode;
|
|
38
90
|
var _useState = useState(false),
|
|
@@ -58,30 +110,57 @@ var Metabase = function Metabase(props) {
|
|
|
58
110
|
return content;
|
|
59
111
|
}, [store.popupData2]);
|
|
60
112
|
var onCheck = function onCheck() {
|
|
61
|
-
|
|
62
|
-
|
|
113
|
+
if (store.joinAliasConflictCheck) {
|
|
114
|
+
var conflict = findJoinRelationConflict(store.metaList);
|
|
115
|
+
if (conflict) {
|
|
116
|
+
Toast.warning("\u5173\u8054\u91CD\u590D\uFF1A\u5DE6\u8868\u300C".concat(formatTableName(conflict.table1), "\u300D\u4E0E\u53F3\u8868\u300C").concat(formatTableName(conflict.table2), "\u300D\u5DF2\u5B58\u5728\u5173\u8054\uFF0C\u4E0D\u80FD\u4FDD\u5B58"));
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
var container = store.popupContainer.current;
|
|
121
|
+
var doms = container ? container.querySelectorAll('.isError') : [];
|
|
122
|
+
var isSqlError = container ? container.querySelectorAll('.isSqlError') : [];
|
|
123
|
+
var sqlIssues = sqlValidationEnabled ? validateMetabaseConfig(normalizeLegacySummarizeForSave(splitByUnion(store.metaList)), sqlDialect, {
|
|
124
|
+
queryKind: sqlValidationQueryKind
|
|
125
|
+
}).issues : [];
|
|
126
|
+
var extraMessages = [];
|
|
127
|
+
if (!sqlIssues.length) {
|
|
128
|
+
if (isSqlError.length) extraMessages.push(__('metabase.sqlErrorFormula'));
|
|
129
|
+
if (doms.length) extraMessages.push(__('metabase.sqlErrorUi'));
|
|
130
|
+
}
|
|
131
|
+
var confirmSave = function () {
|
|
132
|
+
var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
|
|
133
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
134
|
+
while (1) switch (_context.prev = _context.next) {
|
|
135
|
+
case 0:
|
|
136
|
+
_context.next = 1;
|
|
137
|
+
return onSave();
|
|
138
|
+
case 1:
|
|
139
|
+
case "end":
|
|
140
|
+
return _context.stop();
|
|
141
|
+
}
|
|
142
|
+
}, _callee);
|
|
143
|
+
}));
|
|
144
|
+
return function confirmSave() {
|
|
145
|
+
return _ref.apply(this, arguments);
|
|
146
|
+
};
|
|
147
|
+
}();
|
|
148
|
+
if (sqlIssues.length) {
|
|
149
|
+
var hasConfigIssue = sqlIssues.some(function (issue) {
|
|
150
|
+
return issue.severity === 'error';
|
|
151
|
+
});
|
|
152
|
+
confirmSyntaxIssues(sqlIssues, confirmSave, hasConfigIssue ? 'metabase.validationConfigSave' : 'metabase.validationSqlSave');
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (extraMessages.length > 1) {
|
|
156
|
+
confirmSyntaxIssues([], confirmSave, 'metabase.validationConfigSave', extraMessages);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
63
159
|
if (isSqlError.length) {
|
|
64
160
|
Modal.confirm({
|
|
65
161
|
title: __('metabase.prompt'),
|
|
66
162
|
content: __('metabase.validationFormulaSave'),
|
|
67
|
-
onOk:
|
|
68
|
-
var _onOk = _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
|
|
69
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
70
|
-
while (1) switch (_context.prev = _context.next) {
|
|
71
|
-
case 0:
|
|
72
|
-
_context.next = 1;
|
|
73
|
-
return onSave();
|
|
74
|
-
case 1:
|
|
75
|
-
case "end":
|
|
76
|
-
return _context.stop();
|
|
77
|
-
}
|
|
78
|
-
}, _callee);
|
|
79
|
-
}));
|
|
80
|
-
function onOk() {
|
|
81
|
-
return _onOk.apply(this, arguments);
|
|
82
|
-
}
|
|
83
|
-
return onOk;
|
|
84
|
-
}()
|
|
163
|
+
onOk: confirmSave
|
|
85
164
|
});
|
|
86
165
|
return;
|
|
87
166
|
}
|
|
@@ -89,65 +168,55 @@ var Metabase = function Metabase(props) {
|
|
|
89
168
|
Modal.confirm({
|
|
90
169
|
title: __('metabase.prompt'),
|
|
91
170
|
content: __('metabase.validationFailed'),
|
|
92
|
-
onOk:
|
|
93
|
-
var _onOk2 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2() {
|
|
94
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
95
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
96
|
-
case 0:
|
|
97
|
-
_context2.next = 1;
|
|
98
|
-
return onSave();
|
|
99
|
-
case 1:
|
|
100
|
-
case "end":
|
|
101
|
-
return _context2.stop();
|
|
102
|
-
}
|
|
103
|
-
}, _callee2);
|
|
104
|
-
}));
|
|
105
|
-
function onOk() {
|
|
106
|
-
return _onOk2.apply(this, arguments);
|
|
107
|
-
}
|
|
108
|
-
return onOk;
|
|
109
|
-
}()
|
|
171
|
+
onOk: confirmSave
|
|
110
172
|
});
|
|
111
|
-
|
|
112
|
-
onSave();
|
|
173
|
+
return;
|
|
113
174
|
}
|
|
175
|
+
confirmSave();
|
|
114
176
|
};
|
|
115
177
|
var onSave = function () {
|
|
116
|
-
var
|
|
178
|
+
var _ref2 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2() {
|
|
117
179
|
var intercept, _metaList;
|
|
118
|
-
return _regeneratorRuntime.wrap(function (
|
|
119
|
-
while (1) switch (
|
|
180
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
181
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
120
182
|
case 0:
|
|
121
183
|
intercept = false;
|
|
122
184
|
_metaList = normalizeLegacySummarizeForSave(splitByUnion(store.metaList));
|
|
123
185
|
_metaList[0].patchVersion = '1.1.0';
|
|
124
|
-
store.metaList.
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
|
|
186
|
+
store.metaList.forEach(function (v) {
|
|
187
|
+
var _dataMeta$table, _dataMeta$subquery;
|
|
188
|
+
if (v.type === 'union') return;
|
|
189
|
+
var dataMeta = (v.list || []).find(function (item) {
|
|
190
|
+
if ((item === null || item === void 0 ? void 0 : item.type) !== 'data') return false;
|
|
191
|
+
return !item.hidden;
|
|
192
|
+
});
|
|
193
|
+
if (!dataMeta) return;
|
|
194
|
+
var hasTable = Boolean((_dataMeta$table = dataMeta.table) === null || _dataMeta$table === void 0 ? void 0 : _dataMeta$table.name);
|
|
195
|
+
var hasSubquery = Boolean(dataMeta.isSubquery && ((_dataMeta$subquery = dataMeta.subquery) === null || _dataMeta$subquery === void 0 ? void 0 : _dataMeta$subquery.length));
|
|
196
|
+
if (!hasTable && !hasSubquery) {
|
|
128
197
|
intercept = true;
|
|
129
|
-
|
|
198
|
+
Toast.warning(__('data.pleaseSelectDataTable'));
|
|
130
199
|
}
|
|
131
200
|
});
|
|
132
201
|
if (!(saveLoading || intercept)) {
|
|
133
|
-
|
|
202
|
+
_context2.next = 1;
|
|
134
203
|
break;
|
|
135
204
|
}
|
|
136
|
-
return
|
|
205
|
+
return _context2.abrupt("return", null);
|
|
137
206
|
case 1:
|
|
138
207
|
setSaveLoading(true);
|
|
139
|
-
|
|
208
|
+
_context2.next = 2;
|
|
140
209
|
return onOk === null || onOk === void 0 ? void 0 : onOk(_metaList);
|
|
141
210
|
case 2:
|
|
142
211
|
setSaveLoading(false);
|
|
143
212
|
case 3:
|
|
144
213
|
case "end":
|
|
145
|
-
return
|
|
214
|
+
return _context2.stop();
|
|
146
215
|
}
|
|
147
|
-
},
|
|
216
|
+
}, _callee2);
|
|
148
217
|
}));
|
|
149
218
|
return function onSave() {
|
|
150
|
-
return
|
|
219
|
+
return _ref2.apply(this, arguments);
|
|
151
220
|
};
|
|
152
221
|
}();
|
|
153
222
|
useEffect(function () {
|
|
@@ -256,7 +325,7 @@ var Metabase = function Metabase(props) {
|
|
|
256
325
|
className: 'Sqb-fun-btns',
|
|
257
326
|
children: copy()
|
|
258
327
|
}), store.metaList.map(function (v, index) {
|
|
259
|
-
var _v$
|
|
328
|
+
var _v$list;
|
|
260
329
|
if (v.type === 'union' && v.union) {
|
|
261
330
|
return _jsx("div", {
|
|
262
331
|
className: cx("Sqb-list"),
|
|
@@ -273,7 +342,7 @@ var Metabase = function Metabase(props) {
|
|
|
273
342
|
className: cx("Sqb-list"),
|
|
274
343
|
onMouseDownCapture: stopReadonlyInteraction,
|
|
275
344
|
onClickCapture: stopReadonlyInteraction,
|
|
276
|
-
children: v === null || v === void 0 || (_v$
|
|
345
|
+
children: v === null || v === void 0 || (_v$list = v.list) === null || _v$list === void 0 ? void 0 : _v$list.map(function (meta) {
|
|
277
346
|
var metaType = meta.type,
|
|
278
347
|
metaKey = meta.metaKey,
|
|
279
348
|
hidden = meta.hidden;
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
background-color: #fff;
|
|
17
17
|
}
|
|
18
18
|
.Sqb {
|
|
19
|
-
padding:
|
|
19
|
+
--sqb-padding-x: 20px;
|
|
20
|
+
padding: 0 var(--sqb-padding-x) 50px;
|
|
20
21
|
position: relative;
|
|
21
22
|
&-right-click-menu {
|
|
22
23
|
position: fixed;
|
|
@@ -54,18 +55,18 @@
|
|
|
54
55
|
}
|
|
55
56
|
&-fun-btns {
|
|
56
57
|
position: absolute;
|
|
57
|
-
left: 0;
|
|
58
58
|
top: 2px;
|
|
59
|
+
right: var(--sqb-padding-x);
|
|
60
|
+
left: var(--sqb-padding-x);
|
|
59
61
|
display: flex;
|
|
60
|
-
justify-content: end;
|
|
61
|
-
width:
|
|
62
|
+
justify-content: flex-end;
|
|
63
|
+
width: auto;
|
|
62
64
|
}
|
|
63
65
|
&-list {
|
|
64
66
|
padding-top: 1.5rem;
|
|
65
67
|
.Sqb-item-check {
|
|
66
68
|
display: flex;
|
|
67
69
|
align-items: center;
|
|
68
|
-
width: 66.6667%;
|
|
69
70
|
.pd-Checkbox-text {
|
|
70
71
|
width: 100%;
|
|
71
72
|
|
|
@@ -89,12 +90,18 @@
|
|
|
89
90
|
font-size: 14px;
|
|
90
91
|
&--text {
|
|
91
92
|
color: rgb(80, 158, 227);
|
|
92
|
-
width: 66.6667%;
|
|
93
93
|
box-sizing: border-box;
|
|
94
94
|
margin-bottom: 8px;
|
|
95
95
|
display: flex;
|
|
96
96
|
align-items: center;
|
|
97
97
|
font-weight: 600;
|
|
98
|
+
|
|
99
|
+
.Sqb-item--index {
|
|
100
|
+
margin-left: 12px;
|
|
101
|
+
color: #7f8c98;
|
|
102
|
+
font-weight: 500;
|
|
103
|
+
}
|
|
104
|
+
|
|
98
105
|
&.purple-text {
|
|
99
106
|
color: rgb(113, 114, 173);
|
|
100
107
|
}
|
|
@@ -122,28 +129,8 @@
|
|
|
122
129
|
}
|
|
123
130
|
}
|
|
124
131
|
&--content {
|
|
125
|
-
width: 66.6667%;
|
|
126
132
|
box-sizing: border-box;
|
|
127
133
|
|
|
128
|
-
.sqb-Custom-input {
|
|
129
|
-
border-radius: 0;
|
|
130
|
-
padding: 0;
|
|
131
|
-
border-top: 0;
|
|
132
|
-
border-left: 0;
|
|
133
|
-
border-right: 0;
|
|
134
|
-
border: 0;
|
|
135
|
-
background: none !important;
|
|
136
|
-
.pd-Input,
|
|
137
|
-
.pd-Input-inner-wrapper {
|
|
138
|
-
border-radius: 0;
|
|
139
|
-
padding: 0;
|
|
140
|
-
border-top: 0;
|
|
141
|
-
border-left: 0;
|
|
142
|
-
border-right: 0;
|
|
143
|
-
border: 0;
|
|
144
|
-
background: none !important;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
134
|
.Sqb-Filter-item {
|
|
148
135
|
--sqb-item-shell-margin-x: 14px;
|
|
149
136
|
--sqb-action-size: 12px;
|
|
@@ -172,7 +159,10 @@
|
|
|
172
159
|
cursor: pointer;
|
|
173
160
|
pointer-events: none;
|
|
174
161
|
transform: translateY(-50%) scale(0.86);
|
|
175
|
-
transition:
|
|
162
|
+
transition:
|
|
163
|
+
opacity 160ms ease,
|
|
164
|
+
border-color 160ms ease,
|
|
165
|
+
background-color 160ms ease,
|
|
176
166
|
transform 160ms ease;
|
|
177
167
|
|
|
178
168
|
&::before {
|
|
@@ -186,7 +176,9 @@
|
|
|
186
176
|
background: transparent;
|
|
187
177
|
box-shadow: none;
|
|
188
178
|
transform: translateY(-50%);
|
|
189
|
-
transition:
|
|
179
|
+
transition:
|
|
180
|
+
border-color 160ms ease,
|
|
181
|
+
background-color 160ms ease;
|
|
190
182
|
}
|
|
191
183
|
|
|
192
184
|
img {
|
|
@@ -269,6 +261,11 @@
|
|
|
269
261
|
-webkit-box-align: center;
|
|
270
262
|
align-items: center;
|
|
271
263
|
gap: 8px 14px;
|
|
264
|
+
|
|
265
|
+
&.Sqb-NotebookCell--pasteable {
|
|
266
|
+
--sqb-paste-gap: 8px;
|
|
267
|
+
gap: 8px var(--sqb-paste-gap);
|
|
268
|
+
}
|
|
272
269
|
border-radius: 8px;
|
|
273
270
|
background-color: rgba(80, 158, 227, 0.1);
|
|
274
271
|
|
|
@@ -289,7 +286,9 @@
|
|
|
289
286
|
border-radius: 5px;
|
|
290
287
|
color: white;
|
|
291
288
|
background-color: rgb(80, 158, 227);
|
|
292
|
-
transition:
|
|
289
|
+
transition:
|
|
290
|
+
background 300ms linear 0s,
|
|
291
|
+
border 300ms linear 0s;
|
|
293
292
|
box-sizing: border-box;
|
|
294
293
|
margin: 0;
|
|
295
294
|
padding: 4px 7px;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface HeaderProps {
|
|
3
|
-
title:
|
|
3
|
+
title: React.ReactNode;
|
|
4
4
|
className?: string;
|
|
5
5
|
onClose?: Function;
|
|
6
6
|
moduleDiff?: boolean;
|
|
@@ -8,6 +8,7 @@ interface HeaderProps {
|
|
|
8
8
|
groupIndex: number;
|
|
9
9
|
meta?: any;
|
|
10
10
|
isDataModule?: boolean;
|
|
11
|
+
index?: number;
|
|
11
12
|
}
|
|
12
13
|
declare const Header: (props: HeaderProps) => React.JSX.Element;
|
|
13
14
|
export default Header;
|
|
@@ -12,7 +12,8 @@ import { getTopLayerZIndex } from '../../../utils/helper-dom';
|
|
|
12
12
|
var Header = function Header(props) {
|
|
13
13
|
var meta = props.meta,
|
|
14
14
|
groupIndex = props.groupIndex,
|
|
15
|
-
isDataModule = props.isDataModule
|
|
15
|
+
isDataModule = props.isDataModule,
|
|
16
|
+
index = props.index;
|
|
16
17
|
var store = useStore();
|
|
17
18
|
var diff = function () {
|
|
18
19
|
var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
|
|
@@ -50,7 +51,10 @@ var Header = function Header(props) {
|
|
|
50
51
|
}();
|
|
51
52
|
return _jsxs("div", {
|
|
52
53
|
className: "Sqb-item--text ".concat(props.className || ''),
|
|
53
|
-
children: [props.title,
|
|
54
|
+
children: [props.title, index !== undefined && _jsx("span", {
|
|
55
|
+
className: 'Sqb-item--index',
|
|
56
|
+
children: index
|
|
57
|
+
}), store.moduleDiff && isDataModule && _jsx(Tooltip, {
|
|
54
58
|
title: '点击比对当前模块与初始模块的差异',
|
|
55
59
|
children: _jsx(Button, {
|
|
56
60
|
style: {
|
|
@@ -5,7 +5,7 @@ import React, { useEffect } from 'react';
|
|
|
5
5
|
import cx from 'classnames';
|
|
6
6
|
import { __ } from '../../../locale';
|
|
7
7
|
import { TypeEnum } from '../../../store/enum';
|
|
8
|
-
import { Tooltip, Button
|
|
8
|
+
import { Tooltip, Button } from '@gingkoo/pandora';
|
|
9
9
|
import { FfPlus } from '@gingkoo/pandora-icons';
|
|
10
10
|
import storage from '../../../utils/storage';
|
|
11
11
|
import { getHelper, isCanPaste } from '../../../utils';
|
|
@@ -306,9 +306,7 @@ var NextDom = function NextDom(props) {
|
|
|
306
306
|
var handlePaste = function handlePaste() {
|
|
307
307
|
var _store$metaList3;
|
|
308
308
|
var index = (_store$metaList3 = store.metaList) === null || _store$metaList3 === void 0 || (_store$metaList3 = _store$metaList3[groupIndex]) === null || _store$metaList3 === void 0 || (_store$metaList3 = _store$metaList3.list) === null || _store$metaList3 === void 0 ? void 0 : _store$metaList3.indexOf(meta);
|
|
309
|
-
var success = store.addMeta('', index + 1, groupIndex, store.metabaseCopyModule
|
|
310
|
-
Toast.warning("\u8BE5\u8868\u5DF2\u5B58\u5728\u5173\u8054\uFF0C\u4E0D\u80FD\u590D\u5236");
|
|
311
|
-
});
|
|
309
|
+
var success = store.addMeta('', index + 1, groupIndex, store.metabaseCopyModule);
|
|
312
310
|
if (success) {
|
|
313
311
|
store.setMetabaseCopyModule([]);
|
|
314
312
|
store.setIsMetabaseCopy(false);
|
|
@@ -8,6 +8,7 @@ import { Provider } from '../../hooks/use-provider';
|
|
|
8
8
|
import cx from 'classnames';
|
|
9
9
|
import { __ } from '../../locale';
|
|
10
10
|
import { findIndex, isError, isExistsError } from '../../utils';
|
|
11
|
+
import { getAtomListIssue } from '../dialog/formula-list/utils';
|
|
11
12
|
import { sleep, flatArray } from '../../utils/helper';
|
|
12
13
|
import { ChangeType } from '../../store/types';
|
|
13
14
|
import { getHelper } from '../../utils';
|
|
@@ -310,8 +311,10 @@ var CustomColumn = function CustomColumn(props) {
|
|
|
310
311
|
children: _jsxs("div", {
|
|
311
312
|
className: "Sqb-NotebookCell gray-bg",
|
|
312
313
|
children: [meta.customColumn.map(function (v, i) {
|
|
314
|
+
var atomIssue = getAtomListIssue(v.formulaList);
|
|
313
315
|
return _jsx(ItemName, {
|
|
314
|
-
isError: isError(v.formulaList, getColumns()) || isExistsError(v.formulaList, store.existsError),
|
|
316
|
+
isError: atomIssue.isError || isError(v.formulaList, getColumns()) || isExistsError(v.formulaList, store.existsError),
|
|
317
|
+
message: atomIssue.isError ? __('metabase.sqlErrorOpenNested') : undefined,
|
|
315
318
|
children: _jsx(RightClickValue, {
|
|
316
319
|
value: v,
|
|
317
320
|
children: _jsxs("div", {
|