@databrainhq/plugin 0.8.10 → 0.8.12

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,123 @@ 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
+ resizeAttributes: metric == null ? void 0 : metric.resizeAttributes,
7468
+ externalDashboardMetrics: {
7469
+ data: dashboardIds.map((externalDashboardId) => ({
7470
+ externalDashboardId
7471
+ }))
7472
+ },
7473
+ isLive: isLiveMode || data.isLive,
7474
+ chartOptions: getChartOption(chartSettings2)
7475
+ }
7476
+ });
7477
+ else {
7478
+ const set2 = {
7479
+ chartOptions: getChartOption(chartSettings2)
7480
+ };
7481
+ if (data.description)
7482
+ set2.description = data.description;
7483
+ if (data.metricId)
7484
+ set2.metricId = data.metricId;
7485
+ if (data.name)
7486
+ set2.name = data.name;
7487
+ updateMetric({
7488
+ externalMetricId: metric == null ? void 0 : metric.id,
7489
+ set: set2
7490
+ });
7491
+ }
7492
+ },
7493
+ [chartSettings2, metric == null ? void 0 : metric.id, metric == null ? void 0 : metric.isCreatedByClient]
7494
+ );
7495
+ return {
7496
+ createExternalMetric,
7497
+ updateExternalMetric,
7498
+ error: error2,
7499
+ isLoading: isCreatingMetric || isUpdatingAdminMetric || isUpdatingMetric
7500
+ };
7323
7501
  };
7324
7502
  const useGenerateDatasetMetrics = () => {
7325
7503
  const {
@@ -86096,7 +86274,7 @@ const menuContainer$1 = "_menuContainer_1ecv1_13";
86096
86274
  const buttonText = "_buttonText_1ecv1_19";
86097
86275
  const buttonIcon = "_buttonIcon_1ecv1_25";
86098
86276
  const filterName = "_filterName_1ecv1_31";
86099
- const filterDropdown$1 = "_filterDropdown_1ecv1_37";
86277
+ const filterDropdown$2 = "_filterDropdown_1ecv1_37";
86100
86278
  var styles$n = {
86101
86279
  button: button$5,
86102
86280
  menu: menu$3,
@@ -86104,7 +86282,7 @@ var styles$n = {
86104
86282
  buttonText,
86105
86283
  buttonIcon,
86106
86284
  filterName,
86107
- filterDropdown: filterDropdown$1
86285
+ filterDropdown: filterDropdown$2
86108
86286
  };
86109
86287
  const container$a = "_container_1qflp_1";
86110
86288
  const popover$1 = "_popover_1qflp_9";
@@ -86210,8 +86388,8 @@ const FilterField = ({
86210
86388
  tableName
86211
86389
  }) => {
86212
86390
  const [operator, setOperator] = useState({
86213
- value: "",
86214
- label: ""
86391
+ value: "=",
86392
+ label: "Equal to (=)"
86215
86393
  });
86216
86394
  const [option2, setOption] = useState({
86217
86395
  value: "",
@@ -86316,20 +86494,21 @@ const FilterField = ({
86316
86494
  })
86317
86495
  });
86318
86496
  };
86319
- const container$9 = "_container_9vrf0_1";
86320
- const form$1 = "_form_9vrf0_7";
86321
- const filterHeader = "_filterHeader_9vrf0_13";
86322
- const titleContent = "_titleContent_9vrf0_19";
86323
- const title = "_title_9vrf0_19";
86324
- const buttons = "_buttons_9vrf0_31";
86325
- const apply = "_apply_9vrf0_37";
86326
- const applyIcon = "_applyIcon_9vrf0_43";
86327
- const reset = "_reset_9vrf0_49";
86328
- const filterFields = "_filterFields_9vrf0_55";
86329
- const filters = "_filters_9vrf0_61";
86330
- const filterItem = "_filterItem_9vrf0_67";
86331
- const filterItemOperator = "_filterItemOperator_9vrf0_73";
86332
- const remove = "_remove_9vrf0_79";
86497
+ const container$9 = "_container_1cs1m_1";
86498
+ const form$1 = "_form_1cs1m_7";
86499
+ const filterHeader = "_filterHeader_1cs1m_13";
86500
+ const titleContent = "_titleContent_1cs1m_19";
86501
+ const title = "_title_1cs1m_19";
86502
+ const buttons = "_buttons_1cs1m_31";
86503
+ const apply = "_apply_1cs1m_37";
86504
+ const applyIcon = "_applyIcon_1cs1m_43";
86505
+ const reset = "_reset_1cs1m_49";
86506
+ const filterFields = "_filterFields_1cs1m_55";
86507
+ const filterDropdown$1 = "_filterDropdown_1cs1m_61";
86508
+ const filters = "_filters_1cs1m_67";
86509
+ const filterItem = "_filterItem_1cs1m_73";
86510
+ const filterItemOperator = "_filterItemOperator_1cs1m_79";
86511
+ const remove = "_remove_1cs1m_85";
86333
86512
  var styles$l = {
86334
86513
  container: container$9,
86335
86514
  form: form$1,
@@ -86341,6 +86520,7 @@ var styles$l = {
86341
86520
  applyIcon,
86342
86521
  reset,
86343
86522
  filterFields,
86523
+ filterDropdown: filterDropdown$1,
86344
86524
  filters,
86345
86525
  filterItem,
86346
86526
  filterItemOperator,
@@ -86401,6 +86581,14 @@ const GlobalFilters = ({
86401
86581
  filters: filterColumns
86402
86582
  });
86403
86583
  };
86584
+ const getSelectedOption = useCallback((col) => {
86585
+ var _a2;
86586
+ const colValue = ((_a2 = appliedfilters.find((filter2) => filter2.column === col)) == null ? void 0 : _a2.value) || "";
86587
+ return {
86588
+ label: colValue,
86589
+ value: colValue
86590
+ };
86591
+ }, [appliedfilters]);
86404
86592
  return /* @__PURE__ */ jsx(Fragment, {
86405
86593
  children: /* @__PURE__ */ jsxs("div", {
86406
86594
  className: styles$l.container,
@@ -86440,20 +86628,33 @@ const GlobalFilters = ({
86440
86628
  })]
86441
86629
  }), /* @__PURE__ */ jsx("div", {
86442
86630
  className: styles$l.filterFields,
86443
- children: filters2[0].columns.map((col) => /* @__PURE__ */ jsx(FilterField, {
86444
- tableName: filters2[0].tableName,
86445
- filter: col,
86446
- isResetted: !appliedfilters.find((a2) => a2.column === col.name),
86447
- onChange: (field2) => setAppliedFilters((prev) => {
86448
- const index2 = prev.findIndex((f2) => f2.column === field2.column);
86449
- if (index2 === -1)
86450
- return [...prev, field2];
86451
- const updated = [...prev];
86452
- updated[index2] = field2;
86453
- return updated;
86454
- }),
86455
- companyId
86456
- }, col.name))
86631
+ children: filters2[0].columns.map((col) => /* @__PURE__ */ jsx("div", {
86632
+ className: styles$l.filterDropdown,
86633
+ children: /* @__PURE__ */ jsx(FilterDropDown, {
86634
+ filter: {
86635
+ tableName: filters2[0].tableName,
86636
+ columnName: col.name
86637
+ },
86638
+ companyId,
86639
+ selectedOption: getSelectedOption(col.name),
86640
+ autoSelected: false,
86641
+ onChange: (option2) => setAppliedFilters((prev) => {
86642
+ const field2 = {
86643
+ column: col.name,
86644
+ operator: "=",
86645
+ value: option2.value
86646
+ };
86647
+ const index2 = prev.findIndex((f2) => f2.column === col.name);
86648
+ if (index2 === -1)
86649
+ return [...prev, field2];
86650
+ const updated = [...prev];
86651
+ updated[index2] = field2;
86652
+ return updated;
86653
+ }),
86654
+ labelDesign: "client",
86655
+ isSearchEnabled: true
86656
+ })
86657
+ }))
86457
86658
  })]
86458
86659
  }), appliedfilters.length ? /* @__PURE__ */ jsx("ul", {
86459
86660
  className: styles$l.filters,
@@ -86515,12 +86716,12 @@ const InfoTooltip = ({
86515
86716
  });
86516
86717
  };
86517
86718
  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"
86719
+ "header-container": "_header-container_t2r6v_1",
86720
+ "btn-container": "_btn-container_t2r6v_5",
86721
+ "back-btn": "_back-btn_t2r6v_9",
86722
+ "sql-btn": "_sql-btn_t2r6v_13",
86723
+ "save-btn": "_save-btn_t2r6v_17",
86724
+ "save-btn-icon": "_save-btn-icon_t2r6v_21"
86524
86725
  };
86525
86726
  const Header = ({
86526
86727
  setShowMetricCreateModal,
@@ -86572,25 +86773,21 @@ const Header = ({
86572
86773
  })]
86573
86774
  });
86574
86775
  };
