Skip to content

Commit

Permalink
feat(connections): add isClosingConnections spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
kunish committed Oct 10, 2024
1 parent 14b1b39 commit 23193c5
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/pages/Connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default () => {
const [activeTab, setActiveTab] = createSignal(ActiveTab.activeConnections)
const { activeConnections, closedConnections, paused, setPaused } =
useConnections()
const [isClosingConnections, setIsClosingConnections] = createSignal(false)

const [globalFilter, setGlobalFilter] = createSignal('')
const [enableQuickFilter, setEnableQuickFilter] = makePersisted(
Expand Down Expand Up @@ -429,18 +430,30 @@ export default () => {

<Button
class="btn btn-primary join-item btn-sm"
onClick={() => {
onClick={async () => {
setIsClosingConnections(true)

if (table.getState().globalFilter) {
table
.getFilteredRowModel()
.rows.forEach(({ original }) =>
closeSingleConnectionAPI(original.id),
)
await Promise.allSettled(
table
.getFilteredRowModel()
.rows.map(({ original }) =>
closeSingleConnectionAPI(original.id),
),
)
} else {
closeAllConnectionsAPI()
await closeAllConnectionsAPI()
}

setIsClosingConnections(false)
}}
icon={<IconX />}
icon={
isClosingConnections() ? (
<div class="loading loading-spinner" />
) : (
<IconX />
)
}
/>

<Button
Expand Down

0 comments on commit 23193c5

Please sign in to comment.