@databrainhq/plugin 0.8.10 → 0.8.11

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.es.js CHANGED
@@ -2512,69 +2512,73 @@ function useQuery(arg1, arg2, arg3) {
2512
2512
  var parsedOptions = parseQueryArgs(arg1, arg2, arg3);
2513
2513
  return useBaseQuery(parsedOptions, QueryObserver);
2514
2514
  }
2515
- const container$h = "_container_1mfl1_1";
2516
- const fixed = "_fixed_1mfl1_1";
2517
- const absolute = "_absolute_1mfl1_1";
2518
- const flex = "_flex_1mfl1_1";
2519
- const table$4 = "_table_1mfl1_1";
2520
- const grid = "_grid_1mfl1_1";
2521
- const hidden = "_hidden_1mfl1_1";
2522
- const transform = "_transform_1mfl1_1";
2523
- const resize = "_resize_1mfl1_1";
2524
- const truncate = "_truncate_1mfl1_1";
2525
- const border = "_border_1mfl1_1";
2526
- const shadow = "_shadow_1mfl1_1";
2527
- const filter$1 = "_filter_1mfl1_363";
2528
- const floatingFilterButton = "_floatingFilterButton_1mfl1_371";
2529
- const floatingFilterButtonIcon = "_floatingFilterButtonIcon_1mfl1_379";
2530
- const floatingButton = "_floatingButton_1mfl1_387";
2531
- const staticContainer = "_staticContainer_1mfl1_395";
2532
- const floatingContainer = "_floatingContainer_1mfl1_403";
2515
+ const container$h = "_container_1pzq0_1";
2516
+ const fixed = "_fixed_1pzq0_1";
2517
+ const absolute = "_absolute_1pzq0_1";
2518
+ const flex = "_flex_1pzq0_1";
2519
+ const table$4 = "_table_1pzq0_1";
2520
+ const grid = "_grid_1pzq0_1";
2521
+ const hidden = "_hidden_1pzq0_1";
2522
+ const transform = "_transform_1pzq0_1";
2523
+ const resize = "_resize_1pzq0_1";
2524
+ const truncate = "_truncate_1pzq0_1";
2525
+ const border = "_border_1pzq0_1";
2526
+ const shadow = "_shadow_1pzq0_1";
2527
+ const filter$1 = "_filter_1pzq0_363";
2528
+ const floatingFilterButton = "_floatingFilterButton_1pzq0_371";
2529
+ const floatingFilterButtonIcon = "_floatingFilterButtonIcon_1pzq0_379";
2530
+ const floatingCreateButton = "_floatingCreateButton_1pzq0_387";
2531
+ const floatingCreateButtonIcon = "_floatingCreateButtonIcon_1pzq0_395";
2532
+ const floatingButton = "_floatingButton_1pzq0_403";
2533
+ const staticContainer = "_staticContainer_1pzq0_411";
2534
+ const floatingContainer = "_floatingContainer_1pzq0_419";
2533
2535
  var styles$F = {
2534
2536
  container: container$h,
2535
- "static": "_static_1mfl1_395",
2537
+ "static": "_static_1pzq0_411",
2536
2538
  fixed,
2537
2539
  absolute,
2538
- "left-2": "_left-2_1mfl1_1",
2539
- "top-1": "_top-1_1mfl1_1",
2540
- "mt-2.5": "_mt-2.5_1mfl1_1",
2541
- "mt-2": "_mt-2_1mfl1_1",
2542
- "mb-3": "_mb-3_1mfl1_1",
2540
+ "left-2": "_left-2_1pzq0_1",
2541
+ "top-1": "_top-1_1pzq0_1",
2542
+ "mt-2.5": "_mt-2.5_1pzq0_1",
2543
+ "mt-2": "_mt-2_1pzq0_1",
2544
+ "mb-3": "_mb-3_1pzq0_1",
2543
2545
  flex,
2544
2546
  table: table$4,
2545
2547
  grid,
2546
2548
  hidden,
2547
- "h-screen": "_h-screen_1mfl1_1",
2548
- "h-[10%]": "_h-[10%]_1mfl1_1",
2549
- "w-screen": "_w-screen_1mfl1_1",
2550
- "w-full": "_w-full_1mfl1_1",
2549
+ "h-screen": "_h-screen_1pzq0_1",
2550
+ "h-[10%]": "_h-[10%]_1pzq0_1",
2551
+ "w-screen": "_w-screen_1pzq0_1",
2552
+ "w-full": "_w-full_1pzq0_1",
2551
2553
  transform,
2552
2554
  resize,
2553
- "overflow-x-hidden": "_overflow-x-hidden_1mfl1_1",
2555
+ "overflow-x-hidden": "_overflow-x-hidden_1pzq0_1",
2554
2556
  truncate,
2555
2557
  border,
2556
- "p-2": "_p-2_1mfl1_1",
2557
- "p-1": "_p-1_1mfl1_1",
2558
- "text-center": "_text-center_1mfl1_1",
2559
- "text-sm": "_text-sm_1mfl1_1",
2560
- "text-xs": "_text-xs_1mfl1_1",
2561
- "text-blue-700": "_text-blue-700_1mfl1_1",
2558
+ "p-2": "_p-2_1pzq0_1",
2559
+ "p-1": "_p-1_1pzq0_1",
2560
+ "text-center": "_text-center_1pzq0_1",
2561
+ "text-sm": "_text-sm_1pzq0_1",
2562
+ "text-xs": "_text-xs_1pzq0_1",
2563
+ "text-blue-700": "_text-blue-700_1pzq0_1",
2562
2564
  shadow,
2563
2565
  filter: filter$1,
2564
- "!filter": "_!filter_1mfl1_1",
2565
- "embedDashboard-container": "_embedDashboard-container_1mfl1_323",
2566
- "embedDashboard-header-static": "_embedDashboard-header-static_1mfl1_331",
2567
- "embedDashboard-header-floating": "_embedDashboard-header-floating_1mfl1_339",
2568
- "embedDashboard-wrapper": "_embedDashboard-wrapper_1mfl1_347",
2569
- "alt-container": "_alt-container_1mfl1_355",
2566
+ "!filter": "_!filter_1pzq0_1",
2567
+ "embedDashboard-container": "_embedDashboard-container_1pzq0_323",
2568
+ "embedDashboard-header-static": "_embedDashboard-header-static_1pzq0_331",
2569
+ "embedDashboard-header-floating": "_embedDashboard-header-floating_1pzq0_339",
2570
+ "embedDashboard-wrapper": "_embedDashboard-wrapper_1pzq0_347",
2571
+ "alt-container": "_alt-container_1pzq0_355",
2570
2572
  floatingFilterButton,
2571
2573
  floatingFilterButtonIcon,
2574
+ floatingCreateButton,
2575
+ floatingCreateButtonIcon,
2572
2576
  floatingButton,
2573
2577
  staticContainer,
2574
2578
  floatingContainer,
2575
- "hover:cursor-pointer": "_hover:cursor-pointer_1mfl1_1",
2576
- "hover:cursor-text": "_hover:cursor-text_1mfl1_1",
2577
- "disabled:cursor-text": "_disabled:cursor-text_1mfl1_1"
2579
+ "hover:cursor-pointer": "_hover:cursor-pointer_1pzq0_1",
2580
+ "hover:cursor-text": "_hover:cursor-text_1pzq0_1",
2581
+ "disabled:cursor-text": "_disabled:cursor-text_1pzq0_1"
2578
2582
  };
2579
2583
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
2580
2584
  function getAugmentedNamespace(n2) {
@@ -2641,17 +2645,17 @@ var classnames$1 = { exports: {} };
2641
2645
  })(classnames$1);
2642
2646
  var classnames = classnames$1.exports;
2643
2647
  var styles$E = {
2644
- "btn-primary": "_btn-primary_u81u9_1",
2645
- "btn-secondary": "_btn-secondary_u81u9_9",
2646
- "btn-reject": "_btn-reject_u81u9_17",
2647
- "btn-outlined": "_btn-outlined_u81u9_27",
2648
- "btn-tertiary": "_btn-tertiary_u81u9_35",
2649
- "btn-default": "_btn-default_u81u9_43",
2650
- "btn-large": "_btn-large_u81u9_49",
2651
- "btn-small": "_btn-small_u81u9_55",
2652
- "btn-xs": "_btn-xs_u81u9_61",
2653
- "btn-medium": "_btn-medium_u81u9_67",
2654
- "btn-11rem": "_btn-11rem_u81u9_75"
2648
+ "btn-primary": "_btn-primary_17kvk_1",
2649
+ "btn-secondary": "_btn-secondary_17kvk_5",
2650
+ "btn-reject": "_btn-reject_17kvk_9",
2651
+ "btn-outlined": "_btn-outlined_17kvk_14",
2652
+ "btn-tertiary": "_btn-tertiary_17kvk_18",
2653
+ "btn-default": "_btn-default_17kvk_22",
2654
+ "btn-large": "_btn-large_17kvk_25",
2655
+ "btn-small": "_btn-small_17kvk_28",
2656
+ "btn-xs": "_btn-xs_17kvk_31",
2657
+ "btn-medium": "_btn-medium_17kvk_34",
2658
+ "btn-11rem": "_btn-11rem_17kvk_38"
2655
2659
  };
2656
2660
  var jsxRuntime = { exports: {} };
2657
2661
  var reactJsxRuntime_production_min = {};
@@ -4940,39 +4944,39 @@ let xe = "div", ne = S.RenderStrategy, re = C$2(function(e2, s2) {
4940
4944
  let n2 = useContext(F) !== null, m2 = s() !== null;
4941
4945
  return React__default.createElement(React__default.Fragment, null, !n2 && m2 ? React__default.createElement(q, { ref: s$12, ...e2 }) : React__default.createElement(re, { ref: s$12, ...e2 }));
4942
4946
  }), We = Object.assign(q, { Child: Pe, Root: q });