86575
- const floatingCreateButton = "_floatingCreateButton_jfq7q_25";
86576
- const floatingCreateButtonIcon = "_floatingCreateButtonIcon_jfq7q_33";
86577
86776
  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
86777
+ "create-btn": "_create-btn_ihjk8_1",
86778
+ "modal-container": "_modal-container_ihjk8_5",
86779
+ "query-modal": "_query-modal_ihjk8_9"
86583
86780
  };
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";
86781
+ const container$7 = "_container_1q2ss_1";
86782
+ const header$3 = "_header_1q2ss_5";
86783
+ const wrapper$2 = "_wrapper_1q2ss_9";
86784
+ const column = "_column_1q2ss_17";
86785
+ const columnText$1 = "_columnText_1q2ss_21";
86589
86786
  var styles$h = {
86590
86787
  container: container$7,
86591
86788
  header: header$3,
86592
86789
  wrapper: wrapper$2,
86593
- "col-container": "_col-container_u2z1d_25",
86790
+ "col-container": "_col-container_1q2ss_13",
86594
86791
  column,
86595
86792
  columnText: columnText$1
86596
86793
  };
@@ -87966,10 +88163,10 @@ const ChartTab = ({
87966
88163
  })]
87967
88164
  });
87968
88165
  };
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";
88166
+ const container$5 = "_container_yjeiv_1";
88167
+ const wrapper$1 = "_wrapper_yjeiv_5";
88168
+ const text = "_text_yjeiv_9";
88169
+ const table$2 = "_table_yjeiv_12";
87973
88170
  var styles$c = {
87974
88171
  container: container$5,
87975
88172
  wrapper: wrapper$1,
@@ -88002,16 +88199,16 @@ const InputTables = ({
88002
88199
  })
88003
88200
  });
