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

feat(chat): Add the application shared with the user to a "My workspace" (Issue #2955, #2965, #2971, #3004) #3008

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
a2e19b7
Revert "feat(chat): Revert "Add the application shared with the user …
IlyaBondar Jan 24, 2025
0d03e9e
Merge branch 'development' into revert-3007-revert-2961-feat/2955-add…
denys-kolomiitsev Jan 24, 2025
9cc0b9a
Merge branch 'development' into revert-3007-revert-2961-feat/2955-add…
denys-kolomiitsev Jan 24, 2025
b2631fe
fix: fix tests
denys-kolomiitsev Jan 24, 2025
dd410d2
feat: made shared files folders visible
denys-kolomiitsev Jan 27, 2025
8728e29
fix: fix tests
denys-kolomiitsev Jan 27, 2025
9938441
Merge branch 'development' into revert-3007-revert-2961-feat/2955-add…
denys-kolomiitsev Jan 27, 2025
420c985
Merge branch 'development' into revert-3007-revert-2961-feat/2955-add…
denys-kolomiitsev Jan 27, 2025
3272999
fix: disable change folder with source files for the shared app
denys-kolomiitsev Jan 27, 2025
06a6e4d
Merge branch 'revert-3007-revert-2961-feat/2955-add-shared-app-to-ins…
denys-kolomiitsev Jan 27, 2025
6c43b4b
fix: change app shared actions order
denys-kolomiitsev Jan 27, 2025
14bf653
Merge branch 'development' into revert-3007-revert-2961-feat/2955-add…
IlyaBondar Jan 27, 2025
c435511
Merge branch 'development' into revert-3007-revert-2961-feat/2955-add…
denys-kolomiitsev Jan 27, 2025
746f9ea
Merge branch 'development' into revert-3007-revert-2961-feat/2955-add…
IlyaBondar Jan 27, 2025
ad48e44
fix: resolve comments
denys-kolomiitsev Jan 27, 2025
c53180d
Merge branch 'revert-3007-revert-2961-feat/2955-add-shared-app-to-ins…
denys-kolomiitsev Jan 27, 2025
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
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
Loading