4943
- const listBoxButton = "_listBoxButton_kdipy_9";
4944
- const selectedOptionText = "_selectedOptionText_kdipy_33";
4945
- const transitionDiv = "_transitionDiv_kdipy_41";
4946
- const listboxButtonWrapper = "_listboxButtonWrapper_kdipy_49";
4947
- const arrowicon = "_arrowicon_kdipy_55";
4948
- const leave$2 = "_leave_kdipy_61";
4949
- const leaveFrom$2 = "_leaveFrom_kdipy_67";
4950
- const leaveTo$2 = "_leaveTo_kdipy_73";
4951
- const notAvailable = "_notAvailable_kdipy_79";
4952
- const option$1 = "_option_kdipy_85";
4953
- const activeOption = "_activeOption_kdipy_91";
4954
- const optionSelected = "_optionSelected_kdipy_97";
4955
- const inactiveOption = "_inactiveOption_kdipy_103";
4956
- const optionLabel = "_optionLabel_kdipy_109";
4957
- const optionSubLabel = "_optionSubLabel_kdipy_115";
4958
- const selectedLabel = "_selectedLabel_kdipy_121";
4959
- const nonselectedLabel = "_nonselectedLabel_kdipy_127";
4960
- const check = "_check_kdipy_133";
4961
- const checkActive = "_checkActive_kdipy_139";
4962
- const checkInactive = "_checkInactive_kdipy_145";
4963
- const checkIcon$1 = "_checkIcon_kdipy_151";
4964
- const checkIconSelected = "_checkIconSelected_kdipy_157";
4965
- const checkIconUnselected = "_checkIconUnselected_kdipy_163";
4966
- const loadMore$1 = "_loadMore_kdipy_169";
4967
- const selectedList = "_selectedList_kdipy_175";
4968
- const selectedListItem = "_selectedListItem_kdipy_181";
4969
- const label$7 = "_label_kdipy_187";
4970
- const clientText$1 = "_clientText_kdipy_193";
4947
+ const listBoxButton = "_listBoxButton_fw8xj_5";
4948
+ const selectedOptionText = "_selectedOptionText_fw8xj_17";
4949
+ const transitionDiv = "_transitionDiv_fw8xj_21";
4950
+ const listboxButtonWrapper = "_listboxButtonWrapper_fw8xj_25";
4951
+ const arrowicon = "_arrowicon_fw8xj_28";
4952
+ const leave$2 = "_leave_fw8xj_31";
4953
+ const leaveFrom$2 = "_leaveFrom_fw8xj_34";
4954
+ const leaveTo$2 = "_leaveTo_fw8xj_37";
4955
+ const notAvailable = "_notAvailable_fw8xj_40";
4956
+ const option$1 = "_option_fw8xj_43";
4957
+ const activeOption = "_activeOption_fw8xj_46";
4958
+ const optionSelected = "_optionSelected_fw8xj_49";
4959
+ const inactiveOption = "_inactiveOption_fw8xj_52";
4960
+ const optionLabel = "_optionLabel_fw8xj_55";
4961
+ const optionSubLabel = "_optionSubLabel_fw8xj_58";
4962
+ const selectedLabel = "_selectedLabel_fw8xj_61";
4963
+ const nonselectedLabel = "_nonselectedLabel_fw8xj_64";
4964
+ const check = "_check_fw8xj_67";
4965
+ const checkActive = "_checkActive_fw8xj_70";
4966
+ const checkInactive = "_checkInactive_fw8xj_73";
4967
+ const checkIcon$1 = "_checkIcon_fw8xj_76";
4968
+ const checkIconSelected = "_checkIconSelected_fw8xj_79";
4969
+ const checkIconUnselected = "_checkIconUnselected_fw8xj_82";
4970
+ const loadMore$1 = "_loadMore_fw8xj_85";
4971
+ const selectedList = "_selectedList_fw8xj_88";
4972
+ const selectedListItem = "_selectedListItem_fw8xj_91";
4973
+ const label$7 = "_label_fw8xj_94";
4974
+ const clientText$1 = "_clientText_fw8xj_97";
4971
4975
  var style = {
4972
- "listBox-label": "_listBox-label_kdipy_1",
4973
- "listBoxButton-container": "_listBoxButton-container_kdipy_9",
4976
+ "listBox-label": "_listBox-label_fw8xj_1",
4977
+ "listBoxButton-container": "_listBoxButton-container_fw8xj_5",
4974
4978
  listBoxButton,
4975
- "listBox-option": "_listBox-option_kdipy_25",
4979
+ "listBox-option": "_listBox-option_fw8xj_13",
4976
4980
  selectedOptionText,
4977
4981
  transitionDiv,
4978
4982
  listboxButtonWrapper,
@@ -5001,22 +5005,22 @@ var style = {
5001
5005
  label: label$7,
5002
5006
  clientText: clientText$1
5003
5007
  };
5004
- const primary = "_primary_1ipyg_1";
5005
- const secondary = "_secondary_1ipyg_9";
5006
- const tertiary = "_tertiary_1ipyg_19";
5008
+ const primary = "_primary_18yak_1";
5009
+ const secondary = "_secondary_18yak_5";
5010
+ const tertiary = "_tertiary_18yak_10";
5007
5011
  var styles$C = {
5008
5012
  primary,
5009
5013
  secondary,
5010
5014
  tertiary,
5011
- "font-18": "_font-18_1ipyg_27",
5012
- "font-20": "_font-20_1ipyg_35",
5013
- "font-14": "_font-14_1ipyg_43",
5014
- "font-14a": "_font-14a_1ipyg_51",
5015
- "font-14b": "_font-14b_1ipyg_59",
5016
- "font-14c": "_font-14c_1ipyg_67",
5017
- "font-14d": "_font-14d_1ipyg_75",
5018
- "font-15": "_font-15_1ipyg_83",
5019
- "font-34": "_font-34_1ipyg_89"
5015
+ "font-18": "_font-18_18yak_14",
5016
+ "font-20": "_font-20_18yak_18",
5017
+ "font-14": "_font-14_18yak_22",
5018
+ "font-14a": "_font-14a_18yak_26",
5019
+ "font-14b": "_font-14b_18yak_30",
5020
+ "font-14c": "_font-14c_18yak_34",
5021
+ "font-14d": "_font-14d_18yak_38",
5022
+ "font-15": "_font-15_18yak_42",
5023
+ "font-34": "_font-34_18yak_45"
5020
5024
  };
5021
5025
  const variants = {
5022
5026
  h1: "h1",
@@ -5044,10 +5048,10 @@ const Text = ({
5044
5048
  children: children2
5045
5049
  });
5046
5050
  };
5047
- const search$1 = "_search_qirxg_1";
5051
+ const search$1 = "_search_1klck_1";
5048
5052
  var styles$B = {
5049
- "searchTab-container": "_searchTab-container_qirxg_1",
5050
- "searchTab-input": "_searchTab-input_qirxg_9",
5053
+ "searchTab-container": "_searchTab-container_1klck_1",
5054
+ "searchTab-input": "_searchTab-input_1klck_5",
5051
5055
  search: search$1
5052
5056
  };
5053
5057
  const iconoirSearch = (props) => /* @__PURE__ */ jsx("svg", {
@@ -6945,6 +6949,63 @@ const useResizeExternalMetricMutation = (options2) => useMutation(
6945
6949
  (variables) => fetcher(ResizeExternalMetricDocument, variables)(),
6946
6950
  options2
6947
6951
  );
6952
+ const UpdateAdminMetricDocument = `
6953
+ mutation UpdateAdminMetric($externalMetricId: uuid!, $object: externalMetrics_insert_input!, $clientId: String!) {
6954
+ insert_clientDeletedMetrics_one(
6955
+ object: {externalMetricId: $externalMetricId, clientId: $clientId}
6956
+ ) {
6957
+ clientId
6958
+ externalMetricId
6959
+ }
6960
+ insert_externalMetrics_one(object: $object) {
6961
+ chartOptions
6962
+ clientId
6963
+ companyId
6964
+ companyIntegrationId
6965
+ createdAt
6966
+ createdBy
6967
+ description
6968
+ id
6969
+ inputFields
6970
+ integrationName
6971
+ isCreatedByClient
6972
+ isLive
6973
+ metricId
6974
+ metricQuery
6975
+ name
6976
+ outputColumns
6977
+ query
6978
+ resizeAttributes
6979
+ timeGrain
6980
+ updatedAt
6981
+ selectedGroupBy
6982
+ isEnableGroupBy
6983
+ groupBy
6984
+ rlsConditions
6985
+ companyIntegration {
6986
+ name
6987
+ }
6988
+ clickActions
6989
+ }
6990
+ }
6991
+ `;
6992
+ const useUpdateAdminMetricMutation = (options2) => useMutation(
6993
+ ["UpdateAdminMetric"],
6994
+ (variables) => fetcher(UpdateAdminMetricDocument, variables)(),
6995
+ options2
6996
+ );
6997
+ const UpdateExternalMetricDocument = `
6998
+ mutation UpdateExternalMetric($externalMetricId: uuid!, $set: externalMetrics_set_input!) {
6999
+ update_externalMetrics_by_pk(pk_columns: {id: $externalMetricId}, _set: $set) {
7000
+ id
7001
+ }
7002
+ }
7003
+ `;
7004
+ const useUpdateExternalMetricMutation = (options2) => useMutation(
7005
+ ["UpdateExternalMetric"],
7006
+ (variables) => fetcher(UpdateExternalMetricDocument, variables)(),
7007
+ options2
7008
+ );
6948
7009
  const ExternalMetricForm = ({
6949
7010
  onSubmit,
6950
7011
  defaultValues,
@@ -6958,7 +7019,8 @@ const ExternalMetricForm = ({
6958
7019
  var _a2, _b2, _c2;
6959
7020
  const {
6960
7021
  register: register2,
6961
- handleSubmit
7022
+ handleSubmit,
7023
+ setValue
6962
7024
  } = useForm();
6963
7025
  const [isLiveMode, setLiveMode] = useState((_a2 = defaultValues == null ? void 0 : defaultValues.isLive) != null ? _a2 : false);
6964
7026
  const submitMetric = handleSubmit((data) => {
@@ -6980,6 +7042,13 @@ const ExternalMetricForm = ({
6980
7042
  value: dash.id,
6981
7043
  label: dash.name
6982
7044
  }))) != null ? _c2 : [];
7045
+ useEffect(() => {
7046
+ if (!defaultValues)
7047
+ return;
7048
+ setValue("name", defaultValues.name);
7049
+ setValue("description", defaultValues.description);
7050
+ setValue("metricId", defaultValues.metricId);
7051
+ }, [defaultValues]);
6983
7052
  return /* @__PURE__ */ jsxs("form", {
6984
7053
  className: styles$x.form,
6985
7054
  onSubmit: submitMetric,
@@ -7009,8 +7078,7 @@ const ExternalMetricForm = ({
7009
7078
  placeholder: "Unique Id to identify metric",
7010
7079
  label: "Metric ID",
7011
7080
  register: register2("metricId", {
7012
- required: true,
7013
- disabled: !!(defaultValues == null ? void 0 : defaultValues.metricId)
7081
+ required: true
7014
7082
  }),
7015
7083
  defaultValue: defaultValues == null ? void 0 : defaultValues.metricId
7016
7084
  }), /* @__PURE__ */ jsx(TextAreaField, {
@@ -7054,22 +7122,22 @@ const ExternalMetricForm = ({
7054
7122
  })]
7055
7123
  });
7056
7124
  };
7057
- const container$d = "_container_1b6ua_1";
7058
- const wrapper$3 = "_wrapper_1b6ua_9";
7059
- const label$3 = "_label_1b6ua_17";
7060
- const floatingLabel = "_floatingLabel_1b6ua_25";
7061
- const clientText = "_clientText_1b6ua_33";
7062
- const normalText = "_normalText_1b6ua_41";
7063
- const dropdown$1 = "_dropdown_1b6ua_49";
7064
- const options = "_options_1b6ua_57";
7065
- const checkedOption = "_checkedOption_1b6ua_65";
7066
- const option = "_option_1b6ua_57";
7067
- const icon$1 = "_icon_1b6ua_81";
7068
- const text$2 = "_text_1b6ua_89";
7069
- const floatingText = "_floatingText_1b6ua_97";
7070
- const search = "_search_1b6ua_105";
7071
- const loadMore = "_loadMore_1b6ua_113";
7072
- const loadMoreIcon = "_loadMoreIcon_1b6ua_121";
7125
+ const container$d = "_container_q0qrl_1";
7126
+ const wrapper$3 = "_wrapper_q0qrl_5";
7127
+ const label$3 = "_label_q0qrl_9";
7128
+ const floatingLabel = "_floatingLabel_q0qrl_13";
7129
+ const clientText = "_clientText_q0qrl_17";
7130
+ const normalText = "_normalText_q0qrl_21";
7131
+ const dropdown$1 = "_dropdown_q0qrl_25";
7132
+ const options = "_options_q0qrl_29";
7133
+ const checkedOption = "_checkedOption_q0qrl_33";
7134
+ const option = "_option_q0qrl_29";
7135
+ const icon$1 = "_icon_q0qrl_41";
7136
+ const text$2 = "_text_q0qrl_45";
7137
+ const floatingText = "_floatingText_q0qrl_49";
7138
+ const search = "_search_q0qrl_53";
7139
+ const loadMore = "_loadMore_q0qrl_57";
7140
+ const loadMoreIcon = "_loadMoreIcon_q0qrl_61";
7073
7141
  var styles$s = {
7074
7142
  container: container$d,
7075
7143
  wrapper: wrapper$3,
@@ -7097,7 +7165,7 @@ const useEmbeddedDashboard = (token) => {
7097
7165
  const companyId = tokenParams == null ? void 0 : tokenParams.companyId;
7098
7166
  const clientId = tokenParams == null ? void 0 : tokenParams.clientId;
7099
7167
  const workspace = params == null ? void 0 : params.workspace;
7100
- const mode = (_b2 = params == null ? void 0 : params.dashboard) == null ? void 0 : _b2.isLive;
7168
+ const isLiveMode = (_b2 = params == null ? void 0 : params.dashboard) == null ? void 0 : _b2.isLive;
7101
7169
  const rlsSettings = params == null ? void 0 : params.rlsSettings;
7102
7170
  const companyTenancyType = params == null ? void 0 : params.companyTenancyType;
7103
7171
  const isTestKey = params == null ? void 0 : params.isTestKey;
@@ -7124,7 +7192,7 @@ const useEmbeddedDashboard = (token) => {
7124
7192
  data: {
7125
7193
  clientId,
7126
7194
  companyId,
7127
- mode,
7195
+ isLiveMode,
7128
7196
  externalDashboardMetrics,
7129
7197
  externalDashboard: idData == null ? void 0 : idData.externalDashboards[0],
7130
7198
  externalDashboardId,
@@ -7231,40 +7299,31 @@ const getChartOption = ({
7231
7299
  };
7232
7300
  };
7233
7301
  const useExternalMetric = ({
7302
+ onSuccess,
7234
7303
  companyIntegrationId,
7235
7304
  selectedColumns,
7236
7305
  query,
7237
7306
  metricQuery,
7238
7307
  integrationName,
7239
7308
  outputColumns,
7240
- xAxis,
7241
- yAxisList,
7242
- chartType: chartType2,
7243
- step,
7244
- measure,
7245
- sankeyValues,
7246
- singleValue: singleValue2,
7247
- margins,
7248
- legendSettings,
7249
- labelSettings,
7250
- axisSettings,
7251
- customSettings,
7252
- tableSettings,
7253
- backGroundColor,
7309
+ chartSettings: chartSettings2,
7254
7310
  clientId,
7255
7311
  companyId,
7256
- mode,
7312
+ isLiveMode,
7257
7313
  timeGrain,
7258
7314
  dashboardIds,
7259
7315
  isEnableGroupBy,
7260
7316
  groupBy,
7261
- selectedGroupBy
7317
+ selectedGroupBy,
7318
+ userProvidedDashboardId,
7319
+ metric
7262
7320
  }) => {
7263
7321
  const [error2, setError] = useState("");
7264
- const createExternalMetricMutation = useCreateExternalMetricMutation();
7322
+ const queryClient2 = useQueryClient();
7323
+ const { mutate: createExternalMetricMutation, isLoading: isCreatingMetric } = useCreateExternalMetricMutation();
7265
7324
  const createExternalMetric = (data) => {
7266
7325
  setError("");
7267
- createExternalMetricMutation.mutate(
7326
+ createExternalMetricMutation(
7268
7327
  {
7269
7328
  companyId,
7270
7329
  companyIntegrationId,
@@ -7276,24 +7335,9 @@ const useExternalMetric = ({
7276
7335
  metricQuery,
7277
7336
  integrationName,
7278
7337
  outputColumns,
7279
- createdBy: "external user",
7280
- isLive: mode || data.isLive,
7281
- chartOptions: getChartOption({
7282
- xAxis,
7283
- yAxisList,
7284
- chartType: chartType2,
7285
- step,
7286
- measure,
7287
- sankeyValues,
7288
- singleValue: singleValue2,
7289
- margins,
7290
- legendSettings,
7291
- labelSettings,
7292
- axisSettings,
7293
- customSettings,
7294
- backGroundColor,
7295
- tableSettings
7296
- }),
7338
+ createdBy: clientId || "external user",
7339
+ isLive: isLiveMode || data.isLive,
7340
+ chartOptions: getChartOption(chartSettings2),
7297
7341
  clientId: clientId || null,
7298
7342
  isCreatedByClient: !!clientId,
7299
7343
  timeGrain: timeGrain || null,
@@ -7305,10 +7349,28 @@ const useExternalMetric = ({
7305
7349
  selectedGroupBy
7306
7350
  },
7307
7351
  {
7308
- onSuccess: (res) => {
7309
- var _a2;
7352
+ onSuccess: (res, variables) => {
7353
+ var _a2, _b2;
7310
7354
  if ((_a2 = res.insert_externalMetrics_one) == null ? void 0 : _a2.id) {
7311
- window.location.reload();
7355
+ const metricId = (_b2 = res.insert_externalMetrics_one) == null ? void 0 : _b2.id;
7356
+ queryClient2.setQueryData(
7357
+ [
7358
+ "EmbeddedDashboardMetrics",
7359
+ { externalDashboardId: userProvidedDashboardId, clientId }
7360
+ ],
7361
+ (prev) => {
7362
+ const externalDashboardMetrics = prev == null ? void 0 : prev.externalDashboardMetrics;
7363
+ externalDashboardMetrics == null ? void 0 : externalDashboardMetrics.push({
7364
+ externalDashboardId: dashboardIds[0],
7365
+ externalMetricId: metricId,
7366
+ externalMetric: {
7367
+ ...variables,
7368
+ id: metricId
7369
+ }
7370
+ });
7371
+ return { ...prev, externalDashboardMetrics };
7372
+ }
7373
+ );
7312
7374
  }
7313
7375
  },
7314
7376
  onError: () => {
@@ -7319,7 +7381,122 @@ const useExternalMetric = ({
7319
7381
  }
7320
7382
  );
7321
7383
  };
7322
- return { createExternalMetric, error: error2 };
7384
+ const { mutateAsync: updateAdminMetric, isLoading: isUpdatingAdminMetric } = useUpdateAdminMetricMutation({
7385
+ onSuccess: (res) => {
7386
+ var _a2;
7387
+ if (!res.insert_clientDeletedMetrics_one || !res.insert_externalMetrics_one)
7388
+ return;
7389
+ const metricId = (_a2 = res.insert_externalMetrics_one) == null ? void 0 : _a2.id;
7390
+ queryClient2.setQueryData(
7391
+ [
7392
+ "EmbeddedDashboardMetrics",
7393
+ { externalDashboardId: userProvidedDashboardId, clientId }
7394
+ ],
7395
+ (prev) => {
7396
+ var _a3;
7397
+ const externalDashboardMetrics = (_a3 = prev == null ? void 0 : prev.externalDashboardMetrics) == null ? void 0 : _a3.filter(
7398
+ (exdm) => exdm.externalMetricId !== (metric == null ? void 0 : metric.id)
7399
+ );
7400
+ externalDashboardMetrics == null ? void 0 : externalDashboardMetrics.push({
7401
+ externalDashboardId: dashboardIds[0],
7402
+ externalMetricId: metricId,
7403
+ externalMetric: res.insert_externalMetrics_one
7404
+ });
7405
+ return { ...prev, externalDashboardMetrics };
7406
+ }
7407
+ );
7408
+ setError("");
7409
+ onSuccess();
7410
+ },
7411
+ onError: () => {
7412
+ setError("Something went wrong! Please try again later.");
7413
+ }
7414
+ });
7415
+ const { mutateAsync: updateMetric, isLoading: isUpdatingMetric } = useUpdateExternalMetricMutation({
7416
+ onSuccess: (res, variables) => {
7417
+ var _a2;
7418
+ if (!((_a2 = res.update_externalMetrics_by_pk) == null ? void 0 : _a2.id))
7419
+ return;
7420
+ queryClient2.setQueryData(
7421
+ [
7422
+ "EmbeddedDashboardMetrics",
7423
+ { externalDashboardId: userProvidedDashboardId, clientId }
7424
+ ],
7425
+ (prev) => {
7426
+ const externalDashboardMetrics = prev == null ? void 0 : prev.externalDashboardMetrics;
7427
+ const index2 = externalDashboardMetrics == null ? void 0 : externalDashboardMetrics.findIndex(
7428
+ (exdm) => exdm.externalMetricId === (metric == null ? void 0 : metric.id)
7429
+ );
7430
+ if (index2 === -1)
7431
+ return prev;
7432
+ externalDashboardMetrics[index2].externalMetric = {
7433
+ ...externalDashboardMetrics[index2].externalMetric,
7434
+ ...variables.set
7435
+ };
7436
+ return { ...prev, externalDashboardMetrics };
7437
+ }
7438
+ );
7439
+ setError("");
7440
+ onSuccess();
7441
+ },
7442
+ onError: () => {
7443
+ setError("Something went wrong! Please try again later.");
7444
+ }
7445
+ });
7446
+ const updateExternalMetric = useCallback(
7447
+ (data) => {
7448
+ setError("");
7449
+ if (!(metric == null ? void 0 : metric.isCreatedByClient))
7450
+ updateAdminMetric({
7451
+ externalMetricId: metric == null ? void 0 : metric.id,
7452
+ clientId,
7453
+ object: {
7454
+ companyId,
7455
+ companyIntegrationId: companyIntegrationId || (metric == null ? void 0 : metric.companyIntegrationId),
7456
+ description: data.description,
7457
+ inputFields: selectedColumns,
7458
+ metricId: data.metricId === (metric == null ? void 0 : metric.metricId) ? `update_${data.metricId}_by_${clientId}_${Date.now()}` : data.metricId,
7459
+ name: data.name,
7460
+ query,
7461
+ metricQuery,
7462
+ integrationName,
7463
+ outputColumns,
7464
+ createdBy: clientId || "external user",
7465
+ clientId,
7466
+ isCreatedByClient: !!clientId,
7467
+ externalDashboardMetrics: {
7468
+ data: dashboardIds.map((externalDashboardId) => ({
7469
+ externalDashboardId
7470
+ }))
7471
+ },
7472
+ isLive: isLiveMode || data.isLive,
7473
+ chartOptions: getChartOption(chartSettings2)
7474
+ }
7475
+ });
7476
+ else {
7477
+ const set2 = {
7478
+ chartOptions: getChartOption(chartSettings2)
7479
+ };
7480
+ if (data.description)
7481
+ set2.description = data.description;
7482
+ if (data.metricId)
7483
+ set2.metricId = data.metricId;
7484
+ if (data.name)
7485
+ set2.name = data.name;
7486
+ updateMetric({
7487
+ externalMetricId: metric == null ? void 0 : metric.id,
7488
+ set: set2
7489
+ });
7490
+ }
7491
+ },
7492
+ [chartSettings2, metric == null ? void 0 : metric.id, metric == null ? void 0 : metric.isCreatedByClient]
7493
+ );
7494
+ return {
7495
+ createExternalMetric,
7496
+ updateExternalMetric,
7497
+ error: error2,
7498
+ isLoading: isCreatingMetric || isUpdatingAdminMetric || isUpdatingMetric
7499
+ };
7323
7500
  };
7324
7501
  const useGenerateDatasetMetrics = () => {
7325
7502
  const {
@@ -86515,12 +86692,12 @@ const InfoTooltip = ({
86515
86692
  });
86516
86693
  };
86517
86694
  var styles$j = {
86518
- "header-container": "_header-container_1pbz4_1",
86519
- "btn-container": "_btn-container_1pbz4_9",
86520
- "back-btn": "_back-btn_1pbz4_17",
86521
- "sql-btn": "_sql-btn_1pbz4_25",
86522
- "save-btn": "_save-btn_1pbz4_33",
86523
- "save-btn-icon": "_save-btn-icon_1pbz4_41"
86695
+ "header-container": "_header-container_t2r6v_1",
86696
+ "btn-container": "_btn-container_t2r6v_5",
86697
+ "back-btn": "_back-btn_t2r6v_9",
86698
+ "sql-btn": "_sql-btn_t2r6v_13",
86699
+ "save-btn": "_save-btn_t2r6v_17",
86700
+ "save-btn-icon": "_save-btn-icon_t2r6v_21"
86524
86701
  };
86525
86702
  const Header = ({
86526
86703
  setShowMetricCreateModal,
@@ -86572,25 +86749,21 @@ const Header = ({
86572
86749
  })]
86573
86750
  });
86574
86751
  };
86575
- const floatingCreateButton = "_floatingCreateButton_jfq7q_25";
86576
- const floatingCreateButtonIcon = "_floatingCreateButtonIcon_jfq7q_33";
86577
86752
  var styles$i = {
86578
- "create-btn": "_create-btn_jfq7q_1",
86579
- "modal-container": "_modal-container_jfq7q_9",
86580
- "query-modal": "_query-modal_jfq7q_17",
86581
- floatingCreateButton,
86582
- floatingCreateButtonIcon
86753
+ "create-btn": "_create-btn_ihjk8_1",
86754
+ "modal-container": "_modal-container_ihjk8_5",
86755
+ "query-modal": "_query-modal_ihjk8_9"
86583
86756
  };
86584
- const container$7 = "_container_u2z1d_1";
86585
- const header$3 = "_header_u2z1d_9";
86586
- const wrapper$2 = "_wrapper_u2z1d_17";
86587
- const column = "_column_u2z1d_33";
86588
- const columnText$1 = "_columnText_u2z1d_41";
86757
+ const container$7 = "_container_1q2ss_1";
86758
+ const header$3 = "_header_1q2ss_5";
86759
+ const wrapper$2 = "_wrapper_1q2ss_9";
86760
+ const column = "_column_1q2ss_17";
86761
+ const columnText$1 = "_columnText_1q2ss_21";
86589
86762
  var styles$h = {
86590
86763
  container: container$7,
86591
86764
  header: header$3,
86592
86765
  wrapper: wrapper$2,
86593
- "col-container": "_col-container_u2z1d_25",
86766
+ "col-container": "_col-container_1q2ss_13",
86594
86767
  column,
86595
86768
  columnText: columnText$1
86596
86769
  };
@@ -87966,10 +88139,10 @@ const ChartTab = ({
87966
88139
  })]
87967
88140
  });
87968
88141
  };
87969
- const container$5 = "_container_wjdaz_1";
87970
- const wrapper$1 = "_wrapper_wjdaz_9";
87971
- const text = "_text_wjdaz_17";
87972
- const table$2 = "_table_wjdaz_23";
88142
+ const container$5 = "_container_yjeiv_1";
88143
+ const wrapper$1 = "_wrapper_yjeiv_5";
88144
+ const text = "_text_yjeiv_9";
88145
+ const table$2 = "_table_yjeiv_12";
87973
88146
  var styles$c = {
87974
88147
  container: container$5,
87975
88148
  wrapper: wrapper$1,
@@ -88002,16 +88175,16 @@ const InputTables = ({
88002
88175
  })
88003
88176
  });
88004
88177
  };
88005
- const container$4 = "_container_127xg_1";
88006
- const header$1 = "_header_127xg_9";
88007
- const tabButton$1 = "_tabButton_127xg_31";
88008
- const selectedTab = "_selectedTab_127xg_37";
88009
- const table$1 = "_table_127xg_43";
88178
+ const container$4 = "_container_38zl3_1";
88179
+ const header$1 = "_header_38zl3_5";
88180
+ const tabButton$1 = "_tabButton_38zl3_16";
88181
+ const selectedTab = "_selectedTab_38zl3_19";
88182
+ const table$1 = "_table_38zl3_22";
88010
88183
  var styles$b = {
88011
88184
  container: container$4,
88012
88185
  header: header$1,
88013
- "text-container": "_text-container_127xg_17",
88014
- "btn-container": "_btn-container_127xg_25",
88186
+ "text-container": "_text-container_38zl3_9",
88187
+ "btn-container": "_btn-container_38zl3_13",
88015
88188
  tabButton: tabButton$1,
88016
88189
  selectedTab,
88017
88190
  table: table$1
@@ -88020,7 +88193,8 @@ const TableTab = ({
88020
88193
  outpuTableData,
88021
88194
  outputError,
88022
88195
  isOutputLoading,
88023
- previewTableDataList
88196
+ previewTableDataList,
88197
+ isUpdateMetric
88024
88198
  }) => {
88025
88199
  const [selectedTab2, setSelectedTab] = useState(OUTPUT_TABLE);
88026
88200
  const buttonColor = {
@@ -88037,6 +88211,11 @@ const TableTab = ({
88037
88211
  if (selectedTab2 !== INPUT_TABLE)
88038
88212
  setSelectedTab(INPUT_TABLE);
88039
88213
  }, [previewTableDataList]);
88214
+ useEffect(() => {
88215
+ if (!isUpdateMetric)
88216
+ return;
88217
+ setSelectedTab(OUTPUT_TABLE);
88218
+ }, [isUpdateMetric]);
88040
88219
  return /* @__PURE__ */ jsxs("div", {
88041
88220
  className: styles$b.container,
88042
88221
  children: [/* @__PURE__ */ jsxs("div", {
@@ -88086,14 +88265,20 @@ const TableTab = ({
88086
88265
  })]
88087
88266
  });
88088
88267
  };
88089
- const wrapper = "_wrapper_49kql_17";
88090
- const searchCommand = "_searchCommand_49kql_23";
88091
- const tabButton = "_tabButton_49kql_29";
88092
- const tabActive = "_tabActive_49kql_35";
88268
+ const mainContainerUpdate = "_mainContainerUpdate_19iy1_4";
88269
+ const wrapper = "_wrapper_19iy1_12";
88270
+ const updateWrapper = "_updateWrapper_19iy1_15";
88271
+ const updateWrapperContent = "_updateWrapperContent_19iy1_18";
88272
+ const searchCommand = "_searchCommand_19iy1_21";
88273
+ const tabButton = "_tabButton_19iy1_24";
88274
+ const tabActive = "_tabActive_19iy1_27";
88093
88275
  var styles$a = {
88094
- "main-container": "_main-container_49kql_1",
88095
- "outputTab-header": "_outputTab-header_49kql_9",
88276
+ "main-container": "_main-container_19iy1_1",
88277
+ mainContainerUpdate,
88278
+ "outputTab-header": "_outputTab-header_19iy1_8",
88096
88279
  wrapper,
88280
+ updateWrapper,
88281
+ updateWrapperContent,
88097
88282
  searchCommand,
88098
88283
  tabButton,
88099
88284
  tabActive
@@ -88138,7 +88323,8 @@ const MetricOutput = ({
88138
88323
  backGroundColor,
88139
88324
  setBackGroundColor,
88140
88325
  moreTabs,
88141
- chartColors
88326
+ chartColors,
88327
+ isUpdateMetric = false
88142
88328
  }) => {
88143
88329
  var _a2;
88144
88330
  const [selectedTab2, setSelectedTab] = useState(TABLE_TAB);
@@ -88147,8 +88333,8 @@ const MetricOutput = ({
88147
88333
  tableName = item.name;
88148
88334
  });
88149
88335
  return /* @__PURE__ */ jsxs("div", {
88150
- className: styles$a["main-container"],
88151
- children: [/* @__PURE__ */ jsxs("div", {
88336
+ className: `${styles$a["main-container"]} ${isUpdateMetric ? styles$a.mainContainerUpdate : ""}`,
88337
+ children: [!isUpdateMetric && /* @__PURE__ */ jsxs("div", {
88152
88338
  className: styles$a["outputTab-header"],
88153
88339
  children: [/* @__PURE__ */ jsxs(Button, {
88154
88340
  type: "button",
@@ -88174,79 +88360,86 @@ const MetricOutput = ({
88174
88360
  children: tabObj.tab
88175
88361
  }, tabObj.name))]
88176
88362
  }), /* @__PURE__ */ jsxs("div", {
88177
- className: styles$a.wrapper,
88178
- children: [selectedTab2 === TABLE_TAB && /* @__PURE__ */ jsx(TableTab, {
88179
- outpuTableData: data,
88180
- isOutputLoading: isLoading,
88181
- outputError: error2,
88182
- previewTableDataList
88183
- }), selectedTab2 === CHART_TAB && /* @__PURE__ */ jsx(ChartTab, {
88184
- labels: labels2,
88185
- funnelData,
88186
- chartType: chartType2,
88187
- datasets,
88188
- data,
88189
- setChartType,
88190
- setXAxis,
88191
- setYAxisList,
88192
- yAxisList,
88193
- xAxis,
88194
- setMeasure,
88195
- setStep,
88196
- step,
88197
- measure,
88198
- setSankeyValues,
88199
- sankeyData,
88200
- singleValue: singleValue2,
88201
- setSingleValue,
88202
- singleValueData: singleValueData2,
88203
- setMargins,
88204
- margins,
88205
- legendSettings,
88206
- setLegendSettings,
88207
- labelSettings,
88208
- setLabelSettings,
88209
- axisSettings,
88210
- setAxisSettings,
88211
- customSettings,
88212
- setCustomSettings,
88213
- updateGroup,
88214
- isEnableGroupBy,
88215
- isLoading,
88216
- backGroundColor,
88217
- setBackGroundColor,
88218
- tableSettings,
88219
- setTableSettings,
88220
- tableName,
88221
- chartColors
88363
+ className: `${styles$a.wrapper} ${isUpdateMetric ? styles$a.updateWrapper : ""}`,
88364
+ children: [(selectedTab2 === TABLE_TAB || isUpdateMetric) && /* @__PURE__ */ jsx("div", {
88365
+ className: isUpdateMetric ? styles$a.updateWrapperContent : "",
88366
+ children: /* @__PURE__ */ jsx(TableTab, {
88367
+ outpuTableData: data,
88368
+ isOutputLoading: isLoading,
88369
+ outputError: error2,
88370
+ previewTableDataList,
88371
+ isUpdateMetric
88372
+ })
88373
+ }), (selectedTab2 === CHART_TAB || isUpdateMetric) && /* @__PURE__ */ jsx("div", {
88374
+ className: isUpdateMetric ? styles$a.updateWrapperContent : "",
88375
+ children: /* @__PURE__ */ jsx(ChartTab, {
88376
+ labels: labels2,
88377
+ funnelData,
88378
+ chartType: chartType2,
88379
+ datasets,
88380
+ data,
88381
+ setChartType,
88382
+ setXAxis,
88383
+ setYAxisList,
88384
+ yAxisList,
88385
+ xAxis,
88386
+ setMeasure,
88387
+ setStep,
88388
+ step,
88389
+ measure,
88390
+ setSankeyValues,
88391
+ sankeyData,
88392
+ singleValue: singleValue2,
88393
+ setSingleValue,
88394
+ singleValueData: singleValueData2,
88395
+ setMargins,
88396
+ margins,
88397
+ legendSettings,
88398
+ setLegendSettings,
88399
+ labelSettings,
88400
+ setLabelSettings,
88401
+ axisSettings,
88402
+ setAxisSettings,
88403
+ customSettings,
88404
+ setCustomSettings,
88405
+ updateGroup,
88406
+ isEnableGroupBy,
88407
+ isLoading,
88408
+ backGroundColor,
88409
+ setBackGroundColor,
88410
+ tableSettings,
88411
+ setTableSettings,
88412
+ tableName,
88413
+ chartColors
88414
+ })
88222
88415
  }), (_a2 = moreTabs == null ? void 0 : moreTabs.find((tabObj) => tabObj.name === selectedTab2)) == null ? void 0 : _a2.tabContent]
88223
88416
  })]
88224
88417
  });
88225
88418
  };
88226
- const fieldValueIcon = "_fieldValueIcon_fl6kw_49";
88227
- const fieldAddBtnIcon = "_fieldAddBtnIcon_fl6kw_65";
88228
- const group = "_group_fl6kw_1";
88229
- const tooltipWrapper = "_tooltipWrapper_fl6kw_89";
88230
- const tooltip = "_tooltip_fl6kw_89";
88231
- const dropdown = "_dropdown_fl6kw_113";
88232
- const filterDropdown = "_filterDropdown_fl6kw_121";
88233
- const filterValues = "_filterValues_fl6kw_129";
88234
- const columnText = "_columnText_fl6kw_137";
88235
- const disabled = "_disabled_fl6kw_145";
88236
- const checkIcon = "_checkIcon_fl6kw_153";
88237
- const generateButton = "_generateButton_fl6kw_161";
88419
+ const fieldValueIcon = "_fieldValueIcon_z8ldj_25";
88420
+ const fieldAddBtnIcon = "_fieldAddBtnIcon_z8ldj_33";
88421
+ const group = "_group_z8ldj_1";
88422
+ const tooltipWrapper = "_tooltipWrapper_z8ldj_45";
88423
+ const tooltip = "_tooltip_z8ldj_45";
88424
+ const dropdown = "_dropdown_z8ldj_57";
88425
+ const filterDropdown = "_filterDropdown_z8ldj_61";
88426
+ const filterValues = "_filterValues_z8ldj_65";
88427
+ const columnText = "_columnText_z8ldj_69";
88428
+ const disabled = "_disabled_z8ldj_73";
88429
+ const checkIcon = "_checkIcon_z8ldj_77";
88430
+ const generateButton = "_generateButton_z8ldj_81";
88238
88431
  var styles$9 = {
88239
- "form-container": "_form-container_fl6kw_1",
88240
- "field-container": "_field-container_fl6kw_9",
88241
- "field-label": "_field-label_fl6kw_17",
88242
- "field-wrapper": "_field-wrapper_fl6kw_25",
88243
- "field-inner-container": "_field-inner-container_fl6kw_33",
88244
- "field-value": "_field-value_fl6kw_41",
88432
+ "form-container": "_form-container_z8ldj_1",
88433
+ "field-container": "_field-container_z8ldj_5",
88434
+ "field-label": "_field-label_z8ldj_9",
88435
+ "field-wrapper": "_field-wrapper_z8ldj_13",
88436
+ "field-inner-container": "_field-inner-container_z8ldj_17",
88437
+ "field-value": "_field-value_z8ldj_21",
88245
88438
  fieldValueIcon,
88246
- "field-add-btn": "_field-add-btn_fl6kw_57",
88439
+ "field-add-btn": "_field-add-btn_z8ldj_29",
88247
88440
  fieldAddBtnIcon,
88248
- "field-value-container": "_field-value-container_fl6kw_73",
88249
- "field-prompt": "_field-prompt_fl6kw_81",
88441
+ "field-value-container": "_field-value-container_z8ldj_37",
88442
+ "field-prompt": "_field-prompt_z8ldj_41",
88250
88443
  group,
88251
88444
  tooltipWrapper,
88252
88445
  tooltip,
@@ -89398,10 +89591,10 @@ const MetricForm = ({
89398
89591
  })]
89399
89592
  });
89400
89593
  };
89401
- const container$2 = "_container_1v000_1";
89402
- const header = "_header_1v000_9";
89403
- const enableGroupBy = "_enableGroupBy_1v000_15";
89404
- const enableGroupButton = "_enableGroupButton_1v000_21";
89594
+ const container$2 = "_container_rofqe_1";
89595
+ const header = "_header_rofqe_5";
89596
+ const enableGroupBy = "_enableGroupBy_rofqe_8";
89597
+ const enableGroupButton = "_enableGroupButton_rofqe_11";
89405
89598
  var styles$7 = {
89406
89599
  container: container$2,
89407
89600
  header,
@@ -89450,23 +89643,17 @@ const ConstructMetric = ({
89450
89643
  })]
89451
89644
  });
89452
89645
  };
89453
- const mdiPlus = (props) => /* @__PURE__ */ jsx("svg", {
89454
- viewBox: "0 0 24 24",
89455
- width: "1.2em",
89456
- height: "1.2em",
89457
- ...props,
89458
- children: /* @__PURE__ */ jsx("path", {
89459
- fill: "currentColor",
89460
- d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2Z"
89461
- })
89462
- });
89463
89646
  const EmbeddedMetricCreation = ({
89464
89647
  clientId,
89465
89648
  companyId,
89466
- mode,
89649
+ isLiveMode,
89467
89650
  externalDashboardId,
89468
- variant = "static",
89651
+ userProvidedDashboardId,
89469
89652
  chartColors,
89653
+ isShowMetricCreateModal,
89654
+ setShowMetricCreateModal,
89655
+ metric,
89656
+ metricData: metricData2,
89470
89657
  workspaceId
89471
89658
  }) => {
89472
89659
  var _a2;
@@ -89478,7 +89665,6 @@ const EmbeddedMetricCreation = ({
89478
89665
  const [isEnableGroupBy, setEnableGroupBy] = useState(false);
89479
89666
  const [selectedGroupBy, setSelectedGroupBy] = useState([]);
89480
89667
  const [groupBy, setGroupBy] = useState();
89481
- const [isShowMetricCreateModal, setShowMetricCreateModal] = useState(false);
89482
89668
  const [isShowSqlModal, setShowSqlModal] = useState(false);
89483
89669
  const [isShowSaveMetricModal, setShowSaveMetricModal] = useState(false);
89484
89670
  const [selectTable, setSelectTable] = useState({
@@ -89636,36 +89822,45 @@ const EmbeddedMetricCreation = ({
89636
89822
  }, [data, isEnableGroupBy]);
89637
89823
  const {
89638
89824
  createExternalMetric,
89639
- error: saveError
89825
+ error: saveError,
89826
+ updateExternalMetric
89640
89827
  } = useExternalMetric({
89641
89828
  query,
89642
- xAxis,
89643
- backGroundColor,
89644
- customSettings,
89645
- tableSettings,
89646
- chartType: chartType2,
89647
- yAxisList,
89648
- step,
89649
- measure,
89650
- sankeyValues,
89651
- singleValue: singleValue2,
89829
+ chartSettings: {
89830
+ xAxis,
89831
+ backGroundColor,
89832
+ customSettings,
89833
+ tableSettings,
89834
+ chartType: chartType2,
89835
+ yAxisList,
89836
+ step,
89837
+ measure,
89838
+ sankeyValues,
89839
+ singleValue: singleValue2,
89840
+ margins,
89841
+ legendSettings,
89842
+ labelSettings,
89843
+ axisSettings
89844
+ },
89652
89845
  companyIntegrationId: companyIntegration == null ? void 0 : companyIntegration.id,
89653
89846
  integrationName: companyIntegration == null ? void 0 : companyIntegration.name,
89654
- margins,
89655
- legendSettings,
89656
- labelSettings,
89657
- axisSettings,
89658
89847
  metricQuery,
89659
89848
  outputColumns: void 0,
89660
89849
  selectedColumns: void 0,
89661
89850
  clientId,
89662
89851
  isEmbedded: true,
89663
89852
  companyId,
89664
- mode,
89853
+ isLiveMode,
89665
89854
  dashboardIds: [externalDashboardId],
89855
+ userProvidedDashboardId,
89666
89856
  isEnableGroupBy,
89667
89857
  groupBy,
89668
- selectedGroupBy
89858
+ selectedGroupBy,
89859
+ metric,
89860
+ onSuccess: () => {
89861
+ setShowSaveMetricModal(false);
89862
+ setShowMetricCreateModal(false);
89863
+ }
89669
89864
  });
89670
89865
  const {
89671
89866
  mutate: previewTable2
@@ -89729,22 +89924,64 @@ const EmbeddedMetricCreation = ({
89729
89924
  updateGroupData(data, [selectedGroupBy[0]], selectedGroupBy, setGroupedData);
89730
89925
  }
89731
89926
  }, [groupedData, isEnableGroupBy, selectedGroupBy]);
89927
+ useEffect(() => {
89928
+ if (!metric)
89929
+ return;
89930
+ setYAxisList(metric.chartOptions.yAxisList);
89931
+ setXAxis(metric.chartOptions.xAxis);
89932
+ setStep(metric.chartOptions.step);
89933
+ setMeasure(metric.chartOptions.measure);
89934
+ setChartType(metric.chartOptions.chartType);
89935
+ setQuery(metric.query || "");
89936
+ setSankeyValues(metric.chartOptions.sankeyValues);
89937
+ setSingleValue(metric.chartOptions.singleValue);
89938
+ setMargins(metric.chartOptions.margins);
89939
+ setLegendSettings(metric.chartOptions.legendSettings);
89940
+ setLabelSettings(metric.chartOptions.labelSettings);
89941
+ setAxisSettings(metric.chartOptions.axisSettings ? metric.chartOptions.axisSettings : "left");
89942
+ setSelectedGroupBy(metric.selectedGroupBy || []);
89943
+ setGroupBy(metric.groupBy || {});
89944
+ setEnableGroupBy(metric.isEnableGroupBy || false);
89945
+ setBackGroundColor(metric.chartOptions.backGroundColor ? metric.chartOptions.backGroundColor : false);
89946
+ setCustomSettings(metric.chartOptions.customSettings ? metric.chartOptions.customSettings : {
89947
+ hideSplitLines: "none",
89948
+ hideAxisLines: "none",
89949
+ barWidth: 40,
89950
+ barRadius: 0,
89951
+ axisLabels: "none",
89952
+ fontSize: 14,
89953
+ subHeaderShow: false,
89954
+ displayText: "",
89955
+ subHeaderFontSize: 0,
89956
+ dateFormatter: "none",
89957
+ numberFormatter: "original"
89958
+ });
89959
+ setTableSettings(metric.chartOptions.tableSettings ? metric.chartOptions.tableSettings : {
89960
+ contentAlignment: "center",
89961
+ lineGap: "small",
89962
+ hideVerticalDivider: false,
89963
+ enableStripedRows: false,
89964
+ showRowHover: false,
89965
+ showTableTitle: false,
89966
+ showTableDesc: false,
89967
+ enableTableSearch: false,
89968
+ enableFilter: false,
89969
+ enableSorting: false
89970
+ });
89971
+ setCompanyIntegration(metric.companyIntegration);
89972
+ }, [metric]);
89973
+ useEffect(() => {
89974
+ if (!metricData2)
89975
+ return;
89976
+ setData(Array.isArray(metricData2) ? metricData2 : []);
89977
+ }, [metricData2]);
89732
89978
  return /* @__PURE__ */ jsxs(Fragment, {
89733
- children: [/* @__PURE__ */ jsx(Button, {
89734
- type: "button",
89735
- variant: variant === "floating" ? "custom" : "primary",
89736
- size: "large",
89737
- className: variant === "floating" ? styles$i.floatingCreateButton : "",
89738
- onClick: () => setShowMetricCreateModal(true),
89739
- children: variant === "floating" ? /* @__PURE__ */ jsx(mdiPlus, {
89740
- className: styles$i.floatingCreateButtonIcon
89741
- }) : "Create Metric"
89742
- }), /* @__PURE__ */ jsx(Modal, {
89979
+ children: [/* @__PURE__ */ jsx(Modal, {
89743
89980
  headerTitle: "Create Metric",
89744
89981
  isOpen: isShowMetricCreateModal,
89745
89982
  onClose: () => setShowMetricCreateModal(false),
89746
89983
  customHeader: /* @__PURE__ */ jsx(Header, {
89747
- Heading: "Create Metric",
89984
+ Heading: metric ? "Update Metric" : "Create Metric",
89748
89985
  setShowMetricCreateModal,
89749
89986
  isDisableSqlBtn: !query,
89750
89987
  isDisableSaveBtn: !(measure == null ? void 0 : measure.length) && !((_a2 = yAxisList == null ? void 0 : yAxisList.filter((item) => item)) == null ? void 0 : _a2.length) && !singleValue2,
@@ -89753,28 +89990,31 @@ const EmbeddedMetricCreation = ({
89753
89990
  }),
89754
89991
  children: /* @__PURE__ */ jsxs("div", {
89755
89992
  className: styles$i["modal-container"],
89756
- children: [/* @__PURE__ */ jsx(Dataset, {
89757
- setselectTable: setSelectTable,
89758
- selectTable,
89759
- tableList,
89760
- columnList: (selectedTableData == null ? void 0 : selectedTableData.columns) || []
89761
- }), /* @__PURE__ */ jsx(ConstructMetric, {
89762
- dateTimeColumnList,
89763
- columnList,
89764
- database: (companyIntegration == null ? void 0 : companyIntegration.name) || "",
89765
- companyId,
89766
- tableName: selectTable.value,
89767
- setData,
89768
- setError,
89769
- setQuery,
89770
- setLoading,
89771
- isEnableGroupBy,
89772
- setEnableGroupBy,
89773
- setSelectedGroupBy,
89774
- clientId,
89775
- clientColumn
89993
+ children: [!metric && /* @__PURE__ */ jsxs(Fragment, {
89994
+ children: [/* @__PURE__ */ jsx(Dataset, {
89995
+ setselectTable: setSelectTable,
89996
+ selectTable,
89997
+ tableList,
89998
+ columnList: (selectedTableData == null ? void 0 : selectedTableData.columns) || []
89999
+ }), /* @__PURE__ */ jsx(ConstructMetric, {
90000
+ dateTimeColumnList,
90001
+ columnList,
90002
+ database: (companyIntegration == null ? void 0 : companyIntegration.name) || "",
90003
+ companyId,
90004
+ tableName: selectTable.value,
90005
+ setData,
90006
+ setError,
90007
+ setQuery,
90008
+ setLoading,
90009
+ isEnableGroupBy,
90010
+ setEnableGroupBy,
90011
+ setSelectedGroupBy,
90012
+ clientId,
90013
+ clientColumn
90014
+ })]
89776
90015
  }), /* @__PURE__ */ jsx(MetricOutput, {
89777
90016
  data: isEnableGroupBy ? groupedData : data,
90017
+ isUpdateMetric: !!metric,
89778
90018
  error: error2,
89779
90019
  isLoading,
89780
90020
  labels: labels2,
@@ -89829,12 +90069,18 @@ const EmbeddedMetricCreation = ({
89829
90069
  headerTitle: "Save To Dashboard",
89830
90070
  children: /* @__PURE__ */ jsx(ExternalMetricForm, {
89831
90071
  onCancel: () => setShowSaveMetricModal(false),
89832
- onSubmit: createExternalMetric,
90072
+ onSubmit: metric ? updateExternalMetric : createExternalMetric,
89833
90073
  dashboardIds: [externalDashboardId],
89834
90074
  onDashboardChange: () => {
89835
90075
  },
89836
90076
  companyId,
89837
90077
  error: saveError,
90078
+ defaultValues: metric ? {
90079
+ name: metric.name,
90080
+ description: metric.description,
90081
+ isLive: metric.isLive,
90082
+ metricId: metric.isCreatedByClient ? metric.metricId : `update_${metric.metricId}_by_${clientId}_${Date.now()}`
90083
+ } : void 0,
89838
90084
  isEmbedded: true
89839
90085
  })
89840
90086
  })]
@@ -95093,38 +95339,38 @@ var styles$5 = {
95093
95339
  "noMetric-wrapper": "_noMetric-wrapper_1jw09_25",
95094
95340
  "alt-container": "_alt-container_1jw09_33"
95095
95341
  };
95096
- const cardContainer = "_cardContainer_1e5h2_1";
95097
- const listHeader = "_listHeader_1e5h2_9";
95098
- const metricName = "_metricName_1e5h2_17";
95099
- const metricTitle = "_metricTitle_1e5h2_25";
95100
- const metricDescription = "_metricDescription_1e5h2_33";
95101
- const popup = "_popup_1e5h2_41";
95102
- const metricFilter$1 = "_metricFilter_1e5h2_49";
95103
- const popupIcon = "_popupIcon_1e5h2_57";
95104
- const popupMenu = "_popupMenu_1e5h2_65";
95105
- const popupItem = "_popupItem_1e5h2_73";
95106
- const popupItemIcon = "_popupItemIcon_1e5h2_81";
95107
- const csvBtn = "_csvBtn_1e5h2_89";
95108
- const deleteBtn = "_deleteBtn_1e5h2_97";
95109
- const metricData = "_metricData_1e5h2_105";
95110
- const singleValueData = "_singleValueData_1e5h2_113";
95111
- const singleValue = "_singleValue_1e5h2_113";
95112
- const noData = "_noData_1e5h2_129";
95113
- const noDataContent = "_noDataContent_1e5h2_137";
95114
- const noDataText = "_noDataText_1e5h2_145";
95115
- const loading$1 = "_loading_1e5h2_153";
95116
- const features = "_features_1e5h2_161";
95117
- const fullscreen$1 = "_fullscreen_1e5h2_169";
95118
- const deleteModal = "_deleteModal_1e5h2_177";
95119
- const cancelBtn = "_cancelBtn_1e5h2_185";
95120
- const warningIcon = "_warningIcon_1e5h2_193";
95121
- const downloadCsv = "_downloadCsv_1e5h2_201";
95122
- const downloadCsvWrapper = "_downloadCsvWrapper_1e5h2_209";
95123
- const downloadCsvHeader = "_downloadCsvHeader_1e5h2_215";
95124
- const downloadCsvFooter = "_downloadCsvFooter_1e5h2_221";
95125
- const downloadCsvCancelBtn = "_downloadCsvCancelBtn_1e5h2_229";
95126
- const downloadCsvNote = "_downloadCsvNote_1e5h2_237";
95127
- const downloadCsvNoteText = "_downloadCsvNoteText_1e5h2_245";
95342
+ const cardContainer = "_cardContainer_vcex1_1";
95343
+ const listHeader = "_listHeader_vcex1_9";
95344
+ const metricName = "_metricName_vcex1_17";
95345
+ const metricTitle = "_metricTitle_vcex1_25";
95346
+ const metricDescription = "_metricDescription_vcex1_33";
95347
+ const popup = "_popup_vcex1_41";
95348
+ const metricFilter$1 = "_metricFilter_vcex1_49";
95349
+ const popupIcon = "_popupIcon_vcex1_57";
95350
+ const popupMenu = "_popupMenu_vcex1_65";
95351
+ const popupItem = "_popupItem_vcex1_73";
95352
+ const popupItemIcon = "_popupItemIcon_vcex1_81";
95353
+ const csvBtn = "_csvBtn_vcex1_89";
95354
+ const deleteBtn = "_deleteBtn_vcex1_97";
95355
+ const metricData = "_metricData_vcex1_105";
95356
+ const singleValueData = "_singleValueData_vcex1_113";
95357
+ const singleValue = "_singleValue_vcex1_113";
95358
+ const noData = "_noData_vcex1_129";
95359
+ const noDataContent = "_noDataContent_vcex1_137";
95360
+ const noDataText = "_noDataText_vcex1_145";
95361
+ const loading$1 = "_loading_vcex1_153";
95362
+ const features = "_features_vcex1_161";
95363
+ const fullscreen$1 = "_fullscreen_vcex1_169";
95364
+ const deleteModal = "_deleteModal_vcex1_177";
95365
+ const cancelBtn = "_cancelBtn_vcex1_185";
95366
+ const warningIcon = "_warningIcon_vcex1_193";
95367
+ const downloadCsv = "_downloadCsv_vcex1_201";
95368
+ const downloadCsvWrapper = "_downloadCsvWrapper_vcex1_209";
95369
+ const downloadCsvHeader = "_downloadCsvHeader_vcex1_215";
95370
+ const downloadCsvFooter = "_downloadCsvFooter_vcex1_221";
95371
+ const downloadCsvCancelBtn = "_downloadCsvCancelBtn_vcex1_229";
95372
+ const downloadCsvNote = "_downloadCsvNote_vcex1_237";
95373
+ const downloadCsvNoteText = "_downloadCsvNoteText_vcex1_245";
95128
95374
  var styles$4 = {
95129
95375
  cardContainer,
95130
95376
  listHeader,
@@ -95170,6 +95416,16 @@ const materialSymbolsArchiveOutline = (props) => /* @__PURE__ */ jsx("svg", {
95170
95416
  d: "M5 21q-.825 0-1.413-.587Q3 19.825 3 19V6.5q0-.375.125-.675q.125-.3.325-.575l1.4-1.7q.2-.275.5-.413Q5.65 3 6 3h12q.35 0 .65.137q.3.138.5.413l1.4 1.7q.2.275.325.575q.125.3.125.675V19q0 .825-.587 1.413Q19.825 21 19 21Zm.4-15h13.2l-.85-1H6.25ZM5 8v11h14V8Zm7 10l4-4l-1.4-1.4l-1.6 1.6V10h-2v4.2l-1.6-1.6L8 14Zm-7 1h14H5Z"
95171
95417
  })
95172
95418
  });
95419
+ const materialSymbolsEditSquareOutline = (props) => /* @__PURE__ */ jsx("svg", {
95420
+ viewBox: "0 0 24 24",
95421
+ width: "1.2em",
95422
+ height: "1.2em",
95423
+ ...props,
95424
+ children: /* @__PURE__ */ jsx("path", {
95425
+ fill: "currentColor",
95426
+ d: "M5 23.7q-.825 0-1.413-.588Q3 22.525 3 21.7v-14q0-.825.587-1.413Q4.175 5.7 5 5.7h8.925l-2 2H5v14h14v-6.95l2-2v8.95q0 .825-.587 1.412q-.588.588-1.413.588Zm7-9Zm4.175-8.425l1.425 1.4l-6.6 6.6V15.7h1.4l6.625-6.625l1.425 1.4l-7.2 7.225H9v-4.25Zm4.275 4.2l-4.275-4.2l2.5-2.5q.6-.6 1.438-.6q.837 0 1.412.6l1.4 1.425q.575.575.575 1.4T22.925 8Z"
95427
+ })
95428
+ });
95173
95429
  const handleSaveChartImage = (chartRef) => {
95174
95430
  var _a2;
95175
95431
  const chartInstance = (_a2 = chartRef.current) == null ? void 0 : _a2.getEchartsInstance();
@@ -95214,8 +95470,8 @@ const ChartImageDownloadButton = ({
95214
95470
  }), text2]
95215
95471
  });
95216
95472
  };
95217
- const metricFilter = "_metricFilter_1xge8_1";
95218
- const customContainer = "_customContainer_1xge8_7";
95473
+ const metricFilter = "_metricFilter_k2gef_1";
95474
+ const customContainer = "_customContainer_k2gef_4";
95219
95475
  var styles$3 = {
95220
95476
  metricFilter,
95221
95477
  customContainer
@@ -95284,24 +95540,24 @@ const MetricFilterDropDown = ({
95284
95540
  }) : void 0
95285
95541
  });
95286
95542
  };
95287
- const container$1 = "_container_1hc1e_1";
95288
- const popover = "_popover_1hc1e_9";
95289
- const button = "_button_1hc1e_17";
95290
- const buttonOpen = "_buttonOpen_1hc1e_25";
95291
- const menu = "_menu_1hc1e_33";
95292
- const enter = "_enter_1hc1e_41";
95293
- const enterFrom = "_enterFrom_1hc1e_49";
95294
- const enterTo = "_enterTo_1hc1e_57";
95295
- const leave = "_leave_1hc1e_65";
95296
- const leaveFrom = "_leaveFrom_1hc1e_73";
95297
- const leaveTo = "_leaveTo_1hc1e_81";
95298
- const center = "_center_1hc1e_89";
95299
- const top = "_top_1hc1e_97";
95300
- const bottom = "_bottom_1hc1e_105";
95301
- const left = "_left_1hc1e_113";
95302
- const right = "_right_1hc1e_121";
95303
- const chartOptionBtn = "_chartOptionBtn_1hc1e_225";
95304
- const chartpopup = "_chartpopup_1hc1e_233";
95543
+ const container$1 = "_container_1h8m9_1";
95544
+ const popover = "_popover_1h8m9_5";
95545
+ const button = "_button_1h8m9_9";
95546
+ const buttonOpen = "_buttonOpen_1h8m9_13";
95547
+ const menu = "_menu_1h8m9_17";
95548
+ const enter = "_enter_1h8m9_21";
95549
+ const enterFrom = "_enterFrom_1h8m9_25";
95550
+ const enterTo = "_enterTo_1h8m9_29";
95551
+ const leave = "_leave_1h8m9_33";
95552
+ const leaveFrom = "_leaveFrom_1h8m9_37";
95553
+ const leaveTo = "_leaveTo_1h8m9_41";
95554
+ const center = "_center_1h8m9_45";
95555
+ const top = "_top_1h8m9_49";
95556
+ const bottom = "_bottom_1h8m9_53";
95557
+ const left = "_left_1h8m9_57";
95558
+ const right = "_right_1h8m9_61";
95559
+ const chartOptionBtn = "_chartOptionBtn_1h8m9_113";
95560
+ const chartpopup = "_chartpopup_1h8m9_117";
95305
95561
  var styles$2 = {
95306
95562
  container: container$1,
95307
95563
  popover,
@@ -95319,23 +95575,23 @@ var styles$2 = {
95319
95575
  bottom,
95320
95576
  left,
95321
95577
  right,
95322
- "left-top-end": "_left-top-end_1hc1e_129",
95323
- "right-top-end": "_right-top-end_1hc1e_137",
95324
- "left-bottom-end": "_left-bottom-end_1hc1e_145",
95325
- "right-bottom-end": "_right-bottom-end_1hc1e_153",
95326
- "top-left": "_top-left_1hc1e_161",
95327
- "top-right": "_top-right_1hc1e_169",
95328
- "bottom-left": "_bottom-left_1hc1e_177",
95329
- "bottom-right": "_bottom-right_1hc1e_185",
95330
- "left-top": "_left-top_1hc1e_129",
95331
- "left-bottom": "_left-bottom_1hc1e_145",
95332
- "right-top": "_right-top_1hc1e_137",
95333
- "right-bottom": "_right-bottom_1hc1e_153",
95578
+ "left-top-end": "_left-top-end_1h8m9_65",
95579
+ "right-top-end": "_right-top-end_1h8m9_69",
95580
+ "left-bottom-end": "_left-bottom-end_1h8m9_73",
95581
+ "right-bottom-end": "_right-bottom-end_1h8m9_77",
95582
+ "top-left": "_top-left_1h8m9_81",
95583
+ "top-right": "_top-right_1h8m9_85",
95584
+ "bottom-left": "_bottom-left_1h8m9_89",
95585
+ "bottom-right": "_bottom-right_1h8m9_93",
95586
+ "left-top": "_left-top_1h8m9_65",
95587
+ "left-bottom": "_left-bottom_1h8m9_73",
95588
+ "right-top": "_right-top_1h8m9_69",
95589
+ "right-bottom": "_right-bottom_1h8m9_77",
95334
95590
  chartOptionBtn,
95335
95591
  chartpopup
95336
95592
  };
95337
- const fullscreen = "_fullscreen_19jec_1";
95338
- const loading = "_loading_19jec_9";
95593
+ const fullscreen = "_fullscreen_1gpy3_1";
95594
+ const loading = "_loading_1gpy3_5";
95339
95595
  var styles$1 = {
95340
95596
  fullscreen,
95341
95597
  loading
@@ -95680,7 +95936,8 @@ const MetricCard = ({
95680
95936
  param,
95681
95937
  companyTenancyType,
95682
95938
  renderHeaderName,
95683
- onArchive
95939
+ onArchive,
95940
+ onEdit
95684
95941
  }) => {
95685
95942
  var _a2;
95686
95943
  const chartRef = useRef(null);
@@ -96017,7 +96274,7 @@ const MetricCard = ({
96017
96274
  children: [/* @__PURE__ */ jsxs(Button, {
96018
96275
  type: "button",
96019
96276
  variant: "custom",
96020
- className: styles$4.popupItem,
96277
+ className: `${styles$4.popupItem} ${styles$4.csvBtn}`,
96021
96278
  onClick: () => onMaximize({
96022
96279
  labels: labels2,
96023
96280
  data: {
@@ -96076,6 +96333,14 @@ const MetricCard = ({
96076
96333
  className: styles$4.popupItemIcon
96077
96334
  }), "Download Raw CSV"]
96078
96335
  })]
96336
+ }), onEdit && /* @__PURE__ */ jsxs(Button, {
96337
+ variant: "custom",
96338
+ type: "button",
96339
+ className: `${styles$4.popupItem} ${styles$4.csvBtn}`,
96340
+ onClick: () => onEdit(metricItem, dataDb),
96341
+ children: [/* @__PURE__ */ jsx(materialSymbolsEditSquareOutline, {
96342
+ className: styles$4.popupItemIcon
96343
+ }), "Edit Metric"]
96079
96344
  }), onArchive && /* @__PURE__ */ jsxs(Button, {
96080
96345
  variant: "custom",
96081
96346
  type: "button",
@@ -96230,7 +96495,8 @@ const SingleValueCard = ({
96230
96495
  param,
96231
96496
  companyTenancyType,
96232
96497
  renderHeaderName,
96233
- onArchive
96498
+ onArchive,
96499
+ onEdit
96234
96500
  }) => {
96235
96501
  var _a2;
96236
96502
  const filterValues2 = {};
@@ -96432,7 +96698,7 @@ const SingleValueCard = ({
96432
96698
  })]
96433
96699
  }) : null
96434
96700
  })
96435
- })), onArchive && /* @__PURE__ */ jsx(PopoverMenu, {
96701
+ })), (onEdit || onArchive) && /* @__PURE__ */ jsxs(PopoverMenu, {
96436
96702
  buttonClass: styles$4.popup,
96437
96703
  button: /* @__PURE__ */ jsx(Icons, {
96438
96704
  name: "more-icon",
@@ -96440,7 +96706,15 @@ const SingleValueCard = ({
96440
96706
  }),
96441
96707
  menuClass: styles$4.popupMenu,
96442
96708
  position: "bottom-right",
96443
- children: /* @__PURE__ */ jsxs(Button, {
96709
+ children: [onEdit && /* @__PURE__ */ jsxs(Button, {
96710
+ variant: "custom",
96711
+ type: "button",
96712
+ className: `${styles$4.popupItem} ${styles$4.csvBtn}`,
96713
+ onClick: () => onEdit(metricItem, dataDb),
96714
+ children: [/* @__PURE__ */ jsx(materialSymbolsEditSquareOutline, {
96715
+ className: styles$4.popupItemIcon
96716
+ }), "Edit Metric"]
96717
+ }), onArchive && /* @__PURE__ */ jsxs(Button, {
96444
96718
  variant: "custom",
96445
96719
  type: "button",
96446
96720
  className: `${styles$4.popupItem} ${styles$4.csvBtn} ${styles$4.deleteBtn}`,
@@ -96448,7 +96722,7 @@ const SingleValueCard = ({
96448
96722
  children: [/* @__PURE__ */ jsx(materialSymbolsArchiveOutline, {
96449
96723
  className: styles$4.popupItemIcon
96450
96724
  }), "Archive Metric"]
96451
- })
96725
+ })]
96452
96726
  })]
96453
96727
  })]
96454
96728
  }), chartType2 && /* @__PURE__ */ jsx("div", {
@@ -96533,7 +96807,8 @@ const ArchiveMetricModal = ({
96533
96807
  if (!res.insert_clientDeletedMetrics_one)
96534
96808
  return;
96535
96809
  queryClient2.setQueryData(["EmbeddedDashboardMetrics", {
96536
- externalDashboardId: dashboardId
96810
+ externalDashboardId: dashboardId,
96811
+ clientId
96537
96812
  }], (prev) => {
96538
96813
  var _a2;
96539
96814
  const externalDashboardMetrics = (_a2 = prev == null ? void 0 : prev.externalDashboardMetrics) == null ? void 0 : _a2.filter((exDm) => exDm.externalMetricId !== metricId);
@@ -96592,13 +96867,18 @@ const ExternalMetricList = ({
96592
96867
  params,
96593
96868
  companyTenancyType = "TABLE",
96594
96869
  externalDashboardId,
96595
- externalDashboardPk
96870
+ externalDashboardPk,
96871
+ companyId,
96872
+ workspaceId
96596
96873
  }) => {
96597
96874
  const [isFullScreen, setFullScreen] = useState(false);
96598
96875
  const [archiveModal, setArchiveModal] = useState({
96599
96876
  id: "",
96600
96877
  show: false
96601
96878
  });
96879
+ const [editModal, setEditModal] = useState({
96880
+ show: false
96881
+ });
96602
96882
  const [fullScreenChart, setFullScreenChart] = useState();
96603
96883
  const {
96604
96884
  handleLayoutChange
@@ -96664,7 +96944,12 @@ const ExternalMetricList = ({
96664
96944
  onArchive: isAllowedToDeleteMetrics ? (id2) => setArchiveModal({
96665
96945
  id: id2,
96666
96946
  show: true
96667
- }) : void 0
96947
+ }) : void 0,
96948
+ onEdit: (metric, metricData2) => setEditModal({
96949
+ show: true,
96950
+ metric,
96951
+ metricData: metricData2
96952
+ })
96668
96953
  }) : /* @__PURE__ */ jsx(MetricCard, {
96669
96954
  metricItem,
96670
96955
  onMaximize: (chart) => {
@@ -96679,7 +96964,12 @@ const ExternalMetricList = ({
96679
96964
  onArchive: isAllowedToDeleteMetrics ? (id2) => setArchiveModal({
96680
96965
  id: id2,
96681
96966
  show: true
96682
- }) : void 0
96967
+ }) : void 0,
96968
+ onEdit: (metric, metricData2) => setEditModal({
96969
+ show: true,
96970
+ metric,
96971
+ metricData: metricData2
96972
+ })
96683
96973
  })
96684
96974
  }, metricItem.id))
96685
96975
  })
@@ -96700,7 +96990,23 @@ const ExternalMetricList = ({
96700
96990
  show: false
96701
96991
  }),
96702
96992
  dashboardId: externalDashboardId
96703
- }) : null]
96993
+ }) : null, /* @__PURE__ */ jsx(EmbeddedMetricCreation, {
96994
+ clientId: client,
96995
+ externalDashboardId: externalDashboardPk,
96996
+ userProvidedDashboardId: externalDashboardId,
96997
+ isLiveMode,
96998
+ companyId,
96999
+ metric: editModal.metric,
97000
+ metricData: editModal.metricData,
97001
+ isShowMetricCreateModal: editModal.show,
97002
+ setShowMetricCreateModal: (show) => setEditModal({
97003
+ metric: void 0,
97004
+ metricData: void 0,
97005
+ show: Boolean(show)
97006
+ }),
97007
+ chartColors,
97008
+ workspaceId
97009
+ })]
96704
97010
  }) : /* @__PURE__ */ jsx(Fragment, {
96705
97011
  children: !isMetricListLoading ? /* @__PURE__ */ jsx("div", {
96706
97012
  className: styles$5["noMetric-container"],
@@ -96860,17 +97166,28 @@ const icOutlineFilterAltOff = (props) => /* @__PURE__ */ jsx("svg", {
96860
97166
  d: "m16.95 6l-3.57 4.55l1.43 1.43c1.03-1.31 4.98-6.37 4.98-6.37A.998.998 0 0 0 19 4H6.83l2 2h8.12zM2.81 2.81L1.39 4.22L10 13v6c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2.17l5.78 5.78l1.41-1.41L2.81 2.81z"
96861
97167
  })
96862
97168
  });
97169
+ const mdiPlus = (props) => /* @__PURE__ */ jsx("svg", {
97170
+ viewBox: "0 0 24 24",
97171
+ width: "1.2em",
97172
+ height: "1.2em",
97173
+ ...props,
97174
+ children: /* @__PURE__ */ jsx("path", {
97175
+ fill: "currentColor",
97176
+ d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2Z"
97177
+ })
97178
+ });
96863
97179
  const EmbeddedDashboard = React__default.memo(({
96864
97180
  token,
96865
97181
  options: options2,
96866
97182
  theme: theme2
96867
97183
  }) => {
96868
- var _a2, _b2, _c2;
97184
+ var _a2, _b2, _c2, _d;
96869
97185
  const {
96870
97186
  data,
96871
97187
  isLoading
96872
97188
  } = useEmbeddedDashboard(token);
96873
97189
  const [isShowFilters, setShowFilters] = useState(false);
97190
+ const [isShowMetricCreateModal, setShowMetricCreateModal] = useState(false);
96874
97191
  const [globalFilters, setGlobalFilters] = useState({
96875
97192
  tableName: "",
96876
97193
  filters: []
@@ -96883,11 +97200,11 @@ const EmbeddedDashboard = React__default.memo(({
96883
97200
  enabled: !!data.companyId
96884
97201
  });
96885
97202
  const [adminTheme, adminThemeChartColors] = useMemo(() => {
96886
- var _a3, _b3, _c3, _d;
96887
- const colors2 = (_d = (_c3 = (_b3 = (_a3 = adminThemeData == null ? void 0 : adminThemeData.themes[0]) == null ? void 0 : _a3.chart) == null ? void 0 : _b3.palettes) == null ? void 0 : _c3.find((palette) => {
97203
+ var _a3, _b3, _c3, _d2;
97204
+ const colors2 = (_d2 = (_c3 = (_b3 = (_a3 = adminThemeData == null ? void 0 : adminThemeData.themes[0]) == null ? void 0 : _a3.chart) == null ? void 0 : _b3.palettes) == null ? void 0 : _c3.find((palette) => {
96888
97205
  var _a4, _b4;
96889
97206
  return palette.name === ((_b4 = (_a4 = adminThemeData.themes[0]) == null ? void 0 : _a4.chart) == null ? void 0 : _b4.selected);
96890
- })) == null ? void 0 : _d.colors;
97207
+ })) == null ? void 0 : _d2.colors;
96891
97208
  return [adminThemeData == null ? void 0 : adminThemeData.themes[0], colors2];
96892
97209
  }, [adminThemeData == null ? void 0 : adminThemeData.themes[0]]);
96893
97210
  useApplyAdminTheme(adminTheme);
@@ -96916,14 +97233,27 @@ const EmbeddedDashboard = React__default.memo(({
96916
97233
  name: "filter-icon",
96917
97234
  className: styles$F.floatingFilterButtonIcon
96918
97235
  })
96919
- }) : null, !(options2 == null ? void 0 : options2.disableMetricCreation) && data.isAllowedToCreateMetrics && /* @__PURE__ */ jsx(EmbeddedMetricCreation, {
96920
- clientId: data.clientId,
96921
- companyId: data.companyId,
96922
- mode: data.mode,
96923
- externalDashboardId: data.externalDashboard.id,
96924
- variant: options2 == null ? void 0 : options2.headerVariant,
96925
- chartColors: adminThemeChartColors != null ? adminThemeChartColors : options2 == null ? void 0 : options2.chartColors,
96926
- workspaceId: (_b2 = data.workspace) == null ? void 0 : _b2.id
97236
+ }) : null, !(options2 == null ? void 0 : options2.disableMetricCreation) && data.isAllowedToCreateMetrics && /* @__PURE__ */ jsxs(Fragment, {
97237
+ children: [/* @__PURE__ */ jsx(Button, {
97238
+ type: "button",
97239
+ variant: (options2 == null ? void 0 : options2.headerVariant) === "floating" ? "custom" : "primary",
97240
+ size: "large",
97241
+ className: (options2 == null ? void 0 : options2.headerVariant) === "floating" ? styles$F.floatingCreateButton : "",
97242
+ onClick: () => setShowMetricCreateModal(true),
97243
+ children: (options2 == null ? void 0 : options2.headerVariant) === "floating" ? /* @__PURE__ */ jsx(mdiPlus, {
97244
+ className: styles$F.floatingCreateButtonIcon
97245
+ }) : "Create Metric"
97246
+ }), /* @__PURE__ */ jsx(EmbeddedMetricCreation, {
97247
+ clientId: data.clientId,
97248
+ companyId: data.companyId,
97249
+ isLiveMode: data.isLiveMode,
97250
+ externalDashboardId: data.externalDashboard.id,
97251
+ chartColors: adminThemeChartColors != null ? adminThemeChartColors : options2 == null ? void 0 : options2.chartColors,
97252
+ isShowMetricCreateModal,
97253
+ setShowMetricCreateModal,
97254
+ workspaceId: (_b2 = data.workspace) == null ? void 0 : _b2.id,
97255
+ userProvidedDashboardId: data.externalDashboardId
97256
+ })]
96927
97257
  })]
96928
97258
  })]
96929
97259
  }), /* @__PURE__ */ jsxs("div", {
@@ -96934,18 +97264,20 @@ const EmbeddedDashboard = React__default.memo(({
96934
97264
  onApply: (values) => setGlobalFilters(values)
96935
97265
  }) : null, /* @__PURE__ */ jsx(ExternalMetricList, {
96936
97266
  client: data.clientId,
96937
- isLiveMode: data.mode,
97267
+ isLiveMode: data.isLiveMode,
96938
97268
  externalDashboardId: data.externalDashboardId,
96939
97269
  externalDashboardPk: data.externalDashboard.id,
96940
97270
  isAllowedToDeleteMetrics: data.isAllowedToDeleteMetrics,
96941
97271
  externalDashboardMetrics: data.externalDashboardMetrics,
97272
+ companyId: data.companyId,
96942
97273
  isMetricListLoading: isLoading,
96943
97274
  globalFilters,
96944
97275
  breakpoint: theme2 == null ? void 0 : theme2.breakpoint,
96945
97276
  layoutCols: theme2 == null ? void 0 : theme2.metricLayoutCols,
96946
97277
  chartColors: adminThemeChartColors != null ? adminThemeChartColors : options2 == null ? void 0 : options2.chartColors,
96947
97278
  params: Array.isArray(data.rlsSettings) ? data.rlsSettings : [],
96948
- companyTenancyType: data.companyTenancyType
97279
+ companyTenancyType: data.companyTenancyType,
97280
+ workspaceId: (_c2 = data.workspace) == null ? void 0 : _c2.id
96949
97281
  })]
96950
97282
  })]
96951
97283
  }), isLoading && /* @__PURE__ */ jsx("div", {
@@ -96957,7 +97289,7 @@ const EmbeddedDashboard = React__default.memo(({
96957
97289
  color: "blue"
96958
97290
  }
96959
97291
  })
96960
- }), !isLoading && !((_c2 = data.externalDashboard) == null ? void 0 : _c2.id) && /* @__PURE__ */ jsx("div", {
97292
+ }), !isLoading && !((_d = data.externalDashboard) == null ? void 0 : _d.id) && /* @__PURE__ */ jsx("div", {
96961
97293
  className: styles$F["alt-container"],
96962
97294
  children: "Invalid token or Dashboard id"
96963
97295
  })]