Skip to content

Commit

Permalink
feat: Adapt search placeholder if assistant is disabled
Browse files Browse the repository at this point in the history
When the assistant is enabled, the search wording suggests the user to
ask a question, that could be answered by the assistant or the search.
But if the assistant is not enabled, we should adapt the wording to
focus on search only.
  • Loading branch information
paultranvan committed Dec 9, 2024
1 parent 3385442 commit f84d0ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/assistant/AssistantWrapperMobile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const AssistantWrapperMobile = () => {
const { t } = useI18n()
const navigate = useNavigate()

const isAssistantEnabled = flag('cozy.assistant.enabled')

return (
<CozyTheme variant="normal">
<div
Expand All @@ -43,7 +45,9 @@ export const AssistantWrapperMobile = () => {
<Icon className="u-ml-1 u-mr-half" icon={AssistantIcon} size={24} />
}
type="button"
label={t('assistant.search.placeholder')}
label={
isAssistantEnabled ? t('assistant.search.placeholder') : undefined // Fallback on SearchBar default
}
onClick={() => navigate('connected/search')}
/>
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/assistant/Search/SearchBarDesktop.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ const SearchBarDesktop = ({ value, onClear, onChange }) => {
const searchRef = useRef()
const listRef = useRef()

const isAssistantEnabled = flag('cozy.assistant.enabled')

const handleClick = () => {
if (!flag('cozy.assistant.enabled')) return
if (!isAssistantEnabled) return

const conversationId = makeConversationId()
onAssistantExecute({ value, conversationId })
Expand Down Expand Up @@ -84,7 +86,9 @@ const SearchBarDesktop = ({ value, onClear, onChange }) => {
ref={searchRef}
size="large"
icon={<Icon className="u-mh-1" icon={AssistantIcon} size={32} />}
placeholder={t('assistant.search.placeholder')}
placeholder={
isAssistantEnabled ? t('assistant.search.placeholder') : undefined // Fallback on SearchBar default
}
value={value}
componentsProps={{
inputBase: { onKeyDown: handleKeyDown }
Expand Down

0 comments on commit f84d0ab

Please sign in to comment.