Skip to content

Commit 15fd52a

Browse files
Check box for dialog box
- Checkbox to ask if change all db dialog should open again Related to #1048
1 parent 0d2a592 commit 15fd52a

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/dashboard/header/DashboardChangeDatabaseConfirmDialog.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
1-
import React from 'react';
2-
import { Button, Dialog } from '@neo4j-ndl/react';
1+
import React, { useState } from 'react';
2+
import { Button, Checkbox, Dialog } from '@neo4j-ndl/react';
33
import { BackspaceIconOutline, ExclamationTriangleIconOutline } from '@neo4j-ndl/react/icons';
44

55
/**
66
* Configures setting the current Neo4j database connection for the dashboard.
77
*/
88
export const NeoDashboardChangeDatabaseConfirm = ({ open, onConfirm, handleClose }) => {
9+
10+
const [checked, setChecked] = useState(false);
11+
912
return (
10-
<Dialog size='small' open={open == true} onClose={handleClose} aria-labelledby='form-dialog-title'>
13+
<Dialog
14+
size='small'
15+
open={open == true}
16+
onClose={(event, reason) => {
17+
if (reason !== 'backdropClick') {
18+
handleClose();
19+
}
20+
}}
21+
aria-labelledby='form-dialog-title'>
1122
<Dialog.Header id='form-dialog-title'>Change Database For All Reports?</Dialog.Header>
1223
<Dialog.Subtitle>
1324
This will change the database for all reports.
1425
</Dialog.Subtitle>
26+
<Dialog.Actions>
27+
<Checkbox
28+
label="Don't ask again"
29+
checked={checked}
30+
onChange={(event) => setChecked(event.target.checked)}
31+
/>
32+
</Dialog.Actions>
1533
<Dialog.Actions>
1634
<Button
1735
onClick={() => {
@@ -24,6 +42,9 @@ export const NeoDashboardChangeDatabaseConfirm = ({ open, onConfirm, handleClose
2442
</Button>
2543
<Button
2644
onClick={() => {
45+
if (checked == true){
46+
sessionStorage.setItem('ChangeDatabaseConfirmBoolean','True')
47+
}
2748
onConfirm();
2849
handleClose();
2950
}}

src/dashboard/header/DashboardHeader.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,14 @@ export const NeoDashboardHeader = ({
154154
databases={databases}
155155
selected={dataDatabase}
156156
setSelected={(newDatabase) => {
157-
setModalOpen(Modal.CHANGE);
158-
setDataDatabase(newDatabase);
159-
console.log(newDatabase)
160-
console.log(dataDatabase)
161-
refreshPage(newDatabase)
157+
let ChangeDatabaseConfirmBoolean = sessionStorage.getItem("ChangeDatabaseConfirmBoolean") || "False"
158+
if (ChangeDatabaseConfirmBoolean == 'True'){
159+
setDataDatabase(newDatabase);
160+
refreshPage(newDatabase)
161+
}
162+
else{
163+
setModalOpen(Modal.CHANGE);
164+
}
162165
}}
163166
open={menuOpen == Menu.DATABASE}
164167
anchorEl={menuAnchor}

0 commit comments

Comments
 (0)