Skip to content
This repository was archived by the owner on Feb 28, 2026. It is now read-only.

Commit 17234fb

Browse files
authored
Merge pull request #115 from sanyamjain04/refresh-button
added refresh functionality to refresh the query history.
2 parents 4d05a68 + 3d07d1c commit 17234fb

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

frontend/src/components/dbfragments/history.tsx

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useEffect } from 'react'
1+
import { useContext, useEffect } from 'react'
22
import { DBConnection, Tab } from '../../data/models'
33
import { selectDBConnection } from '../../redux/dbConnectionSlice'
44
import { useAppDispatch, useAppSelector } from '../../redux/hooks'
@@ -38,11 +38,24 @@ const DBHistoryFragment = ({ }: DBHistoryPropType) => {
3838
}
3939
}
4040

41+
function refreshHandler() {
42+
dispatch(reset());
43+
fetchDBQueryLogs();
44+
}
45+
4146
return (
4247
<div className={currentTab.isActive ? "db-tab-active" : "db-tab"}>
4348
{dbConnection &&
44-
<React.Fragment>
45-
<h1>Showing History in {dbConnection.name}</h1>
49+
<>
50+
<div className="is-flex is-justify-content-space-between ">
51+
<h1>Showing History in {dbConnection.name}</h1>
52+
<button className="button is-flex" onClick={refreshHandler}>
53+
<span className="icon is-small">
54+
<i className="fas fa-sync" />
55+
</span>
56+
<span>Refresh</span>
57+
</button>
58+
</div>
4659
<br />
4760
<InfiniteScroll
4861
dataLength={dbQueryLogs.length}
@@ -62,8 +75,7 @@ const DBHistoryFragment = ({ }: DBHistoryPropType) => {
6275
>
6376
<table className={"table is-bordered is-striped is-narrow is-hoverable is-fullwidth"}>
6477
<tbody>
65-
{dbQueryLogs.map((log) => {
66-
return (
78+
{dbQueryLogs.map((log) => (
6779
<tr key={log.id}>
6880
<td>
6981
<code>{log.query}</code>
@@ -73,15 +85,14 @@ const DBHistoryFragment = ({ }: DBHistoryPropType) => {
7385
</td>
7486
</tr>
7587
)
76-
})}
88+
)}
7789
</tbody>
7890
</table>
7991
</InfiniteScroll>
80-
</React.Fragment>
92+
</>
8193
}
8294
</div>
8395
)
8496
}
8597

86-
87-
export default DBHistoryFragment
98+
export default DBHistoryFragment

0 commit comments

Comments
 (0)