Skip to content

Commit

Permalink
publish: Merge pull request #281 from cozy/feat/add-translate-apps
Browse files Browse the repository at this point in the history
generated from commit 7e07ec9
  • Loading branch information
Travis CI User committed Nov 14, 2024
1 parent e580d57 commit 9088327
Show file tree
Hide file tree
Showing 6 changed files with 513 additions and 455 deletions.
2 changes: 2 additions & 0 deletions en/cozy-home/src/assistant/ResultMenu/ResultMenuContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ const SearchResult = () => {
<ResultMenuItem
key={result.id || idx}
icon={result.icon}
slug={result.slug}
primaryText={result.primary}
secondaryText={result.secondary}
secondaryUrl={result.secondaryUrl}
query={searchValue}
highlightQuery="true"
selected={
Expand Down
10 changes: 9 additions & 1 deletion en/cozy-home/src/assistant/ResultMenu/ResultMenuItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import ListItem from 'cozy-ui/transpiled/react/ListItem'
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
import SuggestionItemTextHighlighted from './SuggestionItemTextHighlighted'
import SuggestionItemTextSecondary from './SuggestionItemTextSecondary'

const ResultMenuItem = ({
icon,
primaryText,
secondaryText,
secondaryUrl,
slug,
selected,
onClick,
query,
Expand All @@ -32,7 +35,12 @@ const ResultMenuItem = ({
)

const secondary = highlightQuery ? (
<SuggestionItemTextHighlighted text={secondaryText} query={query} />
<SuggestionItemTextSecondary
text={secondaryText}
query={query}
slug={slug}
url={secondaryUrl}
/>
) : (
secondaryText
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Code copied and adapted from cozy-drive
*
* See source: https://github.com/cozy/cozy-drive/blob/fbe2df67199683b23a40f476ccdacb00ee027459/src/modules/search/components/SuggestionItemTextSecondary.jsx
*/
import React from 'react'

import AppLinker from 'cozy-ui/transpiled/react/AppLinker'
import SuggestionItemTextHighlighted from './SuggestionItemTextHighlighted'
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
import Link from 'cozy-ui/transpiled/react/Link'

const SuggestionItemTextSecondary = ({ text, query, url, slug }) => {
const { isMobile } = useBreakpoints()

if (isMobile || !url) {
return <SuggestionItemTextHighlighted text={text} query={query} />
}

const app = { slug }
return (
<AppLinker app={app} href={url}>
{({ href, onClick }) => (
<Link
color="textSecondary"
underline="hover"
href={href}
onClick={e => {
e.stopPropagation()
if (typeof onClick == 'function') {
onClick(e)
}
}}
>
<SuggestionItemTextHighlighted
text={text}
query={query}
slug={slug}
/>
</Link>
)}
</AppLinker>
)
}

export default SuggestionItemTextSecondary
2 changes: 2 additions & 0 deletions en/cozy-home/src/assistant/Search/useFetchResult.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const useFetchResult = searchValue => {
return {
id: r.doc._id,
icon: icon,
slug: r.slug,
secondaryUrl: r.secondaryUrl,
primary: r.title,
secondary: r.subTitle,
onClick: () => {
Expand Down
Loading

0 comments on commit 9088327

Please sign in to comment.