Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1735] fix(web): fix sorting and filtering of the metalakes table #2309

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 55 additions & 41 deletions web/app/ui/MetalakeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { useEffect, useCallback, useState, Fragment } from 'react'

import Link from 'next/link'

import { Box, Grid, Card, IconButton, Typography, Portal, Tooltip } from '@mui/material'
import { DataGrid, GridToolbar } from '@mui/x-data-grid'
import { Box, Grid, Card, Typography, Portal, Tooltip } from '@mui/material'
import { DataGrid, GridActionsCellItem, GridToolbar } from '@mui/x-data-grid'

import Icon from '@/components/Icon'

Expand All @@ -26,7 +26,7 @@ function TableToolbar(props) {
<>
<Fragment>
<Portal container={() => document.getElementById('filter-panel')}>
<Box className={`twc-w-full twc-justify-between twc-hidden`}>
<Box className={`twc-flex twc-w-full twc-justify-between`}>
<GridToolbar {...props} />
</Box>
</Portal>
Expand All @@ -49,7 +49,7 @@ const MetalakeList = () => {
const [openConfirmDelete, setOpenConfirmDelete] = useState(false)
const [confirmCacheData, setConfirmCacheData] = useState(null)

const handleDeleteMetalake = name => {
const handleDeleteMetalake = name => () => {
setOpenConfirmDelete(true)
setConfirmCacheData(name)
}
Expand All @@ -66,7 +66,7 @@ const MetalakeList = () => {
setConfirmCacheData(null)
}

const handleShowEditDialog = data => {
const handleShowEditDialog = data => () => {
setDialogType('update')
setOpenDialog(true)
setDialogData(data)
Expand All @@ -76,7 +76,7 @@ const MetalakeList = () => {
setValue(val)
}, [])

const handleShowDetails = row => {
const handleShowDetails = row => () => {
setDrawerData(row)
setOpenDrawer(true)
}
Expand Down Expand Up @@ -108,6 +108,7 @@ const MetalakeList = () => {
minWidth: 230,
disableColumnMenu: true,
filterable: true,
type: 'string',
field: 'name',
headerName: 'Name',
renderCell: ({ row }) => {
Expand Down Expand Up @@ -142,7 +143,9 @@ const MetalakeList = () => {
flex: 0.15,
minWidth: 150,
disableColumnMenu: true,
type: 'string',
field: 'createdBy',
valueGetter: params => `${params.row.audit?.creator}`,
headerName: 'Created by',
renderCell: ({ row }) => {
return (
Expand All @@ -156,12 +159,13 @@ const MetalakeList = () => {
flex: 0.15,
minWidth: 150,
disableColumnMenu: true,
valueGetter: params => `${params.row.audit?.createTime}`,
type: 'dateTime',
field: 'createdAt',
valueGetter: params => new Date(params.row.audit?.createTime),
headerName: 'Created at',
renderCell: ({ row }) => {
return (
<Typography noWrap sx={{ color: 'text.secondary' }}>
<Typography title={row.audit?.createTime} noWrap sx={{ color: 'text.secondary' }}>
{formatToDateTime(row.audit?.createTime)}
</Typography>
)
Expand All @@ -170,40 +174,48 @@ const MetalakeList = () => {
{
flex: 0.1,
minWidth: 90,
sortable: false,
disableColumnMenu: true,
field: 'actions',
type: 'actions',
headerName: 'Actions',
renderCell: ({ row }) => (
<>
<IconButton
title='Details'
size='small'
sx={{ color: theme => theme.palette.text.secondary }}
onClick={() => handleShowDetails(row)}
>
<Icon icon='bx:show-alt' />
</IconButton>

<IconButton
title='Edit'
size='small'
sx={{ color: theme => theme.palette.text.secondary }}
onClick={() => handleShowEditDialog(row)}
>
<Icon icon='mdi:square-edit-outline' />
</IconButton>

<IconButton
title='Delete'
size='small'
sx={{ color: theme => theme.palette.error.light }}
onClick={() => handleDeleteMetalake(row.name)}
>
<Icon icon='mdi:delete-outline' />
</IconButton>
</>
)
field: 'actions',
getActions: ({ row }) => [
<GridActionsCellItem
key='details'
label='Details'
title='Details'
icon={<Icon icon='bx:show-alt' />}
onClick={handleShowDetails(row)}
sx={{
'& svg': {
fontSize: '24px'
}
}}
/>,
<GridActionsCellItem
key='edit'
label='Edit'
title='Edit'
icon={<Icon icon='mdi:square-edit-outline' />}
onClick={handleShowEditDialog(row)}
sx={{
'& svg': {
fontSize: '24px'
}
}}
/>,
<GridActionsCellItem
key='delete'
icon={<Icon icon='mdi:delete-outline' />}
label='Delete'
title='Delete'
onClick={handleDeleteMetalake(row.name)}
sx={{
'& svg': {
fontSize: '24px',
color: theme => theme.palette.error.light
}
}}
/>
]
}
]

Expand Down Expand Up @@ -238,6 +250,8 @@ const MetalakeList = () => {
rows={store.filteredMetalakes}
columns={columns}
disableRowSelectionOnClick
onCellClick={(params, event) => event.stopPropagation()}
onRowClick={(params, event) => event.stopPropagation()}
pageSizeOptions={[10, 25, 50]}
paginationModel={paginationModel}
onPaginationModelChange={setPaginationModel}
Expand Down
Loading