Skip to content

Commit

Permalink
re-duplicate if some objects cannot be duplicated
Browse files Browse the repository at this point in the history
Signed-off-by: yuye-aws <[email protected]>
  • Loading branch information
yuye-aws committed Sep 18, 2023
1 parent 86bf7b2 commit afb9b37
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,24 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
),
});
} else {
const failedCount = savedObjects.length - result.successCount;
notifications.toasts.addSuccess({
let failedCount = savedObjects.length;
if (result.successCount) {
// reduplicate objects which can be successfully duplicated
const successObjectIds = result.successResults.map((item: { id: string }) => item.id);
const successObjectsToDuplicate = objectsToDuplicate.filter((item) =>
successObjectIds.includes(item.id)
);
result = await duplicateSavedObjects(
http,
successObjectsToDuplicate,
includeReferencesDeep,
targetWorkspace
);
if (result.success) {
failedCount -= successObjectsToDuplicate.length;
}
}
notifications.toasts.addDanger({
title: i18n.translate(
'savedObjectsManagement.objectsTable.duplicate.dangerNotification',
{
Expand All @@ -563,7 +579,8 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
} catch (e) {
notifications.toasts.addDanger({
title: i18n.translate('savedObjectsManagement.objectsTable.duplicate.dangerNotification', {
defaultMessage: 'Unable to duplicate all saved objects',
defaultMessage:
'Unable to duplicate ' + savedObjects.length.toString() + ' saved objects',
}),
});
throw e;
Expand Down

0 comments on commit afb9b37

Please sign in to comment.