This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git
The following commit(s) were added to refs/heads/main by this push:
new cb07f2d8b3 feat: Add Card View to Workflows (#4216)
cb07f2d8b3 is described below
commit cb07f2d8b36ce89172c31461e9f3ef3f5b54de2e
Author: Matthew B. <[email protected]>
AuthorDate: Fri Jun 12 11:30:37 2026 -0700
feat: Add Card View to Workflows (#4216)
<!--
Thanks for sending a pull request (PR)! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
[Contributing to
Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md)
2. Ensure you have added or run the appropriate tests for your PR
3. If the PR is work in progress, mark it a draft on GitHub.
4. Please write your PR title to summarize what this PR proposes, we
are following Conventional Commits style for PR titles as well.
5. Be sure to keep the PR description updated to reflect all changes.
-->
### What changes were proposed in this PR?
<!--
Please clarify what changes you are proposing. The purpose of this
section
is to outline the changes. Here are some tips for you:
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
3. If it is a refactoring, clarify what has been changed.
3. It would be helpful to include a before-and-after comparison using
screenshots or GIFs.
4. Please consider writing useful notes for better and faster reviews.
-->
This PR adds a Grid View (Tile View) for workflows in the dashboard.
- New Card Component: Displays workflows as tiles with a preview image.
- Grid Layout: Responsive grid that adapts to screen size.
- Enhanced Metadata: Shows size, dates, and view counts; pinned to the
bottom.
- Quick Actions: Edit description, rename, duplicate, and share directly
from the card.
- Toggle: Added a button to switch between List and Grid views.
### Old View
<img width="2269" height="1009" alt="image"
src="https://github.com/user-attachments/assets/0174952f-e760-4590-aed7-72c2dfdccd99"
/>
### New View
<img width="2560" height="1410" alt="image"
src="https://github.com/user-attachments/assets/d36ba290-a28f-44be-b406-c70ad43cace4"
/>
### Any related issues, documentation, discussions?
<!--
Please use this section to link other resources if not mentioned
already.
1. If this PR fixes an issue, please include `Fixes #1234`, `Resolves
#1234`
or `Closes #1234`. If it is only related, simply mention the issue
number.
2. If there is design documentation, please add the link.
3. If there is a discussion in the mailing list, please add the link.
-->
N/A
### How was this PR tested?
<!--
If tests were added, say they were added here. Or simply mention that if
the PR
is tested with existing test cases. Make sure to include/update test
cases that
check the changes thoroughly, including negative and positive cases if
possible.
If it was tested in a way different from regular unit tests, please
clarify how
you tested step by step, ideally copy and paste-able, so that other
reviewers can
test and check, and descendants can verify in the future. If tests were
not added,
please describe why they were not added and/or why it was difficult to
add.
-->
- Manually verified switching between views.
- Checked card layout responsiveness.
- Tested all card actions (edit, like, share, delete).
### Was this PR authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this
PR,
please include the phrase: 'Generated-by: ' followed by the name of the
tool
and its version. If no, write 'No'.
Please refer to the [ASF Generative Tooling
Guidance](https://www.apache.org/legal/generative-tooling.html) for
details.
-->
Reviewed by Gemini 3
---------
Co-authored-by: Chen Li <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
---
frontend/src/app/app.module.ts | 2 +
.../list-item/card-item/card-item.component.html | 224 +++++++++++
.../list-item/card-item/card-item.component.scss | 228 +++++++++++
.../card-item/card-item.component.spec.ts | 160 ++++++++
.../list-item/card-item/card-item.component.ts | 427 +++++++++++++++++++++
.../user-workflow/user-workflow.component.html | 38 ++
.../user/user-workflow/user-workflow.component.ts | 13 +
7 files changed, 1092 insertions(+)
diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts
index 511395365d..5ddb97944a 100644
--- a/frontend/src/app/app.module.ts
+++ b/frontend/src/app/app.module.ts
@@ -162,6 +162,7 @@ import { ResultExportationComponent } from
"./workspace/component/result-exporta
import { ReportGenerationService } from
"./workspace/service/report-generation/report-generation.service";
import { SearchBarComponent } from
"./dashboard/component/user/search-bar/search-bar.component";
import { ListItemComponent } from
"./dashboard/component/user/list-item/list-item.component";
+import { CardItemComponent } from
"./dashboard/component/user/list-item/card-item/card-item.component";
import { HubComponent } from "./hub/component/hub.component";
import { HubWorkflowDetailComponent } from
"./hub/component/workflow/detail/hub-workflow-detail.component";
import { LandingPageComponent } from
"./hub/component/landing-page/landing-page.component";
@@ -347,6 +348,7 @@ registerLocaleData(en);
HighlightSearchTermsPipe,
SearchBarComponent,
ListItemComponent,
+ CardItemComponent,
SearchResultsComponent,
HubComponent,
HubWorkflowDetailComponent,
diff --git
a/frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.html
b/frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.html
new file mode 100644
index 0000000000..43b965f5bc
--- /dev/null
+++
b/frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.html
@@ -0,0 +1,224 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<nz-card
+ class="card-item"
+ [class.selected]="entry.checked"
+ [nzBodyStyle]="{ padding: '0' }"
+ (mouseenter)="hovering = true"
+ (mouseleave)="hovering = false">
+ <!-- Preview Section (Blank Space) -->
+ <div
+ class="card-preview"
+ [routerLink]="entryLink">
+ <!-- Checkbox overlay -->
+ <div
+ class="card-checkbox"
+ *ngIf="isPrivateSearch && entry.type === 'workflow'"
+ (click)="$event.stopPropagation()">
+ <label
+ nz-checkbox
+ [(ngModel)]="entry.checked"
+ (ngModelChange)="onCheckboxChange(entry)"></label>
+ </div>
+ <!-- Placeholder or Preview Image -->
+ <img
+ class="card-preview-image"
+ [src]="previewImage"
+ alt="Workflow Preview" />
+ </div>
+
+ <!-- Content Section -->
+ <div class="card-content">
+ <!-- Header: Icon, Name, ID -->
+ <div
+ class="card-header"
+ [routerLink]="entryLink">
+ <div class="title-container">
+ <i
+ nz-icon
+ [nzType]="iconType"
+ class="type-icon"></i>
+
+ <div class="name-container">
+ <div
+ class="resource-name truncate-single-line"
+ *ngIf="!editingName"
+ title="{{ entry.name }}">
+ {{ entry.name }}
+ </div>
+ <input
+ *ngIf="editingName"
+ #nameInput
+ class="resource-name-edit-input"
+ [(ngModel)]="entry.name"
+ (blur)="confirmUpdateCustomName(entry.name)"
+ (keydown.enter)="confirmUpdateCustomName(entry.name)"
+ (click)="$event.stopPropagation()"
+ autofocus />
+ </div>
+ </div>
+
+ <!-- Edit Name Button -->
+ <button
+ *ngIf="isPrivateSearch"
+ nz-button
+ nzType="text"
+ size="small"
+ class="edit-btn"
+ (click)="onEditName(); $event.stopPropagation()">
+ <i
+ nz-icon
+ nzType="edit"></i>
+ </button>
+ </div>
+
+ <!-- Meta Info: Owner, Dates, Size, Views -->
+ <div class="card-meta">
+ <div class="meta-details">
+ <div class="meta-row">
+ <span
+ class="owner-info"
+ title="{{ entry.ownerName || 'User' }}">
+ <texera-user-avatar
+ [googleAvatar]="entry.ownerGoogleAvatar"
+ userColor="#1E90FF"
+ [userName]="entry.ownerName || 'User'"></texera-user-avatar>
+ <span class="owner-name truncate-single-line">{{ entry.ownerName
|| "User" }}</span>
+ </span>
+ </div>
+ <div class="meta-row">
+ <span title="Created"
+ ><i
+ nz-icon
+ nzType="calendar"
+ nzTheme="outline"></i>
+ {{ formatTime(entry.creationTime) }}</span
+ >
+ <span
+ *ngIf="size"
+ title="Size"
+ ><i
+ nz-icon
+ nzType="file"
+ nzTheme="outline"></i>
+ {{ formatSize(size) }}</span
+ >
+ </div>
+ <div class="meta-row">
+ <span title="Edited"
+ ><i
+ nz-icon
+ nzType="edit"
+ nzTheme="outline"></i>
+ {{ formatTime(entry.lastModifiedTime) }}</span
+ >
+ <span title="Views"
+ ><i
+ nz-icon
+ nzType="eye"
+ nzTheme="outline"></i>
+ {{ formatCount(viewCount) }}</span
+ >
+ </div>
+ </div>
+ </div>
+
+ <!-- Actions Footer -->
+ <div class="card-actions">
+ <!-- Like Button -->
+ <button
+ *ngIf="!isPrivateSearch"
+ nz-button
+ nzType="text"
+ class="action-btn like-btn"
+ [class.liked]="isLiked"
+ [disabled]="!currentUid"
+ (click)="toggleLike(); $event.stopPropagation()">
+ <i
+ nz-icon
+ nzType="heart"
+ [nzTheme]="isLiked ? 'fill' : 'outline'"></i>
+ <span>{{ formatCount(this.likeCount) }}</span>
+ </button>
+
+ <!-- Private Search Actions -->
+ <div
+ class="private-actions"
+ *ngIf="isPrivateSearch">
+ <button
+ nz-button
+ nzType="text"
+ class="action-btn"
+ title="Detail"
+ *ngIf="entry.type==='workflow'"
+ (click)="openDetailModal(this.entry.id); $event.stopPropagation()">
+ <i
+ nz-icon
+ nzType="eye"></i>
+ </button>
+ <button
+ nz-button
+ nzType="text"
+ class="action-btn"
+ title="Share"
+ (click)="onClickOpenShareAccess(); $event.stopPropagation()">
+ <i
+ nz-icon
+ nzType="share-alt"></i>
+ </button>
+ <button
+ nz-button
+ nzType="text"
+ class="action-btn"
+ title="Copy"
+ *ngIf="entry.type==='workflow'"
+ (click)="duplicated.emit(); $event.stopPropagation()">
+ <i
+ nz-icon
+ nzType="copy"></i>
+ </button>
+ <button
+ nz-button
+ nzType="text"
+ class="action-btn"
+ title="Download"
+ *ngIf="entry.type === 'workflow' || entry.type === 'dataset'"
+ (click)="onClickDownload(); $event.stopPropagation()">
+ <i
+ nz-icon
+ nzType="cloud-download"></i>
+ </button>
+ <button
+ nz-button
+ nzType="text"
+ class="action-btn delete-btn"
+ title="Delete"
+ [disabled]="disableDelete"
+ nz-popconfirm
+ nzPopconfirmTitle="Confirm to delete this item."
+ (nzOnConfirm)="deleted.emit()"
+ (click)="$event.stopPropagation()">
+ <i
+ nz-icon
+ nzType="delete"></i>
+ </button>
+ </div>
+ </div>
+ </div>
+</nz-card>
diff --git
a/frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.scss
b/frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.scss
new file mode 100644
index 0000000000..92a8ab7c6c
--- /dev/null
+++
b/frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.scss
@@ -0,0 +1,228 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+// Styled to match the dataset card view (dataset-card-item.component.scss) for
+// a consistent card look across the dashboard: 8px radius, 124px cover, a
+// muted #8c8c8c / #595959 meta palette, #f0f0f0 dividers and a #e0506e like
+// accent. Markup/structure intentionally unchanged.
+
+.card-item {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ transition: box-shadow 0.2s;
+ overflow: hidden;
+ border-radius: 8px;
+ cursor: pointer;
+
+ &:hover {
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
+ }
+
+ &.selected {
+ border-color: #1e90ff;
+ background-color: #e6f7ff;
+ }
+
+ ::ng-deep .ant-card-body {
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ }
+}
+
+.card-preview {
+ height: 124px;
+ background-color: #f5f5f5;
+ position: relative;
+ cursor: pointer;
+ overflow: hidden;
+}
+
+.card-preview-image {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ display: block;
+}
+
+.card-checkbox {
+ position: absolute;
+ top: 8px;
+ left: 8px;
+ z-index: 10;
+}
+
+.owner-info {
+ min-width: 0;
+
+ // Scale the avatar down to fit the compact meta row.
+ ::ng-deep nz-avatar {
+ width: 18px;
+ height: 18px;
+ line-height: 18px;
+ font-size: 10px;
+ }
+}
+
+.owner-name {
+ min-width: 0;
+}
+
+.card-content {
+ padding: 12px;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ flex: 1;
+ min-width: 0;
+}
+
+.card-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ cursor: pointer;
+ gap: 6px;
+}
+
+.title-container {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ overflow: hidden;
+ flex: 1;
+ min-width: 0;
+}
+
+.type-icon {
+ flex-shrink: 0;
+ font-size: 16px;
+ color: #8c8c8c;
+}
+
+.name-container {
+ flex: 1;
+ overflow: hidden;
+}
+
+.resource-name {
+ font-size: 15px;
+ font-weight: 600;
+ line-height: 1.35;
+ color: #1f1f1f;
+}
+
+.resource-name-edit-input {
+ width: 100%;
+ font-size: 15px;
+ font-weight: 600;
+ padding: 2px 4px;
+}
+
+.edit-btn {
+ flex-shrink: 0;
+ opacity: 0;
+ color: #8c8c8c;
+ transition: opacity 0.2s;
+
+ &:hover {
+ color: #1f1f1f;
+ }
+}
+
+.card-item:hover .edit-btn {
+ opacity: 1;
+}
+
+.card-meta {
+ display: flex;
+ flex-direction: column;
+ gap: 5px;
+ font-size: 12px;
+ color: #8c8c8c;
+ margin-top: auto;
+}
+
+.meta-details {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+}
+
+.meta-row {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ color: #595959;
+
+ span {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ white-space: nowrap;
+
+ i {
+ font-size: 12px;
+ color: #8c8c8c;
+ }
+ }
+}
+
+.card-actions {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ border-top: 1px solid #f0f0f0;
+ padding-top: 8px;
+ margin-top: 8px;
+}
+
+.action-btn {
+ padding: 4px 8px;
+ border-radius: 4px;
+ color: #8c8c8c;
+
+ &:hover {
+ color: #1f1f1f;
+ background: #f0f0f0;
+ }
+}
+
+.like-btn {
+ &.liked,
+ &:not([disabled]):hover {
+ color: #e0506e;
+ }
+}
+
+.liked {
+ color: #e0506e;
+}
+
+.delete-btn:hover {
+ color: #ff4d4f;
+ background: #fff1f0;
+}
+
+.truncate-single-line {
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
diff --git
a/frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.spec.ts
b/frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.spec.ts
new file mode 100644
index 0000000000..f39f318c34
--- /dev/null
+++
b/frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.spec.ts
@@ -0,0 +1,160 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { CardItemComponent } from "./card-item.component";
+import { WorkflowPersistService } from
"src/app/common/service/workflow-persist/workflow-persist.service";
+import { HttpClientTestingModule } from "@angular/common/http/testing";
+import { NzModalService } from "ng-zorro-antd/modal";
+import { of, throwError } from "rxjs";
+import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
+import { RouterTestingModule } from "@angular/router/testing";
+import { StubUserService } from
"../../../../../common/service/user/stub-user.service";
+import { UserService } from "../../../../../common/service/user/user.service";
+import { commonTestProviders } from "../../../../../common/testing/test-utils";
+import type { Mocked } from "vitest";
+import { DashboardEntry } from "src/app/dashboard/type/dashboard-entry";
+import { HUB_WORKFLOW_RESULT_DETAIL, USER_WORKSPACE } from
"../../../../../app-routing.constant";
+
+function makeWorkflowEntry(overrides: Partial<DashboardEntry> = {}):
DashboardEntry {
+ return {
+ id: 1,
+ name: "wf",
+ description: "",
+ type: "workflow",
+ workflow: { isOwner: true },
+ accessibleUserIds: [],
+ likeCount: 0,
+ viewCount: 0,
+ isLiked: false,
+ size: 0,
+ ...overrides,
+ } as unknown as DashboardEntry;
+}
+
+describe("CardItemComponent", () => {
+ let component: CardItemComponent;
+ let fixture: ComponentFixture<CardItemComponent>;
+ let workflowPersistService: Mocked<WorkflowPersistService>;
+
+ beforeEach(async () => {
+ const workflowPersistServiceSpy = { updateWorkflowName: vi.fn(),
updateWorkflowDescription: vi.fn() };
+
+ await TestBed.configureTestingModule({
+ imports: [CardItemComponent, HttpClientTestingModule,
BrowserAnimationsModule, RouterTestingModule],
+ providers: [
+ { provide: WorkflowPersistService, useValue: workflowPersistServiceSpy
},
+ { provide: UserService, useClass: StubUserService },
+ NzModalService,
+ ...commonTestProviders,
+ ],
+ }).compileComponents();
+
+ fixture = TestBed.createComponent(CardItemComponent);
+ component = fixture.componentInstance;
+ workflowPersistService = TestBed.inject(WorkflowPersistService) as unknown
as Mocked<WorkflowPersistService>;
+ component.entry = makeWorkflowEntry();
+ fixture.detectChanges();
+ });
+
+ it("should update workflow name successfully", () => {
+ const newName = "New Workflow Name";
+ component.entry = makeWorkflowEntry({ id: 1, name: "Old Name" });
+ workflowPersistService.updateWorkflowName.mockReturnValue(of({} as
Response));
+
+ component.confirmUpdateCustomName(newName);
+
+ expect(workflowPersistService.updateWorkflowName).toHaveBeenCalledWith(1,
newName);
+ expect(component.entry.name).toBe(newName);
+ expect(component.editingName).toBe(false);
+ });
+
+ it("should revert the name and exit edit mode when the update fails", () => {
+ component.entry = makeWorkflowEntry({ id: 1, name: "Old Name" });
+ component.originalName = "Old Name";
+ workflowPersistService.updateWorkflowName.mockReturnValue(throwError(() =>
new Error("Error")));
+
+ component.confirmUpdateCustomName("New Workflow Name");
+
+ expect(component.entry.name).toBe("Old Name");
+ expect(component.editingName).toBe(false);
+ });
+
+ it("should update workflow description successfully", () => {
+ component.entry = makeWorkflowEntry({ id: 1, description: "Old
Description" });
+ workflowPersistService.updateWorkflowDescription.mockReturnValue(of({} as
Response));
+
+ component.confirmUpdateCustomDescription("New Description");
+
+
expect(workflowPersistService.updateWorkflowDescription).toHaveBeenCalledWith(1,
"New Description");
+ expect(component.entry.description).toBe("New Description");
+ expect(component.editingDescription).toBe(false);
+ });
+
+ it("should revert the description and exit edit mode when the update fails",
() => {
+ component.entry = makeWorkflowEntry({ id: 1, description: "Old
Description" });
+ component.originalDescription = "Old Description";
+
workflowPersistService.updateWorkflowDescription.mockReturnValue(throwError(()
=> new Error("Error")));
+
+ component.confirmUpdateCustomDescription("New Description");
+
+ expect(component.entry.description).toBe("Old Description");
+ expect(component.editingDescription).toBe(false);
+ });
+
+ it("should route owners to the workspace and non-owners to the hub detail
view", () => {
+ component.currentUid = 42;
+ component.entry = makeWorkflowEntry({ id: 7, accessibleUserIds: [42] });
+ component.ngOnChanges({ entry: { currentValue: component.entry } as any });
+ expect(component.entryLink).toEqual([USER_WORKSPACE, "7"]);
+
+ component.entry = makeWorkflowEntry({ id: 7, accessibleUserIds: [99] });
+ component.ngOnChanges({ entry: { currentValue: component.entry } as any });
+ expect(component.entryLink).toEqual([HUB_WORKFLOW_RESULT_DETAIL, "7"]);
+ });
+
+ it("should format counts as kilo for values >= 1000", () => {
+ expect(component.formatCount(999)).toBe("999");
+ expect(component.formatCount(1500)).toBe("1.5k");
+ expect(component.formatCount(0)).toBe("0");
+ });
+
+ it("should return 'Unknown' for undefined timestamps", () => {
+ expect(component.formatTime(undefined)).toBe("Unknown");
+ });
+
+ it("should emit deleted when the parent triggers the delete confirmation",
() => {
+ const spy = vi.fn();
+ component.deleted.subscribe(spy);
+ component.deleted.emit();
+ expect(spy).toHaveBeenCalledTimes(1);
+ });
+
+ it("should toggle the entry checked flag and emit checkboxChanged", () => {
+ const entry = makeWorkflowEntry({ checked: false } as any);
+ component.entry = entry;
+ const spy = vi.fn();
+ component.checkboxChanged.subscribe(spy);
+
+ component.onCheckboxChange(entry);
+
+ expect((entry as any).checked).toBe(true);
+ expect(spy).toHaveBeenCalledTimes(1);
+ });
+});
diff --git
a/frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.ts
b/frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.ts
new file mode 100644
index 0000000000..ffba9fb9ab
--- /dev/null
+++
b/frontend/src/app/dashboard/component/user/list-item/card-item/card-item.component.ts
@@ -0,0 +1,427 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import {
+ ChangeDetectorRef,
+ Component,
+ ElementRef,
+ EventEmitter,
+ Input,
+ OnChanges,
+ Output,
+ SimpleChanges,
+ ViewChild,
+} from "@angular/core";
+import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy";
+import { NgIf } from "@angular/common";
+import { FormsModule } from "@angular/forms";
+import { RouterLink } from "@angular/router";
+import { NzCardComponent } from "ng-zorro-antd/card";
+import { NzButtonComponent } from "ng-zorro-antd/button";
+import { NzCheckboxComponent } from "ng-zorro-antd/checkbox";
+import { NzIconDirective } from "ng-zorro-antd/icon";
+import { NzPopconfirmDirective } from "ng-zorro-antd/popconfirm";
+import { NzWaveDirective } from "ng-zorro-antd/core/wave";
+import { ɵNzTransitionPatchDirective } from
"ng-zorro-antd/core/transition-patch";
+import { NzModalRef, NzModalService } from "ng-zorro-antd/modal";
+import { DashboardEntry } from "src/app/dashboard/type/dashboard-entry";
+import { ShareAccessComponent } from
"../../share-access/share-access.component";
+import { UserAvatarComponent } from "../../user-avatar/user-avatar.component";
+import {
+ DEFAULT_WORKFLOW_NAME,
+ WorkflowPersistService,
+} from "src/app/common/service/workflow-persist/workflow-persist.service";
+import { firstValueFrom } from "rxjs";
+import { HubWorkflowDetailComponent } from
"../../../../../hub/component/workflow/detail/hub-workflow-detail.component";
+import { ActionType, HubService } from
"../../../../../hub/service/hub.service";
+import { DownloadService } from
"src/app/dashboard/service/user/download/download.service";
+import { formatSize } from "src/app/common/util/size-formatter.util";
+import { formatRelativeTime, formatCount } from
"src/app/common/util/format.util";
+import { DatasetService, DEFAULT_DATASET_NAME } from
"../../../../service/user/dataset/dataset.service";
+import { NotificationService } from
"../../../../../common/service/notification/notification.service";
+import {
+ HUB_DATASET_RESULT_DETAIL,
+ HUB_WORKFLOW_RESULT_DETAIL,
+ USER_DATASET,
+ USER_PROJECT,
+ USER_WORKSPACE,
+} from "../../../../../app-routing.constant";
+import { isDefined } from "../../../../../common/util/predicate";
+
+@UntilDestroy()
+@Component({
+ selector: "texera-card-item",
+ templateUrl: "./card-item.component.html",
+ styleUrls: ["./card-item.component.scss"],
+ imports: [
+ NzCardComponent,
+ RouterLink,
+ NgIf,
+ FormsModule,
+ NzCheckboxComponent,
+ UserAvatarComponent,
+ NzIconDirective,
+ NzButtonComponent,
+ NzPopconfirmDirective,
+ NzWaveDirective,
+ ɵNzTransitionPatchDirective,
+ ],
+})
+export class CardItemComponent implements OnChanges {
+ private owners: number[] = [];
+ public originalName: string = "";
+ public originalDescription: string | undefined = undefined;
+ public disableDelete: boolean = false;
+ @Input() currentUid: number | undefined;
+ @ViewChild("nameInput") nameInput!: ElementRef;
+ @ViewChild("descriptionInput") descriptionInput!: ElementRef;
+ editingName = false;
+ editingDescription = false;
+ likeCount: number = 0;
+ viewCount = 0;
+ entryLink: string[] = [];
+ size: number | undefined = 0;
+ public iconType: string = "";
+ isLiked: boolean = false;
+ @Input() isPrivateSearch = false;
+ @Input() editable = false;
+ private _entry?: DashboardEntry;
+ hovering: boolean = false;
+ /** The default top image, used when the user has not uploaded a custom one.
*/
+ static readonly DEFAULT_PREVIEW_IMAGE = "assets/card_background.jpg";
+
+ @Input()
+ get entry(): DashboardEntry {
+ if (!this._entry) {
+ throw new Error("entry property must be provided.");
+ }
+ return this._entry;
+ }
+
+ set entry(value: DashboardEntry) {
+ this._entry = value;
+ }
+
+ @Output() checkboxChanged = new EventEmitter<void>();
+ @Output() deleted = new EventEmitter<void>();
+ @Output() duplicated = new EventEmitter<void>();
+ @Output() refresh = new EventEmitter<void>();
+
+ constructor(
+ private modalService: NzModalService,
+ private workflowPersistService: WorkflowPersistService,
+ private datasetService: DatasetService,
+ private modal: NzModalService,
+ private hubService: HubService,
+ private downloadService: DownloadService,
+ private cdr: ChangeDetectorRef,
+ private notificationService: NotificationService
+ ) {}
+
+ /** The top image src for the card preview. */
+ get previewImage(): string {
+ return CardItemComponent.DEFAULT_PREVIEW_IMAGE;
+ }
+
+ initializeEntry() {
+ if (this.entry.type === "workflow") {
+ if (typeof this.entry.id === "number") {
+ this.disableDelete = !this.entry.workflow.isOwner;
+ this.owners = this.entry.accessibleUserIds;
+ if (this.currentUid !== undefined &&
this.owners.includes(this.currentUid)) {
+ this.entryLink = [USER_WORKSPACE, String(this.entry.id)];
+ } else {
+ this.entryLink = [HUB_WORKFLOW_RESULT_DETAIL, String(this.entry.id)];
+ }
+ this.size = this.entry.size;
+ }
+ this.iconType = "project";
+ } else if (this.entry.type === "project") {
+ this.entryLink = [USER_PROJECT, String(this.entry.id)];
+ this.iconType = "container";
+ } else if (this.entry.type === "dataset") {
+ if (typeof this.entry.id === "number") {
+ this.disableDelete = !this.entry.dataset.isOwner;
+ this.owners = this.entry.accessibleUserIds;
+ if (this.currentUid !== undefined &&
this.owners.includes(this.currentUid)) {
+ this.entryLink = [USER_DATASET, String(this.entry.id)];
+ } else {
+ this.entryLink = [HUB_DATASET_RESULT_DETAIL, String(this.entry.id)];
+ }
+ this.iconType = "database";
+ this.size = this.entry.size;
+ }
+ } else if (this.entry.type === "file") {
+ // not sure where to redirect
+ this.iconType = "folder-open";
+ } else {
+ throw new Error("Unexpected type in DashboardEntry.");
+ }
+ this.likeCount = this.entry.likeCount;
+ this.viewCount = this.entry.viewCount;
+ this.isLiked = this.entry.isLiked;
+ }
+
+ ngOnChanges(changes: SimpleChanges): void {
+ if (changes["entry"]) {
+ this.initializeEntry();
+ }
+ }
+
+ onCheckboxChange(entry: DashboardEntry): void {
+ entry.checked = !entry.checked;
+ this.cdr.markForCheck();
+ this.checkboxChanged.emit();
+ }
+
+ public async onClickOpenShareAccess(): Promise<void> {
+ let modal: NzModalRef<ShareAccessComponent> | undefined;
+
+ if (this.entry.type === "workflow") {
+ modal = this.modalService.create({
+ nzContent: ShareAccessComponent,
+ nzData: {
+ writeAccess: this.entry.workflow.accessLevel === "WRITE",
+ type: this.entry.type,
+ id: this.entry.id,
+ allOwners: await
firstValueFrom(this.workflowPersistService.retrieveOwners()),
+ inWorkspace: false,
+ },
+ nzFooter: null,
+ nzTitle: "Share this workflow with others",
+ nzCentered: true,
+ nzWidth: "700px",
+ });
+ } else if (this.entry.type === "dataset") {
+ modal = this.modalService.create({
+ nzContent: ShareAccessComponent,
+ nzData: {
+ writeAccess: this.entry.accessLevel === "WRITE",
+ type: "dataset",
+ id: this.entry.id,
+ allOwners: await
firstValueFrom(this.datasetService.retrieveOwners()),
+ },
+ nzFooter: null,
+ nzTitle: "Share this dataset with others",
+ nzCentered: true,
+ nzWidth: "700px",
+ });
+ }
+ if (modal) {
+ modal.componentInstance?.refresh.pipe(untilDestroyed(this)).subscribe(()
=> {
+ this.refresh.emit();
+ });
+ }
+ }
+
+ public onClickDownload = (): void => {
+ if (!this.entry.id) return;
+
+ if (this.entry.type === "workflow") {
+ this.downloadService
+ .downloadWorkflow(this.entry.id, this.entry.workflow.workflow.name)
+ .pipe(untilDestroyed(this))
+ .subscribe();
+ } else if (this.entry.type === "dataset") {
+ this.downloadService.downloadDataset(this.entry.id,
this.entry.name).pipe(untilDestroyed(this)).subscribe();
+ }
+ };
+
+ onEditName(): void {
+ this.originalName = this.entry.name;
+ this.editingName = true;
+ setTimeout(() => {
+ if (this.nameInput) {
+ const inputElement = this.nameInput.nativeElement;
+ const valueLength = inputElement.value.length;
+ inputElement.focus();
+ inputElement.setSelectionRange(valueLength, valueLength);
+ }
+ }, 0);
+ }
+
+ onEditDescription(): void {
+ this.originalDescription = this.entry.description;
+ this.editingDescription = true;
+ setTimeout(() => {
+ if (this.descriptionInput) {
+ const textareaElement = this.descriptionInput.nativeElement;
+ const valueLength = textareaElement.value.length;
+ textareaElement.focus();
+ textareaElement.setSelectionRange(valueLength, valueLength);
+ }
+ }, 0);
+ }
+
+ private updateProperty(
+ updateMethod: (id: number, value: string) => any,
+ propertyName: "name" | "description",
+ newValue: string,
+ originalValue: string | undefined
+ ): void {
+ if (!this.entry.id) {
+ this.notificationService.error("Id is missing");
+ return;
+ }
+
+ updateMethod(this.entry.id, newValue)
+ .pipe(untilDestroyed(this))
+ .subscribe({
+ next: () => {
+ this.entry[propertyName] = newValue; // Dynamic property assignment
+ },
+ error: () => {
+ this.notificationService.error("Update failed");
+ (this.entry as any)[propertyName] = originalValue ?? ""; // Fallback
to original value
+ this.setEditingState(propertyName, false);
+ },
+ complete: () => {
+ this.setEditingState(propertyName, false);
+ },
+ });
+ }
+
+ private setEditingState(propertyName: "name" | "description", state:
boolean): void {
+ if (propertyName === "name") {
+ this.editingName = state;
+ } else if (propertyName === "description") {
+ this.editingDescription = state;
+ }
+ }
+
+ public confirmUpdateCustomName(name: string): void {
+ if (this.entry.name === this.originalName) {
+ this.editingName = false;
+ return;
+ }
+ const newName = this.entry.type === "workflow" ? name ||
DEFAULT_WORKFLOW_NAME : name || DEFAULT_DATASET_NAME;
+
+ if (this.entry.type === "workflow") {
+ this.updateProperty(
+
this.workflowPersistService.updateWorkflowName.bind(this.workflowPersistService),
+ "name",
+ newName,
+ this.originalName
+ );
+ } else if (this.entry.type === "dataset") {
+ this.updateProperty(
+ this.datasetService.updateDatasetName.bind(this.datasetService),
+ "name",
+ newName,
+ this.originalName
+ );
+ }
+ }
+
+ public confirmUpdateCustomDescription(description: string | undefined): void
{
+ if (this.entry.description === this.originalDescription) {
+ this.editingDescription = false;
+ return;
+ }
+ const updatedDescription = description ?? "";
+
+ if (this.entry.type === "workflow") {
+ this.updateProperty(
+
this.workflowPersistService.updateWorkflowDescription.bind(this.workflowPersistService),
+ "description",
+ updatedDescription,
+ this.originalDescription
+ );
+ } else if (this.entry.type === "dataset") {
+ this.updateProperty(
+ this.datasetService.updateDatasetDescription.bind(this.datasetService),
+ "description",
+ updatedDescription,
+ this.originalDescription
+ );
+ }
+ }
+
+ openDetailModal(wid: number | undefined): void {
+ const modalRef = this.modal.create({
+ nzTitle: "Workflow Detail",
+ nzContent: HubWorkflowDetailComponent,
+ nzData: {
+ wid: wid ?? 0,
+ },
+ nzFooter: null,
+ nzStyle: { width: "60%" },
+ nzBodyStyle: { maxHeight: "70vh", overflow: "auto" },
+ });
+
+ const instance = modalRef.componentInstance;
+ if (instance) {
+ if (wid !== undefined) {
+ this.hubService
+ .getCounts([this.entry.type], [wid], [ActionType.View])
+ .pipe(untilDestroyed(this))
+ .subscribe(counts => {
+ const count = counts[0];
+ this.viewCount = (count?.counts.view ?? 0) + 1; // hacky fix to
display view correctly
+ });
+ }
+ }
+ }
+
+ toggleLike(): void {
+ const userId = this.currentUid;
+ if (!isDefined(userId) || !isDefined(this.entry.id)) {
+ return;
+ }
+
+ const entryId = this.entry.id!;
+
+ if (this.isLiked) {
+ this.hubService
+ .postUnlike(entryId, this.entry.type)
+ .pipe(untilDestroyed(this))
+ .subscribe((success: boolean) => {
+ if (success) {
+ this.isLiked = false;
+ this.hubService
+ .getCounts([this.entry.type], [entryId], [ActionType.Like])
+ .pipe(untilDestroyed(this))
+ .subscribe(counts => {
+ this.likeCount = counts[0].counts.like ?? 0;
+ });
+ }
+ });
+ } else {
+ this.hubService
+ .postLike(entryId, this.entry.type)
+ .pipe(untilDestroyed(this))
+ .subscribe((success: boolean) => {
+ if (success) {
+ this.isLiked = true;
+ this.hubService
+ .getCounts([this.entry.type], [entryId], [ActionType.Like])
+ .pipe(untilDestroyed(this))
+ .subscribe(counts => {
+ this.likeCount = counts[0].counts.like ?? 0;
+ });
+ }
+ });
+ }
+ }
+
+ // aliases for the shared formatting utilities so the template can call them
directly
+ formatTime = formatRelativeTime;
+ formatCount = formatCount;
+ formatSize = formatSize;
+}
diff --git
a/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.html
b/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.html
index 1873658797..492efc5376 100644
---
a/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.html
+++
b/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.html
@@ -131,6 +131,26 @@
nzTheme="outline"
nzType="minus-square"></i>
</button>
+ <button
+ nz-button
+ title="List View"
+ (click)="setViewType('list')"
+ [nzType]="viewType === 'list' ? 'primary' : 'default'">
+ <i
+ nz-icon
+ nzType="bars"
+ nzTheme="outline"></i>
+ </button>
+ <button
+ nz-button
+ title="Card View"
+ (click)="setViewType('card')"
+ [nzType]="viewType === 'card' ? 'primary' : 'default'">
+ <i
+ nz-icon
+ nzType="appstore"
+ nzTheme="outline"></i>
+ </button>
</nz-space-compact>
<texera-filters
[pid]="pid"
@@ -153,9 +173,27 @@
</nz-select>
</div>
+ <ng-template
+ #workflowCardTpl
+ let-entry>
+ <texera-card-item
+ class="workflow-card-item"
+ [entry]="entry"
+ [currentUid]="currentUid"
+ [isPrivateSearch]="true"
+ [editable]="true"
+ (deleted)="deleteWorkflow(entry)"
+ (duplicated)="onClickDuplicateWorkflow(entry)"
+ (refresh)="refreshSearchResult()"
+ (checkboxChanged)="searchResultsComponent.onEntryCheckboxChange()">
+ </texera-card-item>
+ </ng-template>
+
<texera-search-results
[editable]="true"
[isPrivateSearch]="true"
+ [viewMode]="viewType"
+ [cardTemplate]="workflowCardTpl"
(deleted)="deleteWorkflow($event)"
(refresh)="refreshSearchResult()"
(duplicated)="onClickDuplicateWorkflow($event)"
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 584191f8bf..cff50d1cda 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
@@ -36,6 +36,7 @@ import { NzUploadFile, NzUploadComponent } from
"ng-zorro-antd/upload";
import * as JSZip from "jszip";
import { FiltersComponent } from "../filters/filters.component";
import { SearchResultsComponent } from
"../search-results/search-results.component";
+import { CardItemComponent } from "../list-item/card-item/card-item.component";
import { SearchService } from "../../../service/user/search.service";
import { SortMethod } from "../../../type/sort-method";
import { isDefined } from "../../../../common/util/predicate";
@@ -107,10 +108,12 @@ import { FormsModule } from "@angular/forms";
NzSelectComponent,
FormsModule,
SearchResultsComponent,
+ CardItemComponent,
NzSpaceCompactComponent,
],
})
export class UserWorkflowComponent implements AfterViewInit {
+ private static readonly VIEW_MODE_STORAGE_KEY =
"texera.userWorkflow.viewMode";
private _searchResultsComponent?: SearchResultsComponent;
public isLogin = this.userService.isLogin();
private includePublic = false;
@@ -141,6 +144,8 @@ export class UserWorkflowComponent implements AfterViewInit
{
@Input() public pid?: number = undefined;
@Input() public accessLevel?: string = undefined;
public sortMethod = SortMethod.EditTimeDesc;
+ public viewType: "list" | "card" =
+ localStorage.getItem(UserWorkflowComponent.VIEW_MODE_STORAGE_KEY) ===
"card" ? "card" : "list";
lastSortMethod: SortMethod | null = null;
constructor(
@@ -163,6 +168,14 @@ export class UserWorkflowComponent implements
AfterViewInit {
});
}
+ public setViewType(viewType: "list" | "card"): void {
+ if (this.viewType === viewType) {
+ return;
+ }
+ this.viewType = viewType;
+ localStorage.setItem(UserWorkflowComponent.VIEW_MODE_STORAGE_KEY,
viewType);
+ }
+
public multiWorkflowsOperationButtonEnabled(): boolean {
if (this._searchResultsComponent) {
return this.searchResultsComponent?.entries.filter(i =>
i.checked).length > 0;