@reltio/components 1.4.1854 → 1.4.1856
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/cjs/SaveSegmentDialog/SaveSegmentDialog.d.ts +3 -1
- package/cjs/SaveSegmentDialog/SaveSegmentDialog.js +9 -6
- package/cjs/hooks/useSavedSearchesRequest/useSavedSearchesRequest.d.ts +1 -1
- package/cjs/hooks/useSavedSearchesRequest/useSavedSearchesRequest.js +7 -3
- package/esm/SaveSegmentDialog/SaveSegmentDialog.d.ts +3 -1
- package/esm/SaveSegmentDialog/SaveSegmentDialog.js +9 -6
- package/esm/hooks/useSavedSearchesRequest/useSavedSearchesRequest.d.ts +1 -1
- package/esm/hooks/useSavedSearchesRequest/useSavedSearchesRequest.js +8 -4
- package/package.json +2 -2
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { SavedSearchData } from '@reltio/mdm-sdk';
|
|
1
2
|
type Props = {
|
|
3
|
+
data?: SavedSearchData;
|
|
2
4
|
isOpen: boolean;
|
|
3
5
|
isSaving: boolean;
|
|
4
6
|
onClose: () => void;
|
|
5
7
|
onSave: (name: string, description: string, isPublic: boolean) => void;
|
|
6
8
|
};
|
|
7
|
-
export declare const SaveSegmentDialog: ({ isOpen, isSaving, onClose, onSave }: Props) => JSX.Element;
|
|
9
|
+
export declare const SaveSegmentDialog: ({ data, isOpen, isSaving, onClose, onSave }: Props) => JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -72,6 +72,7 @@ var DialogActions_1 = __importDefault(require("@mui/material/DialogActions"));
|
|
|
72
72
|
var Button_1 = __importDefault(require("@mui/material/Button"));
|
|
73
73
|
var DropDownEditor_1 = require("../DropDownEditor");
|
|
74
74
|
var TextEditor_1 = require("../TextEditor");
|
|
75
|
+
var contexts_1 = require("../contexts");
|
|
75
76
|
var styles_1 = require("./styles");
|
|
76
77
|
var SharingOption;
|
|
77
78
|
(function (SharingOption) {
|
|
@@ -83,12 +84,14 @@ var SHARING_OPTIONS = [
|
|
|
83
84
|
{ label: ui_i18n_1.default.text('All users'), value: SharingOption.Public }
|
|
84
85
|
];
|
|
85
86
|
var SaveSegmentDialog = function (_a) {
|
|
86
|
-
var isOpen = _a.isOpen, isSaving = _a.isSaving, onClose = _a.onClose, onSave = _a.onSave;
|
|
87
|
+
var data = _a.data, isOpen = _a.isOpen, isSaving = _a.isSaving, onClose = _a.onClose, onSave = _a.onSave;
|
|
87
88
|
var styles = (0, styles_1.useStyles)();
|
|
89
|
+
var username = (0, contexts_1.useMdmUsername)();
|
|
88
90
|
var _b = (0, react_1.useState)(''), name = _b[0], setName = _b[1];
|
|
89
91
|
var _c = (0, react_1.useState)(''), description = _c[0], setDescription = _c[1];
|
|
90
92
|
var _d = (0, react_1.useState)(SharingOption.Private), share = _d[0], setShare = _d[1];
|
|
91
93
|
var isValid = name.trim() !== '';
|
|
94
|
+
var shouldSaveAsNew = (data === null || data === void 0 ? void 0 : data.owner) !== username;
|
|
92
95
|
var handleChangeName = (0, react_1.useCallback)(function (event) {
|
|
93
96
|
setName(event.target.value);
|
|
94
97
|
}, []);
|
|
@@ -106,13 +109,13 @@ var SaveSegmentDialog = function (_a) {
|
|
|
106
109
|
}); }, [onSave, name, description, share]);
|
|
107
110
|
(0, react_1.useEffect)(function () {
|
|
108
111
|
if (isOpen) {
|
|
109
|
-
setName('');
|
|
110
|
-
setDescription('');
|
|
111
|
-
setShare(SharingOption.Private);
|
|
112
|
+
setName((data === null || data === void 0 ? void 0 : data.name) || '');
|
|
113
|
+
setDescription((data === null || data === void 0 ? void 0 : data.description) || '');
|
|
114
|
+
setShare((data === null || data === void 0 ? void 0 : data.isPublic) ? SharingOption.Public : SharingOption.Private);
|
|
112
115
|
}
|
|
113
|
-
}, [isOpen]);
|
|
116
|
+
}, [isOpen, data]);
|
|
114
117
|
return (react_1.default.createElement(Dialog_1.default, { onClose: onClose, open: isOpen, PaperProps: { classes: { root: styles.root } } },
|
|
115
|
-
react_1.default.createElement(DialogTitle_1.default, null, ui_i18n_1.default.text('Save segment')),
|
|
118
|
+
react_1.default.createElement(DialogTitle_1.default, null, shouldSaveAsNew ? ui_i18n_1.default.text('Save as new segment') : ui_i18n_1.default.text('Save segment')),
|
|
116
119
|
react_1.default.createElement(DialogContent_1.default, { className: styles.dialogContent },
|
|
117
120
|
react_1.default.createElement(TextEditor_1.TextEditor, { label: ui_i18n_1.default.text('Name'), required: true, variant: "filled", onInput: handleChangeName, value: name, size: "small", autoFocus: true }),
|
|
118
121
|
react_1.default.createElement(TextEditor_1.TextEditor, { label: ui_i18n_1.default.text('Description (optional)'), multiline: true, variant: "filled", value: description, onInput: handleChangeDescription, size: "small", rows: 5 }),
|
|
@@ -49,7 +49,7 @@ export declare const useSavedSearchesRequest: ({ options, defaultRowsPerPage, qu
|
|
|
49
49
|
readonly error: any;
|
|
50
50
|
readonly result?: undefined;
|
|
51
51
|
}>;
|
|
52
|
-
updateSearch: (savedSearch: SavedSearchData) => Promise<{
|
|
52
|
+
updateSearch: (savedSearch: SavedSearchData, shouldReloadTotal?: boolean) => Promise<{
|
|
53
53
|
success: boolean;
|
|
54
54
|
result: SavedSearchData;
|
|
55
55
|
error?: undefined;
|
|
@@ -186,8 +186,8 @@ var useSavedSearchesRequest = function (_a) {
|
|
|
186
186
|
}
|
|
187
187
|
});
|
|
188
188
|
}); }, [allOptions, page, updateRequestState, loadSavedSearches]);
|
|
189
|
-
var updateSearch = (0, react_1.useCallback)(function (savedSearch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
190
|
-
var result, error_3;
|
|
189
|
+
var updateSearch = (0, react_1.useCallback)(function (savedSearch, shouldReloadTotal) { return __awaiter(void 0, void 0, void 0, function () {
|
|
190
|
+
var result, newSavedSearch_1, error_3;
|
|
191
191
|
return __generator(this, function (_a) {
|
|
192
192
|
switch (_a.label) {
|
|
193
193
|
case 0:
|
|
@@ -198,7 +198,11 @@ var useSavedSearchesRequest = function (_a) {
|
|
|
198
198
|
return [4 /*yield*/, (0, mdm_sdk_1.updateSavedSearch)(savedSearch)];
|
|
199
199
|
case 2:
|
|
200
200
|
result = _a.sent();
|
|
201
|
-
|
|
201
|
+
if (shouldReloadTotal) {
|
|
202
|
+
setProfilesCountMap((0, ramda_1.assocPath)([savedSearch.uri, 'count'], undefined));
|
|
203
|
+
}
|
|
204
|
+
newSavedSearch_1 = shouldReloadTotal ? (0, ramda_1.omit)(['count'], savedSearch) : savedSearch;
|
|
205
|
+
setData(function (prevData) { return prevData.map(function (item) { return (item.uri === savedSearch.uri ? newSavedSearch_1 : item); }); });
|
|
202
206
|
updateRequestState('updating', types_1.RequestStates.LOADED);
|
|
203
207
|
return [2 /*return*/, { success: true, result: result }];
|
|
204
208
|
case 3:
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { SavedSearchData } from '@reltio/mdm-sdk';
|
|
1
2
|
type Props = {
|
|
3
|
+
data?: SavedSearchData;
|
|
2
4
|
isOpen: boolean;
|
|
3
5
|
isSaving: boolean;
|
|
4
6
|
onClose: () => void;
|
|
5
7
|
onSave: (name: string, description: string, isPublic: boolean) => void;
|
|
6
8
|
};
|
|
7
|
-
export declare const SaveSegmentDialog: ({ isOpen, isSaving, onClose, onSave }: Props) => JSX.Element;
|
|
9
|
+
export declare const SaveSegmentDialog: ({ data, isOpen, isSaving, onClose, onSave }: Props) => JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -43,6 +43,7 @@ import DialogActions from '@mui/material/DialogActions';
|
|
|
43
43
|
import Button from '@mui/material/Button';
|
|
44
44
|
import { DropDownEditor } from '../DropDownEditor';
|
|
45
45
|
import { TextEditor } from '../TextEditor';
|
|
46
|
+
import { useMdmUsername } from '../contexts';
|
|
46
47
|
import { useStyles } from './styles';
|
|
47
48
|
var SharingOption;
|
|
48
49
|
(function (SharingOption) {
|
|
@@ -54,12 +55,14 @@ var SHARING_OPTIONS = [
|
|
|
54
55
|
{ label: i18n.text('All users'), value: SharingOption.Public }
|
|
55
56
|
];
|
|
56
57
|
export var SaveSegmentDialog = function (_a) {
|
|
57
|
-
var isOpen = _a.isOpen, isSaving = _a.isSaving, onClose = _a.onClose, onSave = _a.onSave;
|
|
58
|
+
var data = _a.data, isOpen = _a.isOpen, isSaving = _a.isSaving, onClose = _a.onClose, onSave = _a.onSave;
|
|
58
59
|
var styles = useStyles();
|
|
60
|
+
var username = useMdmUsername();
|
|
59
61
|
var _b = useState(''), name = _b[0], setName = _b[1];
|
|
60
62
|
var _c = useState(''), description = _c[0], setDescription = _c[1];
|
|
61
63
|
var _d = useState(SharingOption.Private), share = _d[0], setShare = _d[1];
|
|
62
64
|
var isValid = name.trim() !== '';
|
|
65
|
+
var shouldSaveAsNew = (data === null || data === void 0 ? void 0 : data.owner) !== username;
|
|
63
66
|
var handleChangeName = useCallback(function (event) {
|
|
64
67
|
setName(event.target.value);
|
|
65
68
|
}, []);
|
|
@@ -77,13 +80,13 @@ export var SaveSegmentDialog = function (_a) {
|
|
|
77
80
|
}); }, [onSave, name, description, share]);
|
|
78
81
|
useEffect(function () {
|
|
79
82
|
if (isOpen) {
|
|
80
|
-
setName('');
|
|
81
|
-
setDescription('');
|
|
82
|
-
setShare(SharingOption.Private);
|
|
83
|
+
setName((data === null || data === void 0 ? void 0 : data.name) || '');
|
|
84
|
+
setDescription((data === null || data === void 0 ? void 0 : data.description) || '');
|
|
85
|
+
setShare((data === null || data === void 0 ? void 0 : data.isPublic) ? SharingOption.Public : SharingOption.Private);
|
|
83
86
|
}
|
|
84
|
-
}, [isOpen]);
|
|
87
|
+
}, [isOpen, data]);
|
|
85
88
|
return (React.createElement(Dialog, { onClose: onClose, open: isOpen, PaperProps: { classes: { root: styles.root } } },
|
|
86
|
-
React.createElement(DialogTitle, null, i18n.text('Save segment')),
|
|
89
|
+
React.createElement(DialogTitle, null, shouldSaveAsNew ? i18n.text('Save as new segment') : i18n.text('Save segment')),
|
|
87
90
|
React.createElement(DialogContent, { className: styles.dialogContent },
|
|
88
91
|
React.createElement(TextEditor, { label: i18n.text('Name'), required: true, variant: "filled", onInput: handleChangeName, value: name, size: "small", autoFocus: true }),
|
|
89
92
|
React.createElement(TextEditor, { label: i18n.text('Description (optional)'), multiline: true, variant: "filled", value: description, onInput: handleChangeDescription, size: "small", rows: 5 }),
|
|
@@ -49,7 +49,7 @@ export declare const useSavedSearchesRequest: ({ options, defaultRowsPerPage, qu
|
|
|
49
49
|
readonly error: any;
|
|
50
50
|
readonly result?: undefined;
|
|
51
51
|
}>;
|
|
52
|
-
updateSearch: (savedSearch: SavedSearchData) => Promise<{
|
|
52
|
+
updateSearch: (savedSearch: SavedSearchData, shouldReloadTotal?: boolean) => Promise<{
|
|
53
53
|
success: boolean;
|
|
54
54
|
result: SavedSearchData;
|
|
55
55
|
error?: undefined;
|
|
@@ -57,7 +57,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
57
57
|
return t;
|
|
58
58
|
};
|
|
59
59
|
import { createSavedSearch, deleteSavedSearch, getSavedSearches, getTotalsForQuery, isAbortError, replacePlaceholdersInQuery, updateSavedSearch } from '@reltio/mdm-sdk';
|
|
60
|
-
import { propEq, assocPath, isNil } from 'ramda';
|
|
60
|
+
import { propEq, assocPath, isNil, omit } from 'ramda';
|
|
61
61
|
import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
62
62
|
import { PageRequestsAbortingContext } from '../../contexts';
|
|
63
63
|
import { RequestStates } from '../../types';
|
|
@@ -183,8 +183,8 @@ export var useSavedSearchesRequest = function (_a) {
|
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
185
|
}); }, [allOptions, page, updateRequestState, loadSavedSearches]);
|
|
186
|
-
var updateSearch = useCallback(function (savedSearch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
187
|
-
var result, error_3;
|
|
186
|
+
var updateSearch = useCallback(function (savedSearch, shouldReloadTotal) { return __awaiter(void 0, void 0, void 0, function () {
|
|
187
|
+
var result, newSavedSearch_1, error_3;
|
|
188
188
|
return __generator(this, function (_a) {
|
|
189
189
|
switch (_a.label) {
|
|
190
190
|
case 0:
|
|
@@ -195,7 +195,11 @@ export var useSavedSearchesRequest = function (_a) {
|
|
|
195
195
|
return [4 /*yield*/, updateSavedSearch(savedSearch)];
|
|
196
196
|
case 2:
|
|
197
197
|
result = _a.sent();
|
|
198
|
-
|
|
198
|
+
if (shouldReloadTotal) {
|
|
199
|
+
setProfilesCountMap(assocPath([savedSearch.uri, 'count'], undefined));
|
|
200
|
+
}
|
|
201
|
+
newSavedSearch_1 = shouldReloadTotal ? omit(['count'], savedSearch) : savedSearch;
|
|
202
|
+
setData(function (prevData) { return prevData.map(function (item) { return (item.uri === savedSearch.uri ? newSavedSearch_1 : item); }); });
|
|
199
203
|
updateRequestState('updating', RequestStates.LOADED);
|
|
200
204
|
return [2 /*return*/, { success: true, result: result }];
|
|
201
205
|
case 3:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1856",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
9
9
|
"@react-google-maps/api": "2.7.0",
|
|
10
10
|
"@react-sigma/core": "3.4.0",
|
|
11
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
11
|
+
"@reltio/mdm-sdk": "^1.4.1804",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"d3-cloud": "^1.2.5",
|
|
14
14
|
"d3-geo": "^2.0.1",
|