Skip to content

Commit

Permalink
[apache#1735] fix(web): fix sorting and filtering of the metalakes ta…
Browse files Browse the repository at this point in the history
…ble (apache#2309)

### What changes were proposed in this pull request?

Fix sorting and filtering of the metalakes table.
<img width="1023" alt="image"
src="https://github.com/datastrato/gravitino/assets/17310559/3ade8070-c24d-45f5-a43b-fd693c7d0234">


### Why are the changes needed?

Fix: apache#1735 
Fix: apache#2072

### Does this PR introduce _any_ user-facing change?

N/A

### How was this patch tested?

N/A
  • Loading branch information
ch3yne authored Feb 22, 2024
1 parent cadfc52 commit 4333190
Showing 1 changed file with 55 additions and 41 deletions.
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

0 comments on commit 4333190

Please sign in to comment.