diff --git a/src/fireedge/src/client/components/Tables/Datastores/columns.js b/src/fireedge/src/client/components/Tables/Datastores/columns.js index 8369703a36..fea5f9c6f5 100644 --- a/src/fireedge/src/client/components/Tables/Datastores/columns.js +++ b/src/fireedge/src/client/components/Tables/Datastores/columns.js @@ -1,72 +1,8 @@ -import * as React from 'react' - -import { LinearProgressWithLabel, StatusBadge } from 'client/components/Status' -import * as DatastoreModel from 'client/models/Datastore' - export default [ - /* { - id: 'selection', - // The header can use the table's getToggleAllRowsSelectedProps method - // to render a checkbox. - // Pagination is a problem since this will select all rows even though - // not all rows are on the current page. - // The solution should be server side pagination. - // For one, the clients should not download all rows in most cases. - // The client should only download data for the current page. - // In that case, getToggleAllRowsSelectedProps works fine. - Header: ({ getToggleAllRowsSelectedProps }) => ( - - ), - // The cell can use the individual row's getToggleRowSelectedProps method - // to the render a checkbox - Cell: ({ row }) => ( - - ) - }, */ - { - Header: '', - id: 'STATE', - width: 50, - accessor: row => { - const state = DatastoreModel.getState(row) - - return ( - - ) - } - }, - { Header: '#', accessor: 'ID', width: 45 }, - { Header: 'Name', accessor: 'NAME' }, - { - Header: 'Type', - id: 'TYPE', - width: 100, - accessor: row => DatastoreModel.getType(row)?.name - }, - { - Header: 'Owner/Group', - accessor: row => `${row.UNAME}/${row.GNAME}` - }, - { - Header: 'Clusters', - id: 'CLUSTERS', - width: 100, - accessor: row => [row.CLUSTERS?.ID ?? []].flat().join(',') - }, - { - Header: 'Allocated CPU', - accessor: row => { - const { percentOfUsed, percentLabel } = DatastoreModel.getCapacityInfo(row) - - return ( -
- -
- ) - } - } + { Header: '', accessor: 'ID' }, + { Header: '', accessor: 'NAME' }, + { Header: '', accessor: 'STATE' }, + { Header: '', accessor: 'TYPE' }, + { Header: '', accessor: 'CLUSTERS' }, + { Header: '', accessor: 'ALLOCATED_CPU' } ] diff --git a/src/fireedge/src/client/components/Tables/Datastores/index.js b/src/fireedge/src/client/components/Tables/Datastores/index.js index a29be318a3..4de17363cb 100644 --- a/src/fireedge/src/client/components/Tables/Datastores/index.js +++ b/src/fireedge/src/client/components/Tables/Datastores/index.js @@ -5,11 +5,11 @@ import { useFetch } from 'client/hooks' import { useDatastore, useDatastoreApi } from 'client/features/One' import { EnhancedTable } from 'client/components/Tables' -import { DatastoreCard } from 'client/components/Cards' -import Columns from 'client/components/Tables/Datastores/columns' +import DatastoreColumns from 'client/components/Tables/Datastores/columns' +import DatastoreRow from 'client/components/Tables/Datastores/row' const DatastoresTable = () => { - const columns = React.useMemo(() => Columns, []) + const columns = React.useMemo(() => DatastoreColumns, []) const datastores = useDatastore() const { getDatastores } = useDatastoreApi() @@ -24,7 +24,8 @@ const DatastoresTable = () => { columns={columns} data={datastores} isLoading={loading || reloading} - MobileComponentRow={DatastoreCard} + getRowId={row => String(row.ID)} + RowComponent={DatastoreRow} /> ) } diff --git a/src/fireedge/src/client/components/Tables/Datastores/row.js b/src/fireedge/src/client/components/Tables/Datastores/row.js new file mode 100644 index 0000000000..11378f355a --- /dev/null +++ b/src/fireedge/src/client/components/Tables/Datastores/row.js @@ -0,0 +1,69 @@ +import * as React from 'react' +import PropTypes from 'prop-types' + +import { User, Group, Lock, Cloud, Server } from 'iconoir-react' +import { Typography } from '@material-ui/core' + +import { StatusCircle, LinearProgressWithLabel, StatusChip } from 'client/components/Status' +import { rowStyles } from 'client/components/Tables/styles' + +import * as DatastoreModel from 'client/models/Datastore' + +const Row = ({ value, ...props }) => { + const classes = rowStyles() + const { ID, NAME, UNAME, GNAME, CLUSTERS, LOCK, TEMPLATE } = value + const { PROVISION } = TEMPLATE + + const state = DatastoreModel.getState(value) + const type = DatastoreModel.getType(value) + + const clusters = [CLUSTERS?.ID ?? []].flat() + const { percentOfUsed, percentLabel } = DatastoreModel.getCapacityInfo(value) + + return ( +
+
+ +
+
+ + {NAME} + + {LOCK && } + + + +
+ {`#${ID}`} + + + {` ${UNAME}`} + + + + {` ${GNAME}`} + + {PROVISION?.ID && + + {` ${PROVISION.ID}`} + } + + + {` ${clusters.join(',')}`} + +
+
+
+ +
+
+ ) +} + +Row.propTypes = { + value: PropTypes.object, + isSelected: PropTypes.bool, + handleClick: PropTypes.func +} + +export default Row