@retailcrm/datalens-ui 0.2.2 → 0.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@retailcrm/datalens-ui",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Datalens UI packed as library",
5
5
  "author": "RetailDriverLLC <integration@retailcrm.ru>",
6
6
  "contributors": [
@@ -9,10 +9,10 @@ import "../EntryDialogues/index.js";
9
9
  import { getEntryNameByKey } from "../../../shared/modules/entry.js";
10
10
  import { EntryDialogName } from "../EntryDialogues/EntryDialogues.js";
11
11
  import { EntryDialogResolveStatus } from "../EntryDialogues/constants.js";
12
+ import { EntryScope } from "../../../shared/types/common.js";
12
13
  import { getRouter } from "../../navigation/router.js";
13
14
  import { DL, URL_OPTIONS, URL_QUERY } from "../../constants/common.js";
14
15
  import { Feature } from "../../../shared/types/feature.js";
15
- import { EntryScope } from "../../../shared/types/common.js";
16
16
  import { MenuItemsIds } from "../../../shared/types/menu.js";
17
17
  async function renameEntry(entryDialoguesRef, entry) {
18
18
  if (entryDialoguesRef.current) {
@@ -28,6 +28,16 @@ async function renameEntry(entryDialoguesRef, entry) {
28
28
  const entryData = response.data ? response.data[0] : null;
29
29
  if (entryData) {
30
30
  setEntryKey(entryData);
31
+ if (typeof document !== "undefined") {
32
+ const { scope, key } = entryData;
33
+ if (scope === EntryScope.Dash) {
34
+ document.dispatchEvent(
35
+ new CustomEvent("datalens:dash:rename", {
36
+ detail: { id: entry.entryId, name: getEntryNameByKey({ key }) }
37
+ })
38
+ );
39
+ }
40
+ }
31
41
  } else {
32
42
  getRouter().reload();
33
43
  }
@@ -2,18 +2,20 @@ import { jsx } from "react/jsx-runtime";
2
2
  import React__default from "react";
3
3
  import { I18n } from "../../../../i18n/index.js";
4
4
  import { connect } from "react-redux";
5
+ import "../../../../shared/index.js";
5
6
  import { showToast } from "../../../store/actions/toaster.js";
6
7
  import { isEntryAlreadyExists } from "../../../utils/errors/errorByCode.js";
7
8
  import { DialogCreateWorkbookEntry } from "../DialogCreateWorkbookEntry/DialogCreateWorkbookEntry.js";
8
9
  import { EntryDialogBase } from "../EntryDialogBase/EntryDialogBase.js";
9
10
  import { EntryDialogResolveStatus } from "../constants.js";
11
+ import { getEntryNameByKey } from "../../../../shared/modules/entry.js";
10
12
  const i18n = I18n.keyset("component.dialog-create-dashboard.view");
11
13
  class DialogCreateDashboard extends React__default.Component {
12
14
  constructor() {
13
15
  super(...arguments);
14
- this.onWorkbookApply = ({ name }) => {
16
+ this.onWorkbookApply = async ({ name }) => {
15
17
  const { workbookId, data, annotation } = this.props;
16
- return this.props.sdk.charts.createDash({
18
+ const dash = await this.props.sdk.charts.createDash({
17
19
  data: {
18
20
  workbookId,
19
21
  name,
@@ -21,12 +23,27 @@ class DialogCreateDashboard extends React__default.Component {
21
23
  annotation
22
24
  }
23
25
  });
26
+ if (typeof document !== "undefined") {
27
+ document.dispatchEvent(
28
+ new CustomEvent("datalens:dash:create", {
29
+ detail: { id: dash.entryId, name: getEntryNameByKey(dash) }
30
+ })
31
+ );
32
+ }
33
+ return dash;
24
34
  };
25
35
  this.onApply = async (key) => {
26
36
  const { data, annotation } = this.props;
27
37
  const response = await this.props.sdk.charts.createDash({
28
38
  data: { key, data, annotation }
29
39
  });
40
+ if (typeof document !== "undefined") {
41
+ document.dispatchEvent(
42
+ new CustomEvent("datalens:dash:create", {
43
+ detail: { id: response.entryId, name: getEntryNameByKey(response) }
44
+ })
45
+ );
46
+ }
30
47
  return response;
31
48
  };
32
49
  this.onError = (error) => {
@@ -51,6 +51,13 @@ class DialogDeleteEntry extends React__default.Component {
51
51
  if (entry.scope === EntryScope.Connection) {
52
52
  reachMetricaGoal(CounterName.Main, GoalId.ConnectionDeleteSubmit, { type: entry.type });
53
53
  }
54
+ if (entry.scope === EntryScope.Dash && typeof document !== "undefined") {
55
+ document.dispatchEvent(
56
+ new CustomEvent("datalens:dash:delete", {
57
+ detail: { id: entry.entryId }
58
+ })
59
+ );
60
+ }
54
61
  };
55
62
  }
56
63
  render() {
@@ -35,7 +35,8 @@ const ListWithRemove = ({
35
35
  ...restListProps,
36
36
  itemsHeight: restListProps.items.length * ITEM_HEIGHT,
37
37
  renderItem: wrappedRenderItem,
38
- qa: TabMenuQA.List
38
+ qa: TabMenuQA.List,
39
+ sortable: false
39
40
  }
40
41
  ) });
41
42
  };
@@ -5,6 +5,7 @@ import { i18n } from "../../../../../i18n/index.js";
5
5
  import PropTypes from "prop-types";
6
6
  import "../../../../../shared/index.js";
7
7
  import "../../../../index.js";
8
+ import "../../../../navigation/index.js";
8
9
  import DropdownNavigation_default from "../../../../components/DropdownNavigation/DropdownNavigation.js";
9
10
  import { EntryTypeNode } from "../../modules/constants.js";
10
11
  import { getChartEditLink } from "../../modules/helpers.js";
@@ -12,6 +13,7 @@ import InputLink_default from "./InputLink/InputLink.js";
12
13
  /* empty css */
13
14
  import { EntryScope } from "../../../../../shared/types/common.js";
14
15
  import Utils from "../../../../utils/utils.js";
16
+ import { getRouter } from "../../../../navigation/router.js";
15
17
  import { NavigationInputQA } from "../../../../../shared/constants/qa/components.js";
16
18
  const b = block("navigation-input");
17
19
  class NavigationInput extends React__default.PureComponent {
@@ -63,7 +65,9 @@ class NavigationInput extends React__default.PureComponent {
63
65
  } = this.props;
64
66
  const { showInput, isValidEntry } = this.state;
65
67
  const showOpenButton = isValidEntry && entryId && !isInvalid;
68
+ const router = getRouter();
66
69
  const href = getEntryLink ? getEntryLink(entryId) : getChartEditLink(entryId);
70
+ const url = new URL(href, "https://sample.test");
67
71
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: b("row", navigationMixin) }, /* @__PURE__ */ React__default.createElement(
68
72
  DropdownNavigation_default,
69
73
  {
@@ -85,7 +89,11 @@ class NavigationInput extends React__default.PureComponent {
85
89
  className: b("button"),
86
90
  qa: NavigationInputQA.Open,
87
91
  target: "_blank",
88
- href
92
+ href: router.history.createHref({
93
+ pathname: url.pathname,
94
+ search: url.search,
95
+ hash: url.hash
96
+ })
89
97
  },
90
98
  i18n("dash.navigation-input.edit", "button_open")
91
99
  )), /* @__PURE__ */ React__default.createElement(Flex, { gap: 2, className: b("row", linkMixin) }, showInput ? /* @__PURE__ */ React__default.createElement(
@@ -28,6 +28,7 @@ import { getRouter } from "../../../../navigation/router.js";
28
28
  import { EntryUpdateMode, EntryScope } from "../../../../../shared/types/common.js";
29
29
  import { URL_QUERY } from "../../../../constants/common.js";
30
30
  import { sdk } from "../../../../libs/sdk/index.js";
31
+ import { getEntryNameByKey } from "../../../../../shared/modules/entry.js";
31
32
  import { DashTabItemType } from "../../../../../shared/types/dash.js";
32
33
  const SET_STATE = /* @__PURE__ */ Symbol("dash/SET_STATE");
33
34
  function addDashEditHistoryPoint(stacked = false) {
@@ -540,7 +541,7 @@ function copyDash({
540
541
  dashData = withUnsavedChanges ? selectDashData(state) : selectDashEntry(state).data;
541
542
  description = withUnsavedChanges ? selectDashDescription(state) : selectDashEntry(state).annotation?.description ?? "";
542
543
  }
543
- return sdk.charts.createDash({
544
+ const dash = await sdk.charts.createDash({
544
545
  data: {
545
546
  data: migrateDataSettings(dataProcess ? dataProcess(dashData) : dashData),
546
547
  mode: EntryUpdateMode.Publish,
@@ -551,6 +552,14 @@ function copyDash({
551
552
  annotation: { description }
552
553
  }
553
554
  });
555
+ if (typeof document !== "undefined") {
556
+ document.dispatchEvent(
557
+ new CustomEvent("datalens:dash:create", {
558
+ detail: { id: dash.entryId, name: getEntryNameByKey(dash) }
559
+ })
560
+ );
561
+ }
562
+ return dash;
554
563
  };
555
564
  }
556
565
  function purgeData(data) {
@@ -413,6 +413,13 @@ const deleteEntry = ({
413
413
  type: entry.type
414
414
  });
415
415
  }
416
+ if (scope === EntryScope.Dash && typeof document !== "undefined") {
417
+ document.dispatchEvent(
418
+ new CustomEvent("datalens:dash:delete", {
419
+ detail: { id: entryId }
420
+ })
421
+ );
422
+ }
416
423
  dispatch({
417
424
  type: DELETE_ENTRY_SUCCESS,
418
425
  data