Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Fix conditions controlling the availability of new Controller Service (in flow), new Parameter Context, and Move to Parent Group.

This closes #9132
  • Loading branch information
mcgilman authored Jul 31, 2024
1 parent febde9d commit d41d8ed
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1216,8 +1216,20 @@ export class CanvasContextMenu implements ContextMenuDefinitionProvider {
isSeparator: true
},
{
condition: () => {
return this.canvasUtils.isNotRootGroup();
condition: (selection: d3.Selection<any, any, any, any>) => {
if (selection.empty()) {
return false;
}

if (!this.canvasUtils.canModify(selection)) {
return false;
}

return (
this.canvasUtils.isNotRootGroup() &&
this.canvasUtils.canModifyParentGroup() &&
this.canvasUtils.isDisconnected(selection)
);
},
clazz: 'fa fa-arrows',
text: 'Move To Parent Group',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,19 @@ export class CanvasUtils {
return this.supportsModification(selection);
}

/**
* Returns whether the user can write the parent process group, false otherwise.
*/
public canModifyParentGroup(): boolean {
if (this.breadcrumbs) {
if (this.breadcrumbs.parentBreadcrumb) {
return this.breadcrumbs.parentBreadcrumb.permissions.canWrite;
}
}

return false;
}

/**
* Determines whether the specified selection is configurable.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ <h3 class="primary-color">Controller Services</h3>
<breadcrumbs
[entity]="serviceState.breadcrumb"
[currentProcessGroupId]="serviceState.processGroupId"></breadcrumbs>
<button mat-icon-button color="primary" (click)="openNewControllerServiceDialog()">
<i class="fa fa-plus"></i>
</button>
@if (serviceState.breadcrumb.permissions.canWrite) {
<button mat-icon-button color="primary" (click)="openNewControllerServiceDialog()">
<i class="fa fa-plus"></i>
</button>
}
</div>
@if (flowConfiguration$ | async; as flowConfiguration) {
<div class="flex-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,39 @@
</div>
} @else {
<div class="flex flex-col h-full gap-y-2">
<div class="flex justify-end">
<button mat-icon-button color="primary" (click)="openNewParameterContextDialog()">
<i class="fa fa-plus"></i>
</button>
</div>
<div class="flex-1">
<parameter-context-table
[parameterContexts]="parameterContextListingState.parameterContexts"
[selectedParameterContextId]="selectedParameterContextId$ | async"
[currentUser]="(currentUser$ | async)!"
[flowConfiguration]="(flowConfiguration$ | async)!"
(selectParameterContext)="selectParameterContext($event)"
(editParameterContext)="editParameterContext($event)"
(deleteParameterContext)="deleteParameterContext($event)"
(manageAccessPolicies)="navigateToManageComponentPolicies($event)"></parameter-context-table>
</div>
<div class="flex justify-between">
<div class="text-sm flex items-center gap-x-2">
<button mat-icon-button color="primary" (click)="refreshParameterContextListing()">
<i
class="fa fa-refresh"
[class.fa-spin]="parameterContextListingState.status === 'loading'"></i>
</button>
<div>Last updated:</div>
<div class="accent-color font-medium">
{{ parameterContextListingState.loadedTimestamp }}
@if (currentUser$ | async; as currentUser) {
@if (currentUser.parameterContextPermissions.canWrite) {
<div class="flex justify-end">
<button mat-icon-button color="primary" (click)="openNewParameterContextDialog()">
<i class="fa fa-plus"></i>
</button>
</div>
}
<div class="flex-1">
<parameter-context-table
[parameterContexts]="parameterContextListingState.parameterContexts"
[selectedParameterContextId]="selectedParameterContextId$ | async"
[currentUser]="currentUser"
[flowConfiguration]="(flowConfiguration$ | async)!"
(selectParameterContext)="selectParameterContext($event)"
(editParameterContext)="editParameterContext($event)"
(deleteParameterContext)="deleteParameterContext($event)"
(manageAccessPolicies)="navigateToManageComponentPolicies($event)"></parameter-context-table>
</div>
</div>
<div class="flex justify-between">
<div class="text-sm flex items-center gap-x-2">
<button mat-icon-button color="primary" (click)="refreshParameterContextListing()">
<i
class="fa fa-refresh"
[class.fa-spin]="parameterContextListingState.status === 'loading'"></i>
</button>
<div>Last updated:</div>
<div class="accent-color font-medium">
{{ parameterContextListingState.loadedTimestamp }}
</div>
</div>
</div>
}
</div>
}
}

0 comments on commit d41d8ed

Please sign in to comment.