88004
88201
  };
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";
88202
+ const container$4 = "_container_38zl3_1";
88203
+ const header$1 = "_header_38zl3_5";
88204
+ const tabButton$1 = "_tabButton_38zl3_16";
88205
+ const selectedTab = "_selectedTab_38zl3_19";
88206
+ const table$1 = "_table_38zl3_22";
88010
88207
  var styles$b = {
88011
88208
  container: container$4,
88012
88209
  header: header$1,
88013
- "text-container": "_text-container_127xg_17",
88014
- "btn-container": "_btn-container_127xg_25",
88210
+ "text-container": "_text-container_38zl3_9",
88211
+ "btn-container": "_btn-container_38zl3_13",
88015
88212
  tabButton: tabButton$1,
88016
88213
  selectedTab,
88017
88214
  table: table$1
@@ -88020,7 +88217,8 @@ const TableTab = ({
88020
88217
  outpuTableData,
88021
88218
  outputError,
88022
88219
  isOutputLoading,
88023
- previewTableDataList
88220
+ previewTableDataList,
88221
+ isUpdateMetric
88024
88222
  }) => {
88025
88223
  const [selectedTab2, setSelectedTab] = useState(OUTPUT_TABLE);
88026
88224
  const buttonColor = {
@@ -88037,6 +88235,11 @@ const TableTab = ({
88037
88235
  if (selectedTab2 !== INPUT_TABLE)
88038
88236
  setSelectedTab(INPUT_TABLE);
88039
88237
  }, [previewTableDataList]);
88238
+ useEffect(() => {
88239
+ if (!isUpdateMetric)
88240
+ return;
88241
+ setSelectedTab(OUTPUT_TABLE);
88242
+ }, [isUpdateMetric]);
88040
88243
  return /* @__PURE__ */ jsxs("div", {
88041
88244
  className: styles$b.container,
88042
88245
  children: [/* @__PURE__ */ jsxs("div", {
@@ -88086,14 +88289,20 @@ const TableTab = ({
88086
88289
  })]
88087
88290
  });
88088
88291
  };
88089
- const wrapper = "_wrapper_49kql_17";
88090
- const searchCommand = "_searchCommand_49kql_23";
88091
- const tabButton = "_tabButton_49kql_29";
88092
- const tabActive = "_tabActive_49kql_35";
88292
+ const mainContainerUpdate = "_mainContainerUpdate_19iy1_4";
88293
+ const wrapper = "_wrapper_19iy1_12";
88294
+ const updateWrapper = "_updateWrapper_19iy1_15";
88295
+ const updateWrapperContent = "_updateWrapperContent_19iy1_18";
88296
+ const searchCommand = "_searchCommand_19iy1_21";
88297
+ const tabButton = "_tabButton_19iy1_24";
88298
+ const tabActive = "_tabActive_19iy1_27";
88093
88299
  var styles$a = {
88094
- "main-container": "_main-container_49kql_1",
88095
- "outputTab-header": "_outputTab-header_49kql_9",
88300
+ "main-container": "_main-container_19iy1_1",
88301
+ mainContainerUpdate,
88302
+ "outputTab-header": "_outputTab-header_19iy1_8",
88096
88303
  wrapper,
88304
+ updateWrapper,
88305
+ updateWrapperContent,
88097
88306
  searchCommand,
88098
88307
  tabButton,
88099
88308
  tabActive
@@ -88138,7 +88347,8 @@ const MetricOutput = ({
88138
88347
  backGroundColor,
88139
88348
  setBackGroundColor,
88140
88349
  moreTabs,
88141
- chartColors
88350
+ chartColors,
88351
+ isUpdateMetric = false
88142
88352
  }) => {
88143
88353
  var _a2;
88144
88354
  const [selectedTab2, setSelectedTab] = useState(TABLE_TAB);
@@ -88147,8 +88357,8 @@ const MetricOutput = ({
88147
88357
  tableName = item.name;
88148
88358
  });
88149
88359
  return /* @__PURE__ */ jsxs("div", {
88150
- className: styles$a["main-container"],
88151
- children: [/* @__PURE__ */ jsxs("div", {
88360
+ className: `${styles$a["main-container"]} ${isUpdateMetric ? styles$a.mainContainerUpdate : ""}`,
88361
+ children: [!isUpdateMetric && /* @__PURE__ */ jsxs("div", {
88152
88362
  className: styles$a["outputTab-header"],
88153
88363
  children: [/* @__PURE__ */ jsxs(Button, {
88154
88364
  type: "button",
@@ -88174,79 +88384,86 @@ const MetricOutput = ({
88174
88384
  children: tabObj.tab
88175
88385
  }, tabObj.name))]
88176
88386
  }), /* @__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
88387
+ className: `${styles$a.wrapper} ${isUpdateMetric ? styles$a.updateWrapper : ""}`,
88388
+ children: [(selectedTab2 === TABLE_TAB || isUpdateMetric) && /* @__PURE__ */ jsx("div", {
88389
+ className: isUpdateMetric ? styles$a.updateWrapperContent : "",
88390
+ children: /* @__PURE__ */ jsx(TableTab, {
88391
+ outpuTableData: data,
88392
+ isOutputLoading: isLoading,
88393
+ outputError: error2,
88394
+ previewTableDataList,
88395
+ isUpdateMetric
88396
+ })
88397
+ }), (selectedTab2 === CHART_TAB || isUpdateMetric) && /* @__PURE__ */ jsx("div", {
88398
+ className: isUpdateMetric ? styles$a.updateWrapperContent : "",
88399
+ children: /* @__PURE__ */ jsx(ChartTab, {
88400
+ labels: labels2,
88401
+ funnelData,
88402
+ chartType: chartType2,
88403
+ datasets,
88404
+ data,
88405
+ setChartType,
88406
+ setXAxis,
88407
+ setYAxisList,
88408
+ yAxisList,
88409
+ xAxis,
88410
+ setMeasure,
88411
+ setStep,
88412
+ step,
88413
+ measure,
88414
+ setSankeyValues,
88415
+ sankeyData,
88416
+ singleValue: singleValue2,
88417
+ setSingleValue,
88418
+ singleValueData: singleValueData2,
88419
+ setMargins,
88420
+ margins,
88421
+ legendSettings,
88422
+ setLegendSettings,
88423
+ labelSettings,
88424
+ setLabelSettings,
88425
+ axisSettings,
88426
+ setAxisSettings,
88427
+ customSettings,
88428
+ setCustomSettings,
88429
+ updateGroup,
88430
+ isEnableGroupBy,
88431
+ isLoading,
88432
+ backGroundColor,
88433
+ setBackGroundColor,
88434
+ tableSettings,
88435
+ setTableSettings,
88436
+ tableName,
88437
+ chartColors
88438
+ })
88222
88439
  }), (_a2 = moreTabs == null ? void 0 : moreTabs.find((tabObj) => tabObj.name === selectedTab2)) == null ? void 0 : _a2.tabContent]
88223
88440
  })]
88224
88441
  });
88225
88442
  };
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";
88443
+ const fieldValueIcon = "_fieldValueIcon_z8ldj_25";
88444
+ const fieldAddBtnIcon = "_fieldAddBtnIcon_z8ldj_33";
88445
+ const group = "_group_z8ldj_1";
88446
+ const tooltipWrapper = "_tooltipWrapper_z8ldj_45";
88447
+ const tooltip = "_tooltip_z8ldj_45";
88448
+ const dropdown = "_dropdown_z8ldj_57";
88449
+ const filterDropdown = "_filterDropdown_z8ldj_61";
88450
+ const filterValues = "_filterValues_z8ldj_65";
88451
+ const columnText = "_columnText_z8ldj_69";
88452
+ const disabled = "_disabled_z8ldj_73";
88453
+ const checkIcon = "_checkIcon_z8ldj_77";
88454
+ const generateButton = "_generateButton_z8ldj_81";
88238
88455
  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",
88456
+ "form-container": "_form-container_z8ldj_1",
88457
+ "field-container": "_field-container_z8ldj_5",
88458
+ "field-label": "_field-label_z8ldj_9",
88459
+ "field-wrapper": "_field-wrapper_z8ldj_13",
88460
+ "field-inner-container": "_field-inner-container_z8ldj_17",
88461
+ "field-value": "_field-value_z8ldj_21",
88245
88462
  fieldValueIcon,
88246
- "field-add-btn": "_field-add-btn_fl6kw_57",
88463
+ "field-add-btn": "_field-add-btn_z8ldj_29",
88247
88464
  fieldAddBtnIcon,
88248
- "field-value-container": "_field-value-container_fl6kw_73",
88249
- "field-prompt": "_field-prompt_fl6kw_81",
88465
+ "field-value-container": "_field-value-container_z8ldj_37",
88466
+ "field-prompt": "_field-prompt_z8ldj_41",
88250
88467
  group,
88251
88468
  tooltipWrapper,
88252
88469
  tooltip,
@@ -89398,10 +89615,10 @@ const MetricForm = ({
89398
89615
  })]
89399
89616
  });
89400
89617
  };
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";
89618
+ const container$2 = "_container_rofqe_1";
89619
+ const header = "_header_rofqe_5";
89620
+ const enableGroupBy = "_enableGroupBy_rofqe_8";
89621
+ const enableGroupButton = "_enableGroupButton_rofqe_11";
89405
89622
  var styles$7 = {
89406
89623
  container: container$2,
89407
89624
  header,
@@ -89450,23 +89667,17 @@ const ConstructMetric = ({
89450
89667
  })]
89451
89668
  });
