Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bai 1544 show entry kind for all results in top right search #1778

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 54 additions & 18 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 28 additions & 20 deletions frontend/src/wrapper/EntrySearch.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SearchIcon from '@mui/icons-material/Search'
import { Box, InputBase, List, ListItemButton, ListItemText, Popover, Stack } from '@mui/material'
import { Box, Chip, InputBase, List, ListItem, ListItemButton, ListItemText, Popover, Stack } from '@mui/material'
import { alpha, styled, useTheme } from '@mui/material/styles'
import { useListModels } from 'actions/model'
import { ChangeEvent, useMemo, useState } from 'react'
Expand All @@ -8,6 +8,8 @@ import Loading from 'src/common/Loading'
import useDebounce from 'src/hooks/useDebounce'
import Link from 'src/Link'
import MessageAlert from 'src/MessageAlert'
import { EntryKindLabel } from 'types/types'
import { toTitleCase } from 'utils/stringUtils'

const Search = styled('div')(({ theme }) => ({
borderRadius: theme.shape.borderRadius,
Expand Down Expand Up @@ -53,28 +55,34 @@ export default function EntrySearch() {
const modelList = useMemo(
() =>
entries.map((entry) => (
<Box key={entry.id} sx={{ maxWidth: '300px' }}>
<Box key={entry.id} sx={{ maxWidth: '400px' }}>
<Link href={`/${entry.kind}/${entry.id}`} noLinkStyle>
<ListItemButton>
<ListItemText
primary={entry.name}
secondary={entry.description}
slotProps={{
primary: {
style: {
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
overflow: 'hidden',
color: theme.palette.primary.main,
<ListItem
disablePadding
secondaryAction={<Chip label={toTitleCase(EntryKindLabel[entry.kind])} size='small' />}
>
<ListItemButton>
<ListItemText
primary={entry.name}
secondary={entry.description}
slotProps={{
primary: {
sx: {
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
overflow: 'hidden',
color: theme.palette.primary.main,
mr: 6,
},
},
},

secondary: {
style: { whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden' },
},
}}
/>
</ListItemButton>
secondary: {
sx: { whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden', mr: 6 },
},
}}
/>
</ListItemButton>
</ListItem>
</Link>
</Box>
)),
Expand Down
Loading