Skip to content

Commit 82af13a

Browse files
committed
Implements disable function for restore default button
1 parent ada139d commit 82af13a

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const CustomizeDialog: React.FC<CustomizeDialogProps> = ({
1919
onApply,
2020
visibleFilters,
2121
handleFilterVisibilityChange,
22-
onRestoreDefaults
22+
onRestoreDefaults,
23+
isDefaultState
2324
}) => {
2425
return (
2526
<Dialog open={open} onClose={onClose} fullWidth>
@@ -46,7 +47,11 @@ const CustomizeDialog: React.FC<CustomizeDialogProps> = ({
4647
</DialogContent>
4748
<DialogActions>
4849
<Box sx={{flexGrow: 1}}>
49-
<Button onClick={onRestoreDefaults} color="primary">
50+
<Button
51+
onClick={onRestoreDefaults}
52+
color="primary"
53+
disabled={isDefaultState}
54+
>
5055
RESTORE DEFAULT
5156
</Button>
5257
</Box>

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

+7
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ const CustomFilters: React.FC<CustomFilterProps> = ({
148148
setTempVisibleFilters(defaultVisibleFilters)
149149
}
150150

151+
const isDefaultState = filters => {
152+
return Object.keys(defaultVisibleFilters).every(
153+
key => filters[key] === defaultVisibleFilters[key]
154+
)
155+
}
156+
151157
useEffect(() => {
152158
debounceFetchTransactionLogs(null, true)
153159
return () => debounceFetchTransactionLogs.cancel()
@@ -419,6 +425,7 @@ const CustomFilters: React.FC<CustomFilterProps> = ({
419425
visibleFilters={tempVisibleFilters}
420426
handleFilterVisibilityChange={handleFilterVisibilityChange}
421427
onRestoreDefaults={handleRestoreDefaults}
428+
isDefaultState={isDefaultState(tempVisibleFilters)}
422429
/>
423430
</Box>
424431
)

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ const customizeDialogProps: CustomizeDialogProps = {
8484
handleFilterVisibilityChange: (
8585
event: React.ChangeEvent<HTMLInputElement>
8686
) => {},
87-
onRestoreDefaults: () => {}
87+
onRestoreDefaults: () => {},
88+
isDefaultState: true
8889
}
8990

9091
const settingsDialogProps: SettingsDialogProps = {

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

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export interface CustomizeDialogProps {
8484
event: React.ChangeEvent<HTMLInputElement>
8585
) => void
8686
onRestoreDefaults: () => void
87+
isDefaultState: boolean
8788
}
8889

8990
export interface SettingsDialogProps {

0 commit comments

Comments
 (0)