forked from epam/ai-dial-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
1b8d72c
commit e825189
Showing
11 changed files
with
301 additions
and
138 deletions.
There are no files selected for viewing
138 changes: 138 additions & 0 deletions
138
apps/chat/src/components/Chat/Publish/PublicationItemsList.tsx
This file contains 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,138 @@ | ||
import { useTranslation } from 'next-i18next'; | ||
|
||
import classNames from 'classnames'; | ||
|
||
import { constructPath } from '@/src/utils/app/file'; | ||
import { splitEntityId } from '@/src/utils/app/folders'; | ||
|
||
import { ConversationInfo } from '@/src/types/chat'; | ||
import { ApiKeys, Entity } from '@/src/types/common'; | ||
import { DialFile } from '@/src/types/files'; | ||
import { PublishActions } from '@/src/types/publication'; | ||
import { SharingType } from '@/src/types/share'; | ||
import { Translation } from '@/src/types/translation'; | ||
|
||
import CollapsibleSection from '@/src/components/Common/CollapsibleSection'; | ||
import { | ||
ConversationRow, | ||
PromptsRow, | ||
} from '@/src/components/Common/ReplaceConfirmationModal/Components'; | ||
|
||
import { | ||
ConversationPublicationResources, | ||
FilePublicationResources, | ||
PromptPublicationResources, | ||
} from './PublicationResources'; | ||
|
||
interface Props { | ||
type: SharingType; | ||
entity: Entity; | ||
entities: Entity[]; | ||
path: string; | ||
files: DialFile[]; | ||
containerClassNames?: string; | ||
collapsibleSectionClassNames?: string; | ||
} | ||
|
||
export function PublicationItemsList({ | ||
type, | ||
entities, | ||
entity, | ||
path, | ||
files, | ||
containerClassNames, | ||
collapsibleSectionClassNames, | ||
}: Props) { | ||
const { t } = useTranslation(Translation.Chat); | ||
|
||
return ( | ||
<div | ||
className={classNames( | ||
'flex w-full flex-col gap-[2px] md:max-w-[550px]', | ||
containerClassNames, | ||
)} | ||
> | ||
{(type === SharingType.Conversation || | ||
type === SharingType.ConversationFolder) && ( | ||
<CollapsibleSection | ||
name={t('Conversations')} | ||
openByDefault | ||
className={collapsibleSectionClassNames} | ||
dataQa="conversations-to-send-request" | ||
> | ||
{type === SharingType.Conversation ? ( | ||
<ConversationRow | ||
itemComponentClassNames="cursor-pointer" | ||
item={entity as ConversationInfo} | ||
level={0} | ||
/> | ||
) : ( | ||
<ConversationPublicationResources | ||
rootFolder={entity} | ||
resources={entities.map((entity) => ({ | ||
action: PublishActions.ADD, | ||
sourceUrl: entity.id, | ||
targetUrl: constructPath( | ||
ApiKeys.Conversations, | ||
'public', | ||
path, | ||
splitEntityId(entity.id).name, | ||
), | ||
reviewUrl: entity.id, | ||
}))} | ||
forViewOnly | ||
/> | ||
)} | ||
</CollapsibleSection> | ||
)} | ||
{!!files.length && ( | ||
<CollapsibleSection | ||
name={t('Files')} | ||
openByDefault | ||
dataQa="files-to-send-request" | ||
className={collapsibleSectionClassNames} | ||
> | ||
<FilePublicationResources | ||
uploadedFiles={files} | ||
resources={[]} | ||
forViewOnly | ||
/> | ||
</CollapsibleSection> | ||
)} | ||
{(type === SharingType.Prompt || type === SharingType.PromptFolder) && ( | ||
<CollapsibleSection | ||
name={t('Prompts')} | ||
openByDefault | ||
dataQa="prompts-to-send-request" | ||
className={collapsibleSectionClassNames} | ||
> | ||
{type === SharingType.Prompt ? ( | ||
<PromptsRow | ||
itemComponentClassNames="cursor-pointer" | ||
item={entity} | ||
level={0} | ||
/> | ||
) : ( | ||
<PromptPublicationResources | ||
rootFolder={entity} | ||
resources={[ | ||
{ | ||
action: PublishActions.ADD, | ||
sourceUrl: entity.id, | ||
targetUrl: constructPath( | ||
ApiKeys.Prompts, | ||
'public', | ||
path, | ||
entity.name, | ||
), | ||
reviewUrl: entity.id, | ||
}, | ||
]} | ||
forViewOnly | ||
/> | ||
)} | ||
</CollapsibleSection> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains 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 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.