@retailcrm/datalens-ui 0.2.5 → 0.2.6
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 +1 -6
- package/ui/components/DashKit/helpers.js +4 -4
- package/ui/libs/DatalensChartkit/ChartKit/helpers/apply-hc-handlers.js +23 -2
- package/ui/libs/DatalensChartkit/menu/MenuItems.js +25 -17
- package/ui/libs/DatalensChartkit/modules/data-provider/charts/ui-sandbox.js +23 -2
- package/ui/units/dash/components/DashActionPanel/DashActionPanel.d.ts +1 -0
- package/ui/units/dash/components/DashActionPanel/DashActionPanel.js +5 -4
- package/ui/units/ql/containers/QL/QLActionPanel/QLActionPanel.js +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retailcrm/datalens-ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Datalens UI packed as library",
|
|
5
5
|
"author": "RetailDriverLLC <integration@retailcrm.ru>",
|
|
6
6
|
"contributors": [
|
|
@@ -23,24 +23,19 @@
|
|
|
23
23
|
"@diplodoc/transform": "^4.60.3",
|
|
24
24
|
"@floating-ui/react": "^0.27.13",
|
|
25
25
|
"@gravity-ui/app-layout": "^2.1.0",
|
|
26
|
-
"@gravity-ui/browserslist-config": "^4.3.0",
|
|
27
26
|
"@gravity-ui/chartkit": "^7.33.1",
|
|
28
27
|
"@gravity-ui/components": "^4.11.0",
|
|
29
28
|
"@gravity-ui/dashkit": "^9.3.1",
|
|
30
29
|
"@gravity-ui/date-components": "^3.2.3",
|
|
31
30
|
"@gravity-ui/date-utils": "^2.5.6",
|
|
32
|
-
"@gravity-ui/eslint-config": "^3.2.0",
|
|
33
31
|
"@gravity-ui/expresskit": "^2.4.0",
|
|
34
32
|
"@gravity-ui/gateway": "^4.10.4",
|
|
35
33
|
"@gravity-ui/i18n": "^1.7.0",
|
|
36
34
|
"@gravity-ui/icons": "^2.13.0",
|
|
37
35
|
"@gravity-ui/navigation": "^3.8.0",
|
|
38
36
|
"@gravity-ui/nodekit": "^2.4.1",
|
|
39
|
-
"@gravity-ui/prettier-config": "^1.1.0",
|
|
40
37
|
"@gravity-ui/react-data-table": "^2.2.1",
|
|
41
38
|
"@gravity-ui/sdk": "^1.5.1",
|
|
42
|
-
"@gravity-ui/stylelint-config": "^4.0.1",
|
|
43
|
-
"@gravity-ui/tsconfig": "^1.0.0",
|
|
44
39
|
"@gravity-ui/ui-logger": "^1.1.0",
|
|
45
40
|
"@gravity-ui/uikit": "^7.18.0",
|
|
46
41
|
"@reduxjs/toolkit": "^1.8.3",
|
|
@@ -42,10 +42,10 @@ function getDashKitMenu(onRemoveItem) {
|
|
|
42
42
|
handler: (configItem, params, state) => {
|
|
43
43
|
const entryId = getEntryId(configItem, state);
|
|
44
44
|
if (entryId) {
|
|
45
|
-
getRouter().
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
);
|
|
45
|
+
getRouter().openTab({
|
|
46
|
+
pathname: `/navigate/${entryId}`,
|
|
47
|
+
search: toSearchParams(params)
|
|
48
|
+
});
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
visible: (configItem) => {
|
|
@@ -4,9 +4,31 @@ import get from "lodash/get";
|
|
|
4
4
|
import has from "lodash/has";
|
|
5
5
|
import merge from "lodash/merge";
|
|
6
6
|
import set from "lodash/set";
|
|
7
|
+
import "../../../../navigation/index.js";
|
|
7
8
|
import { clearVmProp } from "../../modules/data-provider/charts/utils.js";
|
|
8
9
|
import { handleChartLoadingForActionParams, handleSeriesClickForActionParams } from "./action-params-handlers.js";
|
|
9
10
|
import { extractHcTypeFromData, getEscapedActionParams } from "./utils.js";
|
|
11
|
+
import { getRouter } from "../../../../navigation/router.js";
|
|
12
|
+
const openGoToUrl = (rawUrl, target) => {
|
|
13
|
+
if (typeof window === "undefined") {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const windowTarget = target === "_self" ? "_self" : "_blank";
|
|
17
|
+
const sanitizedUrl = sanitizeUrl(rawUrl);
|
|
18
|
+
const parsedUrl = new URL(sanitizedUrl, window.location.origin);
|
|
19
|
+
if (parsedUrl.origin === window.location.origin) {
|
|
20
|
+
getRouter().open(
|
|
21
|
+
{
|
|
22
|
+
pathname: parsedUrl.pathname,
|
|
23
|
+
search: parsedUrl.search,
|
|
24
|
+
hash: parsedUrl.hash
|
|
25
|
+
},
|
|
26
|
+
windowTarget
|
|
27
|
+
);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
window.open(parsedUrl.toString(), windowTarget);
|
|
31
|
+
};
|
|
10
32
|
const fixPieTotals = (args) => {
|
|
11
33
|
const { data } = args;
|
|
12
34
|
const pathToSeriesEvents = "libraryConfig.plotOptions.series.events";
|
|
@@ -116,8 +138,7 @@ function handleSeriesClickForGoTo(args) {
|
|
|
116
138
|
return;
|
|
117
139
|
}
|
|
118
140
|
try {
|
|
119
|
-
|
|
120
|
-
window.open(url, target === "_self" ? "_self" : "_blank");
|
|
141
|
+
openGoToUrl(pointUrl, target);
|
|
121
142
|
} catch (e) {
|
|
122
143
|
console.error(e);
|
|
123
144
|
}
|
|
@@ -12,16 +12,24 @@ import { isEnabledFeature } from "../../../utils/isEnabledFeature.js";
|
|
|
12
12
|
import { getExportItem, isExportItemDisabled } from "../components/ChartKitBase/components/Header/components/Menu/Items/Export/Export.js";
|
|
13
13
|
import getInspectorMenuitem from "../components/ChartKitBase/components/Header/components/Menu/Items/Inspector/Inspector.js";
|
|
14
14
|
import ChartKitIcon_default from "../components/ChartKitIcon/ChartKitIcon.js";
|
|
15
|
+
import { getRouter, getLocation } from "../../../navigation/router.js";
|
|
15
16
|
import { Feature } from "../../../../shared/types/feature.js";
|
|
16
17
|
import { MenuItemsIds } from "../../../../shared/types/menu.js";
|
|
17
18
|
import { DL, URL_OPTIONS } from "../../../constants/common.js";
|
|
18
19
|
import { WidgetKind } from "../../../../shared/types/widget.js";
|
|
19
20
|
import { PREVIEW_ROUTE } from "../../../../shared/constants/entry.js";
|
|
20
|
-
import { getLocation } from "../../../navigation/router.js";
|
|
21
21
|
import { FOCUSED_WIDGET_PARAM_NAME } from "../../../../shared/constants/dash.js";
|
|
22
22
|
const getExportMenuItem = getExportItem;
|
|
23
23
|
const getInspectorMenuItem = getInspectorMenuitem;
|
|
24
24
|
const alertI18n = I18n.keyset("component.chartkit-alerts.view");
|
|
25
|
+
const openInternalUrlInNewTab = (rawUrl) => {
|
|
26
|
+
const url = new URL(rawUrl, window.location.origin);
|
|
27
|
+
getRouter().openTab({
|
|
28
|
+
pathname: url.pathname,
|
|
29
|
+
search: url.search,
|
|
30
|
+
hash: url.hash
|
|
31
|
+
});
|
|
32
|
+
};
|
|
25
33
|
const getAlertsMenuItem = ({
|
|
26
34
|
chartsDataProvider,
|
|
27
35
|
customConfig
|
|
@@ -89,7 +97,7 @@ const getNewWindowMenuItem = ({
|
|
|
89
97
|
}
|
|
90
98
|
)
|
|
91
99
|
);
|
|
92
|
-
|
|
100
|
+
openInternalUrlInNewTab(link.toString());
|
|
93
101
|
})
|
|
94
102
|
});
|
|
95
103
|
const getEditMenuItem = ({
|
|
@@ -103,14 +111,15 @@ const getEditMenuItem = ({
|
|
|
103
111
|
icon: customConfig?.icon || /* @__PURE__ */ jsx(ChartKitIcon_default, { data: Pencil }),
|
|
104
112
|
isVisible: () => !DL.IS_MOBILE && (customConfig?.isVisible ? customConfig.isVisible() : true),
|
|
105
113
|
action: customConfig?.action || (({ loadedData = {}, propsData, chartsDataProvider: dataProvider }) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
)
|
|
114
|
+
const url = (dataProvider || chartsDataProvider)?.getGoAwayLink(
|
|
115
|
+
{ loadedData, propsData },
|
|
116
|
+
{
|
|
117
|
+
idPrefix: "/navigate/"
|
|
118
|
+
}
|
|
113
119
|
);
|
|
120
|
+
if (url) {
|
|
121
|
+
openInternalUrlInNewTab(url);
|
|
122
|
+
}
|
|
114
123
|
})
|
|
115
124
|
});
|
|
116
125
|
const getOpenAsTableMenuItem = ({
|
|
@@ -131,15 +140,14 @@ const getOpenAsTableMenuItem = ({
|
|
|
131
140
|
return Boolean(!isCriticalError && isExportAllowed && isChart && customIsVisible);
|
|
132
141
|
},
|
|
133
142
|
action: customConfig?.action || (({ loadedData, propsData, chartsDataProvider: dataProvider }) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
)
|
|
143
|
+
const url = (dataProvider || chartsDataProvider).getGoAwayLink(
|
|
144
|
+
{ loadedData, propsData },
|
|
145
|
+
{
|
|
146
|
+
extraParams: { _chart_type: "table" },
|
|
147
|
+
idPrefix: "/preview/"
|
|
148
|
+
}
|
|
142
149
|
);
|
|
150
|
+
openInternalUrlInNewTab(url);
|
|
143
151
|
})
|
|
144
152
|
});
|
|
145
153
|
const getLinkMenuItem = (customConfig) => ({
|
|
@@ -4,6 +4,7 @@ import get from "lodash/get";
|
|
|
4
4
|
import merge from "lodash/merge";
|
|
5
5
|
import set from "lodash/set";
|
|
6
6
|
import { chartStorage } from "../../../ChartKit/plugins/chart-storage.js";
|
|
7
|
+
import "../../../../../navigation/index.js";
|
|
7
8
|
import "../../../../../../shared/index.js";
|
|
8
9
|
import { wrapHtml } from "../../../../../../shared/utils/ui-sandbox.js";
|
|
9
10
|
import { getRandomCKId } from "../../../ChartKit/helpers/getRandomCKId.js";
|
|
@@ -13,11 +14,32 @@ import { generateHtml } from "../../html-generator/index.js";
|
|
|
13
14
|
import { getParseHtmlFn } from "../../html-generator/utils.js";
|
|
14
15
|
import { UiSandboxRuntime } from "./ui-sandbox-runtime.js";
|
|
15
16
|
import { clearVmProp } from "./utils.js";
|
|
17
|
+
import { getRouter } from "../../../../../navigation/router.js";
|
|
16
18
|
import { EditorType, LegacyEditorType } from "../../../../../../shared/types/widget.js";
|
|
17
19
|
import { WRAPPED_FN_KEY } from "../../../../../../shared/constants/ui-sandbox.js";
|
|
18
20
|
import { WRAPPED_HTML_KEY } from "../../../../../../shared/constants/chartkit-handlers.js";
|
|
19
21
|
const UI_SANDBOX_TOTAL_TIME_LIMIT = 3e3;
|
|
20
22
|
const UI_SANDBOX_FN_TIME_LIMIT = 100;
|
|
23
|
+
const openSandboxUrl = (rawUrl, target) => {
|
|
24
|
+
if (typeof window === "undefined") {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const windowTarget = target === "_self" ? "_self" : "_blank";
|
|
28
|
+
const href = sanitizeUrl(rawUrl);
|
|
29
|
+
const url = new URL(href, window.location.origin);
|
|
30
|
+
if (url.origin === window.location.origin) {
|
|
31
|
+
getRouter().open(
|
|
32
|
+
{
|
|
33
|
+
pathname: url.pathname,
|
|
34
|
+
search: url.search,
|
|
35
|
+
hash: url.hash
|
|
36
|
+
},
|
|
37
|
+
windowTarget
|
|
38
|
+
);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
window.open(url.toString(), windowTarget);
|
|
42
|
+
};
|
|
21
43
|
let uiSandbox;
|
|
22
44
|
let getInterruptAfterDeadlineHandler;
|
|
23
45
|
const getUISandbox = async () => {
|
|
@@ -196,8 +218,7 @@ async function getUnwrappedFunction(args) {
|
|
|
196
218
|
window: {
|
|
197
219
|
open: function(url, target) {
|
|
198
220
|
try {
|
|
199
|
-
|
|
200
|
-
window.open(href, target === "_self" ? "_self" : "_blank");
|
|
221
|
+
openSandboxUrl(url, target);
|
|
201
222
|
} catch (e) {
|
|
202
223
|
console.error(e);
|
|
203
224
|
}
|
|
@@ -55,6 +55,7 @@ declare class DashActionPanel extends React.PureComponent<ActionPanelProps, Acti
|
|
|
55
55
|
private getAdditionalEntryItems;
|
|
56
56
|
private onSelectStateClick;
|
|
57
57
|
private onValueTableOfContentsClick;
|
|
58
|
+
private isDashboardBreadcrumbEditingAccessible;
|
|
58
59
|
private filterEntryContextMenuItems;
|
|
59
60
|
private handleGoBack;
|
|
60
61
|
private handleGoForward;
|
|
@@ -151,10 +151,11 @@ const _DashActionPanel = class _DashActionPanel extends React__default.PureCompo
|
|
|
151
151
|
this.onValueTableOfContentsClick = () => {
|
|
152
152
|
this.props.toggleTableOfContent();
|
|
153
153
|
};
|
|
154
|
+
this.isDashboardBreadcrumbEditingAccessible = () => {
|
|
155
|
+
return capabilities.has(Capability.AccessibleDashboardBreadcrumbEditing);
|
|
156
|
+
};
|
|
154
157
|
this.filterEntryContextMenuItems = ({ items }) => {
|
|
155
|
-
const isDashboardBreadcrumbEditingAccessible =
|
|
156
|
-
Capability.AccessibleDashboardBreadcrumbEditing
|
|
157
|
-
);
|
|
158
|
+
const isDashboardBreadcrumbEditingAccessible = this.isDashboardBreadcrumbEditingAccessible();
|
|
158
159
|
const shouldHideDashEditingItems = this.props.entry?.scope === EntryScope.Dash && !isDashboardBreadcrumbEditingAccessible;
|
|
159
160
|
return items.filter((item) => {
|
|
160
161
|
if (HIDDEN_DASH_ACTION_PANEL_CONTEXT_MENU_ITEMS.has(item.id)) {
|
|
@@ -272,7 +273,7 @@ const _DashActionPanel = class _DashActionPanel extends React__default.PureCompo
|
|
|
272
273
|
canEdit: this.props.canEdit,
|
|
273
274
|
progress: this.props.progress,
|
|
274
275
|
isLoadingEditMode: this.props.isLoadingEditMode,
|
|
275
|
-
showEditButton:
|
|
276
|
+
showEditButton: this.isDashboardBreadcrumbEditingAccessible(),
|
|
276
277
|
onEditClick: this.props.handlerEditClick,
|
|
277
278
|
onAccessClick: this.openDialogAccess,
|
|
278
279
|
entryDialoguesRef: this.props.entryDialoguesRef,
|
|
@@ -96,12 +96,21 @@ const QLActionPanel = (props) => {
|
|
|
96
96
|
icon: /* @__PURE__ */ jsx(Icon, { data: SvgMonitoring, width: 16, height: 16 }),
|
|
97
97
|
id: "sql-to-monitoring",
|
|
98
98
|
action: () => {
|
|
99
|
-
|
|
99
|
+
const url = new URL(redirectUrl, window.location.origin);
|
|
100
|
+
if (url.origin === window.location.origin) {
|
|
101
|
+
router.openTab({
|
|
102
|
+
pathname: url.pathname,
|
|
103
|
+
search: url.search,
|
|
104
|
+
hash: url.hash
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
window.open(url.toString(), "_blank");
|
|
100
109
|
}
|
|
101
110
|
});
|
|
102
111
|
}
|
|
103
112
|
return items;
|
|
104
|
-
}, [redirectUrl]);
|
|
113
|
+
}, [redirectUrl, router]);
|
|
105
114
|
const defaultChartName = React__default.useMemo(() => {
|
|
106
115
|
if (connection === null) {
|
|
107
116
|
return "";
|