Skip to content

Commit 89820ca

Browse files
committed
refactor(QueryEditor): replace warning for query losing with note about how query are saved
1 parent d3dadbd commit 89820ca

File tree

2 files changed

+31
-56
lines changed

2 files changed

+31
-56
lines changed

src/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.js

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
1-
import React, {useState, useRef} from 'react';
1+
import React, {useState} from 'react';
22
import _ from 'lodash';
33
import cn from 'bem-cn-lite';
44
import {useDispatch, useSelector} from 'react-redux';
5-
import {Dialog, DropdownMenu, Popup, TextInput, Button} from '@yandex-cloud/uikit';
5+
import {Dialog, DropdownMenu, TextInput, Button} from '@yandex-cloud/uikit';
66

7-
import Icon from '../../../../components/Icon/Icon';
87
import {setQueryNameToEdit} from '../../../../store/reducers/saveQuery';
98

109
import './SaveQuery.scss';
1110

1211
const b = cn('kv-save-query');
1312

14-
const EMBEDDED_VERSION_WARNING =
15-
'Please be aware: after cookies delete your saved queries will be lost.';
16-
1713
function SaveQuery({savedQueries, onSaveQuery, saveButtonDisabled}) {
1814
const singleClusterMode = useSelector((state) => state.singleClusterMode);
1915
const [isDialogVisible, setIsDialogVisible] = useState(false);
20-
const [isEmbeddedWarningVisible, setIsEmbeddedWarningVisible] = useState(false);
2116
const [queryName, setQueryName] = useState('');
2217
const [validationError, setValidationError] = useState(null);
2318

2419
const queryNameToEdit = useSelector((state) => state.saveQuery);
2520
const dispatch = useDispatch();
2621

27-
const warningRef = useRef();
28-
2922
const onSaveQueryClick = () => {
3023
setIsDialogVisible(true);
3124
dispatch(setQueryNameToEdit(null));
@@ -42,13 +35,6 @@ function SaveQuery({savedQueries, onSaveQuery, saveButtonDisabled}) {
4235
setValidationError(validateQueryName(value));
4336
};
4437

45-
const onEmbeddedWarningOpen = () => {
46-
setIsEmbeddedWarningVisible(true);
47-
};
48-
const onEmbeddedWarningClose = () => {
49-
setIsEmbeddedWarningVisible(false);
50-
};
51-
5238
const validateQueryName = (value) => {
5339
if (_.some(savedQueries, (q) => q.name.toLowerCase() === value.trim().toLowerCase())) {
5440
return 'This name already exists';
@@ -73,15 +59,28 @@ function SaveQuery({savedQueries, onSaveQuery, saveButtonDisabled}) {
7359
<Dialog open={isDialogVisible} hasCloseButton={false} size="s" onClose={onCloseDialog}>
7460
<Dialog.Header caption="Save query" />
7561
<Dialog.Body className={b('dialog-body')}>
76-
<span className={b('field-title', 'required')}>Query name</span>
77-
<div className={b('control-wrapper')}>
78-
<TextInput
79-
placeholder="Enter query name"
80-
text={queryName}
81-
onUpdate={onQueryNameChange}
82-
hasClear
83-
/>
84-
<span className={b('error')}>{validationError}</span>
62+
{singleClusterMode && (
63+
<div className={b('dialog-row')}>
64+
The query will be saved in your browser
65+
</div>
66+
)}
67+
<div className={b('dialog-row')}>
68+
<label
69+
htmlFor="queryName"
70+
className={b('field-title', 'required')}
71+
>
72+
Query name
73+
</label>
74+
<div className={b('control-wrapper')}>
75+
<TextInput
76+
id="queryName"
77+
placeholder="Enter query name"
78+
text={queryName}
79+
onUpdate={onQueryNameChange}
80+
hasClear
81+
/>
82+
<span className={b('error')}>{validationError}</span>
83+
</div>
8584
</div>
8685
</Dialog.Body>
8786
<Dialog.Footer
@@ -121,36 +120,10 @@ function SaveQuery({savedQueries, onSaveQuery, saveButtonDisabled}) {
121120
);
122121
};
123122

124-
const renderEmbeddedVersionWarning = () => {
125-
return (
126-
<React.Fragment>
127-
<Popup
128-
className={b('embedded-popup')}
129-
anchorRef={warningRef}
130-
placement={['top']}
131-
open={isEmbeddedWarningVisible}
132-
hasArrow
133-
>
134-
{EMBEDDED_VERSION_WARNING}
135-
</Popup>
136-
<div
137-
className={b('embedded-tooltip')}
138-
ref={warningRef}
139-
onMouseEnter={onEmbeddedWarningOpen}
140-
onMouseLeave={onEmbeddedWarningClose}
141-
>
142-
<Icon name="question" height={18} width={18} viewBox="0 0 24 24" />
143-
</div>
144-
</React.Fragment>
145-
);
146-
};
147-
148123
return (
149124
<React.Fragment>
150125
{queryNameToEdit ? renderSaveDropdownMenu() : renderSaveButton(onSaveQueryClick)}
151126
{isDialogVisible && renderDialog()}
152-
153-
{singleClusterMode && renderEmbeddedVersionWarning()}
154127
</React.Fragment>
155128
);
156129
}

src/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.scss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
@import '../../../../styles/mixins.scss';
2-
31
.kv-save-query {
4-
&__dialog-body {
2+
&__dialog-row {
53
display: flex;
64
align-items: flex-start;
5+
6+
& + & {
7+
margin-top: var(--yc-text-body-line-height);
8+
}
79
}
810
&__field-title {
911
margin-right: 12px;
1012

1113
font-weight: 500;
12-
line-height: 32px;
14+
line-height: 28px;
1315
white-space: nowrap;
14-
@include body2-typography();
16+
1517
&.required {
1618
&::after {
1719
content: '*';

0 commit comments

Comments
 (0)