Skip to content

Commit

Permalink
Merge pull request #1778 from gchq/BAI-1544-show-entry-kind-for-all-r…
Browse files Browse the repository at this point in the history
…esults-in-top-right-search

Bai 1544 show entry kind for all results in top right search
  • Loading branch information
IR96334 authored Jan 24, 2025
2 parents 78f5b72 + 2884a39 commit afd3fc8
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 38 deletions.
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

0 comments on commit afd3fc8

Please sign in to comment.