@gingkoo/pandora-metabase 1.0.39 → 1.0.41
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.
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
6
|
var _excluded = ["subToolbar", "notExistsColumns", "isExit", "toolbar"];
|
|
6
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
8
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useEffect, useState } from 'react';
|
|
8
10
|
import cx from 'classnames';
|
|
9
11
|
import { __ } from '../../locale';
|
|
10
12
|
import { Tooltip, Button, Modal, Modal2, Input, Toast } from '@gingkoo/pandora';
|
|
@@ -18,14 +20,54 @@ import { SelectTable, SelectColumn } from '../dialog';
|
|
|
18
20
|
import Wrapper from './components/Wrapper';
|
|
19
21
|
import NextDom from './components/meta-icon';
|
|
20
22
|
import Header from './components/header';
|
|
23
|
+
import { ExclamationCircleFill } from '@gingkoo/pandora-icons';
|
|
21
24
|
import { useStore } from '../../hooks/use-provider';
|
|
22
25
|
var TableData = function TableData(props) {
|
|
23
|
-
var _meta$subquery, _meta$subquery2, _meta$subquery3, _meta$
|
|
26
|
+
var _meta$subquery, _meta$subquery2, _meta$subquery3, _meta$table4, _meta$table5, _meta$table7, _meta$table8, _store$showMainColumn;
|
|
24
27
|
var meta = props.meta,
|
|
25
28
|
groupIndex = props.groupIndex;
|
|
26
29
|
var store = useStore();
|
|
27
30
|
var selected = Boolean(meta.table.name);
|
|
28
31
|
var subQuerySelected = Boolean((_meta$subquery = meta.subquery) === null || _meta$subquery === void 0 || (_meta$subquery = _meta$subquery[0]) === null || _meta$subquery === void 0 || (_meta$subquery = _meta$subquery.table) === null || _meta$subquery === void 0 ? void 0 : _meta$subquery.name);
|
|
32
|
+
var _useState = useState(false),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
isDel = _useState2[0],
|
|
35
|
+
setIsDel = _useState2[1];
|
|
36
|
+
var tableIsDel = /*#__PURE__*/function () {
|
|
37
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
38
|
+
var _meta$table;
|
|
39
|
+
var tableName, tables, names;
|
|
40
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
41
|
+
while (1) switch (_context.prev = _context.next) {
|
|
42
|
+
case 0:
|
|
43
|
+
tableName = (_meta$table = meta.table) === null || _meta$table === void 0 ? void 0 : _meta$table.name;
|
|
44
|
+
_context.next = 1;
|
|
45
|
+
return store === null || store === void 0 ? void 0 : store.fetchDataset(meta.table.datasourceId);
|
|
46
|
+
case 1:
|
|
47
|
+
tables = _context.sent;
|
|
48
|
+
names = (tables === null || tables === void 0 ? void 0 : tables.map(function (v) {
|
|
49
|
+
return v.name;
|
|
50
|
+
})) || [];
|
|
51
|
+
if (!names.includes(tableName)) {
|
|
52
|
+
setIsDel(true);
|
|
53
|
+
} else {
|
|
54
|
+
setIsDel(false);
|
|
55
|
+
}
|
|
56
|
+
case 2:
|
|
57
|
+
case "end":
|
|
58
|
+
return _context.stop();
|
|
59
|
+
}
|
|
60
|
+
}, _callee);
|
|
61
|
+
}));
|
|
62
|
+
return function tableIsDel() {
|
|
63
|
+
return _ref.apply(this, arguments);
|
|
64
|
+
};
|
|
65
|
+
}();
|
|
66
|
+
useEffect(function () {
|
|
67
|
+
setTimeout(function () {
|
|
68
|
+
tableIsDel();
|
|
69
|
+
}, 0);
|
|
70
|
+
}, [meta]);
|
|
29
71
|
function selectTable(e) {
|
|
30
72
|
!meta.readonly && store.setPopup({
|
|
31
73
|
visible: true,
|
|
@@ -53,6 +95,7 @@ var TableData = function TableData(props) {
|
|
|
53
95
|
store.setPopup({
|
|
54
96
|
visible: false
|
|
55
97
|
});
|
|
98
|
+
setIsDel(false);
|
|
56
99
|
}
|
|
57
100
|
})
|
|
58
101
|
});
|
|
@@ -86,17 +129,17 @@ var TableData = function TableData(props) {
|
|
|
86
129
|
}
|
|
87
130
|
}),
|
|
88
131
|
onOk: function () {
|
|
89
|
-
var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
132
|
+
var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
90
133
|
var newMetaList;
|
|
91
|
-
return _regeneratorRuntime.wrap(function (
|
|
92
|
-
while (1) switch (
|
|
134
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
135
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
93
136
|
case 0:
|
|
94
137
|
if (isValidSQLAlias(alias)) {
|
|
95
|
-
|
|
138
|
+
_context2.next = 1;
|
|
96
139
|
break;
|
|
97
140
|
}
|
|
98
141
|
Toast.warning(__('SqlQueryBuilder.aliasForRules'));
|
|
99
|
-
return
|
|
142
|
+
return _context2.abrupt("return", false);
|
|
100
143
|
case 1:
|
|
101
144
|
newMetaList = store.metaList[groupIndex].list.slice(); // @ts-ignore
|
|
102
145
|
newMetaList[0].table.alias = alias;
|
|
@@ -104,9 +147,9 @@ var TableData = function TableData(props) {
|
|
|
104
147
|
store.setMeta(newMetaList, groupIndex);
|
|
105
148
|
case 2:
|
|
106
149
|
case "end":
|
|
107
|
-
return
|
|
150
|
+
return _context2.stop();
|
|
108
151
|
}
|
|
109
|
-
},
|
|
152
|
+
}, _callee2);
|
|
110
153
|
}));
|
|
111
154
|
function onOk() {
|
|
112
155
|
return _onOk.apply(this, arguments);
|
|
@@ -207,12 +250,12 @@ var TableData = function TableData(props) {
|
|
|
207
250
|
store.setMeta(newMetaList, groupIndex);
|
|
208
251
|
};
|
|
209
252
|
var tableIsError = function tableIsError() {
|
|
210
|
-
var _store$preProps3, _meta$
|
|
253
|
+
var _store$preProps3, _meta$table2;
|
|
211
254
|
var aliass = ((_store$preProps3 = store.preProps) === null || _store$preProps3 === void 0 || (_store$preProps3 = _store$preProps3.notExistsColumns) === null || _store$preProps3 === void 0 ? void 0 : _store$preProps3.map(function (v) {
|
|
212
255
|
return v.alias;
|
|
213
256
|
})) || [];
|
|
214
|
-
var tableAlias = (_meta$
|
|
215
|
-
if (tableAlias && aliass.includes(tableAlias)) {
|
|
257
|
+
var tableAlias = (_meta$table2 = meta.table) === null || _meta$table2 === void 0 ? void 0 : _meta$table2.alias;
|
|
258
|
+
if (tableAlias && aliass.includes(tableAlias) || isDel) {
|
|
216
259
|
return true;
|
|
217
260
|
}
|
|
218
261
|
return false;
|
|
@@ -235,48 +278,60 @@ var TableData = function TableData(props) {
|
|
|
235
278
|
showSubQuery(meta.subquery);
|
|
236
279
|
},
|
|
237
280
|
children: [subQuerySelected && _jsx(Tooltip, {
|
|
238
|
-
title: __(tableIsError() ? 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
|
|
281
|
+
title: __(tableIsError() ? isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
|
|
239
282
|
children: _jsx(Button, {
|
|
240
283
|
danger: tableIsError(),
|
|
241
284
|
className: cx(':Sqb-TableName-as', {
|
|
242
285
|
isError: tableIsError()
|
|
243
286
|
}),
|
|
244
287
|
shape: 'circle',
|
|
288
|
+
style: isDel ? {
|
|
289
|
+
fontSize: 18,
|
|
290
|
+
backgroundColor: '#fff',
|
|
291
|
+
width: 'auto',
|
|
292
|
+
height: 'auto'
|
|
293
|
+
} : {},
|
|
245
294
|
iconOnly: true,
|
|
246
|
-
primary:
|
|
247
|
-
icon: 'As',
|
|
295
|
+
primary: !isDel,
|
|
296
|
+
icon: isDel ? _jsx(ExclamationCircleFill, {}) : 'As',
|
|
248
297
|
size: 'small',
|
|
249
298
|
onClick: function onClick(e) {
|
|
250
|
-
var _meta$
|
|
299
|
+
var _meta$table3;
|
|
251
300
|
e.stopPropagation();
|
|
252
|
-
onChangeTableAlias(((_meta$
|
|
301
|
+
onChangeTableAlias(((_meta$table3 = meta.table) === null || _meta$table3 === void 0 ? void 0 : _meta$table3.alias) || '');
|
|
253
302
|
}
|
|
254
303
|
})
|
|
255
|
-
}), 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$
|
|
304
|
+
}), 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 ? "as ".concat((_meta$table5 = meta.table) === null || _meta$table5 === void 0 ? void 0 : _meta$table5.alias) : '', " ") : __('SqlQueryBuilder.setSubQuery')]
|
|
256
305
|
}) : _jsxs("div", {
|
|
257
306
|
className: cx("Sqb-TableName", {
|
|
258
307
|
notSelected: !selected
|
|
259
308
|
}),
|
|
260
309
|
onClick: selectTable,
|
|
261
310
|
children: [selected && _jsx(Tooltip, {
|
|
262
|
-
title: __(tableIsError() ? 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
|
|
311
|
+
title: __(tableIsError() ? isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
|
|
263
312
|
children: _jsx(Button, {
|
|
264
313
|
danger: tableIsError(),
|
|
265
314
|
className: cx(':Sqb-TableName-as', {
|
|
266
315
|
isError: tableIsError()
|
|
267
316
|
}),
|
|
268
317
|
shape: 'circle',
|
|
318
|
+
style: isDel ? {
|
|
319
|
+
fontSize: 18,
|
|
320
|
+
backgroundColor: '#fff',
|
|
321
|
+
width: 'auto',
|
|
322
|
+
height: 'auto'
|
|
323
|
+
} : {},
|
|
269
324
|
iconOnly: true,
|
|
270
|
-
primary:
|
|
271
|
-
icon: 'As',
|
|
325
|
+
primary: !isDel,
|
|
326
|
+
icon: isDel ? _jsx(ExclamationCircleFill, {}) : 'As',
|
|
272
327
|
size: 'small',
|
|
273
328
|
onClick: function onClick(e) {
|
|
274
|
-
var _meta$
|
|
329
|
+
var _meta$table6;
|
|
275
330
|
e.stopPropagation();
|
|
276
|
-
onChangeTableAlias(((_meta$
|
|
331
|
+
onChangeTableAlias(((_meta$table6 = meta.table) === null || _meta$table6 === void 0 ? void 0 : _meta$table6.alias) || '');
|
|
277
332
|
}
|
|
278
333
|
})
|
|
279
|
-
}), selected ? "".concat(meta.table.datasourceName, ".").concat(meta.table.name, " ").concat((_meta$
|
|
334
|
+
}), selected ? "".concat(meta.table.datasourceName, ".").concat(meta.table.name, " ").concat((_meta$table7 = meta.table) !== null && _meta$table7 !== void 0 && _meta$table7.alias ? "as ".concat((_meta$table8 = meta.table) === null || _meta$table8 === void 0 ? void 0 : _meta$table8.alias) : '') : __('SqlQueryBuilder.pickTable')]
|
|
280
335
|
}), store.showSubquery && _jsx(Tooltip, {
|
|
281
336
|
title: __('SqlQueryBuilder.switchSubQuery'),
|
|
282
337
|
children: _jsx(Button, {
|