Skip to content

Commit

Permalink
feat(Assitant): Put some fonctionality behind assistant flag
Browse files Browse the repository at this point in the history
  • Loading branch information
JF-Cozy committed Oct 28, 2024
1 parent 0411cd7 commit cab1de6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
25 changes: 14 additions & 11 deletions src/assistant/ResultMenu/ResultMenuContent.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'

import flag from 'cozy-flags'
import List from 'cozy-ui/transpiled/react/List'
import Circle from 'cozy-ui/transpiled/react/Circle'
import PaperplaneIcon from 'cozy-ui/transpiled/react/Icons/Paperplane'
Expand Down Expand Up @@ -46,17 +47,19 @@ const ResultMenuContent = ({ onClick }) => {

return (
<List>
<ResultMenuItem
icon={
<Circle size="small">
<Icon icon={PaperplaneIcon} size={isMobile ? 12 : undefined} />
</Circle>
}
primaryText={searchValue}
query={searchValue}
secondaryText={t('assistant.search.result')}
onClick={onClick}
/>
{flag('cozy.assistant.enabled') && (
<ResultMenuItem
icon={
<Circle size="small">
<Icon icon={PaperplaneIcon} size={isMobile ? 12 : undefined} />
</Circle>
}
primaryText={searchValue}
query={searchValue}
secondaryText={t('assistant.search.result')}
onClick={onClick}
/>
)}
{dataProxyServicesAvailable && <SearchResult />}
</List>
)
Expand Down
3 changes: 3 additions & 0 deletions src/assistant/Search/SearchBar.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react'
import { useNavigate } from 'react-router-dom'

import flag from 'cozy-flags'
import { useBreakpoints } from 'cozy-ui/transpiled/react/providers/Breakpoints'

import { useSearch } from './SearchProvider'
Expand All @@ -21,6 +22,8 @@ const SearchBar = () => {
}

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

const conversationId = makeConversationId()
onAssistantExecute({ value: inputValue, conversationId })
navigate(`assistant/${conversationId}`)
Expand Down
5 changes: 4 additions & 1 deletion src/assistant/Views/SearchDialog.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import { useNavigate } from 'react-router-dom'

import flag from 'cozy-flags'
import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs'

import SearchProvider from '../Search/SearchProvider'
Expand Down Expand Up @@ -40,7 +41,9 @@ const SearchDialog = () => {
content={
<>
{searchValue !== '' && <ResultMenuContent onClick={handleClick} />}
<SearchSubmitFab searchValue={searchValue} onClick={handleClick} />
{flag('cozy.assistant.enabled') && (
<SearchSubmitFab searchValue={searchValue} onClick={handleClick} />
)}
</>
}
onClose={handleClose}
Expand Down

0 comments on commit cab1de6

Please sign in to comment.