@databrainhq/plugin 0.7.23 → 0.8.0

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.
@@ -7,6 +7,7 @@ export declare type ExternalMetricListProps = {
7
7
  chartColors?: string[];
8
8
  globalFilters?: MetricCardProps['globalFilters'];
9
9
  client: ClientType['value'];
10
+ isAllowedToDeleteMetrics?: boolean;
10
11
  isLiveMode: boolean;
11
12
  isMetricListLoading?: boolean;
12
13
  breakpoint: ThemeType['breakpoint'];
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { ModalProps } from '@/components/Modal';
3
+ export interface DeleteMetricModalProps extends Omit<ModalProps, 'headerTitle'> {
4
+ onSuccess: () => void;
5
+ metricId: string;
6
+ }
7
+ export declare const DeleteMetricModal: React.FC<DeleteMetricModalProps>;
@@ -14,5 +14,6 @@ export declare type MetricCardProps = {
14
14
  param?: any;
15
15
  companyTenancyType: string;
16
16
  renderHeaderName?: (name: string) => JSX.Element;
17
+ onDelete?: (metricId: string) => void;
17
18
  };
18
19
  export declare const MetricCard: React.FC<MetricCardProps>;
@@ -1,3 +1,4 @@
1
1
  export * from './MetricList';
2
2
  export * from './components/MetricCard';
3
3
  export * from './components/SingleValueCard';
4
+ export * from './components/DeleteMetricModal';
@@ -7,6 +7,7 @@ declare type SwitchButtonProps = {
7
7
  placeholder?: string;
8
8
  labelClassName?: string;
9
9
  defaultEnabled?: boolean;
10
+ name?: string;
10
11
  };
11
12
  export declare const ToggleButton: React.FC<SwitchButtonProps>;
12
13
  export {};
@@ -49,5 +49,6 @@ export declare const useEmbeddedDashboard: (token: string) => {
49
49
  rlsSettings: any;
50
50
  companyTenancyType: any;
51
51
  isAllowedToCreateMetrics: boolean;
52
+ isAllowedToDeleteMetrics: boolean;
52
53
  };
53
54
  };
package/dist/index.es.js CHANGED
@@ -2512,69 +2512,69 @@ function useQuery(arg1, arg2, arg3) {
2512
2512
  var parsedOptions = parseQueryArgs(arg1, arg2, arg3);
2513
2513
  return useBaseQuery(parsedOptions, QueryObserver);
2514
2514
  }
2515
- const container$g = "_container_1ddns_1";
2516
- const fixed = "_fixed_1ddns_1";
2517
- const absolute = "_absolute_1ddns_1";
2518
- const flex = "_flex_1ddns_1";
2519
- const table$5 = "_table_1ddns_1";
2520
- const grid = "_grid_1ddns_1";
2521
- const hidden = "_hidden_1ddns_1";
2522
- const transform = "_transform_1ddns_1";
2523
- const resize = "_resize_1ddns_1";
2524
- const truncate = "_truncate_1ddns_1";
2525
- const border = "_border_1ddns_1";
2526
- const shadow = "_shadow_1ddns_1";
2527
- const filter$1 = "_filter_1ddns_351";
2528
- const floatingFilterButton = "_floatingFilterButton_1ddns_359";
2529
- const floatingFilterButtonIcon = "_floatingFilterButtonIcon_1ddns_367";
2530
- const floatingButton = "_floatingButton_1ddns_375";
2531
- const staticContainer = "_staticContainer_1ddns_383";
2532
- const floatingContainer = "_floatingContainer_1ddns_391";
2515
+ const container$g = "_container_1gcts_1";
2516
+ const fixed = "_fixed_1gcts_1";
2517
+ const absolute = "_absolute_1gcts_1";
2518
+ const flex = "_flex_1gcts_1";
2519
+ const table$5 = "_table_1gcts_1";
2520
+ const grid = "_grid_1gcts_1";
2521
+ const hidden = "_hidden_1gcts_1";
2522
+ const transform = "_transform_1gcts_1";
2523
+ const resize = "_resize_1gcts_1";
2524
+ const truncate = "_truncate_1gcts_1";
2525
+ const border = "_border_1gcts_1";
2526
+ const shadow = "_shadow_1gcts_1";
2527
+ const filter$1 = "_filter_1gcts_351";
2528
+ const floatingFilterButton = "_floatingFilterButton_1gcts_359";
2529
+ const floatingFilterButtonIcon = "_floatingFilterButtonIcon_1gcts_367";
2530
+ const floatingButton = "_floatingButton_1gcts_375";
2531
+ const staticContainer = "_staticContainer_1gcts_383";
2532
+ const floatingContainer = "_floatingContainer_1gcts_391";
2533
2533
  var styles$D = {
2534
2534
  container: container$g,
2535
- "static": "_static_1ddns_383",
2535
+ "static": "_static_1gcts_383",
2536
2536
  fixed,
2537
2537
  absolute,
2538
- "left-2": "_left-2_1ddns_1",
2539
- "top-1": "_top-1_1ddns_1",
2540
- "mt-2.5": "_mt-2.5_1ddns_1",
2541
- "mt-2": "_mt-2_1ddns_1",
2542
- "mb-3": "_mb-3_1ddns_1",
2538
+ "left-2": "_left-2_1gcts_1",
2539
+ "top-1": "_top-1_1gcts_1",
2540
+ "mt-2.5": "_mt-2.5_1gcts_1",
2541
+ "mt-2": "_mt-2_1gcts_1",
2542
+ "mb-3": "_mb-3_1gcts_1",
2543
2543
  flex,
2544
2544
  table: table$5,
2545
2545
  grid,
2546
2546
  hidden,
2547
- "h-screen": "_h-screen_1ddns_1",
2548
- "h-[10%]": "_h-[10%]_1ddns_1",
2549
- "w-screen": "_w-screen_1ddns_1",
2550
- "w-full": "_w-full_1ddns_1",
2547
+ "h-screen": "_h-screen_1gcts_1",
2548
+ "h-[10%]": "_h-[10%]_1gcts_1",
2549
+ "w-screen": "_w-screen_1gcts_1",
2550
+ "w-full": "_w-full_1gcts_1",
2551
2551
  transform,
2552
2552
  resize,
2553
- "overflow-x-hidden": "_overflow-x-hidden_1ddns_1",
2553
+ "overflow-x-hidden": "_overflow-x-hidden_1gcts_1",
2554
2554
  truncate,
2555
2555
  border,
2556
- "p-2": "_p-2_1ddns_1",
2557
- "p-1": "_p-1_1ddns_1",
2558
- "text-center": "_text-center_1ddns_1",
2559
- "text-sm": "_text-sm_1ddns_1",
2560
- "text-xs": "_text-xs_1ddns_1",
2561
- "text-blue-700": "_text-blue-700_1ddns_1",
2556
+ "p-2": "_p-2_1gcts_1",
2557
+ "p-1": "_p-1_1gcts_1",
2558
+ "text-center": "_text-center_1gcts_1",
2559
+ "text-sm": "_text-sm_1gcts_1",
2560
+ "text-xs": "_text-xs_1gcts_1",
2561
+ "text-blue-700": "_text-blue-700_1gcts_1",
2562
2562
  shadow,
2563
2563
  filter: filter$1,
2564
- "!filter": "_!filter_1ddns_1",
2565
- "embedDashboard-container": "_embedDashboard-container_1ddns_311",
2566
- "embedDashboard-header-static": "_embedDashboard-header-static_1ddns_319",
2567
- "embedDashboard-header-floating": "_embedDashboard-header-floating_1ddns_327",
2568
- "embedDashboard-wrapper": "_embedDashboard-wrapper_1ddns_335",
2569
- "alt-container": "_alt-container_1ddns_343",
2564
+ "!filter": "_!filter_1gcts_1",
2565
+ "embedDashboard-container": "_embedDashboard-container_1gcts_311",
2566
+ "embedDashboard-header-static": "_embedDashboard-header-static_1gcts_319",
2567
+ "embedDashboard-header-floating": "_embedDashboard-header-floating_1gcts_327",
2568
+ "embedDashboard-wrapper": "_embedDashboard-wrapper_1gcts_335",
2569
+ "alt-container": "_alt-container_1gcts_343",
2570
2570
  floatingFilterButton,
2571
2571
  floatingFilterButtonIcon,
2572
2572
  floatingButton,
2573
2573
  staticContainer,
2574
2574
  floatingContainer,
2575
- "hover:cursor-pointer": "_hover:cursor-pointer_1ddns_1",
2576
- "hover:cursor-text": "_hover:cursor-text_1ddns_1",
2577
- "disabled:cursor-text": "_disabled:cursor-text_1ddns_1"
2575
+ "hover:cursor-pointer": "_hover:cursor-pointer_1gcts_1",
2576
+ "hover:cursor-text": "_hover:cursor-text_1gcts_1",
2577
+ "disabled:cursor-text": "_disabled:cursor-text_1gcts_1"
2578
2578
  };