89452
89669
  };
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
89670
  const EmbeddedMetricCreation = ({
89464
89671
  clientId,
89465
89672
  companyId,
89466
- mode,
89673
+ isLiveMode,
89467
89674
  externalDashboardId,
89468
- variant = "static",
89675
+ userProvidedDashboardId,
89469
89676
  chartColors,
89677
+ isShowMetricCreateModal,
89678
+ setShowMetricCreateModal,
89679
+ metric,
89680
+ metricData: metricData2,
89470
89681
  workspaceId
89471
89682
  }) => {
89472
89683
  var _a2;
@@ -89478,7 +89689,6 @@ const EmbeddedMetricCreation = ({
89478
89689
  const [isEnableGroupBy, setEnableGroupBy] = useState(false);
89479
89690
  const [selectedGroupBy, setSelectedGroupBy] = useState([]);
89480
89691
  const [groupBy, setGroupBy] = useState();
89481
- const [isShowMetricCreateModal, setShowMetricCreateModal] = useState(false);
89482
89692
  const [isShowSqlModal, setShowSqlModal] = useState(false);
89483
89693
  const [isShowSaveMetricModal, setShowSaveMetricModal] = useState(false);
89484
89694
  const [selectTable, setSelectTable] = useState({
@@ -89636,36 +89846,45 @@ const EmbeddedMetricCreation = ({
89636
89846
  }, [data, isEnableGroupBy]);
89637
89847
  const {
89638
89848
  createExternalMetric,
89639
- error: saveError
89849
+ error: saveError,
89850
+ updateExternalMetric
89640
89851
  } = useExternalMetric({
89641
89852
  query,
89642
- xAxis,
89643
- backGroundColor,
89644
- customSettings,
89645
- tableSettings,
89646
- chartType: chartType2,
89647
- yAxisList,
89648
- step,
89649
- measure,
89650
- sankeyValues,
89651
- singleValue: singleValue2,
89853
+ chartSettings: {
89854
+ xAxis,
89855
+ backGroundColor,
89856
+ customSettings,
89857
+ tableSettings,
89858
+ chartType: chartType2,
89859
+ yAxisList,
89860
+ step,
89861
+ measure,
89862
+ sankeyValues,
89863
+ singleValue: singleValue2,
89864
+ margins,
89865
+ legendSettings,
89866
+ labelSettings,
89867
+ axisSettings
89868
+ },
89652
89869
  companyIntegrationId: companyIntegration == null ? void 0 : companyIntegration.id,
89653
89870
  integrationName: companyIntegration == null ? void 0 : companyIntegration.name,
89654
- margins,
89655
- legendSettings,
89656
- labelSettings,
89657
- axisSettings,
89658
89871
  metricQuery,
89659
89872
  outputColumns: void 0,
89660
89873
  selectedColumns: void 0,
89661
89874
  clientId,
89662
89875
  isEmbedded: true,
89663
89876
  companyId,
89664
- mode,
89877
+ isLiveMode,
89665
89878
  dashboardIds: [externalDashboardId],
89879
+ userProvidedDashboardId,
89666
89880
  isEnableGroupBy,
89667
89881
  groupBy,
89668
- selectedGroupBy
89882
+ selectedGroupBy,
89883
+ metric,
89884
+ onSuccess: () => {
89885
+ setShowSaveMetricModal(false);
89886
+ setShowMetricCreateModal(false);
89887
+ }
89669
89888
  });
89670
89889
  const {
89671
89890
  mutate: previewTable2
@@ -89729,22 +89948,64 @@ const EmbeddedMetricCreation = ({
89729
89948
  updateGroupData(data, [selectedGroupBy[0]], selectedGroupBy, setGroupedData);
89730
89949
  }
89731
89950
  }, [groupedData, isEnableGroupBy, selectedGroupBy]);
89951
+ useEffect(() => {
89952
+ if (!metric)
89953
+ return;
89954
+ setYAxisList(metric.chartOptions.yAxisList);
89955
+ setXAxis(metric.chartOptions.xAxis);
89956
+ setStep(metric.chartOptions.step);
89957
+ setMeasure(metric.chartOptions.measure);
89958
+ setChartType(metric.chartOptions.chartType);
89959
+ setQuery(metric.query || "");
89960
+ setSankeyValues(metric.chartOptions.sankeyValues);
89961
+ setSingleValue(metric.chartOptions.singleValue);
89962
+ setMargins(metric.chartOptions.margins);
89963
+ setLegendSettings(metric.chartOptions.legendSettings);
89964
+ setLabelSettings(metric.chartOptions.labelSettings);
89965
+ setAxisSettings(metric.chartOptions.axisSettings ? metric.chartOptions.axisSettings : "left");
89966
+ setSelectedGroupBy(metric.selectedGroupBy || []);
89967
+ setGroupBy(metric.groupBy || {});
89968
+ setEnableGroupBy(metric.isEnableGroupBy || false);
89969
+ setBackGroundColor(metric.chartOptions.backGroundColor ? metric.chartOptions.backGroundColor : false);
89970
+ setCustomSettings(metric.chartOptions.customSettings ? metric.chartOptions.customSettings : {
89971
+ hideSplitLines: "none",
89972
+ hideAxisLines: "none",
89973
+ barWidth: 40,
89974
+ barRadius: 0,
89975
+ axisLabels: "none",
89976
+ fontSize: 14,
89977
+ subHeaderShow: false,
89978
+ displayText: "",
89979
+ subHeaderFontSize: 0,
89980
+ dateFormatter: "none",
89981
+ numberFormatter: "original"
89982
+ });
89983
+ setTableSettings(metric.chartOptions.tableSettings ? metric.chartOptions.tableSettings : {
89984
+ contentAlignment: "center",
89985
+ lineGap: "small",
89986
+ hideVerticalDivider: false,
89987
+ enableStripedRows: false,
89988
+ showRowHover: false,
89989
+ showTableTitle: false,
89990
+ showTableDesc: false,
89991
+ enableTableSearch: false,
89992
+ enableFilter: false,
89993
+ enableSorting: false
89994
+ });
89995
+ setCompanyIntegration(metric.companyIntegration);
89996
+ }, [metric]);
89997
+ useEffect(() => {
89998
+ if (!metricData2)
89999
+ return;
90000
+ setData(Array.isArray(metricData2) ? metricData2 : []);
90001
+ }, [metricData2]);
89732
90002
  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, {
90003
+ children: [/* @__PURE__ */ jsx(Modal, {
89743
90004
  headerTitle: "Create Metric",
89744
90005
  isOpen: isShowMetricCreateModal,
89745
90006
  onClose: () => setShowMetricCreateModal(false),
89746
90007
  customHeader: /* @__PURE__ */ jsx(Header, {
89747
- Heading: "Create Metric",
90008
+ Heading: metric ? "Update Metric" : "Create Metric",
89748
90009
  setShowMetricCreateModal,
89749
90010
  isDisableSqlBtn: !query,
89750
90011
  isDisableSaveBtn: !(measure == null ? void 0 : measure.length) && !((_a2 = yAxisList == null ? void 0 : yAxisList.filter((item) => item)) == null ? void 0 : _a2.length) && !singleValue2,
@@ -89753,28 +90014,31 @@ const EmbeddedMetricCreation = ({
89753
90014
  }),
89754
90015
  children: /* @__PURE__ */ jsxs("div", {
89755
90016
  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
90017
+ children: [!metric && /* @__PURE__ */ jsxs(Fragment, {
90018
+ children: [/* @__PURE__ */ jsx(Dataset, {
90019
+ setselectTable: setSelectTable,
90020
+ selectTable,
90021
+ tableList,
90022
+ columnList: (selectedTableData == null ? void 0 : selectedTableData.columns) || []
90023
+ }), /* @__PURE__ */ jsx(ConstructMetric, {
90024
+ dateTimeColumnList,
90025
+ columnList,
90026
+ database: (companyIntegration == null ? void 0 : companyIntegration.name) || "",
90027
+ companyId,
90028
+ tableName: selectTable.value,
90029
+ setData,
90030
+ setError,
90031
+ setQuery,
90032
+ setLoading,
90033
+ isEnableGroupBy,
90034
+ setEnableGroupBy,
90035
+ setSelectedGroupBy,
90036
+ clientId,
90037
+ clientColumn
90038
+ })]
89776
90039
  }), /* @__PURE__ */ jsx(MetricOutput, {
89777
90040
  data: isEnableGroupBy ? groupedData : data,
90041
+ isUpdateMetric: !!metric,
89778
90042
  error: error2,
89779
90043
  isLoading,
89780
90044
  labels: labels2,
@@ -89829,12 +90093,18 @@ const EmbeddedMetricCreation = ({
89829
90093
  headerTitle: "Save To Dashboard",
89830
90094
  children: /* @__PURE__ */ jsx(ExternalMetricForm, {
89831
90095
  onCancel: () => setShowSaveMetricModal(false),
89832
- onSubmit: createExternalMetric,
90096
+ onSubmit: metric ? updateExternalMetric : createExternalMetric,
89833
90097
  dashboardIds: [externalDashboardId],
89834
90098
  onDashboardChange: () => {
89835
90099
  },
89836
90100
  companyId,
89837
90101
  error: saveError,
90102
+ defaultValues: metric ? {
90103
+ name: metric.name,
90104
+ description: metric.description,
90105
+ isLive: metric.isLive,
90106
+ metricId: metric.isCreatedByClient ? metric.metricId : `update_${metric.metricId}_by_${clientId}_${Date.now()}`
90107
+ } : void 0,
89838
90108
  isEmbedded: true
89839
90109
  })
89840
90110
  })]
@@ -95093,38 +95363,38 @@ var styles$5 = {
95093
95363
  "noMetric-wrapper": "_noMetric-wrapper_1jw09_25",
95094
95364
  "alt-container": "_alt-container_1jw09_33"
95095
95365
  };
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";
95366
+ const cardContainer = "_cardContainer_vcex1_1";
95367
+ const listHeader = "_listHeader_vcex1_9";
95368
+ const metricName = "_metricName_vcex1_17";
95369
+ const metricTitle = "_metricTitle_vcex1_25";
95370
+ const metricDescription = "_metricDescription_vcex1_33";
95371
+ const popup = "_popup_vcex1_41";
95372
+ const metricFilter$1 = "_metricFilter_vcex1_49";
95373
+ const popupIcon = "_popupIcon_vcex1_57";
95374
+ const popupMenu = "_popupMenu_vcex1_65";
95375
+ const popupItem = "_popupItem_vcex1_73";
95376
+ const popupItemIcon = "_popupItemIcon_vcex1_81";
95377
+ const csvBtn = "_csvBtn_vcex1_89";
95378
+ const deleteBtn = "_deleteBtn_vcex1_97";
95379
+ const metricData = "_metricData_vcex1_105";
95380
+ const singleValueData = "_singleValueData_vcex1_113";
95381
+ const singleValue = "_singleValue_vcex1_113";
95382
+ const noData = "_noData_vcex1_129";
95383
+ const noDataContent = "_noDataContent_vcex1_137";
95384
+ const noDataText = "_noDataText_vcex1_145";
95385
+ const loading$1 = "_loading_vcex1_153";
95386
+ const features = "_features_vcex1_161";
95387
+ const fullscreen$1 = "_fullscreen_vcex1_169";
95388
+ const deleteModal = "_deleteModal_vcex1_177";
95389
+ const cancelBtn = "_cancelBtn_vcex1_185";
95390
+ const warningIcon = "_warningIcon_vcex1_193";
95391
+ const downloadCsv = "_downloadCsv_vcex1_201";
95392
+ const downloadCsvWrapper = "_downloadCsvWrapper_vcex1_209";
95393
+ const downloadCsvHeader = "_downloadCsvHeader_vcex1_215";
95394
+ const downloadCsvFooter = "_downloadCsvFooter_vcex1_221";
95395
+ const downloadCsvCancelBtn = "_downloadCsvCancelBtn_vcex1_229";
95396
+ const downloadCsvNote = "_downloadCsvNote_vcex1_237";
95397
+ const downloadCsvNoteText = "_downloadCsvNoteText_vcex1_245";
95128
95398
  var styles$4 = {
95129
95399
  cardContainer,
95130
95400
  listHeader,
@@ -95170,6 +95440,16 @@ const materialSymbolsArchiveOutline = (props) => /* @__PURE__ */ jsx("svg", {
95170
95440
  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
95441
  })
95172
95442
  });
95443
+ const materialSymbolsEditSquareOutline = (props) => /* @__PURE__ */ jsx("svg", {
95444
+ viewBox: "0 0 24 24",
95445
+ width: "1.2em",
95446
+ height: "1.2em",
95447
+ ...props,
95448
+ children: /* @__PURE__ */ jsx("path", {
95449
+ fill: "currentColor",
95450
+ 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"
95451
+ })
95452
+ });
95173
95453
  const handleSaveChartImage = (chartRef) => {
95174
95454
  var _a2;
95175
95455
  const chartInstance = (_a2 = chartRef.current) == null ? void 0 : _a2.getEchartsInstance();
@@ -95214,8 +95494,8 @@ const ChartImageDownloadButton = ({
95214
95494
  }), text2]
95215
95495
  });
95216
95496
  };
95217
- const metricFilter = "_metricFilter_1xge8_1";
95218
- const customContainer = "_customContainer_1xge8_7";
95497
+ const metricFilter = "_metricFilter_k2gef_1";
95498
+ const customContainer = "_customContainer_k2gef_4";
95219
95499
  var styles$3 = {
95220
95500
  metricFilter,
95221
95501
  customContainer
@@ -95284,24 +95564,24 @@ const MetricFilterDropDown = ({
95284
95564
  }) : void 0
95285
95565
  });
95286
95566
  };
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";
95567
+ const container$1 = "_container_1h8m9_1";
95568
+ const popover = "_popover_1h8m9_5";
95569
+ const button = "_button_1h8m9_9";
95570
+ const buttonOpen = "_buttonOpen_1h8m9_13";
95571
+ const menu = "_menu_1h8m9_17";
95572
+ const enter = "_enter_1h8m9_21";
95573
+ const enterFrom = "_enterFrom_1h8m9_25";
95574
+ const enterTo = "_enterTo_1h8m9_29";
95575
+ const leave = "_leave_1h8m9_33";
95576
+ const leaveFrom = "_leaveFrom_1h8m9_37";
95577
+ const leaveTo = "_leaveTo_1h8m9_41";
95578
+ const center = "_center_1h8m9_45";
95579
+ const top = "_top_1h8m9_49";
95580
+ const bottom = "_bottom_1h8m9_53";
95581
+ const left = "_left_1h8m9_57";
95582
+ const right = "_right_1h8m9_61";
95583
+ const chartOptionBtn = "_chartOptionBtn_1h8m9_113";
95584
+ const chartpopup = "_chartpopup_1h8m9_117";
95305
95585
  var styles$2 = {
95306
95586
  container: container$1,
95307
95587
  popover,
@@ -95319,23 +95599,23 @@ var styles$2 = {
95319
95599
  bottom,
95320
95600
  left,
95321
95601
  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",
95602
+ "left-top-end": "_left-top-end_1h8m9_65",
95603
+ "right-top-end": "_right-top-end_1h8m9_69",
95604
+ "left-bottom-end": "_left-bottom-end_1h8m9_73",
95605
+ "right-bottom-end": "_right-bottom-end_1h8m9_77",
95606
+ "top-left": "_top-left_1h8m9_81",
95607
+ "top-right": "_top-right_1h8m9_85",
95608
+ "bottom-left": "_bottom-left_1h8m9_89",
95609
+ "bottom-right": "_bottom-right_1h8m9_93",
95610
+ "left-top": "_left-top_1h8m9_65",
95611
+ "left-bottom": "_left-bottom_1h8m9_73",
95612
+ "right-top": "_right-top_1h8m9_69",
95613
+ "right-bottom": "_right-bottom_1h8m9_77",
95334
95614
  chartOptionBtn,
95335
95615
  chartpopup
95336
95616
  };
95337
- const fullscreen = "_fullscreen_19jec_1";
95338
- const loading = "_loading_19jec_9";
95617
+ const fullscreen = "_fullscreen_1gpy3_1";
95618
+ const loading = "_loading_1gpy3_5";
95339
95619
  var styles$1 = {
95340
95620
  fullscreen,
95341
95621
  loading
@@ -95680,7 +95960,8 @@ const MetricCard = ({
95680
95960
  param,
95681
95961
  companyTenancyType,
95682
95962
  renderHeaderName,
95683
- onArchive
95963
+ onArchive,
95964
+ onEdit
95684
95965
  }) => {
95685
95966
  var _a2;
95686
95967
  const chartRef = useRef(null);
@@ -96017,7 +96298,7 @@ const MetricCard = ({
96017
96298
  children: [/* @__PURE__ */ jsxs(Button, {
96018
96299
  type: "button",
96019
96300
  variant: "custom",
96020
- className: styles$4.popupItem,
96301
+ className: `${styles$4.popupItem} ${styles$4.csvBtn}`,
96021
96302
  onClick: () => onMaximize({
96022
96303
  labels: labels2,
96023
96304
  data: {
@@ -96076,6 +96357,14 @@ const MetricCard = ({
96076
96357
  className: styles$4.popupItemIcon
96077
96358
  }), "Download Raw CSV"]
96078
96359
  })]
96360
+ }), onEdit && /* @__PURE__ */ jsxs(Button, {
96361
+ variant: "custom",
96362
+ type: "button",
96363
+ className: `${styles$4.popupItem} ${styles$4.csvBtn}`,
96364
+ onClick: () => onEdit(metricItem, dataDb),
96365
+ children: [/* @__PURE__ */ jsx(materialSymbolsEditSquareOutline, {
96366
+ className: styles$4.popupItemIcon
96367
+ }), "Edit Metric"]
96079
96368
  }), onArchive && /* @__PURE__ */ jsxs(Button, {
96080
96369
  variant: "custom",
96081
96370
  type: "button",
@@ -96230,7 +96519,8 @@ const SingleValueCard = ({
96230
96519
  param,
96231
96520
  companyTenancyType,
96232
96521
  renderHeaderName,
96233
- onArchive
96522
+ onArchive,
96523
+ onEdit
96234
96524
  }) => {
96235
96525
  var _a2;
96236
96526
  const filterValues2 = {};
@@ -96432,7 +96722,7 @@ const SingleValueCard = ({
96432
96722
  })]
96433
96723
  }) : null
96434
96724
  })
96435
- })), onArchive && /* @__PURE__ */ jsx(PopoverMenu, {
96725
+ })), (onEdit || onArchive) && /* @__PURE__ */ jsxs(PopoverMenu, {
96436
96726
  buttonClass: styles$4.popup,
96437
96727
  button: /* @__PURE__ */ jsx(Icons, {
96438
96728
  name: "more-icon",
@@ -96440,7 +96730,15 @@ const SingleValueCard = ({
96440
96730
  }),
96441
96731
  menuClass: styles$4.popupMenu,
96442
96732
  position: "bottom-right",
96443
- children: /* @__PURE__ */ jsxs(Button, {
96733
+ children: [onEdit && /* @__PURE__ */ jsxs(Button, {
96734
+ variant: "custom",
96735
+ type: "button",
96736
+ className: `${styles$4.popupItem} ${styles$4.csvBtn}`,
96737
+ onClick: () => onEdit(metricItem, dataDb),
96738
+ children: [/* @__PURE__ */ jsx(materialSymbolsEditSquareOutline, {
96739
+ className: styles$4.popupItemIcon
96740
+ }), "Edit Metric"]
96741
+ }), onArchive && /* @__PURE__ */ jsxs(Button, {
96444
96742
  variant: "custom",
96445
96743
  type: "button",
96446
96744
  className: `${styles$4.popupItem} ${styles$4.csvBtn} ${styles$4.deleteBtn}`,
@@ -96448,7 +96746,7 @@ const SingleValueCard = ({
96448
96746
  children: [/* @__PURE__ */ jsx(materialSymbolsArchiveOutline, {
96449
96747
  className: styles$4.popupItemIcon
96450
96748
  }), "Archive Metric"]
96451
- })
96749
+ })]
96452
96750
  })]
96453
96751
  })]
96454
96752
  }), chartType2 && /* @__PURE__ */ jsx("div", {
@@ -96533,7 +96831,8 @@ const ArchiveMetricModal = ({
96533
96831
  if (!res.insert_clientDeletedMetrics_one)
96534
96832
  return;
96535
96833
  queryClient2.setQueryData(["EmbeddedDashboardMetrics", {
96536
- externalDashboardId: dashboardId
96834
+ externalDashboardId: dashboardId,
96835
+ clientId
96537
96836
  }], (prev) => {
96538
96837
  var _a2;
96539
96838
  const externalDashboardMetrics = (_a2 = prev == null ? void 0 : prev.externalDashboardMetrics) == null ? void 0 : _a2.filter((exDm) => exDm.externalMetricId !== metricId);
@@ -96592,13 +96891,18 @@ const ExternalMetricList = ({
96592
96891
  params,
96593
96892
  companyTenancyType = "TABLE",
96594
96893
  externalDashboardId,
96595
- externalDashboardPk
96894
+ externalDashboardPk,
96895
+ companyId,
96896
+ workspaceId
96596
96897
  }) => {
96597
96898
  const [isFullScreen, setFullScreen] = useState(false);
96598
96899
  const [archiveModal, setArchiveModal] = useState({
96599
96900
  id: "",
96600
96901
  show: false
96601
96902
  });
96903
+ const [editModal, setEditModal] = useState({
96904
+ show: false
96905
+ });
96602
96906
  const [fullScreenChart, setFullScreenChart] = useState();
96603
96907
  const {
96604
96908
  handleLayoutChange
@@ -96664,7 +96968,12 @@ const ExternalMetricList = ({
96664
96968
  onArchive: isAllowedToDeleteMetrics ? (id2) => setArchiveModal({
96665
96969
  id: id2,
96666
96970
  show: true
96667
- }) : void 0
96971
+ }) : void 0,
96972
+ onEdit: (metric, metricData2) => setEditModal({
96973
+ show: true,
96974
+ metric,
96975
+ metricData: metricData2
96976
+ })
96668
96977
  }) : /* @__PURE__ */ jsx(MetricCard, {
96669
96978
  metricItem,
96670
96979
  onMaximize: (chart) => {
@@ -96679,7 +96988,12 @@ const ExternalMetricList = ({
96679
96988
  onArchive: isAllowedToDeleteMetrics ? (id2) => setArchiveModal({
96680
96989
  id: id2,
96681
96990
  show: true
96682
- }) : void 0
96991
+ }) : void 0,
96992
+ onEdit: (metric, metricData2) => setEditModal({
96993
+ show: true,
96994
+ metric,
96995
+ metricData: metricData2
96996
+ })
96683
96997
  })
96684
96998
  }, metricItem.id))
96685
96999
  })
@@ -96700,7 +97014,23 @@ const ExternalMetricList = ({
96700
97014
  show: false
96701
97015
  }),
96702
97016
  dashboardId: externalDashboardId
96703
- }) : null]
97017
+ }) : null, /* @__PURE__ */ jsx(EmbeddedMetricCreation, {
97018
+ clientId: client,
97019
+ externalDashboardId: externalDashboardPk,
97020
+ userProvidedDashboardId: externalDashboardId,
97021
+ isLiveMode,
97022
+ companyId,
97023
+ metric: editModal.metric,
97024
+ metricData: editModal.metricData,
97025
+ isShowMetricCreateModal: editModal.show,
97026
+ setShowMetricCreateModal: (show) => setEditModal({
97027
+ metric: void 0,
97028
+ metricData: void 0,
97029
+ show: Boolean(show)
97030
+ }),
97031
+ chartColors,
97032
+ workspaceId
97033
+ })]
96704
97034
  }) : /* @__PURE__ */ jsx(Fragment, {
96705
97035
  children: !isMetricListLoading ? /* @__PURE__ */ jsx("div", {
96706
97036
  className: styles$5["noMetric-container"],
@@ -96860,17 +97190,28 @@ const icOutlineFilterAltOff = (props) => /* @__PURE__ */ jsx("svg", {
96860
97190
  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
97191
  })
96862
97192
  });
97193
+ const mdiPlus = (props) => /* @__PURE__ */ jsx("svg", {
97194
+ viewBox: "0 0 24 24",
97195
+ width: "1.2em",
97196
+ height: "1.2em",
97197
+ ...props,
97198
+ children: /* @__PURE__ */ jsx("path", {
97199
+ fill: "currentColor",
97200
+ d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2Z"
97201
+ })
97202
+ });
96863
97203
  const EmbeddedDashboard = React__default.memo(({
96864
97204
  token,
96865
97205
  options: options2,
96866
97206
  theme: theme2
96867
97207
  }) => {
96868
- var _a2, _b2, _c2;
97208
+ var _a2, _b2, _c2, _d;
96869
97209
  const {
96870
97210
  data,
96871
97211
  isLoading
96872
97212
  } = useEmbeddedDashboard(token);
96873
97213
  const [isShowFilters, setShowFilters] = useState(false);
97214
+ const [isShowMetricCreateModal, setShowMetricCreateModal] = useState(false);
96874
97215
  const [globalFilters, setGlobalFilters] = useState({
96875
97216
  tableName: "",
96876
97217
  filters: []
@@ -96883,11 +97224,11 @@ const EmbeddedDashboard = React__default.memo(({
96883
97224
  enabled: !!data.companyId
96884
97225
  });
96885
97226
  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) => {
97227
+ var _a3, _b3, _c3, _d2;
97228
+ 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
97229
  var _a4, _b4;
96889
97230
  return palette.name === ((_b4 = (_a4 = adminThemeData.themes[0]) == null ? void 0 : _a4.chart) == null ? void 0 : _b4.selected);
96890
- })) == null ? void 0 : _d.colors;
97231
+ })) == null ? void 0 : _d2.colors;
96891
97232
  return [adminThemeData == null ? void 0 : adminThemeData.themes[0], colors2];
96892
97233
  }, [adminThemeData == null ? void 0 : adminThemeData.themes[0]]);
