Skip to content

Commit ada139d

Browse files
committed
Adds Implementation for restore default
1 parent d60b50a commit ada139d

File tree

4 files changed

+73
-29
lines changed

4 files changed

+73
-29
lines changed

packages/transaction-log/src/components/dialogs/customize.dialog.component.tsx

+17-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
FormControlLabel,
99
Checkbox,
1010
List,
11-
ListItem
11+
ListItem,
12+
Box
1213
} from '@mui/material'
1314
import {CustomizeDialogProps} from '../../interfaces/index.interface'
1415

@@ -17,7 +18,8 @@ const CustomizeDialog: React.FC<CustomizeDialogProps> = ({
1718
onClose,
1819
onApply,
1920
visibleFilters,
20-
handleFilterVisibilityChange
21+
handleFilterVisibilityChange,
22+
onRestoreDefaults
2123
}) => {
2224
return (
2325
<Dialog open={open} onClose={onClose} fullWidth>
@@ -43,12 +45,19 @@ const CustomizeDialog: React.FC<CustomizeDialogProps> = ({
4345
</List>
4446
</DialogContent>
4547
<DialogActions>
46-
<Button onClick={onClose} color="primary">
47-
CANCEL
48-
</Button>
49-
<Button onClick={onApply} color="primary">
50-
APPLY
51-
</Button>
48+
<Box sx={{flexGrow: 1}}>
49+
<Button onClick={onRestoreDefaults} color="primary">
50+
RESTORE DEFAULT
51+
</Button>
52+
</Box>
53+
<Box>
54+
<Button onClick={onClose} color="primary">
55+
CANCEL
56+
</Button>
57+
<Button onClick={onApply} color="primary">
58+
APPLY
59+
</Button>
60+
</Box>
5261
</DialogActions>
5362
</Dialog>
5463
)

packages/transaction-log/src/components/filters/custom.component.tsx

+23-18
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ import CustomizeDialog from '../dialogs/customize.dialog.component'
77
import {CustomFilterProps} from '../../interfaces/index.interface'
88
import {debounce} from 'lodash'
99

10+
const defaultVisibleFilters = {
11+
status: true,
12+
statusCode: true,
13+
searchQuery: true,
14+
channel: true,
15+
startDate: true,
16+
endDate: true,
17+
limit: true,
18+
reruns: true,
19+
host: false,
20+
port: false,
21+
path: false,
22+
param: false,
23+
client: false,
24+
method: false
25+
}
26+
1027
const CustomFilters: React.FC<CustomFilterProps> = ({
1128
status,
1229
setStatus,
@@ -42,24 +59,7 @@ const CustomFilters: React.FC<CustomFilterProps> = ({
4259
}) => {
4360
const [open, setOpen] = useState(false)
4461
const debounceFetchTransactionLogs = debounce(fetchTransactionLogs, 10000)
45-
46-
const [visibleFilters, setVisibleFilters] = useState({
47-
status: true,
48-
statusCode: true,
49-
searchQuery: true,
50-
channel: true,
51-
startDate: true,
52-
endDate: true,
53-
limit: true,
54-
reruns: true,
55-
host: false,
56-
port: false,
57-
path: false,
58-
param: false,
59-
client: false,
60-
method: false
61-
})
62-
62+
const [visibleFilters, setVisibleFilters] = useState(defaultVisibleFilters)
6363
const [tempVisibleFilters, setTempVisibleFilters] = useState(visibleFilters)
6464

6565
const handleStatusChange = (event: React.ChangeEvent<HTMLInputElement>) => {
@@ -144,6 +144,10 @@ const CustomFilters: React.FC<CustomFilterProps> = ({
144144
setOpen(false)
145145
}
146146

147+
const handleRestoreDefaults = () => {
148+
setTempVisibleFilters(defaultVisibleFilters)
149+
}
150+
147151
useEffect(() => {
148152
debounceFetchTransactionLogs(null, true)
149153
return () => debounceFetchTransactionLogs.cancel()
@@ -414,6 +418,7 @@ const CustomFilters: React.FC<CustomFilterProps> = ({
414418
onApply={handleApplyFilters}
415419
visibleFilters={tempVisibleFilters}
416420
handleFilterVisibilityChange={handleFilterVisibilityChange}
421+
onRestoreDefaults={handleRestoreDefaults}
417422
/>
418423
</Box>
419424
)

packages/transaction-log/src/interfaces/index.interface.spec.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,25 @@ const customizeDialogProps: CustomizeDialogProps = {
6666
open: true,
6767
onClose: () => {},
6868
onApply: () => {},
69-
visibleFilters: {status: true, channel: false},
69+
visibleFilters: {
70+
status: true,
71+
statusCode: true,
72+
channel: true,
73+
startDate: true,
74+
endDate: true,
75+
limit: true,
76+
reruns: true,
77+
host: true,
78+
port: true,
79+
path: true,
80+
param: true,
81+
client: true,
82+
method: true
83+
},
7084
handleFilterVisibilityChange: (
7185
event: React.ChangeEvent<HTMLInputElement>
72-
) => {}
86+
) => {},
87+
onRestoreDefaults: () => {}
7388
}
7489

7590
const settingsDialogProps: SettingsDialogProps = {

packages/transaction-log/src/interfaces/index.interface.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,25 @@ export interface CustomizeDialogProps {
6565
open: boolean
6666
onClose: () => void
6767
onApply: () => void
68-
visibleFilters: {[key: string]: boolean}
68+
visibleFilters: {
69+
status: boolean
70+
statusCode: boolean
71+
channel: boolean
72+
startDate: boolean
73+
endDate: boolean
74+
limit: boolean
75+
reruns: boolean
76+
host: boolean
77+
port: boolean
78+
path: boolean
79+
param: boolean
80+
client: boolean
81+
method: boolean
82+
}
6983
handleFilterVisibilityChange: (
7084
event: React.ChangeEvent<HTMLInputElement>
7185
) => void
86+
onRestoreDefaults: () => void
7287
}
7388

7489
export interface SettingsDialogProps {

0 commit comments

Comments
 (0)