2579
2579
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
2580
2580
  function getAugmentedNamespace(n2) {
@@ -2641,17 +2641,17 @@ var classnames$1 = { exports: {} };
2641
2641
  })(classnames$1);
2642
2642
  var classnames = classnames$1.exports;
2643
2643
  var styles$C = {
2644
- "btn-primary": "_btn-primary_czbha_1",
2645
- "btn-secondary": "_btn-secondary_czbha_5",
2646
- "btn-reject": "_btn-reject_czbha_9",
2647
- "btn-outlined": "_btn-outlined_czbha_14",
2648
- "btn-tertiary": "_btn-tertiary_czbha_18",
2649
- "btn-default": "_btn-default_czbha_22",
2650
- "btn-large": "_btn-large_czbha_25",
2651
- "btn-small": "_btn-small_czbha_28",
2652
- "btn-xs": "_btn-xs_czbha_31",
2653
- "btn-medium": "_btn-medium_czbha_34",
2654
- "btn-11rem": "_btn-11rem_czbha_38"
2644
+ "btn-primary": "_btn-primary_1gon7_1",
2645
+ "btn-secondary": "_btn-secondary_1gon7_5",
2646
+ "btn-reject": "_btn-reject_1gon7_9",
2647
+ "btn-outlined": "_btn-outlined_1gon7_14",
2648
+ "btn-tertiary": "_btn-tertiary_1gon7_18",
2649
+ "btn-default": "_btn-default_1gon7_22",
2650
+ "btn-large": "_btn-large_1gon7_25",
2651
+ "btn-small": "_btn-small_1gon7_28",
2652
+ "btn-xs": "_btn-xs_1gon7_31",
2653
+ "btn-medium": "_btn-medium_1gon7_34",
2654
+ "btn-11rem": "_btn-11rem_1gon7_38"
2655
2655
  };
2656
2656
  var jsxRuntime = { exports: {} };
2657
2657
  var reactJsxRuntime_production_min = {};
