Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class WorkflowEmailNotifier(
private def createDashboardUrl(): String = {
val host = sessionUri.getHost
val port = sessionUri.getPort
val path = s"/dashboard/user/workspace/$workflowId"
val path = s"/user/workspace/$workflowId"
if (port == -1 || port == 80 || port == 443) {
s"http://$host$path"
} else {
Expand Down
49 changes: 24 additions & 25 deletions frontend/src/app/app-routing.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,31 @@
* under the License.
*/

export const DASHBOARD = "/dashboard";
export const DASHBOARD_HOME = `${DASHBOARD}/home`;
export const DASHBOARD_ABOUT = `${DASHBOARD}/about`;
export const HOME = "/home";
export const ABOUT = "/about";

export const DASHBOARD_HUB = `${DASHBOARD}/hub`;
export const DASHBOARD_HUB_WORKFLOW = `${DASHBOARD_HUB}/workflow`;
export const DASHBOARD_HUB_WORKFLOW_RESULT = `${DASHBOARD_HUB_WORKFLOW}/result`;
export const DASHBOARD_HUB_WORKFLOW_RESULT_DETAIL = `${DASHBOARD_HUB_WORKFLOW_RESULT}/detail`;
export const DASHBOARD_HUB_DATASET = `${DASHBOARD_HUB}/dataset`;
export const DASHBOARD_HUB_DATASET_RESULT = `${DASHBOARD_HUB_DATASET}/result`;
export const DASHBOARD_HUB_DATASET_RESULT_DETAIL = `${DASHBOARD_HUB_DATASET_RESULT}/detail`;
export const HUB = "/hub";
export const HUB_WORKFLOW = `${HUB}/workflow`;
export const HUB_WORKFLOW_RESULT = `${HUB_WORKFLOW}/result`;
export const HUB_WORKFLOW_RESULT_DETAIL = `${HUB_WORKFLOW_RESULT}/detail`;
export const HUB_DATASET = `${HUB}/dataset`;
export const HUB_DATASET_RESULT = `${HUB_DATASET}/result`;
export const HUB_DATASET_RESULT_DETAIL = `${HUB_DATASET_RESULT}/detail`;

export const DASHBOARD_USER = `${DASHBOARD}/user`;
export const DASHBOARD_USER_PROJECT = `${DASHBOARD_USER}/project`;
export const DASHBOARD_USER_WORKSPACE = `${DASHBOARD_USER}/workflow`;
export const DASHBOARD_USER_WORKFLOW = `${DASHBOARD_USER}/workflow`;
export const DASHBOARD_USER_DATASET = `${DASHBOARD_USER}/dataset`;
export const DASHBOARD_USER_DATASET_CREATE = `${DASHBOARD_USER_DATASET}/create`;
export const DASHBOARD_USER_COMPUTING_UNIT = `${DASHBOARD_USER}/compute`;
export const DASHBOARD_USER_QUOTA = `${DASHBOARD_USER}/quota`;
export const DASHBOARD_USER_DISCUSSION = `${DASHBOARD_USER}/discussion`;
export const USER = "/user";
export const USER_PROJECT = `${USER}/project`;
export const USER_WORKSPACE = `${USER}/workflow`;
export const USER_WORKFLOW = `${USER}/workflow`;
export const USER_DATASET = `${USER}/dataset`;
export const USER_DATASET_CREATE = `${USER_DATASET}/create`;
export const USER_COMPUTING_UNIT = `${USER}/compute`;
export const USER_QUOTA = `${USER}/quota`;
export const USER_DISCUSSION = `${USER}/discussion`;

export const DASHBOARD_ADMIN = `${DASHBOARD}/admin`;
export const DASHBOARD_ADMIN_USER = `${DASHBOARD_ADMIN}/user`;
export const DASHBOARD_ADMIN_GMAIL = `${DASHBOARD_ADMIN}/gmail`;
export const DASHBOARD_ADMIN_EXECUTION = `${DASHBOARD_ADMIN}/execution`;
export const DASHBOARD_ADMIN_SETTINGS = `${DASHBOARD_ADMIN}/settings`;
export const ADMIN = "/admin";
export const ADMIN_USER = `${ADMIN}/user`;
export const ADMIN_GMAIL = `${ADMIN}/gmail`;
export const ADMIN_EXECUTION = `${ADMIN}/execution`;
export const ADMIN_SETTINGS = `${ADMIN}/settings`;

export const DASHBOARD_SEARCH = `${DASHBOARD}/search`;
export const SEARCH = "/search";
27 changes: 10 additions & 17 deletions frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

import { inject, NgModule } from "@angular/core";
import { CanActivateFn, Router, RouterModule, Routes } from "@angular/router";
import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { DashboardComponent } from "./dashboard/component/dashboard.component";
import { UserWorkflowComponent } from "./dashboard/component/user/user-workflow/user-workflow.component";
import { UserQuotaComponent } from "./dashboard/component/user/user-quota/user-quota.component";
Expand All @@ -38,28 +38,21 @@ import { DatasetDetailComponent } from "./dashboard/component/user/user-dataset/
import { UserDatasetComponent } from "./dashboard/component/user/user-dataset/user-dataset.component";
import { HubWorkflowDetailComponent } from "./hub/component/workflow/detail/hub-workflow-detail.component";
import { LandingPageComponent } from "./hub/component/landing-page/landing-page.component";
import { DASHBOARD_ABOUT, DASHBOARD_USER_WORKFLOW } from "./app-routing.constant";
import { USER_WORKFLOW } from "./app-routing.constant";
import { HubSearchResultComponent } from "./hub/component/hub-search-result/hub-search-result.component";
import { AdminSettingsComponent } from "./dashboard/component/admin/settings/admin-settings.component";
import { GuiConfigService } from "./common/service/gui-config.service";

const rootRedirectGuard: CanActivateFn = () => {
const config = inject(GuiConfigService);
const router = inject(Router);
try {
return router.parseUrl(DASHBOARD_ABOUT);
} catch {
// config not loaded yet, swallow the error and let the app handle it
}
return true;
};

const routes: Routes = [];

routes.push({
path: "dashboard",
path: "",
component: DashboardComponent,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have plan to rename this component?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to my knowledge

children: [
{
path: "",
redirectTo: "about",
pathMatch: "full",
},
{
path: "home",
component: LandingPageComponent,
Expand Down Expand Up @@ -185,7 +178,7 @@ routes.push({
// redirect all other paths to index.
routes.push({
path: "**",
redirectTo: DASHBOARD_USER_WORKFLOW,
redirectTo: USER_WORKFLOW,
});

@NgModule({
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/common/service/user/auth-guard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Injectable } from "@angular/core";
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from "@angular/router";
import { GuiConfigService } from "../gui-config.service";
import { UserService } from "./user.service";
import { DASHBOARD_ABOUT } from "../../../app-routing.constant";
import { ABOUT } from "../../../app-routing.constant";

/**
* AuthGuardService is a service can tell the router whether
Expand All @@ -38,7 +38,7 @@ export class AuthGuardService implements CanActivate {
if (this.userService.isLogin()) {
return true;
} else {
this.router.navigate([DASHBOARD_ABOUT], { queryParams: { returnUrl: state.url === "/" ? null : state.url } });
this.router.navigate([ABOUT], { queryParams: { returnUrl: state.url === "/" ? null : state.url } });
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<tr *ngFor="let execution of basicTable.data">
<td>
<div *ngIf="execution.access; else normalWorkflowName">
<a href="/dashboard/user/workflow/{{execution.workflowId}}">
<a href="/user/workflow/{{execution.workflowId}}">
{{ maxStringLength(execution.workflowName, 16) }} ({{ execution.workflowId }})
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
*/

import { ComponentFixture, inject, TestBed } from "@angular/core/testing";
import { By } from "@angular/platform-browser";
import { AdminExecutionComponent } from "./admin-execution.component";
import { AdminExecutionService } from "../../../service/admin/execution/admin-execution.service";
import { HttpClientTestingModule, HttpTestingController } from "@angular/common/http/testing";
import { NzDropDownModule } from "ng-zorro-antd/dropdown";
import { NzModalModule } from "ng-zorro-antd/modal";
import { commonTestProviders } from "../../../../common/testing/test-utils";
import { Execution } from "../../../../common/type/execution";

describe("AdminDashboardComponent", () => {
let component: AdminExecutionComponent;
Expand All @@ -45,4 +47,23 @@ describe("AdminDashboardComponent", () => {
it("should create", inject([HttpTestingController], () => {
expect(component).toBeTruthy();
}));

it("renders the workflow link to /user/workflow/<id> when the admin has access", () => {
component.listOfExecutions = [
{
access: true,
workflowId: 42,
workflowName: "demo workflow",
executionId: 1,
executionName: "exec",
userName: "alice",
executionStatus: "COMPLETED",
} as unknown as Execution,
];
component.isLoading = false;
fixture.detectChanges();

const anchor = fixture.debugElement.query(By.css('a[href="/user/workflow/42"]'));
expect(anchor).toBeTruthy();
});
});
22 changes: 11 additions & 11 deletions frontend/src/app/dashboard/component/dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
nz-tooltip="Look up the user projects"
nzMatchRouter="true"
nzTooltipPlacement="right"
[routerLink]="DASHBOARD_USER_PROJECT">
[routerLink]="USER_PROJECT">
<span
nz-icon
nzType="container"></span>
Expand All @@ -78,7 +78,7 @@
nz-tooltip="Open the saved workflows"
nzMatchRouter="true"
nzTooltipPlacement="right"
[routerLink]="DASHBOARD_USER_WORKFLOW">
[routerLink]="USER_WORKFLOW">
<span
nz-icon
nzType="project"></span>
Expand All @@ -91,7 +91,7 @@
nz-tooltip="Look up for datasets"
nzMatchRouter="true"
nzTooltipPlacement="right"
[routerLink]="DASHBOARD_USER_DATASET">
[routerLink]="USER_DATASET">
<span
nz-icon
nzType="database"></span>
Expand All @@ -103,7 +103,7 @@
nz-tooltip="Manage computing units"
nzMatchRouter="true"
nzTooltipPlacement="right"
[routerLink]="DASHBOARD_USER_COMPUTING_UNIT">
[routerLink]="USER_COMPUTING_UNIT">
<span
nz-icon
nzType="deployment-unit"></span>
Expand All @@ -115,7 +115,7 @@
nz-tooltip="Quota information"
nzMatchRouter="true"
nzTooltipPlacement="right"
[routerLink]="DASHBOARD_USER_QUOTA">
[routerLink]="USER_QUOTA">
<span
nz-icon
nzType="dashboard"></span>
Expand All @@ -127,7 +127,7 @@
nz-tooltip="Open the discussion forum"
nzMatchRouter="true"
nzTooltipPlacement="right"
[routerLink]="DASHBOARD_USER_DISCUSSION">
[routerLink]="USER_DISCUSSION">
<span
nz-icon
nzType="comment"></span>
Expand All @@ -147,7 +147,7 @@
nz-tooltip="Look up the users"
nzMatchRouter="true"
nzTooltipPlacement="right"
[routerLink]="DASHBOARD_ADMIN_USER">
[routerLink]="ADMIN_USER">
<span
nz-icon
nzType="user"></span>
Expand All @@ -158,7 +158,7 @@
nz-tooltip="View statistics"
nzMatchRouter="true"
nzTooltipPlacement="right"
[routerLink]="DASHBOARD_ADMIN_EXECUTION">
[routerLink]="ADMIN_EXECUTION">
<span
nz-icon
nzType="setting"></span>
Expand All @@ -169,7 +169,7 @@
nz-tooltip="Setup gmail"
nzMatchRouter="true"
nzTooltipPlacement="right"
[routerLink]="DASHBOARD_ADMIN_GMAIL">
[routerLink]="ADMIN_GMAIL">
<span
nz-icon
nzType="mail"></span>
Expand All @@ -180,7 +180,7 @@
nz-tooltip="Settings"
nzMatchRouter="true"
nzTooltipPlacement="right"
[routerLink]="DASHBOARD_ADMIN_SETTINGS">
[routerLink]="ADMIN_SETTINGS">
<span
nz-icon
nzType="edit"></span>
Expand All @@ -194,7 +194,7 @@
nz-menu-item
nz-tooltip
nzTooltipPlacement="right"
[routerLink]="DASHBOARD_ABOUT">
[routerLink]="ABOUT">
<span
nz-icon
nzType="info-circle"></span>
Expand Down
63 changes: 61 additions & 2 deletions frontend/src/app/dashboard/component/dashboard.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,26 @@ import {
NavigationEnd,
Params,
Router,
RouterLink,
UrlSegment,
} from "@angular/router";
import type { Mock } from "vitest";
import { HttpClientTestingModule } from "@angular/common/http/testing";
import { commonTestProviders } from "../../common/testing/test-utils";
import { GuiConfigService } from "../../common/service/gui-config.service";
import {
ABOUT,
ADMIN_EXECUTION,
ADMIN_GMAIL,
ADMIN_SETTINGS,
ADMIN_USER,
USER_COMPUTING_UNIT,
USER_DATASET,
USER_DISCUSSION,
USER_PROJECT,
USER_QUOTA,
USER_WORKFLOW,
} from "../../app-routing.constant";

describe("DashboardComponent", () => {
let component: DashboardComponent;
Expand Down Expand Up @@ -77,11 +91,12 @@ describe("DashboardComponent", () => {
isAdmin: vi.fn().mockReturnValue(false),
isLogin: vi.fn().mockReturnValue(false),
userChanged: vi.fn().mockReturnValue(of(null)),
getCurrentUser: vi.fn().mockReturnValue(undefined),
};

routerMock = {
events: of(new NavigationEnd(1, "/dashboard", "/dashboard")),
url: "/dashboard",
events: of(new NavigationEnd(1, "/", "/")),
url: "/",
navigateByUrl: vi.fn(),
};

Expand Down Expand Up @@ -162,4 +177,48 @@ describe("DashboardComponent", () => {

expect(fixture.debugElement.query(By.css("#powered-by"))).toBeTruthy();
});

it("should hide the navbar on workflow workspace routes", () => {
expect(component.isNavbarEnabled("/user/workflow/42")).toBe(false);
expect(component.isNavbarEnabled("/user/workflow")).toBe(true);
expect(component.isNavbarEnabled("/user/project")).toBe(true);
});

it("exposes route constants without the legacy /dashboard prefix", () => {
expect(USER_PROJECT).toBe("/user/project");
Comment thread
Yicong-Huang marked this conversation as resolved.
expect(USER_WORKFLOW).toBe("/user/workflow");
expect(USER_DATASET).toBe("/user/dataset");
expect(USER_COMPUTING_UNIT).toBe("/user/compute");
expect(USER_QUOTA).toBe("/user/quota");
expect(USER_DISCUSSION).toBe("/user/discussion");
expect(ADMIN_USER).toBe("/admin/user");
expect(ADMIN_EXECUTION).toBe("/admin/execution");
expect(ADMIN_GMAIL).toBe("/admin/gmail");
expect(ADMIN_SETTINGS).toBe("/admin/settings");
expect(ABOUT).toBe("/about");
});

it("renders every sidebar tab's routerLink when fully enabled", () => {
(userServiceMock.isLogin as Mock).mockReturnValue(true);
component.isLogin = true;
component.isAdmin = true;
component.sidebarTabs = {
hub_enabled: false,
home_enabled: true,
workflow_enabled: true,
dataset_enabled: true,
your_work_enabled: true,
projects_enabled: true,
workflows_enabled: true,
datasets_enabled: true,
compute_enabled: true,
quota_enabled: true,
forum_enabled: true,
about_enabled: true,
};
fixture.detectChanges();

// 6 "Your Work" links + 4 admin links + 1 about link = 11
expect(fixture.debugElement.queryAll(By.directive(RouterLink)).length).toBe(11);
});
});
Loading
Loading