From f84d0ab2ac7ce9d26f63b8d0de7b85f1c6cc7f1b Mon Sep 17 00:00:00 2001 From: Paul Tran-Van Date: Mon, 9 Dec 2024 16:26:33 +0100 Subject: [PATCH] feat: Adapt search placeholder if assistant is disabled 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. --- src/assistant/AssistantWrapperMobile.jsx | 6 +++++- src/assistant/Search/SearchBarDesktop.jsx | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/assistant/AssistantWrapperMobile.jsx b/src/assistant/AssistantWrapperMobile.jsx index ad9407e21..34e82130a 100644 --- a/src/assistant/AssistantWrapperMobile.jsx +++ b/src/assistant/AssistantWrapperMobile.jsx @@ -25,6 +25,8 @@ export const AssistantWrapperMobile = () => { const { t } = useI18n() const navigate = useNavigate() + const isAssistantEnabled = flag('cozy.assistant.enabled') + return (
{ } type="button" - label={t('assistant.search.placeholder')} + label={ + isAssistantEnabled ? t('assistant.search.placeholder') : undefined // Fallback on SearchBar default + } onClick={() => navigate('connected/search')} />
diff --git a/src/assistant/Search/SearchBarDesktop.jsx b/src/assistant/Search/SearchBarDesktop.jsx index e22846ed6..b4ec4d906 100644 --- a/src/assistant/Search/SearchBarDesktop.jsx +++ b/src/assistant/Search/SearchBarDesktop.jsx @@ -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 }) @@ -84,7 +86,9 @@ const SearchBarDesktop = ({ value, onClear, onChange }) => { ref={searchRef} size="large" icon={} - placeholder={t('assistant.search.placeholder')} + placeholder={ + isAssistantEnabled ? t('assistant.search.placeholder') : undefined // Fallback on SearchBar default + } value={value} componentsProps={{ inputBase: { onKeyDown: handleKeyDown }