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

Assistant: Change flags name #2230

Merged
merged 5 commits into from
Oct 28, 2024
Merged
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
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
4 changes: 2 additions & 2 deletions src/components/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ const Home = ({ setAppsReady, wrapper }) => {
<Main className="u-flex-grow-1">
<ScrollToTopOnMount target={wrapper} />
{pathname === '/connected' && <Announcements />}
{flag('cozy.assistant.enabled') && !isMobile && (
{flag('cozy.searchbar.enabled') && !isMobile && (
<AssistantWrapperDesktop />
)}
<Content
className={cx('u-flex u-flex-column u-ph-1', {
[styles['homeMainContent--withAssistant']]:
isMobile && flag('cozy.assistant.enabled'),
isMobile && flag('cozy.searchbar.enabled'),
[styles['homeMainContent--immersive']]:
getFlagshipMetadata().immersive
})}
Expand Down
7 changes: 6 additions & 1 deletion src/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ const App = ({ accounts, konnectors, triggers }) => {
: null
const context = useQuery(contextQuery.definition, contextQuery.options)

const showAssistantForMobile = isFlagshipApp()
? flag('cozy.searchbar.enabled-for-flagship')
: flag('cozy.searchbar.enabled') && isMobile
Comment on lines +98 to +100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La variable showAssistantForMobile devrait plutôt s'appeler showSearchbarForMobile du coup?

Copy link
Contributor Author

@JF-Cozy JF-Cozy Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oui mais à ce compte là faudrait renommer les composants également... en fait "assistant" est parfois un mot générique pour toute la feature, parfois parle spécifiquement de la partie chat... je pense faire ça dans une autre PR


useEffect(() => {
setIsFetching(
[accounts, konnectors, triggers, context].some(collection =>
Expand All @@ -112,6 +116,7 @@ const App = ({ accounts, konnectors, triggers }) => {
const flags = toFlagNames(context.attributes.features)
enableFlags(flags)
}

useEffect(() => {
setIsReady(
appsReady &&
Expand Down Expand Up @@ -194,7 +199,7 @@ const App = ({ accounts, konnectors, triggers }) => {
</div>
<FooterLogo />
</MainView>
{flag('cozy.assistant.enabled') && isMobile && <AssistantWrapperMobile />}
{showAssistantForMobile && <AssistantWrapperMobile />}
{isFlagshipApp() && <DefaultRedirectionSnackbar />}
{flag(FLAG_FAB_BUTTON_ENABLED) && isMobile && <AddButton />}
</>
Expand Down
2 changes: 1 addition & 1 deletion src/dataproxy/DataProxyProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const DataProxyProvider = React.memo(({ children }) => {

const initIframe = async () => {
try {
if (!flag('cozy.assistant.withSearchResult')) {
if (!flag('cozy.search.enabled')) {
log.log(
'Dataproxy features will be disabled due to missing feature flags'
)
Expand Down
Loading