1
- import React , { useState , useRef } from 'react' ;
1
+ import React , { useState } from 'react' ;
2
2
import _ from 'lodash' ;
3
3
import cn from 'bem-cn-lite' ;
4
4
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' ;
6
6
7
- import Icon from '../../../../components/Icon/Icon' ;
8
7
import { setQueryNameToEdit } from '../../../../store/reducers/saveQuery' ;
9
8
10
9
import './SaveQuery.scss' ;
11
10
12
11
const b = cn ( 'kv-save-query' ) ;
13
12
14
- const EMBEDDED_VERSION_WARNING =
15
- 'Please be aware: after cookies delete your saved queries will be lost.' ;
16
-
17
13
function SaveQuery ( { savedQueries, onSaveQuery, saveButtonDisabled} ) {
18
14
const singleClusterMode = useSelector ( ( state ) => state . singleClusterMode ) ;
19
15
const [ isDialogVisible , setIsDialogVisible ] = useState ( false ) ;
20
- const [ isEmbeddedWarningVisible , setIsEmbeddedWarningVisible ] = useState ( false ) ;
21
16
const [ queryName , setQueryName ] = useState ( '' ) ;
22
17
const [ validationError , setValidationError ] = useState ( null ) ;
23
18
24
19
const queryNameToEdit = useSelector ( ( state ) => state . saveQuery ) ;
25
20
const dispatch = useDispatch ( ) ;
26
21
27
- const warningRef = useRef ( ) ;
28
-
29
22
const onSaveQueryClick = ( ) => {
30
23
setIsDialogVisible ( true ) ;
31
24
dispatch ( setQueryNameToEdit ( null ) ) ;
@@ -42,13 +35,6 @@ function SaveQuery({savedQueries, onSaveQuery, saveButtonDisabled}) {
42
35
setValidationError ( validateQueryName ( value ) ) ;
43
36
} ;
44
37
45
- const onEmbeddedWarningOpen = ( ) => {
46
- setIsEmbeddedWarningVisible ( true ) ;
47
- } ;
48
- const onEmbeddedWarningClose = ( ) => {
49
- setIsEmbeddedWarningVisible ( false ) ;
50
- } ;
51
-
52
38
const validateQueryName = ( value ) => {
53
39
if ( _ . some ( savedQueries , ( q ) => q . name . toLowerCase ( ) === value . trim ( ) . toLowerCase ( ) ) ) {
54
40
return 'This name already exists' ;
@@ -73,15 +59,28 @@ function SaveQuery({savedQueries, onSaveQuery, saveButtonDisabled}) {
73
59
< Dialog open = { isDialogVisible } hasCloseButton = { false } size = "s" onClose = { onCloseDialog } >
74
60
< Dialog . Header caption = "Save query" />
75
61
< 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 >
85
84
</ div >
86
85
</ Dialog . Body >
87
86
< Dialog . Footer
@@ -121,36 +120,10 @@ function SaveQuery({savedQueries, onSaveQuery, saveButtonDisabled}) {
121
120
) ;
122
121
} ;
123
122
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
-
148
123
return (
149
124
< React . Fragment >
150
125
{ queryNameToEdit ? renderSaveDropdownMenu ( ) : renderSaveButton ( onSaveQueryClick ) }
151
126
{ isDialogVisible && renderDialog ( ) }
152
-
153
- { singleClusterMode && renderEmbeddedVersionWarning ( ) }
154
127
</ React . Fragment >
155
128
) ;
156
129
}
0 commit comments