Skip to content

Commit

Permalink
Merge branch 'development' into fix/2048-apps-files-approval
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Kezik authored Jan 28, 2025
2 parents 001ee28 + b2f78e0 commit 23b039e
Show file tree
Hide file tree
Showing 29 changed files with 497 additions and 346 deletions.
3 changes: 3 additions & 0 deletions apps/chat/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ RECENT_MODELS_IDS="gpt-35-turbo,gpt-4,epam10k-semantic-search,gpt-world,mirror"
RECENT_ADDONS_IDS="addon-epam10k-golden-qna,addon-epam10k-semantic-search"
PUBLICATION_FILTERS="title,job title,role,dial_roles"

# Default header size limit aligned with Docker's default value for consistency
NODE_OPTIONS="--max-http-header-size=32768"

# Themes
# THEMES_CONFIG_HOST=""

Expand Down
2 changes: 1 addition & 1 deletion apps/chat/src/components/Chat/ModelList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export const ModelList = ({

const handleEdit = useCallback(
(currentEntity: DialAIEntityModel) => {
dispatch(ApplicationActions.get(currentEntity.id));
dispatch(ApplicationActions.get({ applicationId: currentEntity.id }));
handleOpenApplicationModal(getApplicationType(currentEntity));
},
[dispatch, handleOpenApplicationModal],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ export function PublicationControlsView<
unselectConversation();
unselectPrompt();
dispatch(
ApplicationActions.get(
resourcesToReview[publicationIdx + offset].reviewUrl,
),
ApplicationActions.get({
applicationId: resourcesToReview[publicationIdx + offset].reviewUrl,
}),
);
dispatch(PublicationActions.setIsApplicationReview(true));
}
Expand Down
11 changes: 4 additions & 7 deletions apps/chat/src/components/Chat/Publish/PublicationHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,10 @@ export function PublicationHandler({ publication }: Props) {
};

const startApplicationsReview = () => {
dispatch(
ApplicationActions.get(
applicationsToReviewIds.length
? applicationsToReviewIds[0].reviewUrl
: reviewedApplicationsIds[0].reviewUrl,
),
);
const applicationId = applicationsToReviewIds.length
? applicationsToReviewIds[0].reviewUrl
: reviewedApplicationsIds[0].reviewUrl;
dispatch(ApplicationActions.get({ applicationId }));
dispatch(PublicationActions.setIsApplicationReview(true));
};

Expand Down
2 changes: 1 addition & 1 deletion apps/chat/src/components/Chat/TalkTo/TalkToModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const TalkToModalView = ({

const handleEditApplication = useCallback(
(entity: DialAIEntityModel) => {
dispatch(ApplicationActions.get(entity.id));
dispatch(ApplicationActions.get({ applicationId: entity.id }));
setEditModel(entity);
},
[dispatch],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ export const CodeAppView: FC<ViewProps> = ({
label={t('Select folder with source files')}
rules={validators['sources']}
error={errors.sources?.message || errors.sourceFiles?.message}
disabled={isSharedWithMe}
tooltip={
isSharedWithMe ? getSharedTooltip('folder with source files') : ''
}
/>

{sources && <CodeEditor sourcesFolderId={sources} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { constructPath } from '@/src/utils/app/file';
import {
getChildAndCurrentFoldersIdsById,
getNextDefaultName,
splitEntityId,
} from '@/src/utils/app/folders';
import { getIdWithoutRootPathSegments } from '@/src/utils/app/id';

Expand Down Expand Up @@ -394,6 +395,7 @@ export const CodeEditor = ({ sourcesFolderId }: Props) => {
const handleUploadEmptyFile = useCallback(
(fileName: string) => {
if (fileName && sourcesFolderId) {
const { bucket } = splitEntityId(sourcesFolderId);
dispatch(
FilesActions.uploadFile({
fileContent: new File([''], fileName, {
Expand All @@ -402,6 +404,7 @@ export const CodeEditor = ({ sourcesFolderId }: Props) => {
relativePath: getIdWithoutRootPathSegments(sourcesFolderId),
id: constructPath(sourcesFolderId, fileName),
name: fileName,
bucket,
}),
);
setNewFileFolder(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ interface SourceFilesEditorProps {
value?: string;
onChange?: (v: string) => void;
error?: string;
tooltip?: string;
disabled?: boolean;
}

const _SourceFilesEditor: FC<SourceFilesEditorProps> = ({
value,
onChange,
error,
tooltip,
disabled,
}) => {
const { t } = useTranslation(Translation.Marketplace);

Expand Down Expand Up @@ -77,26 +81,31 @@ const _SourceFilesEditor: FC<SourceFilesEditorProps> = ({
>
{value ? getIdWithoutRootPathSegments(value) : t('No folder')}
</Tooltip>
<div className="flex items-center gap-3">
<span
className="h-full cursor-pointer text-accent-primary"
data-qa="change-button"
onClick={handleToggleFileManager}
>
{value ? t('Change') : t('Add')}
</span>
{value && (
<Tooltip tooltip={tooltip}>
<div className="flex items-center gap-3">
<button
onClick={() => {
onChange?.('');
}}
className="h-full cursor-pointer text-accent-primary disabled:cursor-not-allowed disabled:text-controls-disable"
data-qa="change-button"
type="button"
className="text-secondary hover:text-accent-primary"
disabled={disabled}
onClick={handleToggleFileManager}
>
<IconX size={18} />
{value ? t('Change') : t('Add')}
</button>
)}
</div>
{value && (
<button
onClick={() => {
onChange?.('');
}}
type="button"
disabled={disabled}
className="text-secondary hover:text-accent-primary disabled:cursor-not-allowed disabled:text-controls-disable"
>
<IconX size={18} />
</button>
)}
</div>
</Tooltip>
</div>
</div>

Expand Down
11 changes: 10 additions & 1 deletion apps/chat/src/components/Files/FileItemContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MouseEvent, MouseEventHandler, useMemo } from 'react';

import { useTranslation } from 'next-i18next';

import { isCurrentFolderOrParentSharedWithMeAndCanEdit } from '@/src/utils/app/folders';
import { isMyEntity } from '@/src/utils/app/id';

import { FeatureType } from '@/src/types/common';
Expand All @@ -17,6 +18,7 @@ import { DisplayMenuItemProps } from '@/src/types/menu';
import { Translation } from '@/src/types/translation';

import { CodeEditorSelectors } from '@/src/store/codeEditor/codeEditor.reducer';
import { FilesSelectors } from '@/src/store/files/files.reducers';
import { useAppSelector } from '@/src/store/hooks';
import { SettingsSelectors } from '@/src/store/settings/settings.reducers';

Expand Down Expand Up @@ -61,6 +63,8 @@ export function FileItemContextMenu({
);
const isCodeEditorFile = !!useAppSelector(selectFileContentSelector);

const folders = useAppSelector(FilesSelectors.selectFolders);

const menuItems: DisplayMenuItemProps[] = useMemo(
() => [
{
Expand Down Expand Up @@ -111,7 +115,11 @@ export function FileItemContextMenu({
{
name: t('Delete'),
dataQa: 'delete',
display: isMyEntity(file, FeatureType.File) || !!file.sharedWithMe,
display:
isMyEntity(file, FeatureType.File) ||
!!file.sharedWithMe ||
isCurrentFolderOrParentSharedWithMeAndCanEdit(folders, file.folderId),

Icon: IconTrashX,
onClick: onDelete,
},
Expand All @@ -125,6 +133,7 @@ export function FileItemContextMenu({
onUnshare,
isPublishingConversationEnabled,
onUnpublish,
folders,
onDelete,
onOpenChange,
],
Expand Down
2 changes: 1 addition & 1 deletion apps/chat/src/components/Marketplace/ApplicationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export const ApplicationCard = ({
triggerIconSize={18}
className="m-0 xl:invisible group-hover:xl:visible"
/>
{!isMyApp && (
{!isMyApp && !entity.sharedWithMe && (
<Tooltip
tooltip={
installedModelIds.has(entity.reference)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,35 +200,36 @@ export const ApplicationDetailsFooter = ({
</button>
</Tooltip>
)}
{isMyApp ? (
<Tooltip tooltip={t(getDisabledTooltip(entity, 'Delete'))}>
<button
disabled={isModifyDisabled}
onClick={() => onDelete(entity)}
className="icon-button"
data-qa="application-delete"
>
<IconTrashX size={24} />
</button>
</Tooltip>
) : (
<Tooltip
tooltip={
installedModelIds.has(entity.reference)
? t('Remove from My workspace')
: t('Add to My workspace')
}
isTriggerClickable
>
<button
onClick={() => onBookmarkClick(entity)}
className="icon-button"
data-qa="application-bookmark"
{!entity.sharedWithMe &&
(isMyApp ? (
<Tooltip tooltip={t(getDisabledTooltip(entity, 'Delete'))}>
<button
disabled={isModifyDisabled}
onClick={() => onDelete(entity)}
className="icon-button"
data-qa="application-delete"
>
<IconTrashX size={24} />
</button>
</Tooltip>
) : (
<Tooltip
tooltip={
installedModelIds.has(entity.reference)
? t('Remove from My workspace')
: t('Add to My workspace')
}
isTriggerClickable
>
<Bookmark size={24} />
</button>
</Tooltip>
)}
<button
onClick={() => onBookmarkClick(entity)}
className="icon-button"
data-qa="application-bookmark"
>
<Bookmark size={24} />
</button>
</Tooltip>
))}

{isApplicationId(entity.id) && (isMyApp || isPublicApp) && (
<Tooltip tooltip={isPublicApp ? t('Unpublish') : t('Publish')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,34 +59,6 @@ export const ApplicationDetailsHeader = ({ entity }: Props) => {
const isApplicationsSharingEnabled = useAppSelector((state) =>
SettingsSelectors.isFeatureEnabled(state, Feature.ApplicationsSharing),
);
// const dispatch = useAppDispatch();

// const contextMenuItems = useMemo(
// () => [
// {
// BrandIcon: IconLink,
// text: t('Copy link'),
// onClick: () => {
// dispatch(UIActions.showInfoToast(t('Link copied')));
// },
// },
// {
// BrandIcon: IconBrandFacebook,
// text: t('Share via Facebook'),
// onClick: () => {
// return 'Share via Facebook';
// },
// },
// {
// BrandIcon: IconBrandX,
// text: t('Share via X'),
// onClick: () => {
// return 'Share via X';
// },
// },
// ],
// [dispatch, t],
// );

return (
<header className="flex items-start justify-between px-3 py-4 md:p-6">
Expand Down Expand Up @@ -130,57 +102,7 @@ export const ApplicationDetailsHeader = ({ entity }: Props) => {
<FunctionStatusIndicator entity={entity} />
</div>
</div>
{/* <div className="flex items-center gap-5">
<Menu
listClassName="bg-layer-1 !z-[60] w-[290px]"
placement="bottom-end"
type="contextMenu"
data-qa="application-share-type-select"
trigger={
<button className="hidden items-center gap-3 text-accent-primary md:flex">
<IconShare className="[&_path]:fill-current" size={18} />
<span className="font-semibold">{t('Share')}</span>
</button>
}
>
<div className="divide-y divide-primary">
<div className="flex items-center gap-2 px-3 py-4">
<ModelIcon
isCustomTooltip
entity={entity}
entityId={entity.id}
size={24}
/>
<h5 className="text-xl">{entity.name}</h5>
</div>
<div>
{contextMenuItems.map(({ BrandIcon, text, ...props }) => (
<MenuItem
key={text}
item={
<>
<BrandIcon size={18} className="text-secondary" />
<span>{text}</span>
</>
}
className="flex w-full items-center gap-3 px-3 py-2 hover:bg-accent-primary-alpha"
{...props}
/>
))}
</div>
</div>
</Menu>
<button
className="text-secondary hover:text-accent-primary"
onClick={onClose}
>
<IconX size={24} />
</button>
</div> */}
</div>
{/* <h2 className="text-lg font-semibold leading-[18px] md:text-xl md:leading-6">
{application.title}
</h2> */}
</div>
</div>
{isMyApp && isApplicationsSharingEnabled && (
Expand Down
2 changes: 1 addition & 1 deletion apps/chat/src/components/Marketplace/TabRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export const TabRenderer = ({ screenState }: TabRendererProps) => {

const handleEditApplication = useCallback(
(entity: DialAIEntityModel) => {
dispatch(ApplicationActions.get(entity.id));
dispatch(ApplicationActions.get({ applicationId: entity.id }));
setApplicationModel({
entity,
action: ApplicationActionType.EDIT,
Expand Down
Loading

0 comments on commit 23b039e

Please sign in to comment.