Skip to content

Commit

Permalink
feat: some optimization
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>
  • Loading branch information
SuZhou-Joe committed Jun 19, 2023
1 parent 0204d64 commit c8287e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const createSavedObjects = async <T>({
// remap results to reflect the object IDs that were submitted for import
// this ensures that consumers understand the results
const remappedResults = expectedResults.map<CreatedObject<T>>((result) => {
const { id } = objectIdMap.get(`${result.type}:${result.id}`)!;
const { id } = objectIdMap.get(`${result.type}:${result.id}`) || ({} as SavedObject<T>);
// also, include a `destinationId` field if the object create attempt was made with a different ID
return { ...result, id, ...(id !== result.id && { destinationId: result.id }) };
});
Expand Down
4 changes: 3 additions & 1 deletion src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,9 @@ export class SavedObjectsRepository {
method,
} = expectedBulkGetResult.value;
let savedObjectWorkspaces: string[] | undefined;
if (object.workspaces) {
if (expectedBulkGetResult.value.method === 'create') {
savedObjectWorkspaces = Array.from(new Set([...(options.workspaces || [])]));
} else if (object.workspaces) {
savedObjectWorkspaces = Array.from(
new Set([...object.workspaces, ...(options.workspaces || [])])
);
Expand Down

0 comments on commit c8287e6

Please sign in to comment.