Skip to content

Commit

Permalink
Merge branch 'development' into 2962/fix-app-sharing-revoke
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Kezik authored Jan 29, 2025
2 parents 6729e5e + ca0f6ea commit 02b947b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ interface Props {
readonly?: boolean;
groupVersions?: boolean;
textBeforeSelector?: string | null;
selectedEntityId?: string;
excludeEntityId?: string;
onChangeSelectedVersion?: (
versionGroupId: string,
newVersion: NonNullable<PublicVersionGroups[string]>['selectedVersion'],
oldVersion: NonNullable<PublicVersionGroups[string]>['selectedVersion'],
) => void;
selectedEntityId?: string;
excludeEntityId?: string;
}

export function PublicVersionSelector({
Expand All @@ -38,9 +38,9 @@ export function PublicVersionSelector({
readonly,
groupVersions,
textBeforeSelector,
onChangeSelectedVersion,
selectedEntityId,
excludeEntityId,
onChangeSelectedVersion,
}: Props) {
const { t } = useTranslation(Translation.Chat);

Expand Down
53 changes: 39 additions & 14 deletions apps/chat/src/store/publication/publication.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,10 @@ const uploadPublishedWithMeItemsEpic: AppEpic = (action$, state$) =>
const selectedIds =
ConversationsSelectors.selectSelectedConversationsIds(state$.value);

const selectedConversationsToUpload = selectedIds
const selectedConversationsToUpload = selectedIds.filter(
// do not upload root entities, as they uploaded with listing
.filter((id) => id.split('/').length > 3)
.filter((id) => isEntityIdPublic({ id }));
(id) => id.split('/').length > 3 && isEntityIdPublic({ id }),
);
const publicationItems = items.map((item) => ({
...item,
id: item.url,
Expand Down Expand Up @@ -664,8 +664,6 @@ const uploadPublishedWithMeItemsEpic: AppEpic = (action$, state$) =>
publicVersionGroups,
}),
),
);
actions.push(
of(
ConversationsActions.addConversations({
conversations,
Expand Down Expand Up @@ -703,8 +701,6 @@ const uploadPublishedWithMeItemsEpic: AppEpic = (action$, state$) =>
publicVersionGroups,
}),
),
);
actions.push(
of(
PromptsActions.addPrompts({
prompts,
Expand Down Expand Up @@ -838,7 +834,7 @@ const approvePublicationEpic: AppEpic = (action$, state$) =>
});

const versionGroups = uniq(
itemsToRemoveIds.map((id) =>
idsToExclude.map((id) =>
getIdWithoutVersionFromApiKey(id, parseConversationApiKey),
),
);
Expand All @@ -860,6 +856,7 @@ const approvePublicationEpic: AppEpic = (action$, state$) =>
name: conv.name,
folderId: conv.folderId,
publicationInfo: {
...conv.publicationInfo,
isNotExist: true,
},
publishedWithMe: false,
Expand Down Expand Up @@ -990,7 +987,7 @@ const approvePublicationEpic: AppEpic = (action$, state$) =>
return !hasPrompts && hasHiddenPrompts;
});
const versionGroups = uniq(
itemsToRemoveIds.map((id) => {
idsToExclude.map((id) => {
return getIdWithoutVersionFromApiKey(id, parsePromptApiKey);
}),
);
Expand All @@ -1011,6 +1008,7 @@ const approvePublicationEpic: AppEpic = (action$, state$) =>
name: prompt.name,
folderId: prompt.folderId,
publicationInfo: {
...prompt.publicationInfo,
isNotExist: true,
},
publishedWithMe: false,
Expand Down Expand Up @@ -1102,6 +1100,12 @@ const approvePublicationEpic: AppEpic = (action$, state$) =>
of(
PublicationActions.approvePublicationSuccess({
url: payload.url,
triggerModelsListing: selectedPublication.resources.some(
(resource) => isApplicationId(resource.reviewUrl),
),
triggerPublicFilesListing: selectedPublication.resources.some(
(resource) => isFileId(resource.reviewUrl),
),
}),
),
);
Expand Down Expand Up @@ -1150,6 +1154,30 @@ const rejectPublicationFailEpic: AppEpic = (action$) =>
),
);

const approvePublicationSuccessEpic: AppEpic = (action$) =>
action$.pipe(
filter(PublicationActions.approvePublicationSuccess.match),
switchMap(({ payload }) => {
const actions: Observable<AnyAction>[] = [];

if (payload.triggerModelsListing) {
actions.push(of(ModelsActions.getModels()));
}

if (payload.triggerPublicFilesListing) {
actions.push(
of(
PublicationActions.uploadPublishedWithMeItems({
featureType: FeatureType.File,
}),
),
);
}

return concat(...actions);
}),
);

const resolvePublicationSuccessEpic: AppEpic = (action$, state$) =>
action$.pipe(
filter(
Expand Down Expand Up @@ -1284,8 +1312,6 @@ const uploadAllPublishedWithMeItemsEpic: AppEpic = (action$, state$) =>
publicVersionGroups,
}),
),
);
actions.push(
of(
ConversationsActions.uploadChildConversationsWithFoldersSuccess(
{
Expand All @@ -1309,8 +1335,6 @@ const uploadAllPublishedWithMeItemsEpic: AppEpic = (action$, state$) =>
publicVersionGroups,
}),
),
);
actions.push(
of(
PromptsActions.uploadChildPromptsWithFoldersSuccess({
parentIds: paths,
Expand Down Expand Up @@ -1368,11 +1392,12 @@ export const PublicationEpics = combineEpics(
uploadAllPublishedWithMeItemsEpic,
uploadAllPublishedWithMeItemsFailEpic,

// handle publications
// resolve publications
approvePublicationEpic,
approvePublicationFailEpic,
rejectPublicationEpic,
rejectPublicationFailEpic,
approvePublicationSuccessEpic,
resolvePublicationSuccessEpic,

// upload rules
Expand Down
8 changes: 7 additions & 1 deletion apps/chat/src/store/publication/publication.reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ export const publicationSlice = createSlice({
state,
approvePublicationSuccess: (
state,
{ payload }: PayloadAction<{ url: string }>,
{
payload,
}: PayloadAction<{
url: string;
triggerModelsListing: boolean;
triggerPublicFilesListing: boolean;
}>,
) => {
state.publications = state.publications.filter(
(p) => p.url !== payload.url,
Expand Down

0 comments on commit 02b947b

Please sign in to comment.