-
Notifications
You must be signed in to change notification settings - Fork 26
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
[PRD-610] feat: Allow click on searched file's path #2246
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on peut squash les 2 commits je pense There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. J'ai voulu laisser la contribution de @Ldoppea 😉 |
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we secure this by checking also the value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so, because I tested with an |
||
return <SuggestionItemTextHighlighted text={text} query={query} /> | ||
} | ||
|
||
const app = { slug } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: For now it is not a problem, but |
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
est-ce qu'on a besoin de rajouter ces 2 props qui ne sont au final utilisé que par SuggestionItemTextSecondary ? 🤔 Est-ce qu'on peut pas plutôt générer le lien en amont et transmettre un composant via
secondaryText
? Car au final ici on ne fait qu'afficher autre chose en secondaryText selon certaines conditions...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l'API de search ne peut pas transmettre un composant, ça va passer par le dataproxy et de la sérialisation. Et ça me semble bien qu'elle n'ait aucune responsabilité UI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
j'ai pas compris le rapport avec l'API. Ici je parle des composants front qu'on a construit dans l'app. Ce qu'on fait ici c'est que dans un certain cas (quand y'a une url) on veut afficher un lien plutôt qu'un texte, et ce au final dans un ListItemText en prop "secondary". Au lieu de passer result.secondaryUrl je me demandais si on ne pouvait pas rester avec la prop secondaryText, sauf qu'on ne lui passerait pas result.secondary mais un composant (celui nécessaire pour construire le lien)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah je pensais que tu parlais côté dataproxy. Pas d'avis particulier, si ce n'est que ça marche comme ça et n'apporte pas de désavantage particulier 😄