From 3b70a7b2222e07bb47ad4153022eb5ebdaf0099e Mon Sep 17 00:00:00 2001 From: Seongjin Yoon Date: Tue, 10 Mar 2026 16:07:37 -0700 Subject: [PATCH] improve onClickDuplicateWorkflow --- .../user-workflow/user-workflow.component.ts | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts b/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts index 75f61a223ce..21e8333cb6d 100644 --- a/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts +++ b/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts @@ -27,7 +27,7 @@ import { } from "../../../../common/service/workflow-persist/workflow-persist.service"; import { NgbdModalAddProjectWorkflowComponent } from "../user-project/user-project-section/ngbd-modal-add-project-workflow/ngbd-modal-add-project-workflow.component"; import { NgbdModalRemoveProjectWorkflowComponent } from "../user-project/user-project-section/ngbd-modal-remove-project-workflow/ngbd-modal-remove-project-workflow.component"; -import { DashboardEntry, UserInfo } from "../../../type/dashboard-entry"; +import { DashboardEntry } from "../../../type/dashboard-entry"; import { UserService } from "../../../../common/service/user/user.service"; import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; import { NotificationService } from "../../../../common/service/notification/notification.service"; @@ -45,6 +45,7 @@ import { DashboardWorkflow } from "../../../type/dashboard-workflow.interface"; import { DownloadService } from "../../../service/user/download/download.service"; import { DASHBOARD_USER_WORKSPACE } from "../../../../app-routing.constant"; import { GuiConfigService } from "../../../../common/service/gui-config.service"; +import { SearchResultItem } from "../../../type/search-result"; /** * Saved-workflow-section component contains information and functionality @@ -289,27 +290,13 @@ export class UserWorkflowComponent implements AfterViewInit { ); } - const userIds = new Set(); - duplicatedWorkflowsInfo.forEach(workflow => { - if (workflow.ownerId) { - userIds.add(workflow.ownerId); - } - }); - - let userIdToInfoMap: { [key: number]: UserInfo } = {}; - if (userIds.size > 0) { - userIdToInfoMap = await firstValueFrom(this.searchService.getUserInfo(Array.from(userIds))); - } - - const newEntries = duplicatedWorkflowsInfo.map(duplicatedWorkflowInfo => { - const entry = new DashboardEntry(duplicatedWorkflowInfo); - const userInfo = userIdToInfoMap[duplicatedWorkflowInfo.ownerId]; - if (userInfo) { - entry.setOwnerName(userInfo.userName); - entry.setOwnerGoogleAvatar(userInfo.googleAvatar ?? ""); - } - return entry; - }); + const searchResultItems: SearchResultItem[] = duplicatedWorkflowsInfo.map(w => ({ + resourceType: "workflow", + workflow: w, + })); + const newEntries = await firstValueFrom( + this.searchService.extendSearchResultsWithHubActivityInfo(searchResultItems, this.isLogin, ["access"]) + ); this.searchResultsComponent.entries = [...newEntries, ...this.searchResultsComponent.entries]; } catch (err: unknown) {