@quillsql/react 2.16.2 → 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.js CHANGED
@@ -393,7 +393,7 @@ var init_constants = __esm({
393
393
  "use strict";
394
394
  MAX_PIVOT_UNIQUE_VALUES = 250;
395
395
  QUILL_SERVER = typeof process !== "undefined" && process.env ? process.env.QUILL_SERVER_HOST ?? "https://quill-344421.uc.r.appspot.com" : "https://quill-344421.uc.r.appspot.com";
396
- QUILL_QUERY_ENDPOINT = typeof process !== "undefined" && process.env ? process.env.QUILL_QUERY_ENDPOINT ?? "/cloud" : "/cloud";
396
+ QUILL_QUERY_ENDPOINT = typeof process !== "undefined" && process.env ? process.env.QUILL_QUERY_ENDPOINT ?? "/cloud/engine" : "/cloud/engine";
397
397
  ALL_TENANTS = "QUILL_ALL_TENANTS";
398
398
  SINGLE_TENANT = "QUILL_SINGLE_TENANT";
399
399
  SAVED_QUERIES_DASHBOARD = "quill-saved-queries";
@@ -15983,6 +15983,7 @@ async function generatePivotWithSQL({
15983
15983
  dateFilter,
15984
15984
  distinctStrings,
15985
15985
  dashboardName,
15986
+ dashboardFilters,
15986
15987
  tenants,
15987
15988
  additionalProcessing,
15988
15989
  pivotQuery,
@@ -16026,6 +16027,7 @@ async function generatePivotWithSQL({
16026
16027
  metadata: {
16027
16028
  clientId: client.clientId,
16028
16029
  pivot: pivotConfig,
16030
+ reportId: report?.id !== "__quillTempReport" ? report?.id : void 0,
16029
16031
  itemQuery: reportBuilderState ? void 0 : report?.queryString,
16030
16032
  // Don't send itemQuery if reportBuilderState is present
16031
16033
  reportBuilderState,
@@ -16033,6 +16035,11 @@ async function generatePivotWithSQL({
16033
16035
  databaseType,
16034
16036
  // Required when sending reportBuilderState
16035
16037
  dashboardName,
16038
+ filters: !report?.id ? void 0 : dashboardFilters?.map((filter) => ({
16039
+ ...filter,
16040
+ options: void 0
16041
+ })),
16042
+ // Only pass dashboard filters in Dashboard context, not ReportBuilder
16036
16043
  tenants,
16037
16044
  additionalProcessing
16038
16045
  },
@@ -16202,6 +16209,7 @@ async function generatePivotTable({
16202
16209
  eventTracking,
16203
16210
  uniqueValues,
16204
16211
  dashboardName,
16212
+ dashboardFilters,
16205
16213
  tenants,
16206
16214
  additionalProcessing,
16207
16215
  caller,
@@ -16219,6 +16227,7 @@ async function generatePivotTable({
16219
16227
  dateBucket,
16220
16228
  dateFilter,
16221
16229
  dashboardName,
16230
+ dashboardFilters,
16222
16231
  tenants,
16223
16232
  additionalProcessing,
16224
16233
  caller,
@@ -17179,7 +17188,6 @@ var init_astProcessing = __esm({
17179
17188
  }
17180
17189
  if (numRetries === MAX_RETRIES) {
17181
17190
  console.error("[Error]: Max retries exceeded.");
17182
- console.info(`%c[Prompt]: ${aiPrompt}`, "color: dimgray");
17183
17191
  throw new Error(
17184
17192
  "Error: Couldn't process your request, please re-word your prompt."
17185
17193
  );
@@ -17209,27 +17217,6 @@ var init_astProcessing = __esm({
17209
17217
  if (!tableInfo) {
17210
17218
  throw new Error("Table info not found");
17211
17219
  }
17212
- console.log("[astProcessing] Calling report-builder-unique-values", {
17213
- table: processedName,
17214
- columnCount: tableInfo.columns.length,
17215
- reportBuilderState: {
17216
- tables: [{ name: processedName }],
17217
- columns: tableInfo.columns.map(
17218
- (col) => ({
17219
- field: col.field,
17220
- table: processedName,
17221
- label: col.label,
17222
- format: col.format,
17223
- aggregate: void 0,
17224
- customExpression: void 0
17225
- })
17226
- ),
17227
- filters: [],
17228
- sorts: [],
17229
- groupByColumns: [],
17230
- limit: void 0
17231
- }
17232
- });
17233
17220
  const uniqueValues = await getUniqueStringValuesByColumn({
17234
17221
  columns: tableInfo.columns,
17235
17222
  tableName: processedName,
@@ -17310,12 +17297,15 @@ var init_astProcessing = __esm({
17310
17297
  if (!report) {
17311
17298
  throw new Error("Report not found");
17312
17299
  }
17313
- const resp = astify(
17314
- report.queryString,
17315
- client.databaseType || "postgresql",
17316
- true
17317
- // useNewNodeSql = true
17318
- );
17300
+ const { data: resp } = await quillFetch({
17301
+ client,
17302
+ task: "astify",
17303
+ metadata: {
17304
+ query: report.queryString,
17305
+ useNewNodeSql: true
17306
+ },
17307
+ getToken
17308
+ });
17319
17309
  if (resp.success === false) {
17320
17310
  throw new Error(resp.message || "Couldn't process report query.");
17321
17311
  }
@@ -17656,7 +17646,15 @@ var init_tableProcessing = __esm({
17656
17646
  baseQuery = withMatch[1];
17657
17647
  }
17658
17648
  const dbType = client.databaseType || "postgresql";
17659
- const astResponse = astify(baseQuery, dbType, true);
17649
+ const { data: astResponse } = await quillFetch({
17650
+ client,
17651
+ task: "astify",
17652
+ metadata: {
17653
+ query: baseQuery,
17654
+ useNewNodeSql: true
17655
+ },
17656
+ getToken
17657
+ });
17660
17658
  if (astResponse.success && astResponse.ast) {
17661
17659
  const selectAst = getSelectFromAST(astResponse.ast);
17662
17660
  const tableNames = selectAst.from ? selectAst.from.map((t) => t.as || t.table || t.name).filter(Boolean) : [];
@@ -17812,7 +17810,7 @@ var init_tableProcessing = __esm({
17812
17810
  task: "report-builder-unique-values",
17813
17811
  metadata: {
17814
17812
  reportBuilderState,
17815
- columns: stringColumns.map((col) => col.field),
17813
+ stringColumns: stringColumns.map((col) => col.field),
17816
17814
  clientId: client.clientId,
17817
17815
  databaseType: client.databaseType?.toLowerCase() || "postgresql",
17818
17816
  customFields,
@@ -17933,7 +17931,6 @@ var init_tableProcessing = __esm({
17933
17931
  dashboardName,
17934
17932
  reportBuilderState
17935
17933
  );
17936
- console.log("dateRanges 1", dateRanges);
17937
17934
  if (dateRanges === null) {
17938
17935
  throw new Error("Couldn't fetch date ranges");
17939
17936
  }
@@ -18050,7 +18047,7 @@ var init_tableProcessing = __esm({
18050
18047
  task: "report-builder-unique-values",
18051
18048
  metadata: {
18052
18049
  reportBuilderState,
18053
- columns,
18050
+ stringColumns: columns,
18054
18051
  clientId: client.clientId,
18055
18052
  databaseType: client.databaseType?.toLowerCase() || "postgresql",
18056
18053
  customFields,
@@ -18188,7 +18185,6 @@ var init_tableProcessing = __esm({
18188
18185
  },
18189
18186
  {}
18190
18187
  );
18191
- console.log("what", results);
18192
18188
  return results;
18193
18189
  }
18194
18190
  const distinctValueQuery = generateMinMaxDateRangeQueries(
@@ -18299,15 +18295,23 @@ var init_tableProcessing = __esm({
18299
18295
  let parsedSuccessfully = true;
18300
18296
  let parsingError = "";
18301
18297
  if (!rowCountOnly) {
18302
- const results = astify(
18303
- query,
18304
- client.databaseType || "postgresql",
18305
- true
18306
- // useNewNodeSql = true
18307
- );
18308
- if (!results || results.success == false) {
18298
+ try {
18299
+ const { data: results } = await quillFetch({
18300
+ client,
18301
+ task: "astify",
18302
+ metadata: {
18303
+ query,
18304
+ useNewNodeSql: true
18305
+ },
18306
+ getToken
18307
+ });
18308
+ if (!results || results.success == false) {
18309
+ parsedSuccessfully = false;
18310
+ parsingError = results.message || "";
18311
+ }
18312
+ } catch (e) {
18309
18313
  parsedSuccessfully = false;
18310
- parsingError = results.message || "";
18314
+ parsingError = e.message || "Failed to parse query";
18311
18315
  }
18312
18316
  }
18313
18317
  const fetchResp = await quillFetch({
@@ -19932,6 +19936,7 @@ async function getPivotTable(report, dashboardFilters, dashboardName, getToken,
19932
19936
  dateBucket,
19933
19937
  dateFilter,
19934
19938
  dashboardName,
19939
+ dashboardFilters,
19935
19940
  tenants,
19936
19941
  additionalProcessing,
19937
19942
  getToken
@@ -19960,6 +19965,7 @@ async function getPivotTable(report, dashboardFilters, dashboardName, getToken,
19960
19965
  client,
19961
19966
  uniqueValues: report.distinctStrings,
19962
19967
  dashboardName,
19968
+ dashboardFilters,
19963
19969
  tenants,
19964
19970
  dateFilter,
19965
19971
  additionalProcessing,
@@ -20367,27 +20373,37 @@ async function saveReport({
20367
20373
  tenants
20368
20374
  }) {
20369
20375
  const { publicKey, databaseType } = client;
20370
- const { reportBuilderState, queryString, ...reportWithoutStateAndQuery } = report;
20376
+ const {
20377
+ reportBuilderState,
20378
+ queryString,
20379
+ adminMode,
20380
+ ...reportWithoutStateAndQuery
20381
+ } = report;
20371
20382
  const reportToSave = reportWithoutStateAndQuery;
20372
- const task = reportBuilderState ? "create-report" : "create";
20383
+ const task = reportBuilderState && !adminMode ? "create-report" : "create";
20384
+ const isCreateTask = task === "create";
20373
20385
  const { data } = await quillFetch({
20374
20386
  client,
20375
20387
  task,
20376
20388
  metadata: {
20377
20389
  ...reportToSave,
20378
- // Pass reportBuilderState for create-report, queryString for create
20390
+ // Pass reportBuilderState if present, queryString otherwise
20379
20391
  ...reportBuilderState ? {
20380
20392
  reportBuilderState,
20381
- databaseType: databaseType || "postgresql"
20393
+ databaseType
20382
20394
  } : {
20383
20395
  queryString
20384
20396
  },
20385
20397
  rows: void 0,
20386
20398
  compareRows: void 0,
20387
20399
  dashboardItemId,
20400
+ ...dashboardItemId ? { reportId: dashboardItemId } : {},
20388
20401
  // Remove useNewNodeSql since backend will handle conversion
20389
20402
  clientId: publicKey,
20390
- tenants
20403
+ tenants,
20404
+ // Only include adminMode for 'create' task, not 'create-report'
20405
+ ...isCreateTask && { adminMode },
20406
+ section: report.section
20391
20407
  },
20392
20408
  getToken
20393
20409
  });
@@ -20664,7 +20680,6 @@ var fetchReportBuilderDataFromAST = async ({
20664
20680
  customFields ?? [],
20665
20681
  dashboardName
20666
20682
  );
20667
- console.log("dateRanges 3", dateRanges);
20668
20683
  if (dateRanges === null) {
20669
20684
  throw new Error("Couldn't fetch date ranges");
20670
20685
  }
@@ -31633,23 +31648,53 @@ function QuillMetricComponent({
31633
31648
  width: "100%"
31634
31649
  }
31635
31650
  }
31636
- ) : !report?.rows?.[0] || report.rows[0][report.xAxisField] === null ? /* @__PURE__ */ jsx43(
31651
+ ) : !report?.rows || report?.rows?.length === 0 || report.rows[0]?.[report.xAxisField] === null || report.rows[0]?.[report.xAxisField] === void 0 ? /* @__PURE__ */ jsx43(
31637
31652
  "div",
31638
31653
  {
31639
31654
  style: {
31640
- display: "flex",
31641
- flex: "1 0 auto",
31642
- // height: '100%',
31643
- margin: "auto",
31644
- justifyContent: "center",
31645
- alignItems: "center",
31646
- fontSize: 13,
31647
- fontFamily: theme?.fontFamily,
31648
- color: theme?.secondaryTextColor,
31649
- maxWidth: "100%",
31650
- width: "100%"
31655
+ padding: 0,
31656
+ height: "100%",
31657
+ width: "100%",
31658
+ boxSizing: "content-box",
31659
+ flex: 1
31651
31660
  },
31652
- children: "No results"
31661
+ children: /* @__PURE__ */ jsx43(
31662
+ "div",
31663
+ {
31664
+ style: {
31665
+ fontFamily: theme?.fontFamily,
31666
+ fontSize: 32,
31667
+ color: theme?.primaryTextColor,
31668
+ fontWeight: "600",
31669
+ textOverflow: "ellipsis",
31670
+ margin: 0,
31671
+ whiteSpace: "nowrap",
31672
+ boxSizing: "content-box",
31673
+ maxWidth: "100%",
31674
+ textAlign: "left",
31675
+ overflow: "hidden",
31676
+ height: "100%",
31677
+ minHeight: "80px",
31678
+ display: "flex",
31679
+ width: "100%",
31680
+ flexDirection: "row",
31681
+ justifyContent: "center",
31682
+ alignItems: "center"
31683
+ },
31684
+ children: /* @__PURE__ */ jsx43(
31685
+ "span",
31686
+ {
31687
+ style: {
31688
+ fontFamily: theme?.fontFamily,
31689
+ fontSize: 13,
31690
+ color: theme?.secondaryTextColor,
31691
+ fontWeight: "normal"
31692
+ },
31693
+ children: "No results"
31694
+ }
31695
+ )
31696
+ }
31697
+ )
31653
31698
  }
31654
31699
  ) : /* @__PURE__ */ jsx43(
31655
31700
  MetricDisplay,
@@ -32882,6 +32927,29 @@ function USMap({
32882
32927
  const hoveredValue = useMemo12(() => {
32883
32928
  return !hoveredState ? void 0 : mappedData[fipsToNames[hoveredState]?.abbreviation ?? ""]?.[measureField] ?? mappedData[fipsToNames[hoveredState]?.name ?? ""]?.[measureField] ?? mappedData[fipsToNames[hoveredState]?.abbreviation?.toLowerCase() ?? ""]?.[measureField] ?? mappedData[fipsToNames[hoveredState]?.name?.toLowerCase() ?? ""]?.[measureField];
32884
32929
  }, [hoveredState, mappedData, measureField]);
32930
+ if (!measureField) {
32931
+ return /* @__PURE__ */ jsx45(
32932
+ "div",
32933
+ {
32934
+ style: {
32935
+ display: "flex",
32936
+ flex: "1 0 auto",
32937
+ marginLeft: "auto",
32938
+ marginRight: "auto",
32939
+ marginTop: "auto",
32940
+ marginBottom: "auto",
32941
+ justifyContent: "center",
32942
+ alignItems: "center",
32943
+ fontSize: 13,
32944
+ color: theme?.secondaryTextColor,
32945
+ fontFamily: theme?.fontFamily,
32946
+ ...containerStyle
32947
+ },
32948
+ className,
32949
+ children: "No results"
32950
+ }
32951
+ );
32952
+ }
32885
32953
  return /* @__PURE__ */ jsxs34(
32886
32954
  "div",
32887
32955
  {
@@ -33050,6 +33118,29 @@ function WorldMap({
33050
33118
  const hoveredValue = useMemo12(() => {
33051
33119
  return !hoveredCountry ? void 0 : mappedData[isoToNames[hoveredCountry]?.abbreviation ?? ""]?.[measureField] ?? mappedData[isoToNames[hoveredCountry]?.name ?? ""]?.[measureField] ?? mappedData[isoToNames[hoveredCountry]?.abbreviation?.toLowerCase() ?? ""]?.[measureField] ?? mappedData[isoToNames[hoveredCountry]?.name?.toLowerCase() ?? ""]?.[measureField];
33052
33120
  }, [hoveredCountry, mappedData, measureField]);
33121
+ if (!measureField) {
33122
+ return /* @__PURE__ */ jsx45(
33123
+ "div",
33124
+ {
33125
+ style: {
33126
+ display: "flex",
33127
+ flex: "1 0 auto",
33128
+ marginLeft: "auto",
33129
+ marginRight: "auto",
33130
+ marginTop: "auto",
33131
+ marginBottom: "auto",
33132
+ justifyContent: "center",
33133
+ alignItems: "center",
33134
+ fontSize: 13,
33135
+ color: theme?.secondaryTextColor,
33136
+ fontFamily: theme?.fontFamily,
33137
+ ...containerStyle
33138
+ },
33139
+ className,
33140
+ children: "No results"
33141
+ }
33142
+ );
33143
+ }
33053
33144
  return /* @__PURE__ */ jsxs34(
33054
33145
  "div",
33055
33146
  {
@@ -35264,7 +35355,7 @@ function Chart({
35264
35355
  index
35265
35356
  )) }),
35266
35357
  loading || !report ? /* @__PURE__ */ jsx48(LoadingComponent, {}) : /* @__PURE__ */ jsxs36(Fragment6, { children: [
35267
- ("table" === report.chartType || "metric" === report.chartType) && /* @__PURE__ */ jsx48(
35358
+ ("table" === report.chartType || "metric" === report.chartType) && /* @__PURE__ */ jsx48(Fragment6, { children: /* @__PURE__ */ jsx48(
35268
35359
  DataLoader,
35269
35360
  {
35270
35361
  item: report,
@@ -35299,13 +35390,17 @@ function Chart({
35299
35390
  error: error2,
35300
35391
  rowCount: rowCount ?? data?.rowCount ?? data?.rows?.length ?? 0,
35301
35392
  rowCountIsLoading,
35302
- onPageChange: (page) => onPageChange(page),
35303
- onSortChange: (sort) => onSortChange(sort),
35393
+ onPageChange: (page) => {
35394
+ onPageChange(page);
35395
+ },
35396
+ onSortChange: (sort) => {
35397
+ onSortChange(sort);
35398
+ },
35304
35399
  hideName: true
35305
35400
  }
35306
35401
  )
35307
35402
  }
35308
- ),
35403
+ ) }),
35309
35404
  report.chartType !== "table" && report.chartType !== "metric" && /* @__PURE__ */ jsx48(
35310
35405
  ChartDataLoader,
35311
35406
  {
@@ -35435,7 +35530,7 @@ var ChartDisplay = ({
35435
35530
  {
35436
35531
  className,
35437
35532
  containerStyle,
35438
- data: config?.rows?.map((row) => {
35533
+ data: !config?.pivot ? config?.rows?.map((row) => {
35439
35534
  return {
35440
35535
  ...row,
35441
35536
  count: (
@@ -35443,7 +35538,7 @@ var ChartDisplay = ({
35443
35538
  parseInt(row[config?.yAxisFields[0]?.field]) / sumByKey(config?.rows, config?.yAxisFields[0]?.field)
35444
35539
  )
35445
35540
  };
35446
- }) || [],
35541
+ }) || [] : config?.rows || [],
35447
35542
  category: config?.yAxisFields?.[0]?.field,
35448
35543
  index: config?.xAxisField,
35449
35544
  colors: chartColors,
@@ -35558,27 +35653,41 @@ var ChartDisplay = ({
35558
35653
  );
35559
35654
  }
35560
35655
  if (config?.chartType?.toLowerCase() === "metric") {
35561
- if (!config?.rows || config?.rows?.length === 0 || // @ts-ignore
35562
- config?.rows[0][config?.xAxisField] === null) {
35656
+ if (!config?.rows || config?.rows?.length === 0 || config?.rows[0]?.[config?.xAxisField] === null || config?.rows[0]?.[config?.xAxisField] === void 0) {
35563
35657
  return /* @__PURE__ */ jsx48(
35564
35658
  "div",
35565
35659
  {
35566
35660
  style: {
35567
- display: "flex",
35568
- flex: "1 0 auto",
35569
- // height: containerStyle?.height || '100%',
35570
- margin: "auto",
35571
- justifyContent: "center",
35572
- alignItems: "center",
35573
- fontSize: 13,
35574
35661
  fontFamily: theme?.fontFamily,
35575
- color: theme?.secondaryTextColor,
35662
+ fontSize: 32,
35663
+ color: theme?.primaryTextColor,
35664
+ fontWeight: "600",
35665
+ textOverflow: "ellipsis",
35666
+ margin: 0,
35667
+ whiteSpace: "nowrap",
35668
+ boxSizing: "content-box",
35576
35669
  maxWidth: "100%",
35670
+ textAlign: "left",
35671
+ overflow: "hidden",
35672
+ height: containerStyle?.height || "100%",
35673
+ display: "flex",
35577
35674
  width: "100%",
35675
+ flexDirection: "row",
35676
+ alignItems: "center",
35578
35677
  ...containerStyle
35579
35678
  },
35580
35679
  className,
35581
- children: "No results"
35680
+ children: /* @__PURE__ */ jsx48(
35681
+ "span",
35682
+ {
35683
+ style: {
35684
+ fontFamily: theme?.fontFamily,
35685
+ fontSize: 13,
35686
+ color: theme?.secondaryTextColor
35687
+ },
35688
+ children: "No results"
35689
+ }
35690
+ )
35582
35691
  }
35583
35692
  );
35584
35693
  }
@@ -38453,7 +38562,7 @@ function Dashboard({
38453
38562
  data: data2,
38454
38563
  rowCount,
38455
38564
  rowCountIsLoading
38456
- }) => /* @__PURE__ */ jsx57(
38565
+ }) => /* @__PURE__ */ jsx57(Fragment10, { children: /* @__PURE__ */ jsx57(
38457
38566
  TableComponent,
38458
38567
  {
38459
38568
  report: data2,
@@ -38478,10 +38587,14 @@ function Dashboard({
38478
38587
  hoverActions,
38479
38588
  rowCount: rowCount ?? data2?.rowCount ?? data2?.rows?.length ?? 0,
38480
38589
  rowCountIsLoading,
38481
- onPageChange: (page) => onPageChange(page),
38482
- onSortChange: (sort) => onSortChange(sort)
38590
+ onPageChange: (page) => {
38591
+ onPageChange(page);
38592
+ },
38593
+ onSortChange: (sort) => {
38594
+ onSortChange(sort);
38595
+ }
38483
38596
  }
38484
- )
38597
+ ) })
38485
38598
  },
38486
38599
  `${name2}${item.id}`
38487
38600
  )) })
@@ -38501,7 +38614,11 @@ function Dashboard({
38501
38614
  children: ({
38502
38615
  isLoading: isLoading2,
38503
38616
  error,
38504
- data: data2
38617
+ onPageChange,
38618
+ onSortChange,
38619
+ data: data2,
38620
+ rowCount,
38621
+ rowCountIsLoading
38505
38622
  }) => item.chartType === "metric" ? /* @__PURE__ */ jsx57(
38506
38623
  MetricComponent,
38507
38624
  {
@@ -38548,7 +38665,14 @@ function Dashboard({
38548
38665
  });
38549
38666
  } : void 0,
38550
38667
  hoverActions,
38551
- rowCount: data2.rowCount ?? data2.rows?.length ?? 0
38668
+ rowCount: rowCount ?? data2.rowCount ?? data2.rows?.length ?? 0,
38669
+ rowCountIsLoading,
38670
+ onPageChange: (page) => {
38671
+ onPageChange(page);
38672
+ },
38673
+ onSortChange: (sort) => {
38674
+ onSortChange(sort);
38675
+ }
38552
38676
  }
38553
38677
  )
38554
38678
  },
@@ -39544,11 +39668,6 @@ var PivotModal = ({
39544
39668
  dashboardName,
39545
39669
  reportBuilderState
39546
39670
  );
39547
- console.log("[PivotModal] Calling report-builder-unique-values", {
39548
- columnCount: smallStringColumns.length,
39549
- hasReportBuilderState: !!reportBuilderState,
39550
- reportBuilderState
39551
- });
39552
39671
  newUniqueValues = await getUniqueValuesByQuery({
39553
39672
  columns: smallStringColumns,
39554
39673
  query: query || "",
@@ -41786,6 +41905,7 @@ function InternalChart({
41786
41905
  // src/ChartBuilder.tsx
41787
41906
  init_paginationProcessing();
41788
41907
  init_tableProcessing();
41908
+ init_dataFetcher();
41789
41909
  init_dates();
41790
41910
 
41791
41911
  // src/components/QuillMultiSelectSectionList.tsx
@@ -42631,15 +42751,19 @@ function ChartBuilderWithModal(props) {
42631
42751
  title: title || "Add to dashboard",
42632
42752
  width: isHorizontalView ? modalWidth : void 0,
42633
42753
  height: isHorizontalView ? modalHeight : void 0,
42634
- children: (props.reportId ? dashboard[props.reportId] ?? props.tempReport : props.tempReport) ? /* @__PURE__ */ jsx65(
42635
- ChartBuilder,
42636
- {
42637
- ...props,
42638
- filtersEnabled: filtersEnabledState,
42639
- onFiltersEnabledChanged: setFiltersEnabledState,
42640
- runQueryOnMount: filtersEnabledState
42641
- }
42642
- ) : /* @__PURE__ */ jsx65("div", { style: { padding: 20 }, children: /* @__PURE__ */ jsx65(QuillLoadingComponent, {}) })
42754
+ children: (() => {
42755
+ const resolvedReport = props.tempReport ?? (props.reportId ? dashboard[props.reportId] : void 0);
42756
+ return resolvedReport ? /* @__PURE__ */ jsx65(
42757
+ ChartBuilder,
42758
+ {
42759
+ ...props,
42760
+ tempReport: resolvedReport,
42761
+ filtersEnabled: filtersEnabledState,
42762
+ onFiltersEnabledChanged: setFiltersEnabledState,
42763
+ runQueryOnMount: filtersEnabledState
42764
+ }
42765
+ ) : /* @__PURE__ */ jsx65("div", { style: { padding: 20 }, children: /* @__PURE__ */ jsx65(QuillLoadingComponent, {}) });
42766
+ })()
42643
42767
  }
42644
42768
  ) });
42645
42769
  }
@@ -42719,8 +42843,9 @@ function ChartBuilder({
42719
42843
  const { dashboardConfig } = useContext26(DashboardConfigContext);
42720
42844
  const { tenants, flags } = useContext26(TenantContext);
42721
42845
  const report = useMemo21(() => {
42722
- return reportId && !tempReport ? allReportsById[reportId] : tempReport;
42723
- }, [reportId]);
42846
+ const resolvedReport = reportId && !tempReport ? allReportsById[reportId] : tempReport;
42847
+ return resolvedReport;
42848
+ }, [reportId, tempReport, allReportsById]);
42724
42849
  const [windowWidth, setWindowWidth] = useState28(1200);
42725
42850
  const [rows, setRows] = useState28(report?.rows ?? []);
42726
42851
  const [itemQuery, setItemQuery] = useState28(report?.itemQuery);
@@ -42729,8 +42854,9 @@ function ChartBuilder({
42729
42854
  const [isLoading, setIsLoading] = useState28(false);
42730
42855
  const [rowCountIsLoading, setRowCountIsLoading] = useState28(false);
42731
42856
  const [isSubmitting, setIsSubmitting] = useState28(false);
42732
- const [pivotCardWidth, setPivotCardWidth] = useState28(665);
42733
- const [formWidth, setFormWidth] = useState28(665);
42857
+ const MIN_FORM_WIDTH = 710;
42858
+ const [pivotCardWidth, setPivotCardWidth] = useState28(MIN_FORM_WIDTH);
42859
+ const [formWidth, setFormWidth] = useState28(MIN_FORM_WIDTH);
42734
42860
  const inputRef = useRef17(null);
42735
42861
  const selectRef = useRef17(null);
42736
42862
  const processColumns = (columns2) => {
@@ -42800,10 +42926,10 @@ function ChartBuilder({
42800
42926
  const spaceBetween = selectSize.left - inputSize.right;
42801
42927
  const gap = showDash ? (spaceBetween - selectWidth) / 2 : spaceBetween;
42802
42928
  const width = inputSize.width + 2 * gap + 2 * selectWidth;
42803
- setPivotCardWidth(width);
42929
+ setPivotCardWidth(Math.max(width, MIN_FORM_WIDTH));
42804
42930
  const deleteSize = deleteRef.current?.getBoundingClientRect();
42805
42931
  const deleteWidth = deleteSize?.width ?? 0;
42806
- setFormWidth(width + deleteWidth);
42932
+ setFormWidth(Math.max(width + deleteWidth, MIN_FORM_WIDTH));
42807
42933
  }
42808
42934
  };
42809
42935
  handleResize();
@@ -42918,7 +43044,7 @@ function ChartBuilder({
42918
43044
  };
42919
43045
  const [currentProcessing, setCurrentProcessing] = useState28(baseProcessing);
42920
43046
  const [customTenantAccess, setCustomTenantAccess] = useState28(
42921
- !!Object.values(report?.flags ?? {}).length
43047
+ report?.flags === null ? false : !!Object.values(report?.flags ?? {}).length
42922
43048
  );
42923
43049
  const [dateFieldOptions, setDateFieldOptions] = useState28([]);
42924
43050
  const [allTables, setAllTables] = useState28([]);
@@ -43068,23 +43194,40 @@ function ChartBuilder({
43068
43194
  return result;
43069
43195
  };
43070
43196
  const getReferencedTables = async (client2, dbTables, sqlQuery, reportBuilderState2, skipStar) => {
43071
- const { data: resp } = await quillFetchWithToken({
43072
- client: client2,
43073
- task: "astify",
43074
- metadata: reportBuilderState2 ? {
43075
- reportBuilderState: reportBuilderState2,
43076
- clientId: client2.clientId,
43077
- useNewNodeSql: true
43078
- } : {
43079
- query: sqlQuery,
43080
- clientId: client2.clientId,
43081
- useNewNodeSql: true
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);
43082
43214
  }
43083
- });
43084
- if (resp.success === false) {
43085
- return getTablesHelper(getSelectFromAST({}), dbTables, skipStar);
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
+ };
43086
43230
  }
43087
- return getTablesHelper(getSelectFromAST(resp.ast), dbTables, skipStar);
43088
43231
  };
43089
43232
  const getCurrentSection = () => {
43090
43233
  let id2 = report?.id ?? "";
@@ -43631,16 +43774,6 @@ function ChartBuilder({
43631
43774
  fetchRowCount(processing, overrideFilters);
43632
43775
  if (formData.pivot) {
43633
43776
  try {
43634
- console.log(
43635
- "[ChartBuilder] Calling report-builder-unique-values for pivot",
43636
- {
43637
- columns: tableInfo.columns.filter(
43638
- (column) => column.field === formData.pivot?.columnField
43639
- ).map((c) => c.field),
43640
- hasReportBuilderState: !!reportBuilderState,
43641
- reportBuilderState
43642
- }
43643
- );
43644
43777
  const uniqueValues = await getUniqueValuesByQuery({
43645
43778
  reportBuilderState,
43646
43779
  columns: tableInfo.columns.filter(
@@ -44028,9 +44161,46 @@ function ChartBuilder({
44028
44161
  event.preventDefault();
44029
44162
  };
44030
44163
  const deleteChart = async () => {
44031
- if (onDelete && onDelete()) {
44032
- setIsOpen(false);
44033
- setIsSubmitting(false);
44164
+ if (!client || !reportId) {
44165
+ console.error("Cannot delete: missing client or reportId");
44166
+ return;
44167
+ }
44168
+ try {
44169
+ const { status, error } = await quillFetch({
44170
+ client,
44171
+ task: "delete",
44172
+ metadata: {
44173
+ dashboardItemId: reportId,
44174
+ tenants
44175
+ },
44176
+ getToken
44177
+ });
44178
+ if (status !== "success") {
44179
+ throw new Error(`Error deleting report: ${error}`);
44180
+ } else {
44181
+ if (onDelete) {
44182
+ onDelete();
44183
+ }
44184
+ reloadDashboard(destinationDashboard, true, {
44185
+ report: { id: reportId },
44186
+ action: "delete"
44187
+ });
44188
+ setIsOpen(false);
44189
+ setIsSubmitting(false);
44190
+ }
44191
+ } catch (err) {
44192
+ console.error("Error deleting chart:", err);
44193
+ eventTracking?.logError?.({
44194
+ type: "bug",
44195
+ severity: "high",
44196
+ message: "Error deleting chart",
44197
+ errorMessage: err.message,
44198
+ errorStack: err.stack,
44199
+ errorData: {
44200
+ caller: "ChartBuilder",
44201
+ function: "deleteChart"
44202
+ }
44203
+ });
44034
44204
  }
44035
44205
  };
44036
44206
  const editChart = async () => {
@@ -44047,7 +44217,7 @@ function ChartBuilder({
44047
44217
  return;
44048
44218
  }
44049
44219
  let dashboardItemId = reportId ? reportId : void 0;
44050
- if (report && !isAdmin && formData.template) {
44220
+ if (report && !isAdmin && formData.template && !isEditingMode) {
44051
44221
  dashboardItemId = void 0;
44052
44222
  }
44053
44223
  const newReport = {
@@ -44069,14 +44239,17 @@ function ChartBuilder({
44069
44239
  includeCustomFields: includeCustomFields || containsCustomFields,
44070
44240
  template: tenants ? void 0 : report && !isAdmin && formData.template ? false : formData.template,
44071
44241
  adminMode: isAdmin,
44072
- flags: containsCustomFields && customTenantAccess ? currentTenantAsFormFlags : formFlags ? Object.fromEntries(
44073
- Object.entries(formFlags).filter(([, value]) => value.length > 0).map(([key, value]) => {
44074
- return [
44075
- key,
44076
- Object.keys(allTenantMap).length > 1 && allTenantMap[key]?.length === value.length ? ALL_TENANTS : value
44077
- ];
44078
- })
44079
- ) : void 0,
44242
+ reportBuilderState,
44243
+ ...isAdmin && {
44244
+ reportFlags: !customTenantAccess && !containsCustomFields ? null : containsCustomFields && customTenantAccess ? currentTenantAsFormFlags : formFlags ? Object.fromEntries(
44245
+ Object.entries(formFlags).filter(([, value]) => value.length > 0).map(([key, value]) => {
44246
+ return [
44247
+ key,
44248
+ Object.keys(allTenantMap).length > 1 && allTenantMap[key]?.length === value.length ? ALL_TENANTS : value
44249
+ ];
44250
+ })
44251
+ ) : void 0
44252
+ },
44080
44253
  referenceLines: formData.referenceLines.map((line) => {
44081
44254
  return {
44082
44255
  label: line.label,
@@ -45445,7 +45618,7 @@ function ChartBuilder({
45445
45618
  right: 16
45446
45619
  },
45447
45620
  children: [
45448
- !hideDeleteButton && !isHorizontalView && report && /* @__PURE__ */ jsx65(
45621
+ !hideDeleteButton && report && /* @__PURE__ */ jsx65(
45449
45622
  SecondaryButtonComponent,
45450
45623
  {
45451
45624
  onClick: deleteChart,
@@ -46201,6 +46374,7 @@ function SQLEditor({
46201
46374
  CheckboxComponent = QuillChartBuilderCheckboxComponent,
46202
46375
  defaultQuery,
46203
46376
  destinationDashboard,
46377
+ destinationSection,
46204
46378
  onChangeQuery,
46205
46379
  onChangeData,
46206
46380
  onChangeColumns,
@@ -46210,12 +46384,16 @@ function SQLEditor({
46210
46384
  onCloseChartBuilder,
46211
46385
  isChartBuilderEnabled = false,
46212
46386
  isAdminEnabled = false,
46387
+ chartBuilderOptions,
46213
46388
  chartBuilderTitle,
46214
46389
  runQueryOnMount = false,
46215
46390
  onAddToDashboardComplete,
46391
+ onSubmitCreateReport,
46392
+ onSubmitEditReport,
46216
46393
  onSaveQueryComplete,
46217
46394
  addToDashboardButtonLabel = "Add to dashboard",
46218
46395
  report = void 0,
46396
+ reportId = void 0,
46219
46397
  organizationName = void 0,
46220
46398
  isChartBuilderHorizontalView = true,
46221
46399
  containerStyle = { height: "100vh" },
@@ -46223,10 +46401,11 @@ function SQLEditor({
46223
46401
  onClickChartElement,
46224
46402
  onRequestAddVirtualTable
46225
46403
  }) {
46404
+ const computedButtonLabel = addToDashboardButtonLabel === "Add to dashboard" ? reportId || report?.id ? "Save changes" : "Add to dashboard" : addToDashboardButtonLabel;
46226
46405
  const [sqlPrompt, setSqlPrompt] = useState30("");
46227
46406
  const [client] = useContext28(ClientContext);
46228
46407
  const [theme] = useContext28(ThemeContext);
46229
- const { tenants } = useContext28(TenantContext);
46408
+ const { tenants, flags } = useContext28(TenantContext);
46230
46409
  const { dashboards } = useDashboards();
46231
46410
  const {
46232
46411
  data,
@@ -46235,6 +46414,7 @@ function SQLEditor({
46235
46414
  } = useDashboardInternal(destinationDashboard);
46236
46415
  const { getToken, quillFetchWithToken } = useContext28(FetchContext);
46237
46416
  const { eventTracking } = useContext28(EventTrackingContext);
46417
+ const { allReportsById } = useAllReports();
46238
46418
  const destinationDashboardConfig = useMemo22(() => {
46239
46419
  return dashboards?.find((d) => d.name === destinationDashboard);
46240
46420
  }, [dashboards, destinationDashboard]);
@@ -46302,6 +46482,46 @@ function SQLEditor({
46302
46482
  reload();
46303
46483
  }
46304
46484
  }, [data, dashboardIsLoading]);
46485
+ useEffect24(() => {
46486
+ const loadReport = async () => {
46487
+ let reportToLoad;
46488
+ if (!client) {
46489
+ return;
46490
+ }
46491
+ try {
46492
+ if (!reportId) {
46493
+ throw new Error("Report ID is required");
46494
+ }
46495
+ reportToLoad = allReportsById[reportId];
46496
+ if (!reportToLoad) {
46497
+ throw new Error("Report not found");
46498
+ }
46499
+ setQuery(reportToLoad.queryString || "");
46500
+ setTempReport(reportToLoad);
46501
+ if (reportToLoad.rows && reportToLoad.rows.length > 0) {
46502
+ setRows(reportToLoad.rows);
46503
+ setDisplayTable(true);
46504
+ }
46505
+ } catch (err) {
46506
+ console.error(err);
46507
+ eventTracking?.logError?.({
46508
+ type: "bug",
46509
+ severity: "high",
46510
+ message: "Error loading report",
46511
+ errorMessage: err.message,
46512
+ errorStack: err.stack,
46513
+ errorData: {
46514
+ caller: "SQLEditor",
46515
+ function: "loadReport"
46516
+ }
46517
+ });
46518
+ setErrorMessage("Error when loading report");
46519
+ }
46520
+ };
46521
+ if (reportId && client) {
46522
+ loadReport();
46523
+ }
46524
+ }, [allReportsById[reportId || ""], client]);
46305
46525
  const dynamicHeight = tableRef.current ? tableRef.current.clientHeight : cachedHeight;
46306
46526
  const rowsPerPage = Math.max(
46307
46527
  DEFAULT_ROWS_PER_PAGE,
@@ -46505,25 +46725,35 @@ function SQLEditor({
46505
46725
  onChangeFields(tableInfo.columns);
46506
46726
  }
46507
46727
  const formData = report ? report : createInitialFormData(tableInfo.columns);
46508
- const newReport = {
46728
+ const baseReport = reportId ? tempReport : {
46509
46729
  ...tempReport,
46510
- ...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 } : {},
46511
46736
  itemQuery: tableInfo.itemQuery,
46512
46737
  rowCount: tableInfo.rowCount ?? tableInfo.rows.length,
46513
46738
  rows: tempRows,
46514
46739
  columns: tableInfo.columns,
46515
- referencedTables: tableInfo.referencedTables
46740
+ referencedTables: tableInfo.referencedTables,
46741
+ queryString: query ?? tempReport.queryString ?? ""
46516
46742
  };
46517
- const cleaned = await cleanDashboardItem({
46518
- item: newReport,
46519
- dashboardFilters: newReport.filtersApplied,
46520
- client,
46521
- customFields: schemaData.customFields,
46522
- getToken,
46523
- tenants,
46524
- eventTracking
46525
- });
46526
- setTempReport(cleaned);
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
+ }
46527
46757
  setLastSuccessfulQuery(query);
46528
46758
  } catch (e) {
46529
46759
  eventTracking?.logError?.({
@@ -46830,7 +47060,7 @@ function SQLEditor({
46830
47060
  height: 70
46831
47061
  },
46832
47062
  children: /* @__PURE__ */ jsxs48("div", { style: { display: "flex", gap: 12 }, children: [
46833
- addToDashboardButtonLabel === "Add to dashboard" ? /* @__PURE__ */ jsx66(
47063
+ computedButtonLabel === "Add to dashboard" ? /* @__PURE__ */ jsx66(
46834
47064
  SecondaryButtonComponent,
46835
47065
  {
46836
47066
  onClick: () => {
@@ -46920,7 +47150,7 @@ function SQLEditor({
46920
47150
  label: "Clear query"
46921
47151
  }
46922
47152
  ),
46923
- addToDashboardButtonLabel === "Add to dashboard" && /* @__PURE__ */ jsx66(
47153
+ computedButtonLabel === "Add to dashboard" && /* @__PURE__ */ jsx66(
46924
47154
  ButtonComponent,
46925
47155
  {
46926
47156
  onClick: async () => {
@@ -46944,9 +47174,9 @@ function SQLEditor({
46944
47174
  return (schemaData.customFields?.[table] ?? []).map((field) => field.field);
46945
47175
  }).flat();
46946
47176
  }
46947
- setTempReport({
47177
+ const newTempReport = {
46948
47178
  ...tempReport,
46949
- id: TEMP_REPORT_ID,
47179
+ id: reportId || report?.id || TEMP_REPORT_ID,
46950
47180
  rows,
46951
47181
  columns: isSelectStar ? (
46952
47182
  // so Automatic Custom Fields can be applied
@@ -46963,10 +47193,11 @@ function SQLEditor({
46963
47193
  rowCount: rowCount ?? 0,
46964
47194
  queryString: query ?? "",
46965
47195
  dashboardName: report?.dashboardName ?? destinationDashboard
46966
- });
47196
+ };
47197
+ setTempReport(newTempReport);
46967
47198
  setIsChartBuilderOpen(true);
46968
47199
  },
46969
- label: addToDashboardButtonLabel,
47200
+ label: computedButtonLabel,
46970
47201
  disabled: !!errorMessage || !(lastSuccessfulQuery === query) || !query,
46971
47202
  tooltipText: !!errorMessage || !(lastSuccessfulQuery === query) ? "Please run a query" : ""
46972
47203
  }
@@ -47079,25 +47310,14 @@ function SQLEditor({
47079
47310
  label: "Discard changes"
47080
47311
  }
47081
47312
  ),
47082
- addToDashboardButtonLabel !== "Add to dashboard" && /* @__PURE__ */ jsx66(
47313
+ computedButtonLabel !== "Add to dashboard" && /* @__PURE__ */ jsx66(
47083
47314
  ButtonComponent,
47084
47315
  {
47085
47316
  onClick: async () => {
47086
47317
  onSaveChanges && onSaveChanges();
47087
- setTempReport({
47088
- ...tempReport,
47089
- id: TEMP_REPORT_ID,
47090
- rows,
47091
- columns,
47092
- columnInternal: columns,
47093
- rowCount: rowCount ?? 0,
47094
- queryString: query ?? "",
47095
- dashboardName: report?.dashboardName ?? destinationDashboard
47096
- // flags: flagsToAdd,
47097
- });
47098
47318
  setIsChartBuilderOpen(true);
47099
47319
  },
47100
- label: addToDashboardButtonLabel,
47320
+ label: computedButtonLabel,
47101
47321
  disabled: !!errorMessage || !(lastSuccessfulQuery === query)
47102
47322
  }
47103
47323
  )
@@ -47120,13 +47340,38 @@ function SQLEditor({
47120
47340
  isHorizontalView: isChartBuilderHorizontalView,
47121
47341
  isOpen: isChartBuilderOpen,
47122
47342
  setIsOpen: setIsChartBuilderOpen,
47123
- onAddToDashboardComplete,
47343
+ onAddToDashboardComplete: reportId || report?.id ? (data2) => {
47344
+ if (onSubmitEditReport) {
47345
+ onSubmitEditReport(data2);
47346
+ } else if (onAddToDashboardComplete) {
47347
+ onAddToDashboardComplete(data2);
47348
+ }
47349
+ if (!isAdminEnabled && destinationDashboard) {
47350
+ reload(destinationDashboard, false, {
47351
+ report: data2,
47352
+ action: "upsert"
47353
+ });
47354
+ }
47355
+ } : (data2) => {
47356
+ if (onSubmitCreateReport) {
47357
+ onSubmitCreateReport(data2);
47358
+ } else if (onAddToDashboardComplete) {
47359
+ onAddToDashboardComplete(data2);
47360
+ }
47361
+ if (!isAdminEnabled && destinationDashboard) {
47362
+ reload(destinationDashboard, false, {
47363
+ report: data2,
47364
+ action: "upsert"
47365
+ });
47366
+ }
47367
+ },
47124
47368
  destinationDashboard,
47369
+ destinationSection,
47125
47370
  isAdmin: isAdminEnabled,
47126
47371
  title: chartBuilderTitle,
47127
- buttonLabel: addToDashboardButtonLabel,
47372
+ buttonLabel: computedButtonLabel,
47128
47373
  tempReport,
47129
- reportId: report?.id,
47374
+ reportId: reportId || report?.id,
47130
47375
  organizationName,
47131
47376
  CardComponent,
47132
47377
  TableComponent,
@@ -47151,6 +47396,8 @@ function SQLEditor({
47151
47396
  CheckboxComponent,
47152
47397
  hideDateRangeFilter: true,
47153
47398
  hideDeleteButton: true,
47399
+ showTableFormatOptions: chartBuilderOptions?.showTableFormatOptions,
47400
+ showDashboardFilterFields: chartBuilderOptions?.showDashboardFilterFields,
47154
47401
  onClickChartElement,
47155
47402
  isEditingMode: true
47156
47403
  }
@@ -47170,7 +47417,7 @@ function SQLEditor({
47170
47417
  isAdmin: false,
47171
47418
  title: "Save query",
47172
47419
  buttonLabel: "Save query",
47173
- tempReport,
47420
+ tempReport: { ...tempReport, dashboardName: SAVED_QUERIES_DASHBOARD },
47174
47421
  reportId: report?.id,
47175
47422
  organizationName,
47176
47423
  CardComponent,
@@ -51503,7 +51750,10 @@ var SaveReport = ({
51503
51750
  chartBuilderTitle,
51504
51751
  onSubmitEditReport = () => void 0,
51505
51752
  onSubmitCreateReport = () => void 0,
51753
+ onDiscardChanges = () => void 0,
51506
51754
  destinationSection,
51755
+ showTableFormatOptions,
51756
+ showDashboardFilterFields,
51507
51757
  SelectComponent = QuillSelectComponent,
51508
51758
  TextInputComponent = QuillTextInput,
51509
51759
  ButtonComponent = MemoizedButton,
@@ -51536,6 +51786,9 @@ var SaveReport = ({
51536
51786
  ),
51537
51787
  submitButtonLabel
51538
51788
  }) => {
51789
+ const { reload } = useDashboardInternal(
51790
+ reportBuilder.destinationDashboard ?? null
51791
+ );
51539
51792
  return /* @__PURE__ */ jsxs59("div", { children: [
51540
51793
  SaveTrigger,
51541
51794
  /* @__PURE__ */ jsx79(
@@ -51549,7 +51802,24 @@ var SaveReport = ({
51549
51802
  isHorizontalView: true,
51550
51803
  isOpen,
51551
51804
  setIsOpen,
51552
- onAddToDashboardComplete: reportBuilder.reportId ? onSubmitEditReport : onSubmitCreateReport,
51805
+ onAddToDashboardComplete: reportBuilder.reportId ? (data) => {
51806
+ onSubmitEditReport(data);
51807
+ if (!isAdminEnabled && reportBuilder.destinationDashboard) {
51808
+ reload(reportBuilder.destinationDashboard, false, {
51809
+ report: data,
51810
+ action: "upsert"
51811
+ });
51812
+ }
51813
+ } : (data) => {
51814
+ onSubmitCreateReport(data);
51815
+ if (!isAdminEnabled && reportBuilder.destinationDashboard) {
51816
+ reload(reportBuilder.destinationDashboard, false, {
51817
+ report: data,
51818
+ action: "upsert"
51819
+ });
51820
+ }
51821
+ },
51822
+ onDiscardChanges,
51553
51823
  destinationDashboard: reportBuilder.destinationDashboard,
51554
51824
  destinationSection,
51555
51825
  initialUniqueValues: reportBuilder.columnUniqueValues,
@@ -51578,6 +51848,8 @@ var SaveReport = ({
51578
51848
  FormContainer: ChartBuilderFormContainer,
51579
51849
  hideDateRangeFilter: true,
51580
51850
  hideDeleteButton: true,
51851
+ showTableFormatOptions,
51852
+ showDashboardFilterFields,
51581
51853
  buttonLabel: submitButtonLabel ?? (!!reportBuilder.reportId ? "Save changes" : "Add to dashboard"),
51582
51854
  onClickChartElement,
51583
51855
  isEditingMode: true
@@ -51674,6 +51946,7 @@ function ReportBuilder({
51674
51946
  containerStyle,
51675
51947
  className,
51676
51948
  pivotRecommendationsEnabled = true,
51949
+ chartBuilderOptions,
51677
51950
  reportId,
51678
51951
  hideCopySQL = true,
51679
51952
  isChartBuilderHorizontalView = true,
@@ -52130,6 +52403,9 @@ function ReportBuilder({
52130
52403
  ErrorMessageComponent,
52131
52404
  PivotRowContainer,
52132
52405
  PivotColumnContainer,
52406
+ showTableFormatOptions: chartBuilderOptions?.showTableFormatOptions,
52407
+ showDashboardFilterFields: chartBuilderOptions?.showDashboardFilterFields,
52408
+ onDiscardChanges,
52133
52409
  onClickChartElement,
52134
52410
  submitButtonLabel
52135
52411
  }
@@ -52150,7 +52426,7 @@ function ReportBuilder({
52150
52426
  isAdmin: false,
52151
52427
  title: "Save query",
52152
52428
  buttonLabel: "Save query",
52153
- tempReport,
52429
+ tempReport: { ...tempReport, dashboardName: SAVED_QUERIES_DASHBOARD },
52154
52430
  reportId,
52155
52431
  organizationName,
52156
52432
  CardComponent,
@@ -52204,7 +52480,10 @@ function ChartEditor({
52204
52480
  chartBuilderTitle = "Edit chart",
52205
52481
  chartBuilderButtonLabel,
52206
52482
  onAddToDashboardComplete,
52483
+ onSubmitEditReport,
52484
+ onDiscardChanges,
52207
52485
  destinationDashboard,
52486
+ destinationSection,
52208
52487
  organizationName,
52209
52488
  isHorizontalView = true,
52210
52489
  onDelete,
@@ -52232,6 +52511,9 @@ function ChartEditor({
52232
52511
  ErrorComponent = QuillChartErrorWithAction,
52233
52512
  hideDeleteButton = false,
52234
52513
  hideSubmitButton = false,
52514
+ showTableFormatOptions,
52515
+ showDashboardFilterFields,
52516
+ chartBuilderOptions,
52235
52517
  onClickChartElement,
52236
52518
  onClickChartError
52237
52519
  }) {
@@ -52320,7 +52602,12 @@ function ChartEditor({
52320
52602
  ModalComponent,
52321
52603
  {
52322
52604
  isOpen,
52323
- setIsOpen,
52605
+ setIsOpen: (value) => {
52606
+ if (!value) {
52607
+ setChartBuilderKey(chartBuilderKey + 1);
52608
+ }
52609
+ setIsOpen(value);
52610
+ },
52324
52611
  title: chartBuilderTitle || "Add to dashboard",
52325
52612
  width: isHorizontalView ? modalWidth : void 0,
52326
52613
  height: isHorizontalView ? modalHeight : void 0,
@@ -52333,8 +52620,15 @@ function ChartEditor({
52333
52620
  isComparison: dateFilter?.comparisonRange,
52334
52621
  setIsOpen,
52335
52622
  showDashboardDropdown: isAdmin,
52336
- onAddToDashboardComplete,
52623
+ onAddToDashboardComplete: (data) => {
52624
+ if (onSubmitEditReport) {
52625
+ onSubmitEditReport(data);
52626
+ } else if (onAddToDashboardComplete) {
52627
+ onAddToDashboardComplete(data);
52628
+ }
52629
+ },
52337
52630
  destinationDashboard,
52631
+ destinationSection,
52338
52632
  dateRange,
52339
52633
  SelectComponent,
52340
52634
  TextInputComponent,
@@ -52360,13 +52654,18 @@ function ChartEditor({
52360
52654
  onClickChartError,
52361
52655
  onDelete,
52362
52656
  onDiscardChanges: () => {
52657
+ if (onDiscardChanges) {
52658
+ onDiscardChanges();
52659
+ }
52363
52660
  setChartBuilderKey(chartBuilderKey + 1);
52364
52661
  },
52365
52662
  title: chartBuilderTitle,
52366
52663
  buttonLabel: chartBuilderButtonLabel,
52367
52664
  organizationName,
52368
52665
  hideSubmitButton,
52369
- hideDeleteButton,
52666
+ hideDeleteButton: chartBuilderOptions?.showDeleteButton !== void 0 ? !chartBuilderOptions.showDeleteButton : hideDeleteButton,
52667
+ showTableFormatOptions: chartBuilderOptions?.showTableFormatOptions ?? showTableFormatOptions,
52668
+ showDashboardFilterFields: chartBuilderOptions?.showDashboardFilterFields ?? showDashboardFilterFields,
52370
52669
  filtersEnabled,
52371
52670
  onFiltersEnabledChanged: (value) => {
52372
52671
  setFiltersEnabled(value);