- Consolidated JavaScript completion sources into a new module, improving organization and maintainability. - Updated the `fcTemplateLang` to utilize the new `javascriptCompletionSources` for enhanced autocomplete capabilities. - Removed redundant imports and streamlined the code in various components, including Invoices, Payments, TaxRecords, and Inventory sections, by replacing dropdown actions with a unified `ObjectActions` component. - Improved the handling of object actions across multiple inventory and finance components, enhancing user experience and code consistency.
93 lines
2.9 KiB
JavaScript
93 lines
2.9 KiB
JavaScript
// src/hosts.js
|
|
|
|
import { useRef } from 'react'
|
|
import { Flex, Space } from 'antd'
|
|
|
|
|
|
import useColumnVisibility from '../hooks/useColumnVisibility'
|
|
import ColumnViewButton from '../common/ColumnViewButton'
|
|
import ExportListButton from '../common/ExportListButton'
|
|
import ObjectTable from '../common/ObjectTable'
|
|
import ObjectActions from '../common/ObjectActions'
|
|
import useViewMode from '../hooks/useViewMode'
|
|
import ObjectTableViewButton from '../common/ObjectTableViewButton'
|
|
import FilterSidebarButton from '../common/FilterSidebarButton'
|
|
import SortSidebarButton from '../common/SortSidebarButton'
|
|
import useFilterSidebarVisibility from '../hooks/useFilterSidebarVisibility'
|
|
import useSortSidebarVisibility from '../hooks/useSortSidebarVisibility'
|
|
|
|
const Hosts = () => {
|
|
const tableRef = useRef()
|
|
|
|
// View mode state (cards/list), persisted in sessionStorage via custom hook
|
|
const [viewMode, setViewMode] = useViewMode('host')
|
|
|
|
const [columnVisibility, setColumnVisibility] = useColumnVisibility('host')
|
|
|
|
const [showFilterSidebar, setShowFilterSidebar] =
|
|
useFilterSidebarVisibility('Hosts')
|
|
|
|
const [showSortSidebar, setShowSortSidebar] =
|
|
useSortSidebarVisibility('Hosts')
|
|
|
|
|
|
return (
|
|
<>
|
|
<Flex vertical={'true'} gap='large' className='h-100'>
|
|
<Flex justify={'space-between'} style={{ minHeight: 0 }}>
|
|
<Space>
|
|
<ObjectActions
|
|
type='host'
|
|
pageName='list'
|
|
onReload={() => tableRef.current?.reload()}
|
|
/>
|
|
<ColumnViewButton
|
|
type='host'
|
|
loading={false}
|
|
visibleState={columnVisibility}
|
|
updateVisibleState={setColumnVisibility}
|
|
/>
|
|
<ExportListButton objectType='host' />
|
|
</Space>
|
|
<Space>
|
|
<SortSidebarButton
|
|
active={showSortSidebar}
|
|
onClick={() => setShowSortSidebar(!showSortSidebar)}
|
|
/>
|
|
<FilterSidebarButton
|
|
active={showFilterSidebar}
|
|
onClick={() => setShowFilterSidebar(!showFilterSidebar)}
|
|
/>
|
|
<ObjectTableViewButton
|
|
viewMode={viewMode}
|
|
setViewMode={setViewMode}
|
|
showEndingDivider={true}
|
|
/>
|
|
</Space>
|
|
</Flex>
|
|
|
|
<ObjectTable
|
|
ref={tableRef}
|
|
type='host'
|
|
cards={viewMode === 'cards'}
|
|
visibleColumns={columnVisibility}
|
|
showFilterSidebar={showFilterSidebar}
|
|
showSortSidebar={showSortSidebar}
|
|
expandHeight={true}
|
|
saveFilterInSession={true}
|
|
saveFilterInUrl={true}
|
|
useFilterInSession={true}
|
|
useFilterInUrl={true}
|
|
saveSortInSession={true}
|
|
saveSortInUrl={true}
|
|
useSortInSession={true}
|
|
useSortInUrl={true}
|
|
/>
|
|
|
|
</Flex>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default Hosts
|