Skip to content

Commit

Permalink
Merge branch 'development' into fix/language-syntax-extended
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaBondar authored Dec 20, 2024
2 parents e0cfba6 + 96b1bfb commit ae8339a
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 22 deletions.
42 changes: 38 additions & 4 deletions apps/chat/src/components/Chat/TalkTo/TalkToCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
IconFileDescription,
IconPencilMinus,
IconPlayerPlay,
IconPlaystationSquare,
Expand All @@ -18,8 +19,10 @@ import {
getApplicationSimpleStatus,
getModelShortDescription,
isApplicationStatusUpdating,
isExecutableApp,
} from '@/src/utils/app/application';
import { getRootId } from '@/src/utils/app/id';
import { isEntityIdPublic } from '@/src/utils/app/publications';
import { PseudoModel, isPseudoModel } from '@/src/utils/server/api';

import {
Expand Down Expand Up @@ -50,7 +53,8 @@ import { ApplicationTopic } from '@/src/components/Marketplace/ApplicationTopic'
import { FunctionStatusIndicator } from '@/src/components/Marketplace/FunctionStatusIndicator';

import LoaderIcon from '@/public/images/icons/loader.svg';
import { Feature } from '@epam/ai-dial-shared';
import UnpublishIcon from '@/public/images/icons/unpublish.svg';
import { Feature, PublishActions } from '@epam/ai-dial-shared';

const DESKTOP_ICON_SIZE = 80;
const TABLET_ICON_SIZE = 48;
Expand Down Expand Up @@ -78,10 +82,11 @@ interface ApplicationCardProps {
disabled: boolean;
isUnavailableModel: boolean;
onClick: (entity: DialAIEntityModel) => void;
onPublish: (entity: DialAIEntityModel) => void;
onPublish: (entity: DialAIEntityModel, action: PublishActions) => void;
onDelete: (entity: DialAIEntityModel) => void;
onEdit: (entity: DialAIEntityModel) => void;
onSelectVersion: (entity: DialAIEntityModel) => void;
onOpenLogs: (entity: DialAIEntityModel) => void;
}

export const TalkToCard = ({
Expand All @@ -95,6 +100,7 @@ export const TalkToCard = ({
onEdit,
onPublish,
onSelectVersion,
onOpenLogs,
}: ApplicationCardProps) => {
const { t } = useTranslation(Translation.Marketplace);

Expand All @@ -109,6 +115,10 @@ export const TalkToCard = ({
);
const isAdmin = useAppSelector(AuthSelectors.selectIsAdmin);

const isMyApp = entity.id.startsWith(
getRootId({ featureType: FeatureType.Application }),
);
const isExecutable = isExecutableApp(entity) && (isMyApp || isAdmin);
const screenState = useScreenState();

const versionsToSelect = useMemo(() => {
Expand Down Expand Up @@ -205,7 +215,29 @@ export const TalkToCard = ({
Icon: IconWorldShare,
onClick: (e: React.MouseEvent) => {
e.stopPropagation();
onPublish(entity);
onPublish?.(entity, PublishActions.ADD);
},
},
{
name: t('Unpublish'),
dataQa: 'unpublish',
display: isEntityIdPublic(entity) && !!onPublish,
Icon: UnpublishIcon,
onClick: (e: React.MouseEvent) => {
e.stopPropagation();
onPublish?.(entity, PublishActions.DELETE);
},
},
{
name: t('Logs'),
dataQa: 'app-logs',
display:
isExecutable && playerStatus === SimpleApplicationStatus.UNDEPLOY,
Icon: IconFileDescription,
onClick: (e: React.MouseEvent) => {
e.preventDefault();
e.stopPropagation();
onOpenLogs(entity);
},
},
{
Expand All @@ -230,10 +262,12 @@ export const TalkToCard = ({
isCodeAppsEnabled,
PlayerIcon,
onEdit,
isModifyDisabled,
onPublish,
isExecutable,
onDelete,
isModifyDisabled,
handleUpdateFunctionStatus,
onOpenLogs,
],
);

Expand Down
61 changes: 47 additions & 14 deletions apps/chat/src/components/Chat/TalkTo/TalkToModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { ConfirmDialog } from '@/src/components/Common/ConfirmDialog';
import Modal from '@/src/components/Common/Modal';
import { NoResultsFound } from '@/src/components/Common/NoResultsFound';

import { ApplicationLogs } from '../../Marketplace/ApplicationLogs';
import { TalkToCard } from './TalkToCard';

import { Feature, PublishActions, ShareEntity } from '@epam/ai-dial-shared';
Expand Down Expand Up @@ -81,8 +82,12 @@ interface SliderModelsGroupProps {
rowsCount: number;
onEditApplication: (entity: DialAIEntityModel) => void;
onDeleteApplication: (entity: DialAIEntityModel) => void;
onSetPublishEntity: (entity: DialAIEntityModel) => void;
onSetPublishEntity: (
entity: DialAIEntityModel,
action: PublishActions,
) => void;
onSelectModel: (entity: DialAIEntityModel) => void;
onOpenLogs: (entity: DialAIEntityModel) => void;
}
const SliderModelsGroup = ({
modelsGroup,
Expand All @@ -93,6 +98,7 @@ const SliderModelsGroup = ({
onDeleteApplication,
onSetPublishEntity,
onSelectModel,
onOpenLogs,
}: SliderModelsGroupProps) => {
const config = getMaxChunksCountConfig();

Expand Down Expand Up @@ -145,6 +151,7 @@ const SliderModelsGroup = ({
onPublish={onSetPublishEntity}
onSelectVersion={onSelectModel}
onClick={onSelectModel}
onOpenLogs={onOpenLogs}
/>
);
})}
Expand Down Expand Up @@ -191,12 +198,15 @@ const TalkToModalView = ({
const [activeSlide, setActiveSlide] = useState(0);
const [editModel, setEditModel] = useState<DialAIEntityModel>();
const [deleteModel, setDeleteModel] = useState<DialAIEntityModel>();
const [publishModel, setPublishModel] = useState<
ShareEntity & { iconUrl?: string }
>();
const [logModel, setLogModel] = useState<DialAIEntityModel>();
const [publishModel, setPublishModel] = useState<{
entity: ShareEntity & { iconUrl?: string };
action: PublishActions;
}>();
const [sliderHeight, setSliderHeight] = useState(0);
const [sharedConversationNewModel, setSharedConversationNewModel] =
useState<DialAIEntityModel>();
const [isOpenLogs, setIsOpenLogs] = useState<boolean>();

const sliderRef = useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -430,17 +440,32 @@ const TalkToModalView = ({
[deleteModel, dispatch],
);

const handleSetPublishEntity = useCallback((entity: DialAIEntityModel) => {
setPublishModel({
name: entity.name,
id: ApiUtils.decodeApiUrl(entity.id),
folderId: getFolderIdFromEntityId(entity.id),
iconUrl: entity.iconUrl,
});
}, []);
const handleSetPublishEntity = useCallback(
(entity: DialAIEntityModel, action: PublishActions) =>
setPublishModel({
entity: {
name: entity.name,
id: ApiUtils.decodeApiUrl(entity.id),
folderId: getFolderIdFromEntityId(entity.id),
iconUrl: entity.iconUrl,
},
action,
}),
[],
);

const handlePublishClose = useCallback(() => setPublishModel(undefined), []);

const handleCloseApplicationLogs = useCallback(
() => setIsOpenLogs(false),
[setIsOpenLogs],
);

const handleOpenApplicationLogs = useCallback((entity: DialAIEntityModel) => {
setIsOpenLogs(true);
setLogModel(entity);
}, []);

const handleDeleteApplication = useCallback(
(entity: DialAIEntityModel) => {
setDeleteModel(entity);
Expand Down Expand Up @@ -524,6 +549,7 @@ const TalkToModalView = ({
onDeleteApplication={handleDeleteApplication}
onSetPublishEntity={handleSetPublishEntity}
onSelectModel={handleSelectModel}
onOpenLogs={handleOpenApplicationLogs}
/>
))
) : (
Expand Down Expand Up @@ -631,11 +657,18 @@ const TalkToModalView = ({
)}
{publishModel && (
<PublishModal
entity={publishModel}
entity={publishModel.entity}
type={SharingType.Application}
isOpen={!!publishModel}
onClose={handlePublishClose}
publishAction={PublishActions.ADD}
publishAction={publishModel.action}
/>
)}
{logModel && isOpenLogs && (
<ApplicationLogs
isOpen={isOpenLogs}
onClose={handleCloseApplicationLogs}
entityId={logModel.id}
/>
)}

Expand Down
7 changes: 3 additions & 4 deletions apps/chat/src/components/Marketplace/ApplicationLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const LogsView = () => {
}

return (
<div className="flex grow flex-col items-center gap-1 overflow-y-auto break-all px-3 pb-6 md:px-6">
<div className="flex grow flex-col gap-1 overflow-y-auto break-all px-3 pb-6 md:px-6">
<div className="flex flex-col gap-1">
{applicationLogs.split('\n').map((log, index) => (
<p key={index}>{log}</p>
Expand Down Expand Up @@ -128,11 +128,10 @@ export const ApplicationLogs = ({
}: ApplicationLogsProps) => {
return (
<Modal
portalId="chat"
portalId="theme-main"
state={isOpen}
dataQa="marketplace-application-logs"
overlayClassName="!z-40"
containerClassName="flex w-full flex-col min-h-[350px] xl:max-w-[820px] max-w-[800px]"
containerClassName="group/modal flex w-full flex-col min-h-[350px] xl:max-w-[820px] max-w-[800px]"
onClose={onClose}
>
<LogsHeader />
Expand Down

0 comments on commit ae8339a

Please sign in to comment.