@quillsql/react 2.16.3 → 2.16.4
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/dist/index.cjs +77 -60
- package/dist/index.js +77 -60
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -17152,7 +17152,6 @@ var init_astProcessing = __esm({
|
|
|
17152
17152
|
}
|
|
17153
17153
|
if (numRetries === MAX_RETRIES) {
|
|
17154
17154
|
console.error("[Error]: Max retries exceeded.");
|
|
17155
|
-
console.info(`%c[Prompt]: ${aiPrompt}`, "color: dimgray");
|
|
17156
17155
|
throw new Error(
|
|
17157
17156
|
"Error: Couldn't process your request, please re-word your prompt."
|
|
17158
17157
|
);
|
|
@@ -20390,11 +20389,13 @@ async function saveReport({
|
|
|
20390
20389
|
rows: void 0,
|
|
20391
20390
|
compareRows: void 0,
|
|
20392
20391
|
dashboardItemId,
|
|
20392
|
+
...dashboardItemId ? { reportId: dashboardItemId } : {},
|
|
20393
20393
|
// Remove useNewNodeSql since backend will handle conversion
|
|
20394
20394
|
clientId: publicKey,
|
|
20395
20395
|
tenants,
|
|
20396
20396
|
// Only include adminMode for 'create' task, not 'create-report'
|
|
20397
|
-
...isCreateTask && { adminMode }
|
|
20397
|
+
...isCreateTask && { adminMode },
|
|
20398
|
+
section: report.section
|
|
20398
20399
|
},
|
|
20399
20400
|
getToken
|
|
20400
20401
|
});
|
|
@@ -39001,7 +39002,6 @@ var Table_default = Table;
|
|
|
39001
39002
|
|
|
39002
39003
|
// src/SQLEditor.tsx
|
|
39003
39004
|
var import_react45 = require("react");
|
|
39004
|
-
var import_react_dom5 = require("react-dom");
|
|
39005
39005
|
var import_react46 = __toESM(require("@monaco-editor/react"), 1);
|
|
39006
39006
|
|
|
39007
39007
|
// src/ChartBuilder.tsx
|
|
@@ -42698,7 +42698,8 @@ function ChartBuilder({
|
|
|
42698
42698
|
const { dashboardConfig } = (0, import_react43.useContext)(DashboardConfigContext);
|
|
42699
42699
|
const { tenants, flags } = (0, import_react43.useContext)(TenantContext);
|
|
42700
42700
|
const report = (0, import_react43.useMemo)(() => {
|
|
42701
|
-
|
|
42701
|
+
const resolvedReport = reportId && !tempReport ? allReportsById[reportId] : tempReport;
|
|
42702
|
+
return resolvedReport;
|
|
42702
42703
|
}, [reportId, tempReport, allReportsById]);
|
|
42703
42704
|
const [windowWidth, setWindowWidth] = (0, import_react43.useState)(1200);
|
|
42704
42705
|
const [rows, setRows] = (0, import_react43.useState)(report?.rows ?? []);
|
|
@@ -42708,8 +42709,9 @@ function ChartBuilder({
|
|
|
42708
42709
|
const [isLoading, setIsLoading] = (0, import_react43.useState)(false);
|
|
42709
42710
|
const [rowCountIsLoading, setRowCountIsLoading] = (0, import_react43.useState)(false);
|
|
42710
42711
|
const [isSubmitting, setIsSubmitting] = (0, import_react43.useState)(false);
|
|
42711
|
-
const
|
|
42712
|
-
const [
|
|
42712
|
+
const MIN_FORM_WIDTH = 710;
|
|
42713
|
+
const [pivotCardWidth, setPivotCardWidth] = (0, import_react43.useState)(MIN_FORM_WIDTH);
|
|
42714
|
+
const [formWidth, setFormWidth] = (0, import_react43.useState)(MIN_FORM_WIDTH);
|
|
42713
42715
|
const inputRef = (0, import_react43.useRef)(null);
|
|
42714
42716
|
const selectRef = (0, import_react43.useRef)(null);
|
|
42715
42717
|
const processColumns = (columns2) => {
|
|
@@ -42779,10 +42781,10 @@ function ChartBuilder({
|
|
|
42779
42781
|
const spaceBetween = selectSize.left - inputSize.right;
|
|
42780
42782
|
const gap = showDash ? (spaceBetween - selectWidth) / 2 : spaceBetween;
|
|
42781
42783
|
const width = inputSize.width + 2 * gap + 2 * selectWidth;
|
|
42782
|
-
setPivotCardWidth(width);
|
|
42784
|
+
setPivotCardWidth(Math.max(width, MIN_FORM_WIDTH));
|
|
42783
42785
|
const deleteSize = deleteRef.current?.getBoundingClientRect();
|
|
42784
42786
|
const deleteWidth = deleteSize?.width ?? 0;
|
|
42785
|
-
setFormWidth(width + deleteWidth);
|
|
42787
|
+
setFormWidth(Math.max(width + deleteWidth, MIN_FORM_WIDTH));
|
|
42786
42788
|
}
|
|
42787
42789
|
};
|
|
42788
42790
|
handleResize();
|
|
@@ -43047,23 +43049,40 @@ function ChartBuilder({
|
|
|
43047
43049
|
return result;
|
|
43048
43050
|
};
|
|
43049
43051
|
const getReferencedTables = async (client2, dbTables, sqlQuery, reportBuilderState2, skipStar) => {
|
|
43050
|
-
const
|
|
43051
|
-
|
|
43052
|
-
|
|
43053
|
-
|
|
43054
|
-
|
|
43055
|
-
|
|
43056
|
-
|
|
43057
|
-
|
|
43058
|
-
|
|
43059
|
-
|
|
43060
|
-
|
|
43052
|
+
const metadata = reportBuilderState2 ? {
|
|
43053
|
+
reportBuilderState: reportBuilderState2,
|
|
43054
|
+
clientId: client2.clientId,
|
|
43055
|
+
useNewNodeSql: true
|
|
43056
|
+
} : {
|
|
43057
|
+
query: sqlQuery,
|
|
43058
|
+
clientId: client2.clientId,
|
|
43059
|
+
useNewNodeSql: true
|
|
43060
|
+
};
|
|
43061
|
+
try {
|
|
43062
|
+
const { data: resp } = await quillFetchWithToken({
|
|
43063
|
+
client: client2,
|
|
43064
|
+
task: "astify",
|
|
43065
|
+
metadata
|
|
43066
|
+
});
|
|
43067
|
+
if (resp.success === false) {
|
|
43068
|
+
return getTablesHelper(getSelectFromAST({}), dbTables, skipStar);
|
|
43061
43069
|
}
|
|
43062
|
-
|
|
43063
|
-
|
|
43064
|
-
|
|
43070
|
+
return getTablesHelper(getSelectFromAST(resp.ast), dbTables, skipStar);
|
|
43071
|
+
} catch (error) {
|
|
43072
|
+
console.error(
|
|
43073
|
+
"[ChartBuilder#getReferencedTables] Failed to fetch referenced tables",
|
|
43074
|
+
{
|
|
43075
|
+
error,
|
|
43076
|
+
hasReportBuilderState: !!reportBuilderState2,
|
|
43077
|
+
hasSqlQuery: !!sqlQuery,
|
|
43078
|
+
skipStar: !!skipStar
|
|
43079
|
+
}
|
|
43080
|
+
);
|
|
43081
|
+
return {
|
|
43082
|
+
referencedTablesAndColumns: [],
|
|
43083
|
+
dateFields: []
|
|
43084
|
+
};
|
|
43065
43085
|
}
|
|
43066
|
-
return getTablesHelper(getSelectFromAST(resp.ast), dbTables, skipStar);
|
|
43067
43086
|
};
|
|
43068
43087
|
const getCurrentSection = () => {
|
|
43069
43088
|
let id2 = report?.id ?? "";
|
|
@@ -44053,7 +44072,7 @@ function ChartBuilder({
|
|
|
44053
44072
|
return;
|
|
44054
44073
|
}
|
|
44055
44074
|
let dashboardItemId = reportId ? reportId : void 0;
|
|
44056
|
-
if (report && !isAdmin && formData.template) {
|
|
44075
|
+
if (report && !isAdmin && formData.template && !isEditingMode) {
|
|
44057
44076
|
dashboardItemId = void 0;
|
|
44058
44077
|
}
|
|
44059
44078
|
const newReport = {
|
|
@@ -46237,6 +46256,7 @@ function SQLEditor({
|
|
|
46237
46256
|
onClickChartElement,
|
|
46238
46257
|
onRequestAddVirtualTable
|
|
46239
46258
|
}) {
|
|
46259
|
+
const computedButtonLabel = addToDashboardButtonLabel === "Add to dashboard" ? reportId || report?.id ? "Save changes" : "Add to dashboard" : addToDashboardButtonLabel;
|
|
46240
46260
|
const [sqlPrompt, setSqlPrompt] = (0, import_react45.useState)("");
|
|
46241
46261
|
const [client] = (0, import_react45.useContext)(ClientContext);
|
|
46242
46262
|
const [theme] = (0, import_react45.useContext)(ThemeContext);
|
|
@@ -46560,25 +46580,35 @@ function SQLEditor({
|
|
|
46560
46580
|
onChangeFields(tableInfo.columns);
|
|
46561
46581
|
}
|
|
46562
46582
|
const formData = report ? report : createInitialFormData(tableInfo.columns);
|
|
46563
|
-
const
|
|
46583
|
+
const baseReport = reportId ? tempReport : {
|
|
46564
46584
|
...tempReport,
|
|
46565
|
-
...formData
|
|
46585
|
+
...formData
|
|
46586
|
+
};
|
|
46587
|
+
const newReport = {
|
|
46588
|
+
...baseReport,
|
|
46589
|
+
// In edit mode, preserve critical fields that shouldn't be overwritten
|
|
46590
|
+
...reportId && tempReport.name ? { name: tempReport.name } : {},
|
|
46566
46591
|
itemQuery: tableInfo.itemQuery,
|
|
46567
46592
|
rowCount: tableInfo.rowCount ?? tableInfo.rows.length,
|
|
46568
46593
|
rows: tempRows,
|
|
46569
46594
|
columns: tableInfo.columns,
|
|
46570
|
-
referencedTables: tableInfo.referencedTables
|
|
46595
|
+
referencedTables: tableInfo.referencedTables,
|
|
46596
|
+
queryString: query ?? tempReport.queryString ?? ""
|
|
46571
46597
|
};
|
|
46572
|
-
|
|
46573
|
-
|
|
46574
|
-
|
|
46575
|
-
|
|
46576
|
-
|
|
46577
|
-
|
|
46578
|
-
|
|
46579
|
-
|
|
46580
|
-
|
|
46581
|
-
|
|
46598
|
+
if (reportId) {
|
|
46599
|
+
setTempReport(newReport);
|
|
46600
|
+
} else {
|
|
46601
|
+
const cleaned = await cleanDashboardItem({
|
|
46602
|
+
item: newReport,
|
|
46603
|
+
dashboardFilters: newReport.filtersApplied,
|
|
46604
|
+
client,
|
|
46605
|
+
customFields: schemaData.customFields,
|
|
46606
|
+
getToken,
|
|
46607
|
+
tenants,
|
|
46608
|
+
eventTracking
|
|
46609
|
+
});
|
|
46610
|
+
setTempReport(cleaned);
|
|
46611
|
+
}
|
|
46582
46612
|
setLastSuccessfulQuery(query);
|
|
46583
46613
|
} catch (e) {
|
|
46584
46614
|
eventTracking?.logError?.({
|
|
@@ -46885,7 +46915,7 @@ function SQLEditor({
|
|
|
46885
46915
|
height: 70
|
|
46886
46916
|
},
|
|
46887
46917
|
children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { style: { display: "flex", gap: 12 }, children: [
|
|
46888
|
-
|
|
46918
|
+
computedButtonLabel === "Add to dashboard" ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
46889
46919
|
SecondaryButtonComponent,
|
|
46890
46920
|
{
|
|
46891
46921
|
onClick: () => {
|
|
@@ -46975,7 +47005,7 @@ function SQLEditor({
|
|
|
46975
47005
|
label: "Clear query"
|
|
46976
47006
|
}
|
|
46977
47007
|
),
|
|
46978
|
-
|
|
47008
|
+
computedButtonLabel === "Add to dashboard" && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
46979
47009
|
ButtonComponent,
|
|
46980
47010
|
{
|
|
46981
47011
|
onClick: async () => {
|
|
@@ -46999,9 +47029,9 @@ function SQLEditor({
|
|
|
46999
47029
|
return (schemaData.customFields?.[table] ?? []).map((field) => field.field);
|
|
47000
47030
|
}).flat();
|
|
47001
47031
|
}
|
|
47002
|
-
|
|
47032
|
+
const newTempReport = {
|
|
47003
47033
|
...tempReport,
|
|
47004
|
-
id: TEMP_REPORT_ID,
|
|
47034
|
+
id: reportId || report?.id || TEMP_REPORT_ID,
|
|
47005
47035
|
rows,
|
|
47006
47036
|
columns: isSelectStar ? (
|
|
47007
47037
|
// so Automatic Custom Fields can be applied
|
|
@@ -47018,10 +47048,11 @@ function SQLEditor({
|
|
|
47018
47048
|
rowCount: rowCount ?? 0,
|
|
47019
47049
|
queryString: query ?? "",
|
|
47020
47050
|
dashboardName: report?.dashboardName ?? destinationDashboard
|
|
47021
|
-
}
|
|
47051
|
+
};
|
|
47052
|
+
setTempReport(newTempReport);
|
|
47022
47053
|
setIsChartBuilderOpen(true);
|
|
47023
47054
|
},
|
|
47024
|
-
label:
|
|
47055
|
+
label: computedButtonLabel,
|
|
47025
47056
|
disabled: !!errorMessage || !(lastSuccessfulQuery === query) || !query,
|
|
47026
47057
|
tooltipText: !!errorMessage || !(lastSuccessfulQuery === query) ? "Please run a query" : ""
|
|
47027
47058
|
}
|
|
@@ -47134,28 +47165,14 @@ function SQLEditor({
|
|
|
47134
47165
|
label: "Discard changes"
|
|
47135
47166
|
}
|
|
47136
47167
|
),
|
|
47137
|
-
|
|
47168
|
+
computedButtonLabel !== "Add to dashboard" && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
47138
47169
|
ButtonComponent,
|
|
47139
47170
|
{
|
|
47140
47171
|
onClick: async () => {
|
|
47141
47172
|
onSaveChanges && onSaveChanges();
|
|
47142
|
-
const updatedReport = {
|
|
47143
|
-
...tempReport,
|
|
47144
|
-
id: TEMP_REPORT_ID,
|
|
47145
|
-
rows,
|
|
47146
|
-
columns,
|
|
47147
|
-
columnInternal: columns,
|
|
47148
|
-
rowCount: rowCount ?? 0,
|
|
47149
|
-
queryString: query ?? "",
|
|
47150
|
-
dashboardName: report?.dashboardName ?? destinationDashboard
|
|
47151
|
-
// flags: flagsToAdd,
|
|
47152
|
-
};
|
|
47153
|
-
(0, import_react_dom5.flushSync)(() => {
|
|
47154
|
-
setTempReport(updatedReport);
|
|
47155
|
-
});
|
|
47156
47173
|
setIsChartBuilderOpen(true);
|
|
47157
47174
|
},
|
|
47158
|
-
label:
|
|
47175
|
+
label: computedButtonLabel,
|
|
47159
47176
|
disabled: !!errorMessage || !(lastSuccessfulQuery === query)
|
|
47160
47177
|
}
|
|
47161
47178
|
)
|
|
@@ -47207,7 +47224,7 @@ function SQLEditor({
|
|
|
47207
47224
|
destinationSection,
|
|
47208
47225
|
isAdmin: isAdminEnabled,
|
|
47209
47226
|
title: chartBuilderTitle,
|
|
47210
|
-
buttonLabel:
|
|
47227
|
+
buttonLabel: computedButtonLabel,
|
|
47211
47228
|
tempReport,
|
|
47212
47229
|
reportId: reportId || report?.id,
|
|
47213
47230
|
organizationName,
|
package/dist/index.js
CHANGED
|
@@ -17188,7 +17188,6 @@ var init_astProcessing = __esm({
|
|
|
17188
17188
|
}
|
|
17189
17189
|
if (numRetries === MAX_RETRIES) {
|
|
17190
17190
|
console.error("[Error]: Max retries exceeded.");
|
|
17191
|
-
console.info(`%c[Prompt]: ${aiPrompt}`, "color: dimgray");
|
|
17192
17191
|
throw new Error(
|
|
17193
17192
|
"Error: Couldn't process your request, please re-word your prompt."
|
|
17194
17193
|
);
|
|
@@ -20398,11 +20397,13 @@ async function saveReport({
|
|
|
20398
20397
|
rows: void 0,
|
|
20399
20398
|
compareRows: void 0,
|
|
20400
20399
|
dashboardItemId,
|
|
20400
|
+
...dashboardItemId ? { reportId: dashboardItemId } : {},
|
|
20401
20401
|
// Remove useNewNodeSql since backend will handle conversion
|
|
20402
20402
|
clientId: publicKey,
|
|
20403
20403
|
tenants,
|
|
20404
20404
|
// Only include adminMode for 'create' task, not 'create-report'
|
|
20405
|
-
...isCreateTask && { adminMode }
|
|
20405
|
+
...isCreateTask && { adminMode },
|
|
20406
|
+
section: report.section
|
|
20406
20407
|
},
|
|
20407
20408
|
getToken
|
|
20408
20409
|
});
|
|
@@ -39100,7 +39101,6 @@ import {
|
|
|
39100
39101
|
useMemo as useMemo22,
|
|
39101
39102
|
useCallback as useCallback3
|
|
39102
39103
|
} from "react";
|
|
39103
|
-
import { flushSync as flushSync2 } from "react-dom";
|
|
39104
39104
|
import MonacoEditor from "@monaco-editor/react";
|
|
39105
39105
|
|
|
39106
39106
|
// src/ChartBuilder.tsx
|
|
@@ -42843,7 +42843,8 @@ function ChartBuilder({
|
|
|
42843
42843
|
const { dashboardConfig } = useContext26(DashboardConfigContext);
|
|
42844
42844
|
const { tenants, flags } = useContext26(TenantContext);
|
|
42845
42845
|
const report = useMemo21(() => {
|
|
42846
|
-
|
|
42846
|
+
const resolvedReport = reportId && !tempReport ? allReportsById[reportId] : tempReport;
|
|
42847
|
+
return resolvedReport;
|
|
42847
42848
|
}, [reportId, tempReport, allReportsById]);
|
|
42848
42849
|
const [windowWidth, setWindowWidth] = useState28(1200);
|
|
42849
42850
|
const [rows, setRows] = useState28(report?.rows ?? []);
|
|
@@ -42853,8 +42854,9 @@ function ChartBuilder({
|
|
|
42853
42854
|
const [isLoading, setIsLoading] = useState28(false);
|
|
42854
42855
|
const [rowCountIsLoading, setRowCountIsLoading] = useState28(false);
|
|
42855
42856
|
const [isSubmitting, setIsSubmitting] = useState28(false);
|
|
42856
|
-
const
|
|
42857
|
-
const [
|
|
42857
|
+
const MIN_FORM_WIDTH = 710;
|
|
42858
|
+
const [pivotCardWidth, setPivotCardWidth] = useState28(MIN_FORM_WIDTH);
|
|
42859
|
+
const [formWidth, setFormWidth] = useState28(MIN_FORM_WIDTH);
|
|
42858
42860
|
const inputRef = useRef17(null);
|
|
42859
42861
|
const selectRef = useRef17(null);
|
|
42860
42862
|
const processColumns = (columns2) => {
|
|
@@ -42924,10 +42926,10 @@ function ChartBuilder({
|
|
|
42924
42926
|
const spaceBetween = selectSize.left - inputSize.right;
|
|
42925
42927
|
const gap = showDash ? (spaceBetween - selectWidth) / 2 : spaceBetween;
|
|
42926
42928
|
const width = inputSize.width + 2 * gap + 2 * selectWidth;
|
|
42927
|
-
setPivotCardWidth(width);
|
|
42929
|
+
setPivotCardWidth(Math.max(width, MIN_FORM_WIDTH));
|
|
42928
42930
|
const deleteSize = deleteRef.current?.getBoundingClientRect();
|
|
42929
42931
|
const deleteWidth = deleteSize?.width ?? 0;
|
|
42930
|
-
setFormWidth(width + deleteWidth);
|
|
42932
|
+
setFormWidth(Math.max(width + deleteWidth, MIN_FORM_WIDTH));
|
|
42931
42933
|
}
|
|
42932
42934
|
};
|
|
42933
42935
|
handleResize();
|
|
@@ -43192,23 +43194,40 @@ function ChartBuilder({
|
|
|
43192
43194
|
return result;
|
|
43193
43195
|
};
|
|
43194
43196
|
const getReferencedTables = async (client2, dbTables, sqlQuery, reportBuilderState2, skipStar) => {
|
|
43195
|
-
const
|
|
43196
|
-
|
|
43197
|
-
|
|
43198
|
-
|
|
43199
|
-
|
|
43200
|
-
|
|
43201
|
-
|
|
43202
|
-
|
|
43203
|
-
|
|
43204
|
-
|
|
43205
|
-
|
|
43197
|
+
const metadata = reportBuilderState2 ? {
|
|
43198
|
+
reportBuilderState: reportBuilderState2,
|
|
43199
|
+
clientId: client2.clientId,
|
|
43200
|
+
useNewNodeSql: true
|
|
43201
|
+
} : {
|
|
43202
|
+
query: sqlQuery,
|
|
43203
|
+
clientId: client2.clientId,
|
|
43204
|
+
useNewNodeSql: true
|
|
43205
|
+
};
|
|
43206
|
+
try {
|
|
43207
|
+
const { data: resp } = await quillFetchWithToken({
|
|
43208
|
+
client: client2,
|
|
43209
|
+
task: "astify",
|
|
43210
|
+
metadata
|
|
43211
|
+
});
|
|
43212
|
+
if (resp.success === false) {
|
|
43213
|
+
return getTablesHelper(getSelectFromAST({}), dbTables, skipStar);
|
|
43206
43214
|
}
|
|
43207
|
-
|
|
43208
|
-
|
|
43209
|
-
|
|
43215
|
+
return getTablesHelper(getSelectFromAST(resp.ast), dbTables, skipStar);
|
|
43216
|
+
} catch (error) {
|
|
43217
|
+
console.error(
|
|
43218
|
+
"[ChartBuilder#getReferencedTables] Failed to fetch referenced tables",
|
|
43219
|
+
{
|
|
43220
|
+
error,
|
|
43221
|
+
hasReportBuilderState: !!reportBuilderState2,
|
|
43222
|
+
hasSqlQuery: !!sqlQuery,
|
|
43223
|
+
skipStar: !!skipStar
|
|
43224
|
+
}
|
|
43225
|
+
);
|
|
43226
|
+
return {
|
|
43227
|
+
referencedTablesAndColumns: [],
|
|
43228
|
+
dateFields: []
|
|
43229
|
+
};
|
|
43210
43230
|
}
|
|
43211
|
-
return getTablesHelper(getSelectFromAST(resp.ast), dbTables, skipStar);
|
|
43212
43231
|
};
|
|
43213
43232
|
const getCurrentSection = () => {
|
|
43214
43233
|
let id2 = report?.id ?? "";
|
|
@@ -44198,7 +44217,7 @@ function ChartBuilder({
|
|
|
44198
44217
|
return;
|
|
44199
44218
|
}
|
|
44200
44219
|
let dashboardItemId = reportId ? reportId : void 0;
|
|
44201
|
-
if (report && !isAdmin && formData.template) {
|
|
44220
|
+
if (report && !isAdmin && formData.template && !isEditingMode) {
|
|
44202
44221
|
dashboardItemId = void 0;
|
|
44203
44222
|
}
|
|
44204
44223
|
const newReport = {
|
|
@@ -46382,6 +46401,7 @@ function SQLEditor({
|
|
|
46382
46401
|
onClickChartElement,
|
|
46383
46402
|
onRequestAddVirtualTable
|
|
46384
46403
|
}) {
|
|
46404
|
+
const computedButtonLabel = addToDashboardButtonLabel === "Add to dashboard" ? reportId || report?.id ? "Save changes" : "Add to dashboard" : addToDashboardButtonLabel;
|
|
46385
46405
|
const [sqlPrompt, setSqlPrompt] = useState30("");
|
|
46386
46406
|
const [client] = useContext28(ClientContext);
|
|
46387
46407
|
const [theme] = useContext28(ThemeContext);
|
|
@@ -46705,25 +46725,35 @@ function SQLEditor({
|
|
|
46705
46725
|
onChangeFields(tableInfo.columns);
|
|
46706
46726
|
}
|
|
46707
46727
|
const formData = report ? report : createInitialFormData(tableInfo.columns);
|
|
46708
|
-
const
|
|
46728
|
+
const baseReport = reportId ? tempReport : {
|
|
46709
46729
|
...tempReport,
|
|
46710
|
-
...formData
|
|
46730
|
+
...formData
|
|
46731
|
+
};
|
|
46732
|
+
const newReport = {
|
|
46733
|
+
...baseReport,
|
|
46734
|
+
// In edit mode, preserve critical fields that shouldn't be overwritten
|
|
46735
|
+
...reportId && tempReport.name ? { name: tempReport.name } : {},
|
|
46711
46736
|
itemQuery: tableInfo.itemQuery,
|
|
46712
46737
|
rowCount: tableInfo.rowCount ?? tableInfo.rows.length,
|
|
46713
46738
|
rows: tempRows,
|
|
46714
46739
|
columns: tableInfo.columns,
|
|
46715
|
-
referencedTables: tableInfo.referencedTables
|
|
46740
|
+
referencedTables: tableInfo.referencedTables,
|
|
46741
|
+
queryString: query ?? tempReport.queryString ?? ""
|
|
46716
46742
|
};
|
|
46717
|
-
|
|
46718
|
-
|
|
46719
|
-
|
|
46720
|
-
|
|
46721
|
-
|
|
46722
|
-
|
|
46723
|
-
|
|
46724
|
-
|
|
46725
|
-
|
|
46726
|
-
|
|
46743
|
+
if (reportId) {
|
|
46744
|
+
setTempReport(newReport);
|
|
46745
|
+
} else {
|
|
46746
|
+
const cleaned = await cleanDashboardItem({
|
|
46747
|
+
item: newReport,
|
|
46748
|
+
dashboardFilters: newReport.filtersApplied,
|
|
46749
|
+
client,
|
|
46750
|
+
customFields: schemaData.customFields,
|
|
46751
|
+
getToken,
|
|
46752
|
+
tenants,
|
|
46753
|
+
eventTracking
|
|
46754
|
+
});
|
|
46755
|
+
setTempReport(cleaned);
|
|
46756
|
+
}
|
|
46727
46757
|
setLastSuccessfulQuery(query);
|
|
46728
46758
|
} catch (e) {
|
|
46729
46759
|
eventTracking?.logError?.({
|
|
@@ -47030,7 +47060,7 @@ function SQLEditor({
|
|
|
47030
47060
|
height: 70
|
|
47031
47061
|
},
|
|
47032
47062
|
children: /* @__PURE__ */ jsxs48("div", { style: { display: "flex", gap: 12 }, children: [
|
|
47033
|
-
|
|
47063
|
+
computedButtonLabel === "Add to dashboard" ? /* @__PURE__ */ jsx66(
|
|
47034
47064
|
SecondaryButtonComponent,
|
|
47035
47065
|
{
|
|
47036
47066
|
onClick: () => {
|
|
@@ -47120,7 +47150,7 @@ function SQLEditor({
|
|
|
47120
47150
|
label: "Clear query"
|
|
47121
47151
|
}
|
|
47122
47152
|
),
|
|
47123
|
-
|
|
47153
|
+
computedButtonLabel === "Add to dashboard" && /* @__PURE__ */ jsx66(
|
|
47124
47154
|
ButtonComponent,
|
|
47125
47155
|
{
|
|
47126
47156
|
onClick: async () => {
|
|
@@ -47144,9 +47174,9 @@ function SQLEditor({
|
|
|
47144
47174
|
return (schemaData.customFields?.[table] ?? []).map((field) => field.field);
|
|
47145
47175
|
}).flat();
|
|
47146
47176
|
}
|
|
47147
|
-
|
|
47177
|
+
const newTempReport = {
|
|
47148
47178
|
...tempReport,
|
|
47149
|
-
id: TEMP_REPORT_ID,
|
|
47179
|
+
id: reportId || report?.id || TEMP_REPORT_ID,
|
|
47150
47180
|
rows,
|
|
47151
47181
|
columns: isSelectStar ? (
|
|
47152
47182
|
// so Automatic Custom Fields can be applied
|
|
@@ -47163,10 +47193,11 @@ function SQLEditor({
|
|
|
47163
47193
|
rowCount: rowCount ?? 0,
|
|
47164
47194
|
queryString: query ?? "",
|
|
47165
47195
|
dashboardName: report?.dashboardName ?? destinationDashboard
|
|
47166
|
-
}
|
|
47196
|
+
};
|
|
47197
|
+
setTempReport(newTempReport);
|
|
47167
47198
|
setIsChartBuilderOpen(true);
|
|
47168
47199
|
},
|
|
47169
|
-
label:
|
|
47200
|
+
label: computedButtonLabel,
|
|
47170
47201
|
disabled: !!errorMessage || !(lastSuccessfulQuery === query) || !query,
|
|
47171
47202
|
tooltipText: !!errorMessage || !(lastSuccessfulQuery === query) ? "Please run a query" : ""
|
|
47172
47203
|
}
|
|
@@ -47279,28 +47310,14 @@ function SQLEditor({
|
|
|
47279
47310
|
label: "Discard changes"
|
|
47280
47311
|
}
|
|
47281
47312
|
),
|
|
47282
|
-
|
|
47313
|
+
computedButtonLabel !== "Add to dashboard" && /* @__PURE__ */ jsx66(
|
|
47283
47314
|
ButtonComponent,
|
|
47284
47315
|
{
|
|
47285
47316
|
onClick: async () => {
|
|
47286
47317
|
onSaveChanges && onSaveChanges();
|
|
47287
|
-
const updatedReport = {
|
|
47288
|
-
...tempReport,
|
|
47289
|
-
id: TEMP_REPORT_ID,
|
|
47290
|
-
rows,
|
|
47291
|
-
columns,
|
|
47292
|
-
columnInternal: columns,
|
|
47293
|
-
rowCount: rowCount ?? 0,
|
|
47294
|
-
queryString: query ?? "",
|
|
47295
|
-
dashboardName: report?.dashboardName ?? destinationDashboard
|
|
47296
|
-
// flags: flagsToAdd,
|
|
47297
|
-
};
|
|
47298
|
-
flushSync2(() => {
|
|
47299
|
-
setTempReport(updatedReport);
|
|
47300
|
-
});
|
|
47301
47318
|
setIsChartBuilderOpen(true);
|
|
47302
47319
|
},
|
|
47303
|
-
label:
|
|
47320
|
+
label: computedButtonLabel,
|
|
47304
47321
|
disabled: !!errorMessage || !(lastSuccessfulQuery === query)
|
|
47305
47322
|
}
|
|
47306
47323
|
)
|
|
@@ -47352,7 +47369,7 @@ function SQLEditor({
|
|
|
47352
47369
|
destinationSection,
|
|
47353
47370
|
isAdmin: isAdminEnabled,
|
|
47354
47371
|
title: chartBuilderTitle,
|
|
47355
|
-
buttonLabel:
|
|
47372
|
+
buttonLabel: computedButtonLabel,
|
|
47356
47373
|
tempReport,
|
|
47357
47374
|
reportId: reportId || report?.id,
|
|
47358
47375
|
organizationName,
|