Skip to content

Commit

Permalink
Disable the “Clone” button for restricted and inactive users (#3208)
Browse files Browse the repository at this point in the history
### Purpose
It looks to restricted/inactive users as they can clone a workflow, when
they actually cannot. To reduce the confusion, the clone button is
disabled in the GUI.
fix #3066 

### Changes

Added variables isAdminOrRegularUser in
hub-workflow-detail-component.ts. Check the user role. If the user is
not an admin or regular user, disable the clone button.



https://github.com/user-attachments/assets/c426c50d-fb31-4377-a2b7-3de2a24da512

---------

Co-authored-by: Texera <[email protected]>
  • Loading branch information
paulschatt and Texera authored Jan 14, 2025
1 parent ae0c7bc commit 8ee3570
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h1>Workflow Detail Page</h1>
nzType="primary"
class="clone-button"
title="Copy"
[disabled]="!isLogin || !isHub"
[disabled]="!isLogin || !isHub || !isActivatedUser"
(click)="cloneWorkflow()">
<i
nz-icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { throttleTime } from "rxjs/operators";
import { Workflow } from "../../../../common/type/workflow";
import { isDefined } from "../../../../common/util/predicate";
import { HubWorkflowService } from "../../../service/workflow/hub-workflow.service";
import { User } from "src/app/common/type/user";
import { Role, User } from "src/app/common/type/user";
import { Location } from "@angular/common";
import { NotificationService } from "../../../../common/service/notification/notification.service";
import { WorkflowPersistService } from "../../../../common/service/workflow-persist/workflow-persist.service";
Expand All @@ -28,6 +28,7 @@ export class HubWorkflowDetailComponent implements AfterViewInit, OnDestroy, OnI
ownerName: string = "";
workflowDescription: string = "";
isLogin = this.userService.isLogin();
isActivatedUser: boolean = false;
isLiked: boolean = false;
likeCount: number = 0;
cloneCount: number = 0;
Expand All @@ -54,6 +55,9 @@ export class HubWorkflowDetailComponent implements AfterViewInit, OnDestroy, OnI
this.isHub = true;
}
this.currentUser = this.userService.getCurrentUser();
if (this.currentUser?.role === Role.ADMIN || this.currentUser?.role === Role.REGULAR) {
this.isActivatedUser = true;
}
this.workflowActionService.disableWorkflowModification();
}

Expand Down

0 comments on commit 8ee3570

Please sign in to comment.