fix(ui): сохранять контекст и свежесть опроса BGP
This commit is contained in:
1 parent
8fdc4b917b
commit
2e17cbe926
8 files changed
+182
-19
No files matched your search
@@ -102,9 +102,11 @@ function TypeBadge({ type }: { type: BgpType }) {
|
||||
interface BgpSessionsDataGridProps {
|
||||
sessions: BgpSessionRow[]
|
||||
emptyTitle?: string
|
||||
selectedSessionId?: string | null
|
||||
onSelectSession?: (id: string | null) => void
|
||||
}
|
||||
|
||||
function BgpSessionsDataGrid({ sessions, emptyTitle }: BgpSessionsDataGridProps) {
|
||||
function BgpSessionsDataGrid({ sessions, emptyTitle, selectedSessionId, onSelectSession }: BgpSessionsDataGridProps) {
|
||||
const columns = useMemo<ColumnDef<DataGridFeatures, BgpSessionRow>[]>(
|
||||
() => [
|
||||
{
|
||||
@@ -268,6 +270,7 @@ function BgpSessionsDataGrid({ sessions, emptyTitle }: BgpSessionsDataGridProps)
|
||||
columns,
|
||||
getRowId: (row) => row.id,
|
||||
getRowCanExpand: () => true,
|
||||
...(onSelectSession ? { state: { expanded: selectedSessionId ? { [selectedSessionId]: true } : {} } } : {}),
|
||||
})
|
||||
|
||||
if (sessions.length === 0) {
|
||||
@@ -285,7 +288,7 @@ function BgpSessionsDataGrid({ sessions, emptyTitle }: BgpSessionsDataGridProps)
|
||||
<DataGridShell
|
||||
table={table}
|
||||
recordCount={sessions.length}
|
||||
onRowClick={(row) => table.getRow(row.id).toggleExpanded()}
|
||||
onRowClick={(row) => onSelectSession ? onSelectSession(row.id === selectedSessionId ? null : row.id) : table.getRow(row.id).toggleExpanded()}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user