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

fix(chat): fix app icon on admin review panel (Issue #2699) #2705

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
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
57 changes: 47 additions & 10 deletions apps/chat/src/components/Chat/Publish/PublicationResources.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { IconDownload } from '@tabler/icons-react';
import { useMemo } from 'react';
import { useEffect, useState } from 'react';

import { useTranslation } from 'next-i18next';

import { catchError, finalize, forkJoin, map, of, tap } from 'rxjs';

import classNames from 'classnames';

import { usePublicVersionGroupId } from '@/src/hooks/usePublicVersionGroupIdFromPublicEntity';
import { usePublicationResources } from '@/src/hooks/usePublicationResources';

import { ApplicationService } from '@/src/utils/app/data/application-service';
import { constructPath } from '@/src/utils/app/file';
import { isApplicationId } from '@/src/utils/app/id';
import { ApiUtils } from '@/src/utils/server/api';

import { AdditionalItemData, FeatureType } from '@/src/types/common';
Expand All @@ -31,6 +35,7 @@
import { NA_VERSION } from '@/src/constants/public';

import { PromptComponent } from '../../Promptbar/components/Prompt';
import Loader from '@/src/components/Common/Loader';

import { ConversationComponent } from '../../Chatbar/Conversation';
import {
Expand All @@ -48,6 +53,7 @@
ShareEntity,
UploadStatus,
} from '@epam/ai-dial-shared';
import { isNull } from 'lodash-es';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
import { isNull } from 'lodash-es';
import isNull from 'lodash-es/isNull';


interface PublicationResourcesVersionGroupInterface {
entity: ShareEntity;
Expand Down Expand Up @@ -467,23 +473,54 @@
isOpen = true,
resources,
}: PublicationResources) => {
const [isLoading, setIsLoading] = useState(false);
const [entities, setEntities] = useState<ShareEntity[]>([]);

const publishRequestModels = useAppSelector(
ModelsSelectors.selectPublishRequestModels,
);

const filteredApps = useMemo(() => {
const resourcesIds = resources.map((resource) => resource.reviewUrl);
const getIncompleteFallbackModel = (id: string) => {
return publishRequestModels.find((model) => id.includes(model.id)) ?? null;
};

useEffect(() => {
setIsLoading(true);
const applications = resources
.map((resource) => resource.reviewUrl)
.filter(isApplicationId)
.map((id) =>
ApplicationService.get(id).pipe(
map((r) => r ?? getIncompleteFallbackModel(id)),
catchError(() => of(getIncompleteFallbackModel(id))),
),
);

const sub = forkJoin(applications)
.pipe(
tap((apps) => {
const result = apps.filter((app) => !isNull(app)) as ShareEntity[];

return publishRequestModels.filter((model) =>
resourcesIds.includes(model.id),
);
}, [publishRequestModels, resources]);
setEntities(result);
}),
finalize(() => setIsLoading(false)),
)
.subscribe();

return () => sub.unsubscribe();
}, [resources]);

Check warning on line 511 in apps/chat/src/components/Chat/Publish/PublicationResources.tsx

View workflow job for this annotation

GitHub Actions / run_tests / test / style_checks

React Hook useEffect has a missing dependency: 'getIncompleteFallbackModel'. Either include it or remove the dependency array
Copy link
Collaborator

Choose a reason for hiding this comment

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

has a missing dependency: 'getIncompleteFallbackModel'


return (
<div className={classNames(!isOpen && 'hidden')}>
{filteredApps.map((application) => (
<ApplicationRow item={application} key={application.id} />
))}
{isLoading ? (
<div className="flex h-[38px] w-min items-center px-[14px]">
<Loader size={18} />
</div>
) : (
entities.map((application) => (
<ApplicationRow item={application} key={application.id} />
))
)}
</div>
);
};
Loading