Skip to content

Commit

Permalink
fix(chat): add warning messages for published or shared application i…
Browse files Browse the repository at this point in the history
…con (Issue #3047) (#3074)
  • Loading branch information
IlyaBondar authored Jan 31, 2025
1 parent a859859 commit 5221cf7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ export const PublicationItemsList = memo(
<ErrorMessage
type="warning"
error={t(
`The icon used for this app is in the ${isEntityIdPublic({ id: entity.iconUrl }) ? 'organization' : 'shared'} section and cannot be published. Please replace the icon, otherwise the app will be published with the default one.`,
`The icon used for this application is in the "${isEntityIdPublic({ id: entity.iconUrl }) ? 'Organization' : 'Shared with me'}" section and cannot be published. Please replace the icon, otherwise the application will be published with the default one.`,
)}
/>
</CollapsibleSection>
Expand Down
38 changes: 29 additions & 9 deletions apps/chat/src/store/share/share.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ import { splitEntityId } from '@/src/utils/app/folders';
import {
isApplicationId,
isConversationId,
isEntityIdExternal,
isFolderId,
isPromptId,
} from '@/src/utils/app/id';
import { EnumMapper } from '@/src/utils/app/mappers';
import { isEntityIdPublic } from '@/src/utils/app/publications';
import { hasWritePermission } from '@/src/utils/app/share';
import { translate } from '@/src/utils/app/translation';
import { ApiUtils, parseConversationApiKey } from '@/src/utils/server/api';
Expand Down Expand Up @@ -331,10 +333,23 @@ const shareApplicationEpic: AppEpic = (action$, state$) =>
},
];

const actions: Observable<AnyAction>[] = [];

if (application?.iconUrl) {
resources.push({
url: ApiUtils.encodeApiUrl(application.iconUrl),
});
const iconId = application.iconUrl;
if (isEntityIdExternal({ id: iconId })) {
actions.push(
of(
UIActions.showWarningToast(
`The icon used for this application is in the "${isEntityIdPublic({ id: iconId }) ? 'Organization' : 'Shared with me'}" section and cannot be shared. Please replace the icon, otherwise the application will be shared with the default one.`,
),
),
);
} else {
resources.push({
url: ApiUtils.encodeApiUrl(iconId),
});
}
}

if (
Expand All @@ -344,7 +359,7 @@ const shareApplicationEpic: AppEpic = (action$, state$) =>
) {
resources.push({
url:
ApiUtils.encodeApiUrl(applicationDetails?.function?.sourceFolder) +
ApiUtils.encodeApiUrl(applicationDetails.function.sourceFolder) +
'/',
permissions: payload.permissions,
});
Expand All @@ -354,11 +369,16 @@ const shareApplicationEpic: AppEpic = (action$, state$) =>
invitationType: ShareRequestType.link,
resources,
}).pipe(
map((response: ShareByLinkResponseModel) => {
return ShareActions.shareSuccess({
invitationId: response.invitationLink.split('/').slice(-1)?.[0],
permissions: payload.permissions,
});
switchMap((response: ShareByLinkResponseModel) => {
return concat(
of(
ShareActions.shareSuccess({
invitationId: response.invitationLink.split('/').slice(-1)?.[0],
permissions: payload.permissions,
}),
),
...actions,
);
}),
catchError((err) => {
console.error(err);
Expand Down

0 comments on commit 5221cf7

Please sign in to comment.