96893
97234
  useApplyAdminTheme(adminTheme);
@@ -96916,14 +97257,27 @@ const EmbeddedDashboard = React__default.memo(({
96916
97257
  name: "filter-icon",
96917
97258
  className: styles$F.floatingFilterButtonIcon
96918
97259
  })
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
97260
+ }) : null, !(options2 == null ? void 0 : options2.disableMetricCreation) && data.isAllowedToCreateMetrics && /* @__PURE__ */ jsxs(Fragment, {
97261
+ children: [/* @__PURE__ */ jsx(Button, {
97262
+ type: "button",
97263
+ variant: (options2 == null ? void 0 : options2.headerVariant) === "floating" ? "custom" : "primary",
97264
+ size: "large",
97265
+ className: (options2 == null ? void 0 : options2.headerVariant) === "floating" ? styles$F.floatingCreateButton : "",
97266
+ onClick: () => setShowMetricCreateModal(true),
97267
+ children: (options2 == null ? void 0 : options2.headerVariant) === "floating" ? /* @__PURE__ */ jsx(mdiPlus, {
97268
+ className: styles$F.floatingCreateButtonIcon
97269
+ }) : "Create Metric"
97270
+ }), /* @__PURE__ */ jsx(EmbeddedMetricCreation, {
97271
+ clientId: data.clientId,
97272
+ companyId: data.companyId,
97273
+ isLiveMode: data.isLiveMode,
97274
+ externalDashboardId: data.externalDashboard.id,
97275
+ chartColors: adminThemeChartColors != null ? adminThemeChartColors : options2 == null ? void 0 : options2.chartColors,
97276
+ isShowMetricCreateModal,
97277
+ setShowMetricCreateModal,
97278
+ workspaceId: (_b2 = data.workspace) == null ? void 0 : _b2.id,
97279
+ userProvidedDashboardId: data.externalDashboardId
97280
+ })]
96927
97281
  })]