@@ -6464,7 +6464,8 @@ const ToggleButton = ({
6464
6464
  className = "",
6465
6465
  placeholder,
6466
6466
  labelClassName,
6467
- defaultEnabled
6467
+ defaultEnabled,
6468
+ name = `toggle-${Date.now()}`
6468
6469
  }) => {
6469
6470
  return /* @__PURE__ */ jsxs("div", {
6470
6471
  className: `${styles$s.group} ${className}`,
@@ -6475,14 +6476,14 @@ const ToggleButton = ({
6475
6476
  children: label2
6476
6477
  }) : null, /* @__PURE__ */ jsx("input", {
6477
6478
  type: "checkbox",
6478
- id: "toggle",
6479
+ id: name,
6479
6480
  checked: defaultEnabled,
6480
6481
  onChange: ({
6481
6482
  target
6482
6483
  }) => onChange == null ? void 0 : onChange(target.checked),
6483
6484
  className: styles$s.checkbox
6484
6485
  }), /* @__PURE__ */ jsxs("label", {
6485
- htmlFor: "toggle",
6486
+ htmlFor: name,
6486
6487
  className: styles$s.button,
6487
6488
  children: [/* @__PURE__ */ jsx("span", {
6488
6489
  className: `${styles$s.switch} ${enabled2 ? styles$s.enabled : styles$s.notenabled}`
@@ -6767,16 +6768,17 @@ const useGuestTokenParamsQuery = (variables, options2) => useQuery(
6767
6768
  fetcher(GuestTokenParamsDocument, variables),
6768
6769
  options2
6769
6770
  );
6770
- const MetricCreationAccessDocument = `
6771
- query MetricCreationAccess($companyId: uuid = "") {
6771
+ const MetricAccessDocument = `
6772
+ query MetricAccess($companyId: uuid = "") {
6772
6773
  companySubsetTables(where: {companyId: {_eq: $companyId}}) {
6773
6774
  isAllowMetricCreation
6775
+ isAllowMetricDeletion
6774
6776
  }
6775
6777
  }
6776
6778
  `;
6777
- const useMetricCreationAccessQuery = (variables, options2) => useQuery(
6778
- variables === void 0 ? ["MetricCreationAccess"] : ["MetricCreationAccess", variables],
6779
- fetcher(MetricCreationAccessDocument, variables),
6779
+ const useMetricAccessQuery = (variables, options2) => useQuery(
6780
+ variables === void 0 ? ["MetricAccess"] : ["MetricAccess", variables],
6781
+ fetcher(MetricAccessDocument, variables),
6780
6782
  options2
6781
6783
  );
6782
6784
  const GetThemesDocument = `
@@ -6797,6 +6799,21 @@ const useGetThemesQuery = (variables, options2) => useQuery(
6797
6799
  fetcher(GetThemesDocument, variables),
6798
6800
  options2
6799
6801
  );
6802
+ const MarkDeleteMetricDocument = `
6803
+ mutation MarkDeleteMetric($id: uuid! = "") {
6804
+ update_externalMetrics_by_pk(
6805
+ pk_columns: {id: $id}
6806
+ _set: {isMarkedDeleted: true}
6807
+ ) {
6808
+ id
6809
+ }
6810
+ }
6811
+ `;
6812
+ const useMarkDeleteMetricMutation = (options2) => useMutation(
6813
+ ["MarkDeleteMetric"],
6814
+ (variables) => fetcher(MarkDeleteMetricDocument, variables)(),
6815
+ options2
6816
+ );
6800
6817
  const PreviewTableDocument = `
6801
6818
  mutation PreviewTable($companyId: String = "", $tableName: String = "", $limit: Int = 10) {
6802
6819
  previewTable(
@@ -6995,7 +7012,10 @@ const useEmbeddedDashboard = (token) => {
6995
7012
  {
6996
7013
  where: {
6997
7014
  externalDashboard: {
6998
- externalDashboardId: { _eq: externalDashboardId }
7015
+ externalDashboardId: { _eq: externalDashboardId },
7016
+ externalDashboardMetrics: {
7017
+ externalMetric: { isMarkedDeleted: { _eq: false } }
7018
+ }
6999
7019
  }
7000
7020
  }
7001
7021
  },
@@ -7003,8 +7023,9 @@ const useEmbeddedDashboard = (token) => {
7003
7023
  );
7004
7024
  const { data: idData, isLoading: isLoadingId } = useGetExternalDashboardIdQuery({ externalDashboardId });
7005
7025
  const externalDashboardMetrics = externalDashboardMetricsData == null ? void 0 : externalDashboardMetricsData.externalDashboardMetrics;
7006
- const { data: accessData, isLoading: isLoadingAccessData } = useMetricCreationAccessQuery({ companyId });
7026
+ const { data: accessData, isLoading: isLoadingAccessData } = useMetricAccessQuery({ companyId });
7007
7027
  const isAllowedToCreateMetrics = (accessData == null ? void 0 : accessData.companySubsetTables.length) ? accessData.companySubsetTables[0].isAllowMetricCreation && !isTestKey : false;
7028
+ const isAllowedToDeleteMetrics = (accessData == null ? void 0 : accessData.companySubsetTables.length) ? accessData.companySubsetTables[0].isAllowMetricDeletion && !isTestKey : false;
7008
7029
  return {
7009
7030
  isLoading: isParamsLoading || isExternalDashboardMetricsDataLoading || isLoadingId || isLoadingAccessData,
7010
7031
  data: {
@@ -7015,7 +7036,8 @@ const useEmbeddedDashboard = (token) => {
7015
7036
  externalDashboard: idData == null ? void 0 : idData.externalDashboards[0],
7016
7037
  rlsSettings,
7017
7038
  companyTenancyType: companyTenancyType || "TABLE",
7018
- isAllowedToCreateMetrics
7039
+ isAllowedToCreateMetrics,
7040
+ isAllowedToDeleteMetrics
7019
7041
  }
7020
7042
  };
7021
7043
  };
@@ -81527,7 +81549,7 @@ const TableChart = ({
81527
81549
  className: style.tableColLabel,
81528
81550
  isDisabled: !chartClickConfig.isEnable,
81529
81551
  onClick: () => handleChartClick(chartClickConfig, JSON.stringify(d2)),
81530
- children: JSON.stringify(d2)
81552
+ children: JSON.stringify(d2).replace(/"/g, "")
81531
81553
  })
81532
81554
  }, d2 + index2)
81533
81555
  });
@@ -84048,7 +84070,7 @@ const Table = ({
84048
84070
  children: /* @__PURE__ */ jsx(Text, {
84049
84071
  styleClass: "font-14",
84050
84072
  variant: "p",
84051
- children: JSON.stringify(item[d2])
84073
+ children: JSON.stringify(item[d2]).replace(/"/g, "")
84052
84074
  })
84053
84075
  }, index2))
84054
84076
  }, i))
@@ -91175,26 +91197,30 @@ var styles$2 = {
91175
91197
  "noMetric-wrapper": "_noMetric-wrapper_1b506_25",
91176
91198
  "alt-container": "_alt-container_1b506_33"
91177
91199
  };
91178
- const cardContainer = "_cardContainer_3ltmz_1";
91179
- const listHeader = "_listHeader_3ltmz_9";
91180
- const metricName = "_metricName_3ltmz_17";
91181
- const metricDescription = "_metricDescription_3ltmz_25";
91182
- const popup = "_popup_3ltmz_33";
91183
- const metricFilter$1 = "_metricFilter_3ltmz_41";
91184
- const popupIcon = "_popupIcon_3ltmz_49";
91185
- const popupMenu = "_popupMenu_3ltmz_57";
91186
- const popupItem = "_popupItem_3ltmz_65";
91187
- const popupItemIcon = "_popupItemIcon_3ltmz_73";
91188
- const csvBtn = "_csvBtn_3ltmz_81";
91189
- const metricData = "_metricData_3ltmz_89";
91190
- const singleValueData = "_singleValueData_3ltmz_97";
91191
- const singleValue = "_singleValue_3ltmz_97";
91192
- const noData = "_noData_3ltmz_113";
91193
- const noDataContent = "_noDataContent_3ltmz_121";
91194
- const noDataText = "_noDataText_3ltmz_129";
91195
- const loading = "_loading_3ltmz_137";
91196
- const features = "_features_3ltmz_145";
91197
- const fullscreen = "_fullscreen_3ltmz_151";
91200
+ const cardContainer = "_cardContainer_btizd_1";
91201
+ const listHeader = "_listHeader_btizd_9";
91202
+ const metricName = "_metricName_btizd_17";
91203
+ const metricDescription = "_metricDescription_btizd_25";
91204
+ const popup = "_popup_btizd_33";
91205
+ const metricFilter$1 = "_metricFilter_btizd_41";
91206
+ const popupIcon = "_popupIcon_btizd_49";
91207
+ const popupMenu = "_popupMenu_btizd_57";
91208
+ const popupItem = "_popupItem_btizd_65";
91209
+ const popupItemIcon = "_popupItemIcon_btizd_73";
91210
+ const csvBtn = "_csvBtn_btizd_81";
91211
+ const deleteBtn = "_deleteBtn_btizd_89";
91212
+ const metricData = "_metricData_btizd_97";
91213
+ const singleValueData = "_singleValueData_btizd_105";
91214
+ const singleValue = "_singleValue_btizd_105";
91215
+ const noData = "_noData_btizd_121";
91216
+ const noDataContent = "_noDataContent_btizd_129";
91217
+ const noDataText = "_noDataText_btizd_137";
91218
+ const loading = "_loading_btizd_145";
91219
+ const features = "_features_btizd_153";
91220
+ const fullscreen = "_fullscreen_btizd_161";
91221
+ const deleteModal = "_deleteModal_btizd_169";
91222
+ const cancelBtn = "_cancelBtn_btizd_177";
91223
+ const warningIcon = "_warningIcon_btizd_185";
91198
91224
  var styles$1 = {
91199
91225
  cardContainer,
91200
91226
  listHeader,
@@ -91207,6 +91233,7 @@ var styles$1 = {
91207
91233
  popupItem,
91208
91234
  popupItemIcon,
91209
91235
  csvBtn,
91236
+ deleteBtn,
91210
91237
  metricData,
91211
91238
  singleValueData,
91212
91239
  singleValue,
@@ -91215,9 +91242,22 @@ var styles$1 = {
91215
91242
  noDataText,
91216
91243
  loading,
91217
91244
  features,
91218
- fullscreen
91245
+ fullscreen,
91246
+ deleteModal,
91247
+ cancelBtn,
91248
+ warningIcon
91219
91249
  };
91220
91250
  var NoData = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMDAgMzAwIj48ZGVmcz48c3R5bGU+LmNscy0xe3N0cm9rZTojMTgyYzYwO30uY2xzLTEsLmNscy0ye2ZpbGw6bm9uZTtzdHJva2UtbGluZWNhcDpyb3VuZDtzdHJva2UtbGluZWpvaW46cm91bmQ7fS5jbHMtM3tmaWxsOiM1ODY1ZjY7b3BhY2l0eTouMTt9LmN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DQsNC4wNi0yMi44OCw2LjA5LTM0LjMyLjcyLTQuMDgsMS43Ny04LjI1LDIuMTYtMTIuMzguMzktNC4xNi0xLjY4LTguNzktNS42Ny0xMC4zMSIvPjxwYXRoIGNsYXNzPSJjbHMtNyIgZD0ibTIyMy41MSwxMjAuMDhzLjQ5LDEuNjIuNTMsMS43My4zMiwyLjQ0LjMyLDIuNDRsLS4wNCwxLjkxLTEuMzgsNy4xMy0zLjM5LDE5LjMxLTIuODksMTUuOTItMi45NiwxNi43Ni0yLjQ0LDEzLjE2LS45MiwyLjY1LDQuOTgsNS4xNS44NS0yLjE1LjgxLTQuMDYsMS40OC04LjMzLDIuODItMTUuNzEsMi4xNS0xMi4xMSwxLjk0LTExLjM2LDIuNzUtMTQuNzUuODgtNC42OS4yOC0yLjU4LjA3LTIuMTItLjYtMi43NS0xLjI0LTIuMzYtMS4wOS0xLjU5LTIuMDEtMS4zMS0uOTItLjI4WiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNyIgcG9pbnRzPSI4NS42OCAyMDMuOTMgMjA0LjU1IDIwMy44NCAyMDkuMzUgMjA4LjczIDE0OC40OCAyMDguODggOTAuOTUgMjA5LjAyIDg5LjUgMjA4LjY2IDg3Ljk4IDIwNy45MiA4Ni44MiAyMDYuNTggODYuMDEgMjA1LjAzIDg1LjY4IDIwMy45MyIvPjwvc3ZnPg==";
91251
+ const materialSymbolsDeleteOutline = (props) => /* @__PURE__ */ jsx("svg", {
91252
+ viewBox: "0 0 24 24",
91253
+ width: "1.2em",
91254
+ height: "1.2em",
91255
+ ...props,
91256
+ children: /* @__PURE__ */ jsx("path", {
91257
+ fill: "currentColor",
91258
+ d: "M7 21q-.825 0-1.412-.587Q5 19.825 5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413Q17.825 21 17 21ZM17 6H7v13h10ZM9 17h2V8H9Zm4 0h2V8h-2ZM7 6v13Z"
91259
+ })
91260
+ });
91221
91261
  const handleSaveChartImage = (chartRef) => {
91222
91262
  var _a2;
91223
91263
  const chartInstance = (_a2 = chartRef.current) == null ? void 0 : _a2.getEchartsInstance();
@@ -91341,7 +91381,8 @@ const MetricCard = ({
91341
91381
  colors: colors2,
91342
91382
  param,
91343
91383
  companyTenancyType,
91344
- renderHeaderName
91384
+ renderHeaderName,
91385
+ onDelete
91345
91386
  }) => {
91346
91387
  var _a2, _b2, _c2;
91347
91388
  const chartRef = useRef(null);
@@ -91717,6 +91758,14 @@ const MetricCard = ({
91717
91758
  name: "table-tab-icon",
91718
91759
  className: styles$1.popupItemIcon
91719
91760
  }), "View As Table"]
91761
+ }), onDelete && /* @__PURE__ */ jsxs(Button, {
91762
+ variant: "custom",
91763
+ type: "button",
91764
+ className: `${styles$1.popupItem} ${styles$1.csvBtn} ${styles$1.deleteBtn}`,
91765
+ onClick: () => onDelete(metricItem.id),
91766
+ children: [/* @__PURE__ */ jsx(materialSymbolsDeleteOutline, {
91767
+ className: styles$1.popupItemIcon
91768
+ }), "Delete Metric"]
91720
91769
  })]
91721
91770
  })]
91722
91771
  })]
@@ -91794,7 +91843,8 @@ const SingleValueCard = ({
91794
91843
  client,
91795
91844
  param,
91796
91845
  companyTenancyType,
91797
- renderHeaderName
91846
+ renderHeaderName,
91847
+ onDelete
91798
91848
  }) => {
91799
91849
  var _a2;
91800
91850
  const {
@@ -91966,9 +92016,9 @@ const SingleValueCard = ({
91966
92016
  style: descriptionStyle,
91967
92017
  children: metricItem.description
91968
92018
  })]
91969
- }), /* @__PURE__ */ jsx("div", {
92019
+ }), /* @__PURE__ */ jsxs("div", {
91970
92020
  className: styles$1.features,
91971
- children: !!rlsConditions.length && (rlsConditions[0].datatype !== "date" ? /* @__PURE__ */ jsx("div", {
92021
+ children: [!!rlsConditions.length && (rlsConditions[0].datatype !== "date" ? /* @__PURE__ */ jsx("div", {
91972
92022
  className: styles$1.metricFilter,
91973
92023
  children: /* @__PURE__ */ jsx(FloatingDropDown, {
91974
92024
  label: rlsConditions[0].name,
@@ -92022,7 +92072,24 @@ const SingleValueCard = ({
92022
92072
  })]
92023
92073
  }) : null
92024
92074
  })
92025
- }))
92075
+ })), onDelete && /* @__PURE__ */ jsx(PopoverMenu, {
92076
+ buttonClass: styles$1.popup,
92077
+ button: /* @__PURE__ */ jsx(Icons, {
92078
+ name: "more-icon",
92079
+ className: styles$1.popupIcon
92080
+ }),
92081
+ menuClass: styles$1.popupMenu,
92082
+ position: "bottom-right",
92083
+ children: /* @__PURE__ */ jsxs(Button, {
92084
+ variant: "custom",
92085
+ type: "button",
92086
+ className: `${styles$1.popupItem} ${styles$1.csvBtn} ${styles$1.deleteBtn}`,
92087
+ onClick: () => onDelete(metricItem.id),
92088
+ children: [/* @__PURE__ */ jsx(materialSymbolsDeleteOutline, {
92089
+ className: styles$1.popupItemIcon
92090
+ }), "Delete Metric"]
92091
+ })
92092
+ })]
92026
92093
  })]
92027
92094
  }), chartType2 && /* @__PURE__ */ jsx("div", {
92028
92095
  className: `${styles$1.metricData} ${styles$1.singleValueData}`,
@@ -92058,12 +92125,87 @@ const SingleValueCard = ({
92058
92125
  })
92059
92126
  });
92060
92127
  };
92128
+ const ionWarningOutline = (props) => /* @__PURE__ */ jsxs("svg", {
92129
+ viewBox: "0 0 512 512",
92130
+ width: "1.2em",
92131
+ height: "1.2em",
92132
+ ...props,
92133
+ children: [/* @__PURE__ */ jsx("path", {
92134
+ fill: "none",
92135
+ stroke: "currentColor",
92136
+ strokeLinecap: "round",
92137
+ strokeLinejoin: "round",
92138
+ strokeWidth: 32,
92139
+ d: "M85.57 446.25h340.86a32 32 0 0 0 28.17-47.17L284.18 82.58c-12.09-22.44-44.27-22.44-56.36 0L57.4 399.08a32 32 0 0 0 28.17 47.17Z"
92140
+ }), /* @__PURE__ */ jsx("path", {
92141
+ fill: "none",
92142
+ stroke: "currentColor",
92143
+ strokeLinecap: "round",
92144
+ strokeLinejoin: "round",
92145
+ strokeWidth: 32,
92146
+ d: "m250.26 195.39l5.74 122l5.73-121.95a5.74 5.74 0 0 0-5.79-6h0a5.74 5.74 0 0 0-5.68 5.95Z"
92147
+ }), /* @__PURE__ */ jsx("path", {
92148
+ fill: "currentColor",
92149
+ d: "M256 397.25a20 20 0 1 1 20-20a20 20 0 0 1-20 20Z"
92150
+ })]
92151
+ });
92152
+ const DeleteMetricModal = ({
92153
+ isOpen,
92154
+ onClose,
92155
+ onSuccess,
92156
+ metricId
92157
+ }) => {
92158
+ const {
92159
+ mutateAsync: deleteMetric,
92160
+ isLoading
92161
+ } = useMarkDeleteMetricMutation();
92162
+ const handleDeleteMetric = async () => {
92163
+ await deleteMetric({
92164
+ id: metricId
92165
+ }, {
92166
+ onSuccess: () => {
92167
+ onSuccess();
92168
+ }
92169
+ });
92170
+ };
92171
+ return /* @__PURE__ */ jsxs(Modal, {
92172
+ headerTitle: "Delete Metric",
92173
+ isOpen,
92174
+ onClose,
92175
+ children: [/* @__PURE__ */ jsxs("div", {
92176
+ className: styles$1.deleteModal,
92177
+ children: [/* @__PURE__ */ jsx(ionWarningOutline, {
92178
+ className: styles$1.warningIcon
92179
+ }), /* @__PURE__ */ jsx(Text, {
92180
+ variant: "p",
92181
+ styleClass: "font-14",
92182
+ children: "Are you sure you want to delete the metric?"
92183
+ })]
92184
+ }), /* @__PURE__ */ jsxs(ModalFooter, {
92185
+ children: [/* @__PURE__ */ jsx(Button, {
92186
+ variant: "secondary",
92187
+ type: "button",
92188
+ size: "default",
92189
+ className: styles$1.cancelBtn,
92190
+ onClick: onClose,
92191
+ children: "Cancel"
92192
+ }), /* @__PURE__ */ jsx(Button, {
92193
+ variant: "reject",
92194
+ type: "button",
92195
+ size: "default",
92196
+ onClick: handleDeleteMetric,
92197
+ children: isLoading ? "Delete..." : "Delete"
92198
+ })]
92199
+ })]
92200
+ });
92201
+ };
92061
92202
  const GridLayout = reactGridLayout.exports.WidthProvider(reactGridLayout.exports.Responsive);
92062
92203
  const ExternalMetricList = ({
92063
92204
  chartColors,
92064
92205
  globalFilters,
92065
92206
  client,
92066
92207
  isLiveMode,
92208
+ isAllowedToDeleteMetrics,
92067
92209
  externalDashboardMetrics,
92068
92210
  isMetricListLoading,
92069
92211
  breakpoint,
@@ -92072,6 +92214,10 @@ const ExternalMetricList = ({
92072
92214
  companyTenancyType = "TABLE"
92073
92215
  }) => {
92074
92216
  const [isFullScreen, setFullScreen] = useState(false);
92217
+ const [deleteModal2, setDeleteModal] = useState({
92218
+ id: "",
92219
+ show: false
92220
+ });
92075
92221
  const [fullScreenChart, setFullScreenChart] = useState();
92076
92222
  const metricListData = externalDashboardMetrics == null ? void 0 : externalDashboardMetrics.map((data2) => data2.externalMetric);
92077
92223
  const adminMetrics = metricListData == null ? void 0 : metricListData.filter((data2) => !data2.isCreatedByClient);
@@ -92128,7 +92274,11 @@ const ExternalMetricList = ({
92128
92274
  client,
92129
92275
  globalFilters,
92130
92276
  param: params == null ? void 0 : params.find((obj) => obj.metricId === metricItem.metricId),
92131
- companyTenancyType
92277
+ companyTenancyType,
92278
+ onDelete: isAllowedToDeleteMetrics ? (id2) => setDeleteModal({
92279
+ id: id2,
92280
+ show: true
92281
+ }) : void 0
92132
92282
  }) : /* @__PURE__ */ jsx(MetricCard, {
92133
92283
  metricItem,
92134
92284
  onMaximize: (chart) => {
@@ -92139,7 +92289,11 @@ const ExternalMetricList = ({
92139
92289
  colors: chartColors,
92140
92290
  globalFilters,
92141
92291
  param: params == null ? void 0 : params.find((obj) => obj.metricId === metricItem.metricId),
92142
- companyTenancyType
92292
+ companyTenancyType,
92293
+ onDelete: isAllowedToDeleteMetrics ? (id2) => setDeleteModal({
92294
+ id: id2,
92295
+ show: true
92296
+ }) : void 0
92143
92297
  })
92144
92298
  }, metricItem.id))
92145
92299
  })
@@ -92147,7 +92301,18 @@ const ExternalMetricList = ({
92147
92301
  onCancel: () => setFullScreen(false),
92148
92302
  isShow: isFullScreen,
92149
92303
  chart: fullScreenChart
92150
- })]
92304
+ }), isAllowedToDeleteMetrics ? /* @__PURE__ */ jsx(DeleteMetricModal, {
92305
+ metricId: deleteModal2.id,
92306
+ isOpen: deleteModal2.show,
92307
+ onSuccess: () => setDeleteModal({
92308
+ id: "",
92309
+ show: false
92310
+ }),
92311
+ onClose: () => setDeleteModal({
92312
+ id: "",
92313
+ show: false
92314
+ })
92315
+ }) : null]
92151
92316
  }) : /* @__PURE__ */ jsx(Fragment, {
92152
92317
  children: !isMetricListLoading ? /* @__PURE__ */ jsx("div", {
92153
92318
  className: styles$2["noMetric-container"],
@@ -92208,6 +92373,7 @@ var index$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
92208
92373
  ExternalMetricList,
92209
92374
  MetricCard,
92210
92375
  SingleValueCard,
92376
+ DeleteMetricModal,
92211
92377
  MetricTable,
92212
92378
  Modal,
92213
92379
  ModalFooter,
@@ -92317,6 +92483,7 @@ const EmbeddedDashboard = React__default.memo(({
92317
92483
  }) : null, /* @__PURE__ */ jsx(ExternalMetricList, {
92318
92484
  client: data2.clientId,
92319
92485
  isLiveMode: data2.mode,
92486
+ isAllowedToDeleteMetrics: data2.isAllowedToDeleteMetrics,
92320
92487
  externalDashboardMetrics: data2.externalDashboardMetrics,
92321
92488
  isMetricListLoading: isLoading,
92322
92489
  globalFilters,