-
Notifications
You must be signed in to change notification settings - Fork 14
New assistant UI #2925
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
Merged
Merged
New assistant UI #2925
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2d0f64a
refactor: Reorganize folder structure :recycle:
599a01a
feat: Migrate assistant-ui :sparkles:
4077038
feat: Add sidebar and search section :sparkles:
9b16cbe
feat: Implement source knowledge :sparkles:
72c13a1
feat: Display top bar in assistant page :sparkles:
c2ffce8
fix: Resolve conflict of yarn.lock :bug:
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import React, { forwardRef } from 'react' | ||
|
|
||
| import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem' | ||
| import Icon from 'cozy-ui/transpiled/react/Icon' | ||
| import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash' | ||
| import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon' | ||
| import ListItemText from 'cozy-ui/transpiled/react/ListItemText' | ||
|
|
||
| const makeComponent = (label, icon) => { | ||
| const Component = forwardRef((props, ref) => { | ||
| return ( | ||
| <ActionsMenuItem className="u-error" {...props} ref={ref}> | ||
| <ListItemIcon> | ||
| <Icon className="u-error" icon={icon} /> | ||
| </ListItemIcon> | ||
| <ListItemText primary={label} /> | ||
| </ActionsMenuItem> | ||
| ) | ||
| }) | ||
|
|
||
| Component.displayName = 'Delete' | ||
|
|
||
| return Component | ||
| } | ||
|
|
||
| export const remove = ({ t }) => { | ||
| const icon = TrashIcon | ||
| const label = t('assistant.sidebar.conversation.actions.delete') | ||
|
|
||
| return { | ||
| name: 'delete', | ||
| icon, | ||
| label, | ||
| Component: makeComponent(label, icon), | ||
| displayCondition: () => true, | ||
| action: () => { | ||
| // TO DO: Add action to remove | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import React, { forwardRef } from 'react' | ||
|
|
||
| import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem' | ||
| import Icon from 'cozy-ui/transpiled/react/Icon' | ||
| import RenameIcon from 'cozy-ui/transpiled/react/Icons/Rename' | ||
| import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon' | ||
| import ListItemText from 'cozy-ui/transpiled/react/ListItemText' | ||
|
|
||
| const makeComponent = (label, icon) => { | ||
| const Component = forwardRef((props, ref) => { | ||
| return ( | ||
| <ActionsMenuItem {...props} ref={ref}> | ||
| <ListItemIcon> | ||
| <Icon icon={icon} /> | ||
| </ListItemIcon> | ||
| <ListItemText primary={label} /> | ||
| </ActionsMenuItem> | ||
| ) | ||
| }) | ||
|
|
||
| Component.displayName = 'Rename' | ||
|
|
||
| return Component | ||
| } | ||
|
|
||
| export const rename = ({ t }) => { | ||
| const icon = RenameIcon | ||
| const label = t('assistant.sidebar.conversation.actions.rename') | ||
|
|
||
| return { | ||
| name: 'rename', | ||
| icon, | ||
| label, | ||
| Component: makeComponent(label, icon), | ||
| displayCondition: () => true, | ||
| action: () => { | ||
| // TO DO: Add action to remove | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import React, { forwardRef } from 'react' | ||
|
|
||
| import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem' | ||
| import Icon from 'cozy-ui/transpiled/react/Icon' | ||
| import ShareIcon from 'cozy-ui/transpiled/react/Icons/Share' | ||
| import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon' | ||
| import ListItemText from 'cozy-ui/transpiled/react/ListItemText' | ||
|
|
||
| const makeComponent = (label, icon) => { | ||
| const Component = forwardRef((props, ref) => { | ||
| return ( | ||
| <ActionsMenuItem {...props} ref={ref}> | ||
| <ListItemIcon> | ||
| <Icon icon={icon} /> | ||
| </ListItemIcon> | ||
| <ListItemText primary={label} /> | ||
| </ActionsMenuItem> | ||
| ) | ||
| }) | ||
|
|
||
| Component.displayName = 'Share' | ||
|
|
||
| return Component | ||
| } | ||
|
|
||
| export const share = ({ t }) => { | ||
| const icon = ShareIcon | ||
| const label = t('assistant.sidebar.conversation.actions.share') | ||
|
|
||
| return { | ||
| name: 'share', | ||
| icon, | ||
| label, | ||
| Component: makeComponent(label, icon), | ||
| displayCondition: () => true, | ||
| action: () => { | ||
| // TO DO: Add action to remove | ||
| } | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions
55
packages/cozy-search/src/components/Assistant/AssistantAvatar.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import cx from 'classnames' | ||
| import React from 'react' | ||
|
|
||
| import Icon from 'cozy-ui/transpiled/react/Icon' | ||
| import AssistantIcon from 'cozy-ui/transpiled/react/Icons/Assistant' | ||
| import AssistantColorIcon from 'cozy-ui/transpiled/react/Icons/AssistantColor' | ||
|
|
||
| import styles from './styles.styl' | ||
| import { DEFAULT_ASSISTANT } from '../constants' | ||
|
|
||
| const AssistantAvatar = ({ assistant, isSmall, className }) => { | ||
| if (!assistant) return | ||
|
lethemanh marked this conversation as resolved.
|
||
|
|
||
| if (assistant.id !== DEFAULT_ASSISTANT.id && !assistant.icon) { | ||
| return ( | ||
| <Icon | ||
| icon={AssistantIcon} | ||
| className={cx( | ||
| styles['assistant-icon'], | ||
| { | ||
| [styles['assistant-icon--small']]: isSmall | ||
| }, | ||
| className | ||
| )} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| return assistant.id === DEFAULT_ASSISTANT.id ? ( | ||
| <Icon | ||
| icon={AssistantColorIcon} | ||
| className={cx( | ||
| styles['assistant-icon'], | ||
| { | ||
| [styles['assistant-icon--small']]: isSmall | ||
| }, | ||
| className | ||
| )} | ||
| /> | ||
| ) : ( | ||
| <img | ||
| src={assistant.icon} | ||
| alt={assistant.name} | ||
| className={cx( | ||
| styles['assistant-icon'], | ||
| { | ||
| [styles['assistant-icon--small']]: isSmall | ||
| }, | ||
| className | ||
| )} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| export default AssistantAvatar | ||
|
zatteo marked this conversation as resolved.
|
||
56 changes: 56 additions & 0 deletions
56
packages/cozy-search/src/components/Assistant/AssistantContainer.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import cx from 'classnames' | ||
| import React from 'react' | ||
|
|
||
| import flag from 'cozy-flags' | ||
| import Divider from 'cozy-ui/transpiled/react/Divider' | ||
|
|
||
| import { useAssistant } from '../AssistantProvider' | ||
| import styles from './styles.styl' | ||
| import PrettyScrollbar from '../Containers/PrettyScrollbar' | ||
| import Conversation from '../Conversations/Conversation' | ||
| import CozyAssistantRuntimeProvider from '../CozyAssistantRuntimeProvider' | ||
| import SearchConversation from '../Search/SearchConversation' | ||
| import Sidebar from '../Sidebar' | ||
| import TwakeKnowledgePanel from '../TwakeKnowledges/TwakeKnowledgePanel' | ||
|
|
||
| const AssistantContainer = () => { | ||
| const { | ||
| isOpenSearchConversation, | ||
| openedKnowledgePanel, | ||
| setOpenedKnowledgePanel | ||
| } = useAssistant() | ||
|
|
||
| return ( | ||
| <div | ||
| className={cx( | ||
| 'u-flex u-ov-hidden u-h-100', | ||
| styles['assistant-container'] | ||
| )} | ||
| > | ||
| <Sidebar className="u-w-5 u-pb-1 u-bg-white" /> | ||
|
|
||
| <Divider orientation="vertical" flexItem /> | ||
|
|
||
| <PrettyScrollbar className="u-flex-auto u-flex u-flex-column u-pb-1 u-ov-hidden u-bg-white"> | ||
| {isOpenSearchConversation && | ||
| flag('cozy.search-conversation.enabled') ? ( | ||
| <SearchConversation /> | ||
| ) : ( | ||
| <CozyAssistantRuntimeProvider> | ||
| <Conversation /> | ||
| </CozyAssistantRuntimeProvider> | ||
| )} | ||
| </PrettyScrollbar> | ||
|
|
||
| {openedKnowledgePanel && flag('cozy.source-knowledge.enabled') && ( | ||
| <div className="u-ml-half u-h-100 u-maw-7"> | ||
| <TwakeKnowledgePanel | ||
| onClose={() => setOpenedKnowledgePanel(undefined)} | ||
| /> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default AssistantContainer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| .assistant-container | ||
| z-index 1 | ||
|
|
||
| .trigger-button | ||
| border-radius 20px | ||
| padding 4px 12px | ||
| border 1px solid var(--borderMainColor) | ||
| background-color var(--paperBackgroundColor) | ||
| text-transform none | ||
| min-width 0 | ||
|
|
||
| .assistant-icon | ||
| width 24px | ||
| height 24px | ||
| border-radius 50% | ||
| margin-right 8px | ||
| object-fit cover | ||
|
|
||
| &--small | ||
| width 20px | ||
| height 20px | ||
|
|
||
| .menu-item | ||
| display flex !important | ||
| align-items center !important | ||
| justify-content space-between !important | ||
|
|
||
| &.create-item | ||
| border-top 1px solid var(--dividerColor) | ||
|
|
||
| &:hover | ||
| .menu-item-icon-button | ||
| display block !important | ||
|
|
||
| .menu-item-icon-button | ||
| display none !important | ||
|
|
||
| .create-icon | ||
| margin-right 8px |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.