96928
97282
  })]
96929
97283
  }), /* @__PURE__ */ jsxs("div", {
@@ -96934,18 +97288,20 @@ const EmbeddedDashboard = React__default.memo(({
96934
97288
  onApply: (values) => setGlobalFilters(values)
96935
97289
  }) : null, /* @__PURE__ */ jsx(ExternalMetricList, {
96936
97290
  client: data.clientId,
96937
- isLiveMode: data.mode,
97291
+ isLiveMode: data.isLiveMode,
96938
97292
  externalDashboardId: data.externalDashboardId,
96939
97293
  externalDashboardPk: data.externalDashboard.id,
96940
97294
  isAllowedToDeleteMetrics: data.isAllowedToDeleteMetrics,
96941
97295
  externalDashboardMetrics: data.externalDashboardMetrics,
97296
+ companyId: data.companyId,
96942
97297
  isMetricListLoading: isLoading,
96943
97298
  globalFilters,
96944
97299
  breakpoint: theme2 == null ? void 0 : theme2.breakpoint,
96945
97300
  layoutCols: theme2 == null ? void 0 : theme2.metricLayoutCols,
96946
97301
  chartColors: adminThemeChartColors != null ? adminThemeChartColors : options2 == null ? void 0 : options2.chartColors,
96947
97302
  params: Array.isArray(data.rlsSettings) ? data.rlsSettings : [],
96948
- companyTenancyType: data.companyTenancyType
97303
+ companyTenancyType: data.companyTenancyType,
97304
+ workspaceId: (_c2 = data.workspace) == null ? void 0 : _c2.id
96949
97305
  })]
96950
97306
  })]
96951
97307
  }), isLoading && /* @__PURE__ */ jsx("div", {
@@ -96957,7 +97313,7 @@ const EmbeddedDashboard = React__default.memo(({
96957
97313
  color: "blue"
96958
97314
  }
96959
97315
  })
96960
- }), !isLoading && !((_c2 = data.externalDashboard) == null ? void 0 : _c2.id) && /* @__PURE__ */ jsx("div", {
97316
+ }), !isLoading && !((_d = data.externalDashboard) == null ? void 0 : _d.id) && /* @__PURE__ */ jsx("div", {
96961
97317
  className: styles$F["alt-container"],
96962
97318
  children: "Invalid token or Dashboard id"
96963
97319
  })]