Skip to content

Commit 061c7f9

Browse files
committed
fix(ui): resolve docstore conflicts and keep dark-theme action button styling
1 parent 1fc1fb1 commit 061c7f9

File tree

3 files changed

+21
-36
lines changed

3 files changed

+21
-36
lines changed

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

Lines changed: 4 additions & 15 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,19 +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-
color: theme.palette.text.primary,
261-
backgroundColor:
262-
theme.palette.mode === 'dark'
263-
? theme.palette.background.default
264-
: theme.palette.background.paper,
265-
border: `1px solid ${theme.palette.divider}`,
266-
'&:hover': {
267-
backgroundColor: theme.palette.action.hover,
268-
borderColor: theme.palette.text.secondary
269-
}
270-
}}
259+
sx={getDocStoreActionButtonSx(theme)}
271260
onClick={(event) => {
272261
event.stopPropagation()
273262
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 & 21 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,17 +402,7 @@ const Documents = () => {
406402
zIndex: 2,
407403
width: 30,
408404
height: 30,
409-
p: 0.5,
410-
color: theme.palette.text.primary,
411-
backgroundColor:
412-
theme.palette.mode === 'dark'
413-
? theme.palette.background.default
414-
: theme.palette.background.paper,
415-
border: `1px solid ${theme.palette.divider}`,
416-
'&:hover': {
417-
backgroundColor: theme.palette.action.hover,
418-
borderColor: theme.palette.text.secondary
419-
},
405+
...getDocStoreActionButtonSx(theme),
420406
[theme.breakpoints.down('sm')]: {
421407
top: 8,
422408
right: 8,

0 commit comments

Comments
 (0)