Skip to content

Commit edff152

Browse files
authored
Feat/docstore rename delete actions (optimised for dark theme) (#6144)
* feat(ui): add document store rename/delete actions for cards and table * refactor(docstore): inline action button styles into index.jsx
1 parent deb1330 commit edff152

2 files changed

Lines changed: 23 additions & 28 deletions

File tree

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const StyledTableRow = styled(TableRow)(() => ({
4040
}
4141
}))
4242

43-
export const DocumentStoreTable = ({ data, isLoading, onRowClick, images, showActions, onActionMenuClick }) => {
43+
export const DocumentStoreTable = ({ data, isLoading, onRowClick, images, showActions, onActionMenuClick, actionButtonSx }) => {
4444
const theme = useTheme()
4545
const customization = useSelector((state) => state.customization)
4646

@@ -159,12 +159,12 @@ export const DocumentStoreTable = ({ data, isLoading, onRowClick, images, showAc
159159
</>
160160
) : (
161161
<>
162-
{sortedData.map((row, index) => {
162+
{sortedData.map((row) => {
163163
return (
164164
<StyledTableRow
165165
onClick={() => onRowClick(row)}
166166
hover
167-
key={index}
167+
key={row.id}
168168
sx={{ cursor: 'pointer', '&:last-child td, &:last-child th': { border: 0 } }}
169169
>
170170
<StyledTableCell>
@@ -255,14 +255,7 @@ export const DocumentStoreTable = ({ data, isLoading, onRowClick, images, showAc
255255
<IconButton
256256
size='small'
257257
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-
}}
258+
sx={actionButtonSx}
266259
onClick={(event) => {
267260
event.stopPropagation()
268261
onActionMenuClick(event, row)
@@ -290,7 +283,8 @@ DocumentStoreTable.propTypes = {
290283
images: PropTypes.object,
291284
onRowClick: PropTypes.func,
292285
showActions: PropTypes.bool,
293-
onActionMenuClick: PropTypes.func
286+
onActionMenuClick: PropTypes.func,
287+
actionButtonSx: PropTypes.object
294288
}
295289

296290
DocumentStoreTable.displayName = 'DocumentStoreTable'

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ import { closeSnackbar as closeSnackbarAction, enqueueSnackbar as enqueueSnackba
3535
import useNotifier from '@/utils/useNotifier'
3636

3737
// ==============================|| DOCUMENTS ||============================== //
38+
const getDocStoreActionButtonSx = (theme) => ({
39+
p: 0.5,
40+
color: theme.palette.text.primary,
41+
backgroundColor: theme.palette.mode === 'dark' ? theme.palette.background.default : theme.palette.background.paper,
42+
border: `1px solid ${theme.palette.divider}`,
43+
'&:hover': {
44+
backgroundColor: theme.palette.action.hover,
45+
borderColor: theme.palette.text.secondary
46+
}
47+
})
3848

3949
const Documents = () => {
4050
const theme = useTheme()
@@ -88,14 +98,9 @@ const Documents = () => {
8898
return responseData
8999
}
90100

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-
}
101+
const responseMessage = responseData && typeof responseData === 'object' ? responseData.message || responseData.error : undefined
102+
if (typeof responseMessage === 'string' && responseMessage.trim()) {
103+
return responseMessage
99104
}
100105

101106
if (typeof error?.message === 'string' && error.message.trim()) {
@@ -387,8 +392,8 @@ const Documents = () => {
387392
<React.Fragment>
388393
{!view || view === 'card' ? (
389394
<Box display='grid' gridTemplateColumns='repeat(3, 1fr)' gap={gridSpacing}>
390-
{docStores?.filter(filterDocStores).map((data, index) => (
391-
<Box key={index} sx={{ position: 'relative' }}>
395+
{docStores?.filter(filterDocStores).map((data) => (
396+
<Box key={data.id} sx={{ position: 'relative' }}>
392397
<DocumentStoreCard
393398
images={images[data.id]}
394399
data={data}
@@ -406,12 +411,7 @@ const Documents = () => {
406411
zIndex: 2,
407412
width: 30,
408413
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-
},
414+
...getDocStoreActionButtonSx(theme),
415415
[theme.breakpoints.down('sm')]: {
416416
top: 8,
417417
right: 8,
@@ -435,6 +435,7 @@ const Documents = () => {
435435
onRowClick={(row) => goToDocumentStore(row.id)}
436436
showActions={canManageDocumentStore}
437437
onActionMenuClick={handleActionMenuOpen}
438+
actionButtonSx={getDocStoreActionButtonSx(theme)}
438439
/>
439440
)}
440441
{/* Pagination and Page Size Controls */}

0 commit comments

Comments
 (0)