Skip to content
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

feat: Adapt search placeholder if assistant is disabled #2255

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading