Skip to content

Commit ac05e2c

Browse files
committed
feat(ui): add document store rename/delete actions for cards and table
1 parent 2555f10 commit ac05e2c

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed

packages/ui/src/ui-component/table/DocumentStoreTable.jsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from '@mui/material'
2020
import { tableCellClasses } from '@mui/material/TableCell'
2121
import DocumentStoreStatus from '@/views/docstore/DocumentStoreStatus'
22+
import { getDocStoreActionButtonSx } from '@/views/docstore/actionButtonStyles'
2223
import { IconDotsVertical } from '@tabler/icons-react'
2324

2425
const StyledTableCell = styled(TableCell)(({ theme }) => ({
@@ -159,12 +160,12 @@ export const DocumentStoreTable = ({ data, isLoading, onRowClick, images, showAc
159160
</>
160161
) : (
161162
<>
162-
{sortedData.map((row, index) => {
163+
{sortedData.map((row) => {
163164
return (
164165
<StyledTableRow
165166
onClick={() => onRowClick(row)}
166167
hover
167-
key={index}
168+
key={row.id}
168169
sx={{ cursor: 'pointer', '&:last-child td, &:last-child th': { border: 0 } }}
169170
>
170171
<StyledTableCell>
@@ -255,14 +256,7 @@ export const DocumentStoreTable = ({ data, isLoading, onRowClick, images, showAc
255256
<IconButton
256257
size='small'
257258
aria-label='Document store options'
258-
sx={{
259-
p: 0.5,
260-
backgroundColor: theme.palette.background.paper,
261-
border: `1px solid ${theme.palette.grey[900]}25`,
262-
'&:hover': {
263-
backgroundColor: theme.palette.action.hover
264-
}
265-
}}
259+
sx={getDocStoreActionButtonSx(theme)}
266260
onClick={(event) => {
267261
event.stopPropagation()
268262
onActionMenuClick(event, row)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const getDocStoreActionButtonSx = (theme) => ({
2+
p: 0.5,
3+
color: theme.palette.text.primary,
4+
backgroundColor: theme.palette.mode === 'dark' ? theme.palette.background.default : theme.palette.background.paper,
5+
border: `1px solid ${theme.palette.divider}`,
6+
'&:hover': {
7+
backgroundColor: theme.palette.action.hover,
8+
borderColor: theme.palette.text.secondary
9+
}
10+
})

packages/ui/src/views/docstore/index.jsx

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import DocumentStoreCard from '@/ui-component/cards/DocumentStoreCard'
1515
import MainCard from '@/ui-component/cards/MainCard'
1616
import TablePagination, { DEFAULT_ITEMS_PER_PAGE } from '@/ui-component/pagination/TablePagination'
1717
import AddDocStoreDialog from '@/views/docstore/AddDocStoreDialog'
18+
import { getDocStoreActionButtonSx } from '@/views/docstore/actionButtonStyles'
1819
import DeleteDocStoreDialog from '@/views/docstore/DeleteDocStoreDialog'
1920

2021
// API
@@ -88,14 +89,9 @@ const Documents = () => {
8889
return responseData
8990
}
9091

91-
if (responseData && typeof responseData === 'object') {
92-
if (typeof responseData.message === 'string' && responseData.message.trim()) {
93-
return responseData.message
94-
}
95-
96-
if (typeof responseData.error === 'string' && responseData.error.trim()) {
97-
return responseData.error
98-
}
92+
const responseMessage = responseData && typeof responseData === 'object' ? responseData.message || responseData.error : undefined
93+
if (typeof responseMessage === 'string' && responseMessage.trim()) {
94+
return responseMessage
9995
}
10096

10197
if (typeof error?.message === 'string' && error.message.trim()) {
@@ -387,8 +383,8 @@ const Documents = () => {
387383
<React.Fragment>
388384
{!view || view === 'card' ? (
389385
<Box display='grid' gridTemplateColumns='repeat(3, 1fr)' gap={gridSpacing}>
390-
{docStores?.filter(filterDocStores).map((data, index) => (
391-
<Box key={index} sx={{ position: 'relative' }}>
386+
{docStores?.filter(filterDocStores).map((data) => (
387+
<Box key={data.id} sx={{ position: 'relative' }}>
392388
<DocumentStoreCard
393389
images={images[data.id]}
394390
data={data}
@@ -406,12 +402,7 @@ const Documents = () => {
406402
zIndex: 2,
407403
width: 30,
408404
height: 30,
409-
p: 0.5,
410-
backgroundColor: theme.palette.background.paper,
411-
border: `1px solid ${theme.palette.grey[900]}25`,
412-
'&:hover': {
413-
backgroundColor: theme.palette.action.hover
414-
},
405+
...getDocStoreActionButtonSx(theme),
415406
[theme.breakpoints.down('sm')]: {
416407
top: 8,
417408
right: 8,

0 commit comments

Comments
 (0)