@gingkoo/pandora-metabase 1.0.154 → 1.0.155
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/components/metabase/index.less +3 -3
- package/lib/cjs/components/modules/join-data.js +77 -83
- package/lib/cjs/components/modules/summarize/group-by.js +18 -14
- package/lib/cjs/components/modules/summarize/select-index.js +18 -14
- package/lib/cjs/components/modules/table-data.js +55 -64
- package/lib/cjs/components/right-click-menu.d.ts +1 -0
- package/lib/cjs/components/right-click-menu.js +33 -20
- package/lib/cjs/locale/en.js +3 -0
- package/lib/cjs/locale/zh.js +3 -0
- package/lib/es/components/metabase/index.less +3 -3
- package/lib/es/components/modules/join-data.js +77 -84
- package/lib/es/components/modules/summarize/group-by.js +18 -14
- package/lib/es/components/modules/summarize/select-index.js +18 -14
- package/lib/es/components/modules/table-data.js +55 -65
- package/lib/es/components/right-click-menu.d.ts +1 -0
- package/lib/es/components/right-click-menu.js +33 -20
- package/lib/es/locale/en.js +3 -0
- package/lib/es/locale/zh.js +3 -0
- package/package.json +1 -1
|
@@ -30,7 +30,6 @@ import ItemWrapper from './components/item-wrapper';
|
|
|
30
30
|
import SelectList from '../dialog/select-list';
|
|
31
31
|
import { LeftJoinIcon, InnerJoinIcon } from '../icons';
|
|
32
32
|
import { SelectTable, SelectJoin, SelectColumnMultiple, SelectColumn, Expression, SelectPermissionTable, FormulaList, getTemplateItem } from '../dialog';
|
|
33
|
-
import { ExclamationCircleFill } from '@gingkoo/pandora-icons';
|
|
34
33
|
import { useStore } from '../../hooks/use-provider';
|
|
35
34
|
var PrevResult = 'Previous results';
|
|
36
35
|
var normalizeJoinOperator = function normalizeJoinOperator(val) {
|
|
@@ -1379,90 +1378,84 @@ var JoinData = function JoinData(props) {
|
|
|
1379
1378
|
cursor: 'pointer'
|
|
1380
1379
|
}
|
|
1381
1380
|
})
|
|
1382
|
-
}), meta.isSubquery ? _jsx(
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
}) : null;
|
|
1423
|
-
}()
|
|
1424
|
-
}), subQuerySelected ? "".concat(((_meta$subquery2 = meta.subquery) === null || _meta$subquery2 === void 0 ? void 0 : _meta$subquery2[0]).table.datasourceName, ".").concat(((_meta$subquery3 = meta.subquery) === null || _meta$subquery3 === void 0 ? void 0 : _meta$subquery3[0]).table.name, " ").concat((_meta$table4 = meta.table2) !== null && _meta$table4 !== void 0 && _meta$table4.alias && store.tableEnableAlias ? "as ".concat((_meta$table5 = meta.table2) === null || _meta$table5 === void 0 ? void 0 : _meta$table5.alias) : '', " ") : __('SqlQueryBuilder.setSubQuery')]
|
|
1381
|
+
}), meta.isSubquery ? _jsx(ItemName, {
|
|
1382
|
+
isError: !store.tableEnableAlias && tableIsError(),
|
|
1383
|
+
message: __(isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias'),
|
|
1384
|
+
children: _jsx(RightClickValue, {
|
|
1385
|
+
value: meta,
|
|
1386
|
+
children: _jsxs("div", {
|
|
1387
|
+
className: cx("Sqb-TableName", {
|
|
1388
|
+
notSelected: !subQuerySelected
|
|
1389
|
+
}),
|
|
1390
|
+
"data-sqb-snapshot-allow": 'true',
|
|
1391
|
+
onClick: function onClick() {
|
|
1392
|
+
showSubQuery(meta.subquery);
|
|
1393
|
+
},
|
|
1394
|
+
children: [subQuerySelected && _jsx(_Fragment, {
|
|
1395
|
+
children: function () {
|
|
1396
|
+
var showButton = !store.snapshotMode && store.tableEnableAlias;
|
|
1397
|
+
return !store.snapshotMode ? _jsx(_Fragment, {
|
|
1398
|
+
children: showButton && _jsx(Tooltip, {
|
|
1399
|
+
title: __(tableIsError() ? isDel ? store.tableEnableAlias ? 'metabase.verifyAliasAction' : 'metabase.verify' : store.tableEnableAlias ? 'SqlQueryBuilder.repeatAliasAction' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
|
|
1400
|
+
children: _jsx(Button, {
|
|
1401
|
+
danger: tableIsError(),
|
|
1402
|
+
className: cx(':Sqb-TableName-as', {
|
|
1403
|
+
isError: tableIsError()
|
|
1404
|
+
}),
|
|
1405
|
+
shape: 'circle',
|
|
1406
|
+
iconOnly: true,
|
|
1407
|
+
primary: true,
|
|
1408
|
+
icon: 'As',
|
|
1409
|
+
size: 'small',
|
|
1410
|
+
onClick: function onClick(e) {
|
|
1411
|
+
var _meta$table3;
|
|
1412
|
+
e.stopPropagation();
|
|
1413
|
+
onChangeTableAlias(((_meta$table3 = meta.table2) === null || _meta$table3 === void 0 ? void 0 : _meta$table3.alias) || '');
|
|
1414
|
+
}
|
|
1415
|
+
})
|
|
1416
|
+
})
|
|
1417
|
+
}) : null;
|
|
1418
|
+
}()
|
|
1419
|
+
}), subQuerySelected ? "".concat(((_meta$subquery2 = meta.subquery) === null || _meta$subquery2 === void 0 ? void 0 : _meta$subquery2[0]).table.datasourceName, ".").concat(((_meta$subquery3 = meta.subquery) === null || _meta$subquery3 === void 0 ? void 0 : _meta$subquery3[0]).table.name, " ").concat((_meta$table4 = meta.table2) !== null && _meta$table4 !== void 0 && _meta$table4.alias && store.tableEnableAlias ? "as ".concat((_meta$table5 = meta.table2) === null || _meta$table5 === void 0 ? void 0 : _meta$table5.alias) : '', " ") : __('SqlQueryBuilder.setSubQuery')]
|
|
1420
|
+
})
|
|
1425
1421
|
})
|
|
1426
|
-
}) : _jsx(
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
}) : null;
|
|
1464
|
-
}()
|
|
1465
|
-
}), table2Selected ? "".concat(meta.table2.datasourceName, ".").concat(meta.table2.name, " ").concat((_meta$table7 = meta.table2) !== null && _meta$table7 !== void 0 && _meta$table7.alias && store.tableEnableAlias ? "as ".concat((_meta$table8 = meta.table2) === null || _meta$table8 === void 0 ? void 0 : _meta$table8.alias) : '') : __('SqlQueryBuilder.pickTable')]
|
|
1422
|
+
}) : _jsx(ItemName, {
|
|
1423
|
+
isError: !store.tableEnableAlias && tableIsError(),
|
|
1424
|
+
message: __(isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias'),
|
|
1425
|
+
children: _jsx(RightClickValue, {
|
|
1426
|
+
value: meta.table2,
|
|
1427
|
+
children: _jsxs("div", {
|
|
1428
|
+
className: cx("Sqb-TableName", {
|
|
1429
|
+
notSelected: !table2Selected
|
|
1430
|
+
}),
|
|
1431
|
+
onClick: selectTable,
|
|
1432
|
+
children: [table2Selected && _jsx(_Fragment, {
|
|
1433
|
+
children: function () {
|
|
1434
|
+
var showButton = !store.snapshotMode && store.tableEnableAlias;
|
|
1435
|
+
return !store.snapshotMode ? _jsx(_Fragment, {
|
|
1436
|
+
children: showButton && _jsx(Tooltip, {
|
|
1437
|
+
title: __(tableIsError() ? isDel ? store.tableEnableAlias ? 'metabase.verifyAliasAction' : 'metabase.verify' : store.tableEnableAlias ? 'SqlQueryBuilder.repeatAliasAction' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
|
|
1438
|
+
children: _jsx(Button, {
|
|
1439
|
+
danger: tableIsError(),
|
|
1440
|
+
className: cx(':Sqb-TableName-as', {
|
|
1441
|
+
isError: tableIsError()
|
|
1442
|
+
}),
|
|
1443
|
+
shape: 'circle',
|
|
1444
|
+
iconOnly: true,
|
|
1445
|
+
primary: true,
|
|
1446
|
+
icon: 'As',
|
|
1447
|
+
size: 'small',
|
|
1448
|
+
onClick: function onClick(e) {
|
|
1449
|
+
var _meta$table6;
|
|
1450
|
+
e.stopPropagation();
|
|
1451
|
+
onChangeTableAlias(((_meta$table6 = meta.table2) === null || _meta$table6 === void 0 ? void 0 : _meta$table6.alias) || '');
|
|
1452
|
+
}
|
|
1453
|
+
})
|
|
1454
|
+
})
|
|
1455
|
+
}) : null;
|
|
1456
|
+
}()
|
|
1457
|
+
}), table2Selected ? "".concat(meta.table2.datasourceName, ".").concat(meta.table2.name, " ").concat((_meta$table7 = meta.table2) !== null && _meta$table7 !== void 0 && _meta$table7.alias && store.tableEnableAlias ? "as ".concat((_meta$table8 = meta.table2) === null || _meta$table8 === void 0 ? void 0 : _meta$table8.alias) : '') : __('SqlQueryBuilder.pickTable')]
|
|
1458
|
+
})
|
|
1466
1459
|
})
|
|
1467
1460
|
}), store.showSubquery && (!store.snapshotMode || meta.isSubquery) && _jsx(Tooltip, {
|
|
1468
1461
|
title: __('SqlQueryBuilder.switchSubQuery'),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
2
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
4
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
@@ -525,19 +524,24 @@ var GroupBy = function GroupBy(props) {
|
|
|
525
524
|
return handleUpdate(e, i);
|
|
526
525
|
},
|
|
527
526
|
children: [v.quotes && _jsx(_Fragment, {
|
|
528
|
-
children: store.groupByEnableAlias && !store.snapshotMode && _jsx(
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
527
|
+
children: store.groupByEnableAlias && !store.snapshotMode && _jsx(_Fragment, {
|
|
528
|
+
children: _jsx(Tooltip, {
|
|
529
|
+
title: __(!isValidSQLAlias(v === null || v === void 0 ? void 0 : v.fieldAlias) ? 'SqlQueryBuilder.aliasForRulesAction' : 'SqlQueryBuilder.alias'),
|
|
530
|
+
children: _jsx(Button, {
|
|
531
|
+
danger: !isValidSQLAlias(v === null || v === void 0 ? void 0 : v.fieldAlias),
|
|
532
|
+
className: cx(':Sqb-TableName-as :Sqb-TableName green-name', {
|
|
533
|
+
isError: !isValidSQLAlias(v === null || v === void 0 ? void 0 : v.fieldAlias)
|
|
534
|
+
}),
|
|
535
|
+
shape: 'circle',
|
|
536
|
+
iconOnly: true,
|
|
537
|
+
primary: true,
|
|
538
|
+
icon: 'As',
|
|
539
|
+
size: 'small',
|
|
540
|
+
onClick: function onClick(e) {
|
|
541
|
+
e.stopPropagation();
|
|
542
|
+
onChangeFieldAlias((v === null || v === void 0 ? void 0 : v.fieldAlias) || '', i);
|
|
543
|
+
}
|
|
544
|
+
})
|
|
541
545
|
})
|
|
542
546
|
})
|
|
543
547
|
}), "".concat(v.quotes, " ").concat(v.fieldAlias ? "as ".concat(v.fieldAlias) : ''), !store.snapshotMode && _jsx("span", {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
2
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
4
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
@@ -423,19 +422,24 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
423
422
|
return handleUpdate(e, i);
|
|
424
423
|
},
|
|
425
424
|
children: [v.quotes && _jsx(_Fragment, {
|
|
426
|
-
children: store.groupByEnableAlias && !store.snapshotMode && _jsx(
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
425
|
+
children: store.groupByEnableAlias && !store.snapshotMode && _jsx(_Fragment, {
|
|
426
|
+
children: _jsx(Tooltip, {
|
|
427
|
+
title: __(!isValidSQLAlias(v === null || v === void 0 ? void 0 : v.fieldAlias) ? 'SqlQueryBuilder.aliasForRulesAction' : 'SqlQueryBuilder.alias'),
|
|
428
|
+
children: _jsx(Button, {
|
|
429
|
+
danger: !isValidSQLAlias(v === null || v === void 0 ? void 0 : v.fieldAlias),
|
|
430
|
+
className: cx(':Sqb-TableName-as :Sqb-TableName green-name', {
|
|
431
|
+
isError: !isValidSQLAlias(v === null || v === void 0 ? void 0 : v.fieldAlias)
|
|
432
|
+
}),
|
|
433
|
+
shape: 'circle',
|
|
434
|
+
iconOnly: true,
|
|
435
|
+
primary: true,
|
|
436
|
+
icon: 'As',
|
|
437
|
+
size: 'small',
|
|
438
|
+
onClick: function onClick(e) {
|
|
439
|
+
e.stopPropagation();
|
|
440
|
+
onChangeFieldAlias((v === null || v === void 0 ? void 0 : v.fieldAlias) || '', i);
|
|
441
|
+
}
|
|
442
|
+
})
|
|
439
443
|
})
|
|
440
444
|
})
|
|
441
445
|
}), "".concat(v.quotes, " ").concat(v.fieldAlias ? "as ".concat(v.fieldAlias) : ''), !store.snapshotMode && _jsx("span", {
|
|
@@ -24,7 +24,6 @@ import Wrapper from './components/Wrapper';
|
|
|
24
24
|
import NextDom from './components/meta-icon';
|
|
25
25
|
import Header from './components/header';
|
|
26
26
|
import ItemWrapper from './components/item-wrapper';
|
|
27
|
-
import { ExclamationCircleFill } from '@gingkoo/pandora-icons';
|
|
28
27
|
import { useStore } from '../../hooks/use-provider';
|
|
29
28
|
var TableData = function TableData(props) {
|
|
30
29
|
var _meta$subquery, _meta$subquery2, _meta$subquery3, _meta$table4, _meta$table5, _meta$table7, _meta$table8, _store$showMainColumn;
|
|
@@ -293,7 +292,8 @@ var TableData = function TableData(props) {
|
|
|
293
292
|
children: _jsxs("div", {
|
|
294
293
|
className: "Sqb-NotebookCell",
|
|
295
294
|
children: [meta.isSubquery ? _jsx(ItemName, {
|
|
296
|
-
isError: isExistsError(meta.subquery || [], store.existsError),
|
|
295
|
+
isError: isExistsError(meta.subquery || [], store.existsError) || !store.tableEnableAlias && tableIsError(),
|
|
296
|
+
message: !store.tableEnableAlias && tableIsError() ? __(isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias') : undefined,
|
|
297
297
|
children: _jsx(RightClickValue, {
|
|
298
298
|
value: meta,
|
|
299
299
|
children: _jsxs("div", {
|
|
@@ -306,79 +306,69 @@ var TableData = function TableData(props) {
|
|
|
306
306
|
},
|
|
307
307
|
children: [subQuerySelected && _jsx(_Fragment, {
|
|
308
308
|
children: function () {
|
|
309
|
-
var showButton = !store.snapshotMode &&
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
} : {},
|
|
325
|
-
iconOnly: true,
|
|
326
|
-
primary: !isDel,
|
|
327
|
-
icon: icon,
|
|
328
|
-
size: 'small',
|
|
329
|
-
onClick: function onClick(e) {
|
|
330
|
-
if (store.tableEnableAlias) {
|
|
309
|
+
var showButton = !store.snapshotMode && store.tableEnableAlias;
|
|
310
|
+
return !store.snapshotMode ? _jsx(_Fragment, {
|
|
311
|
+
children: showButton && _jsx(Tooltip, {
|
|
312
|
+
title: __(tableIsError() ? isDel ? store.tableEnableAlias ? 'metabase.verifyAliasAction' : 'metabase.verify' : store.tableEnableAlias ? 'SqlQueryBuilder.repeatAliasAction' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
|
|
313
|
+
children: _jsx(Button, {
|
|
314
|
+
danger: tableIsError(),
|
|
315
|
+
className: cx(':Sqb-TableName-as', {
|
|
316
|
+
isError: tableIsError()
|
|
317
|
+
}),
|
|
318
|
+
shape: 'circle',
|
|
319
|
+
iconOnly: true,
|
|
320
|
+
primary: true,
|
|
321
|
+
icon: 'As',
|
|
322
|
+
size: 'small',
|
|
323
|
+
onClick: function onClick(e) {
|
|
331
324
|
var _meta$table3;
|
|
332
325
|
e.stopPropagation();
|
|
333
326
|
onChangeTableAlias(((_meta$table3 = meta.table) === null || _meta$table3 === void 0 ? void 0 : _meta$table3.alias) || '');
|
|
334
327
|
}
|
|
335
|
-
}
|
|
328
|
+
})
|
|
336
329
|
})
|
|
337
330
|
}) : null;
|
|
338
331
|
}()
|
|
339
332
|
}), subQuerySelected ? "".concat(((_meta$subquery2 = meta.subquery) === null || _meta$subquery2 === void 0 ? void 0 : _meta$subquery2[0]).table.datasourceName, ".").concat(((_meta$subquery3 = meta.subquery) === null || _meta$subquery3 === void 0 ? void 0 : _meta$subquery3[0]).table.name, " ").concat((_meta$table4 = meta.table) !== null && _meta$table4 !== void 0 && _meta$table4.alias && store.tableEnableAlias ? "as ".concat((_meta$table5 = meta.table) === null || _meta$table5 === void 0 ? void 0 : _meta$table5.alias) : '', " ") : __('SqlQueryBuilder.setSubQuery')]
|
|
340
333
|
})
|
|
341
334
|
})
|
|
342
|
-
}) : _jsx(
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}) : null;
|
|
380
|
-
}()
|
|
381
|
-
}), selected ? "".concat(meta.table.datasourceName, ".").concat(meta.table.name, " ").concat((_meta$table7 = meta.table) !== null && _meta$table7 !== void 0 && _meta$table7.alias && store.tableEnableAlias ? "as ".concat((_meta$table8 = meta.table) === null || _meta$table8 === void 0 ? void 0 : _meta$table8.alias) : '') : __('SqlQueryBuilder.pickTable')]
|
|
335
|
+
}) : _jsx(ItemName, {
|
|
336
|
+
isError: !store.tableEnableAlias && tableIsError(),
|
|
337
|
+
message: __(isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias'),
|
|
338
|
+
children: _jsx(RightClickValue, {
|
|
339
|
+
value: meta.table,
|
|
340
|
+
children: _jsxs("div", {
|
|
341
|
+
className: cx("Sqb-TableName", {
|
|
342
|
+
notSelected: !selected
|
|
343
|
+
}),
|
|
344
|
+
onClick: selectTable,
|
|
345
|
+
children: [selected && _jsx(_Fragment, {
|
|
346
|
+
children: function () {
|
|
347
|
+
var showButton = !store.snapshotMode && store.tableEnableAlias;
|
|
348
|
+
return !store.snapshotMode ? _jsx(_Fragment, {
|
|
349
|
+
children: showButton && _jsx(Tooltip, {
|
|
350
|
+
title: __(tableIsError() ? isDel ? store.tableEnableAlias ? 'metabase.verifyAliasAction' : 'metabase.verify' : store.tableEnableAlias ? 'SqlQueryBuilder.repeatAliasAction' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
|
|
351
|
+
children: _jsx(Button, {
|
|
352
|
+
danger: tableIsError(),
|
|
353
|
+
className: cx(':Sqb-TableName-as', {
|
|
354
|
+
isError: tableIsError()
|
|
355
|
+
}),
|
|
356
|
+
shape: 'circle',
|
|
357
|
+
iconOnly: true,
|
|
358
|
+
primary: true,
|
|
359
|
+
icon: 'As',
|
|
360
|
+
size: 'small',
|
|
361
|
+
onClick: function onClick(e) {
|
|
362
|
+
var _meta$table6;
|
|
363
|
+
e.stopPropagation();
|
|
364
|
+
onChangeTableAlias(((_meta$table6 = meta.table) === null || _meta$table6 === void 0 ? void 0 : _meta$table6.alias) || '');
|
|
365
|
+
}
|
|
366
|
+
})
|
|
367
|
+
})
|
|
368
|
+
}) : null;
|
|
369
|
+
}()
|
|
370
|
+
}), selected ? "".concat(meta.table.datasourceName, ".").concat(meta.table.name, " ").concat((_meta$table7 = meta.table) !== null && _meta$table7 !== void 0 && _meta$table7.alias && store.tableEnableAlias ? "as ".concat((_meta$table8 = meta.table) === null || _meta$table8 === void 0 ? void 0 : _meta$table8.alias) : '') : __('SqlQueryBuilder.pickTable')]
|
|
371
|
+
})
|
|
382
372
|
})
|
|
383
373
|
}), store.showSubquery && (!store.snapshotMode || meta.isSubquery) && _jsx(Tooltip, {
|
|
384
374
|
title: __('SqlQueryBuilder.switchSubQuery'),
|
|
@@ -5,6 +5,7 @@ export type RightClickMenuState = {
|
|
|
5
5
|
item: any;
|
|
6
6
|
itemText: string;
|
|
7
7
|
target: HTMLElement;
|
|
8
|
+
ownerDocument?: Document;
|
|
8
9
|
};
|
|
9
10
|
export declare const openSqbRightClickMenu: (store: any, event: React.MouseEvent<HTMLElement>, setMenuState?: (state: RightClickMenuState | null) => void) => void;
|
|
10
11
|
interface SqbRightClickMenuProps {
|
|
@@ -9,8 +9,17 @@ import cx from 'classnames';
|
|
|
9
9
|
import { normalizeLegacySummarizeForSave, splitByUnion } from '../utils';
|
|
10
10
|
import { useStore } from '../hooks/use-provider';
|
|
11
11
|
var MENU_VIEWPORT_GAP = 8;
|
|
12
|
+
var isHTMLElement = function isHTMLElement(target) {
|
|
13
|
+
var _target$ownerDocument;
|
|
14
|
+
if (!target) return false;
|
|
15
|
+
var ownerWindow = (_target$ownerDocument = target.ownerDocument) === null || _target$ownerDocument === void 0 ? void 0 : _target$ownerDocument.defaultView;
|
|
16
|
+
if (ownerWindow !== null && ownerWindow !== void 0 && ownerWindow.HTMLElement) {
|
|
17
|
+
return target instanceof ownerWindow.HTMLElement;
|
|
18
|
+
}
|
|
19
|
+
return typeof HTMLElement !== 'undefined' && target instanceof HTMLElement;
|
|
20
|
+
};
|
|
12
21
|
var findRightClickTarget = function findRightClickTarget(target) {
|
|
13
|
-
var element = target
|
|
22
|
+
var element = isHTMLElement(target) ? target : null;
|
|
14
23
|
while (element) {
|
|
15
24
|
var _element$classList, _element$classList2, _element$classList3;
|
|
16
25
|
if ((_element$classList = element.classList) !== null && _element$classList !== void 0 && _element$classList.contains('Sqb-TableName') || (_element$classList2 = element.classList) !== null && _element$classList2 !== void 0 && _element$classList2.contains(':Sqb-TableName') && !((_element$classList3 = element.classList) !== null && _element$classList3 !== void 0 && _element$classList3.contains('operator-trigger'))) {
|
|
@@ -73,7 +82,8 @@ export var openSqbRightClickMenu = function openSqbRightClickMenu(store, event,
|
|
|
73
82
|
y: event.clientY,
|
|
74
83
|
item: item,
|
|
75
84
|
itemText: itemText,
|
|
76
|
-
target: target
|
|
85
|
+
target: target,
|
|
86
|
+
ownerDocument: target.ownerDocument
|
|
77
87
|
});
|
|
78
88
|
};
|
|
79
89
|
var SqbRightClickMenu = function SqbRightClickMenu(_ref) {
|
|
@@ -97,6 +107,8 @@ var SqbRightClickMenu = function SqbRightClickMenu(_ref) {
|
|
|
97
107
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
98
108
|
menuPosition = _useState4[0],
|
|
99
109
|
setMenuPosition = _useState4[1];
|
|
110
|
+
var menuDocument = (rightClickMenuState === null || rightClickMenuState === void 0 ? void 0 : rightClickMenuState.ownerDocument) || (typeof document === 'undefined' ? undefined : document);
|
|
111
|
+
var menuWindow = (menuDocument === null || menuDocument === void 0 ? void 0 : menuDocument.defaultView) || (typeof window === 'undefined' ? undefined : window);
|
|
100
112
|
var handleRightClickMenuItem = function () {
|
|
101
113
|
var _ref2 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(menuItem) {
|
|
102
114
|
var _store$getRightClickM2;
|
|
@@ -142,51 +154,52 @@ var SqbRightClickMenu = function SqbRightClickMenu(_ref) {
|
|
|
142
154
|
};
|
|
143
155
|
}();
|
|
144
156
|
useEffect(function () {
|
|
145
|
-
if (!rightClickMenuState) return;
|
|
157
|
+
if (!rightClickMenuState || !menuDocument || !menuWindow) return;
|
|
146
158
|
var closeRightClickMenu = function closeRightClickMenu() {
|
|
147
159
|
return setRightClickMenuState(null);
|
|
148
160
|
};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
161
|
+
menuDocument.addEventListener('click', closeRightClickMenu);
|
|
162
|
+
menuWindow.addEventListener('scroll', closeRightClickMenu, true);
|
|
163
|
+
menuWindow.addEventListener('resize', closeRightClickMenu);
|
|
152
164
|
return function () {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
165
|
+
menuDocument.removeEventListener('click', closeRightClickMenu);
|
|
166
|
+
menuWindow.removeEventListener('scroll', closeRightClickMenu, true);
|
|
167
|
+
menuWindow.removeEventListener('resize', closeRightClickMenu);
|
|
156
168
|
};
|
|
157
|
-
}, [rightClickMenuState]);
|
|
169
|
+
}, [rightClickMenuState, menuDocument, menuWindow]);
|
|
158
170
|
useEffect(function () {
|
|
159
|
-
if (!rightClickMenuState ||
|
|
171
|
+
if (!rightClickMenuState || !(menuDocument !== null && menuDocument !== void 0 && menuDocument.body)) {
|
|
160
172
|
setMenuContainer(null);
|
|
161
173
|
return;
|
|
162
174
|
}
|
|
163
|
-
var container =
|
|
175
|
+
var container = menuDocument.createElement('div');
|
|
164
176
|
container.setAttribute('data-sqb-right-click-menu-container', 'true');
|
|
165
|
-
|
|
177
|
+
menuDocument.body.appendChild(container);
|
|
166
178
|
setMenuContainer(container);
|
|
167
179
|
return function () {
|
|
168
|
-
if (
|
|
169
|
-
|
|
180
|
+
if (menuDocument.body.contains(container)) {
|
|
181
|
+
menuDocument.body.removeChild(container);
|
|
170
182
|
}
|
|
171
183
|
};
|
|
172
|
-
}, [rightClickMenuState]);
|
|
184
|
+
}, [rightClickMenuState, menuDocument]);
|
|
173
185
|
useLayoutEffect(function () {
|
|
174
|
-
if (!rightClickMenuState) return;
|
|
186
|
+
if (!rightClickMenuState || !menuWindow) return;
|
|
175
187
|
var menuElement = menuRef.current;
|
|
176
188
|
var menuWidth = (menuElement === null || menuElement === void 0 ? void 0 : menuElement.offsetWidth) || 0;
|
|
177
189
|
var menuHeight = (menuElement === null || menuElement === void 0 ? void 0 : menuElement.offsetHeight) || 0;
|
|
178
|
-
var maxLeft = Math.max(MENU_VIEWPORT_GAP,
|
|
179
|
-
var maxTop = Math.max(MENU_VIEWPORT_GAP,
|
|
190
|
+
var maxLeft = Math.max(MENU_VIEWPORT_GAP, menuWindow.innerWidth - menuWidth - MENU_VIEWPORT_GAP);
|
|
191
|
+
var maxTop = Math.max(MENU_VIEWPORT_GAP, menuWindow.innerHeight - menuHeight - MENU_VIEWPORT_GAP);
|
|
180
192
|
setMenuPosition({
|
|
181
193
|
left: Math.min(Math.max(rightClickMenuState.x, MENU_VIEWPORT_GAP), maxLeft),
|
|
182
194
|
top: Math.min(Math.max(rightClickMenuState.y, MENU_VIEWPORT_GAP), maxTop)
|
|
183
195
|
});
|
|
184
|
-
}, [rightClickMenuState, rightClickMenu.length, menuContainer]);
|
|
196
|
+
}, [rightClickMenuState, rightClickMenu.length, menuContainer, menuWindow]);
|
|
185
197
|
if (!rightClickMenuState) return null;
|
|
186
198
|
var menuNode = _jsx("div", {
|
|
187
199
|
ref: menuRef,
|
|
188
200
|
className: 'Sqb-right-click-menu',
|
|
189
201
|
style: {
|
|
202
|
+
position: 'fixed',
|
|
190
203
|
left: menuPosition.left,
|
|
191
204
|
top: menuPosition.top,
|
|
192
205
|
zIndex: popupZIndex ? popupZIndex + 10 : 9999
|
package/lib/es/locale/en.js
CHANGED
|
@@ -50,9 +50,11 @@ export default register('en', {
|
|
|
50
50
|
'SqlQueryBuilder.selectColumnAll': 'select all',
|
|
51
51
|
'SqlQueryBuilder.alias': 'alias',
|
|
52
52
|
'SqlQueryBuilder.aliasForRules': 'The alias only supports a combination of letters, numbers, and underscores. It must start with a letter and cannot exceed 30 bytes',
|
|
53
|
+
'SqlQueryBuilder.aliasForRulesAction': 'Invalid alias: use only letters, numbers, and underscores; start with a letter and keep it within 30 bytes. Click to modify the alias',
|
|
53
54
|
'SqlQueryBuilder.nameForRules': 'The name only supports a combination of letters, numbers, and underscores. It must start with a letter and cannot exceed 30 bytes',
|
|
54
55
|
'SqlQueryBuilder.pleaseSelectTable': 'The currently dependent table is empty or has been deleted',
|
|
55
56
|
'SqlQueryBuilder.repeatAlias': 'If there are duplicate names, please modify them',
|
|
57
|
+
'SqlQueryBuilder.repeatAliasAction': 'Duplicate alias. Click to modify the alias',
|
|
56
58
|
'customColumn.operator': 'operator',
|
|
57
59
|
'customColumn.collection': 'collection',
|
|
58
60
|
'customColumn.field': 'field',
|
|
@@ -166,6 +168,7 @@ export default register('en', {
|
|
|
166
168
|
'metabase.nextBtn': 'next step',
|
|
167
169
|
'metabase.nextOk': 'ok',
|
|
168
170
|
'metabase.verify': 'The table has been modified. Please select again',
|
|
171
|
+
'metabase.verifyAliasAction': 'The table has been modified. Please select it again; click As to modify the alias',
|
|
169
172
|
'metabase.validationFailed': 'Validation failed. Do you still want to save?',
|
|
170
173
|
'metabase.validationFilter': 'The filter configuration is incorrect. Saving is prohibited!',
|
|
171
174
|
'metabase.validationFormula': 'The formula configuration is incorrect. Saving is prohibited!',
|
package/lib/es/locale/zh.js
CHANGED
|
@@ -46,9 +46,11 @@ export default register('zh', {
|
|
|
46
46
|
'SqlQueryBuilder.selectColumnAll': '全选',
|
|
47
47
|
'SqlQueryBuilder.alias': '别名',
|
|
48
48
|
'SqlQueryBuilder.aliasForRules': '别名只支持字母 + 数字 + 下划线组合,必须是字母开头,且不能超过30个字节',
|
|
49
|
+
'SqlQueryBuilder.aliasForRulesAction': '别名格式错误:只支持字母、数字和下划线,必须以字母开头且不超过30个字节。点击修改别名',
|
|
49
50
|
'SqlQueryBuilder.nameForRules': '名字只支持字母 + 数字 + 下划线组合,必须是字母开头,且不能超过30个字节',
|
|
50
51
|
'SqlQueryBuilder.pleaseSelectTable': '当前依赖的表为空或被删除',
|
|
51
52
|
'SqlQueryBuilder.repeatAlias': '有重名请修改',
|
|
53
|
+
'SqlQueryBuilder.repeatAliasAction': '别名重复,点击修改别名',
|
|
52
54
|
'customColumn.operator': '操作符',
|
|
53
55
|
'customColumn.collection': '自定义组合',
|
|
54
56
|
'customColumn.field': '字段',
|
|
@@ -166,6 +168,7 @@ export default register('zh', {
|
|
|
166
168
|
'metabase.nextBtn': '下一步',
|
|
167
169
|
'metabase.nextOk': '确定',
|
|
168
170
|
'metabase.verify': '表已修改,请重新选择',
|
|
171
|
+
'metabase.verifyAliasAction': '表已修改,请重新选择;点击 As 可修改别名',
|
|
169
172
|
'metabase.validationFailed': '校验未通过,是否依然保存?',
|
|
170
173
|
'metabase.validationFilter': '过滤器配置有误,禁止保存!',
|
|
171
174
|
'metabase.validationFormula': '公式配置有误,禁止保存!',
|