feat(connections): add isClosingConnections spinner

This commit is contained in:
kunish 2024-10-11 02:23:33 +08:00
parent 14b1b39e2c
commit 23193c5c98
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430

View File

@ -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(
@ -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