From 97e068c4480a9c9fa7c038612228f7e837e5e80f Mon Sep 17 00:00:00 2001 From: CHEYNE Date: Tue, 30 Jan 2024 19:48:11 +0800 Subject: [PATCH] [#1734] fix(web): fix the metalake sorting (#1790) ### What changes were proposed in this pull request? Fix the metalake sorting. 1. Sort by Date image image 2. Full match image ### Why are the changes needed? Fix: #1734 Fix: #1688 ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? N/A --- web/app/ui/MetalakeList.js | 50 ++++++++++++++++++++++++++++++++------ web/app/ui/TableHeader.js | 7 +++--- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/web/app/ui/MetalakeList.js b/web/app/ui/MetalakeList.js index 532a86ff6f7..071284d7044 100644 --- a/web/app/ui/MetalakeList.js +++ b/web/app/ui/MetalakeList.js @@ -3,12 +3,12 @@ * This software is licensed under the Apache License version 2. */ -import { useEffect, useCallback, useState } from 'react' +import { useEffect, useCallback, useState, Fragment } from 'react' import Link from 'next/link' -import { Box, Grid, Card, IconButton, Typography, Tooltip } from '@mui/material' -import { DataGrid } from '@mui/x-data-grid' +import { Box, Grid, Card, IconButton, Typography, Portal, Tooltip } from '@mui/material' +import { DataGrid, GridToolbar } from '@mui/x-data-grid' import Icon from '@/components/Icon' @@ -21,6 +21,20 @@ import DetailsDrawer from '@/components/DetailsDrawer' import CreateMetalakeDialog from './CreateMetalakeDialog' import ConfirmDeleteDialog from '@/components/ConfirmDeleteDialog' +function TableToolbar(props) { + return ( + <> + + document.getElementById('filter-panel')}> + + + + + + + ) +} + const MetalakeList = () => { const dispatch = useAppDispatch() const store = useAppSelector(state => state.metalakes) @@ -72,7 +86,14 @@ const MetalakeList = () => { }, [dispatch]) useEffect(() => { - const filteredData = store.metalakes.filter(i => i.name.toLowerCase().includes(value.toLowerCase())) + const filteredData = store.metalakes + .filter(i => i.name.toLowerCase().includes(value.toLowerCase())) + .sort((a, b) => { + if (a.name.toLowerCase() === value.toLowerCase()) return -1 + if (b.name.toLowerCase() === value.toLowerCase()) return 1 + + return 0 + }) dispatch(setFilteredMetalakes(filteredData)) }, [dispatch, store.metalakes, value]) @@ -81,6 +102,8 @@ const MetalakeList = () => { { flex: 0.2, minWidth: 230, + disableColumnMenu: true, + filterable: true, field: 'name', headerName: 'Name', renderCell: ({ row }) => { @@ -88,7 +111,7 @@ const MetalakeList = () => { return ( - + { { flex: 0.15, minWidth: 150, + disableColumnMenu: true, field: 'createdBy', headerName: 'Created By', renderCell: ({ row }) => { @@ -125,8 +149,10 @@ const MetalakeList = () => { }, { flex: 0.15, - field: 'createdAt', minWidth: 150, + disableColumnMenu: true, + valueGetter: params => `${params.row.audit?.createTime}`, + field: 'createdAt', headerName: 'Created At', renderCell: ({ row }) => { return ( @@ -140,6 +166,7 @@ const MetalakeList = () => { flex: 0.1, minWidth: 90, sortable: false, + disableColumnMenu: true, field: 'actions', headerName: 'Actions', renderCell: ({ row }) => ( @@ -187,9 +214,18 @@ const MetalakeList = () => { setDialogType={setDialogType} /> { } return ( - - - handleFilter(e.target.value)} /> - + + + handleFilter(e.target.value)} />