Skip to content

Commit

Permalink
Merge branch 'development' into feat/isolated-view-test
Browse files Browse the repository at this point in the history
  • Loading branch information
nartovm authored Jan 24, 2025
2 parents b9205ff + a6f64c0 commit b16724d
Show file tree
Hide file tree
Showing 28 changed files with 553 additions and 444 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ export const ConversationSettings = Inversify.register(
const isPlayback = !!conversation.playback?.isPlayback;

if (!model) {
return <SettingContainer>{t('Agent is not available')}</SettingContainer>;
return (
<SettingContainer>
<FieldContainer>{t('Agent is not available')}</FieldContainer>
</SettingContainer>
);
}

if (!doesModelHaveSettings(model)) {
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({ applicationId: currentEntity.id }));
dispatch(ApplicationActions.get(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({
applicationId: resourcesToReview[publicationIdx + offset].reviewUrl,
}),
ApplicationActions.get(
resourcesToReview[publicationIdx + offset].reviewUrl,
),
);
dispatch(PublicationActions.setIsApplicationReview(true));
}
Expand Down
11 changes: 7 additions & 4 deletions apps/chat/src/components/Chat/Publish/PublicationHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,13 @@ export function PublicationHandler({ publication }: Props) {
};

const startApplicationsReview = () => {
const applicationId = applicationsToReviewIds.length
? applicationsToReviewIds[0].reviewUrl
: reviewedApplicationsIds[0].reviewUrl;
dispatch(ApplicationActions.get({ applicationId }));
dispatch(
ApplicationActions.get(
applicationsToReviewIds.length
? applicationsToReviewIds[0].reviewUrl
: reviewedApplicationsIds[0].reviewUrl,
),
);
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({ applicationId: entity.id }));
dispatch(ApplicationActions.get(entity.id));
setEditModel(entity);
},
[dispatch],
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 && !entity.sharedWithMe && (
{!isMyApp && (
<Tooltip
tooltip={
installedModelIds.has(entity.reference)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,36 +200,35 @@ export const ApplicationDetailsFooter = ({
</button>
</Tooltip>
)}
{!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
{isMyApp ? (
<Tooltip tooltip={t(getDisabledTooltip(entity, 'Delete'))}>
<button
disabled={isModifyDisabled}
onClick={() => onDelete(entity)}
className="icon-button"
data-qa="application-delete"
>
<button
onClick={() => onBookmarkClick(entity)}
className="icon-button"
data-qa="application-bookmark"
>
<Bookmark size={24} />
</button>
</Tooltip>
))}
<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"
>
<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,6 +59,34 @@ 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 @@ -102,7 +130,57 @@ 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({ applicationId: entity.id }));
dispatch(ApplicationActions.get(entity.id));
setApplicationModel({
entity,
action: ApplicationActionType.EDIT,
Expand Down
12 changes: 11 additions & 1 deletion apps/chat/src/constants/marketplace.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ApplicationType } from '../types/applications';
import { EntityType } from '../types/common';

export enum MarketplaceQueryParams {
Expand Down Expand Up @@ -40,12 +41,21 @@ export enum SourceType {
MyCustomApps = 'My Custom Apps',
MyQuickApps = 'My Quick Apps',
MyCodeApps = 'My Code Apps',
MyMindMaps = 'My Mindmaps',
}

export const SourceTypeOrder = {
export const SourceTypeFilterOrder = {
[SourceType.Public]: 1,
[SourceType.SharedWithMe]: 2,
[SourceType.MyCustomApps]: 3,
[SourceType.MyQuickApps]: 4,
[SourceType.MyCodeApps]: 5,
[SourceType.MyMindMaps]: 6,
};

export const ApplicationTypeToSourceType = {
[ApplicationType.CODE_APP]: SourceType.MyCodeApps,
[ApplicationType.QUICK_APP]: SourceType.MyQuickApps,
[ApplicationType.CUSTOM_APP]: SourceType.MyCustomApps,
[ApplicationType.MINDMAP]: SourceType.MyMindMaps,
};
47 changes: 9 additions & 38 deletions apps/chat/src/store/application/application.epics.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
EMPTY,
Observable,
concat,
concatMap,
from,
Expand All @@ -11,8 +10,6 @@ import {
} from 'rxjs';
import { catchError, filter, map, switchMap } from 'rxjs/operators';

import { AnyAction } from '@reduxjs/toolkit';

import { combineEpics } from 'redux-observable';

import { regenerateApplicationId } from '@/src/utils/app/application';
Expand All @@ -36,7 +33,6 @@ import { DeleteType } from '@/src/constants/marketplace';
import { ApplicationActions } from '../application/application.reducers';
import { AuthSelectors } from '../auth/auth.reducers';
import { ModelsActions, ModelsSelectors } from '../models/models.reducers';
import { ShareActions, ShareSelectors } from '../share/share.reducers';

const createApplicationEpic: AppEpic = (action$) =>
action$.pipe(
Expand Down Expand Up @@ -183,42 +179,17 @@ const getApplicationEpic: AppEpic = (action$, state$) =>
action$.pipe(
filter(ApplicationActions.get.match),
switchMap(({ payload }) =>
ApplicationService.get(payload.applicationId).pipe(
switchMap((application) => {
if (!application) {
return of(ApplicationActions.getFail());
}

ApplicationService.get(payload).pipe(
map((application) => {
const modelsMap = ModelsSelectors.selectModelsMap(state$.value);
const modelFromState = modelsMap[application.reference];

const actions: Observable<AnyAction>[] = [];
actions.push(
of(
ApplicationActions.getSuccess({
return application
? ApplicationActions.getSuccess({
...application,
sharedWithMe: modelFromState?.sharedWithMe,
permissions: modelFromState?.permissions,
isShared: modelFromState?.isShared,
}),
),
);

if (payload.isForSharing) {
const permissionsFromState = ShareSelectors.selectSharePermissions(
state$.value,
);
actions.push(
of(
ShareActions.shareApplication({
resourceId: application.id,
permissions: permissionsFromState,
}),
),
);
}

return concat(...actions);
sharedWithMe: modelsMap[application.reference]?.sharedWithMe,
permissions: modelsMap[application.reference]?.permissions,
isShared: modelsMap[application.reference]?.isShared,
})
: ApplicationActions.getFail();
}),
catchError((err) => {
console.error('Failed to get application:', err);
Expand Down
5 changes: 1 addition & 4 deletions apps/chat/src/store/application/application.reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ export const applicationSlice = createSlice({
updateFail: (state) => {
state.appLoading = UploadStatus.FAILED;
},
get: (
state,
_action: PayloadAction<{ applicationId: string; isForSharing?: boolean }>,
) => {
get: (state, _action: PayloadAction<string>) => {
state.appLoading = UploadStatus.LOADING;
},
getSuccess: (state, action: PayloadAction<CustomApplicationModel>) => {
Expand Down
20 changes: 9 additions & 11 deletions apps/chat/src/store/marketplace/marketplace.selectors.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { createSelector } from '@reduxjs/toolkit';

import {
getApplicationType,
isApplicationPublic,
isExecutableApp,
isQuickApp,
} from '@/src/utils/app/application';
import { isMyApplication } from '@/src/utils/app/id';

import { DialAIEntityModel } from '@/src/types/models';

import { SourceType, SourceTypeOrder } from '@/src/constants/marketplace';
import {
ApplicationTypeToSourceType,
SourceType,
SourceTypeFilterOrder,
} from '@/src/constants/marketplace';

import { RootState } from '../index';
import { ModelsSelectors } from '../models/models.reducers';
Expand Down Expand Up @@ -63,20 +66,15 @@ export const selectSourceTypes = createSelector(

models.forEach((model) => {
if (isMyApplication(model)) {
if (isQuickApp(model)) {
sourceTypes.add(SourceType.MyQuickApps);
} else if (isExecutableApp(model)) {
sourceTypes.add(SourceType.MyCodeApps);
} else {
sourceTypes.add(SourceType.MyCustomApps);
}
const applicationType = getApplicationType(model);
sourceTypes.add(ApplicationTypeToSourceType[applicationType]);
} else if (!isApplicationPublic(model)) {
sourceTypes.add(SourceType.SharedWithMe);
}
});

return Array.from(sourceTypes).sort(
(a, b) => SourceTypeOrder[a] - SourceTypeOrder[b],
(a, b) => SourceTypeFilterOrder[a] - SourceTypeFilterOrder[b],
);
},
);
Loading

0 comments on commit b16724d

Please sign in to comment.