Skip to content

Commit 6346a87

Browse files
authored
NIFI-15051 - Allow users to only show controller services for the current process group (scope) in the listing (#10396)
1 parent e81448f commit 6346a87

File tree

8 files changed

+514
-45
lines changed

8 files changed

+514
-45
lines changed

nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/service/guard/base-guard.utils.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616
*/
1717

1818
import { inject } from '@angular/core';
19-
import { ActivatedRouteSnapshot, CanActivateFn, CanMatchFn, Router, RouterStateSnapshot, UrlSegment, UrlTree } from '@angular/router';
19+
import {
20+
ActivatedRouteSnapshot,
21+
CanActivateFn,
22+
CanMatchFn,
23+
Router,
24+
RouterStateSnapshot,
25+
UrlSegment,
26+
UrlTree
27+
} from '@angular/router';
2028
import { Store } from '@ngrx/store';
2129
import { NiFiRegistryState } from '../../state';
2230
import { RegistryAuthService } from '../registry-auth.service';
@@ -47,7 +55,12 @@ export const showAccessDenied = (store: Store, router: Router): UrlTree => {
4755
return router.parseUrl(fallbackUrl);
4856
};
4957

50-
const redirectToLogin = (store: Store, router: Router, authService: RegistryAuthService, requestedUrl: string): UrlTree => {
58+
const redirectToLogin = (
59+
store: Store,
60+
router: Router,
61+
authService: RegistryAuthService,
62+
requestedUrl: string
63+
): UrlTree => {
5164
authService.setRedirectUrl(requestedUrl || fallbackUrl);
5265
return router.parseUrl('/login');
5366
};
@@ -72,10 +85,7 @@ const evaluateAuthorization = (
7285
return showAccessDenied(store, router);
7386
};
7487

75-
const authorize = (
76-
requestedUrl: string,
77-
authorizationCheck: AuthorizationCheck
78-
): Observable<boolean | UrlTree> => {
88+
const authorize = (requestedUrl: string, authorizationCheck: AuthorizationCheck): Observable<boolean | UrlTree> => {
7989
const store = inject(Store<NiFiRegistryState>);
8090
const router = inject(Router);
8191
const authService = inject(RegistryAuthService);
@@ -120,4 +130,5 @@ export const buildCanActivateGuard = (authorizationCheck: AuthorizationCheck): C
120130
authorize(computeRequestedUrlFromState(state), authorizationCheck);
121131
};
122132

123-
export const buildGuard = (authorizationCheck: AuthorizationCheck): CanMatchFn => buildCanMatchGuard(authorizationCheck);
133+
export const buildGuard = (authorizationCheck: AuthorizationCheck): CanMatchFn =>
134+
buildCanMatchGuard(authorizationCheck);

nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/service/guard/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ export * from './resources.guard';
1919
export * from './admin-workflow.guard';
2020
export * from './admin-tenants.guard';
2121
export * from './login.guard';
22-

nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/service/guard/login.guard.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,3 @@ export const loginGuard: CanActivateFn = (_route, state: RouterStateSnapshot): O
8282
})
8383
);
8484
};
85-

nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/ui/controller-service/controller-services.component.html

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</header>
2222
<div class="pb-5 px-5 flex-1 flex flex-col">
2323
<h3 class="primary-color">Controller Services</h3>
24-
@if (serviceState$ | async; as serviceState) {
24+
@if (serviceState(); as serviceState) {
2525
@if (isInitialLoading(serviceState)) {
2626
<div>
2727
<ngx-skeleton-loader count="3"></ngx-skeleton-loader>
@@ -34,20 +34,42 @@ <h3 class="primary-color">Controller Services</h3>
3434
[entity]="serviceState.breadcrumb"
3535
[currentProcessGroupId]="serviceState.processGroupId"></breadcrumbs>
3636
</div>
37-
@if (serviceState.breadcrumb.permissions.canWrite) {
38-
<button
39-
mat-icon-button
40-
class="primary-icon-button shrink-0"
41-
(click)="openNewControllerServiceDialog()">
42-
<i class="fa fa-plus"></i>
43-
</button>
44-
}
37+
<div class="flex items-center gap-x-3 shrink-0">
38+
@if (shouldShowFilter()) {
39+
<div class="flex items-center justify-between gap-x-2 current-scope-only">
40+
<mat-checkbox [(ngModel)]="showCurrentScopeOnly" data-qa="current-scope-filter">
41+
</mat-checkbox>
42+
<div class="flex items-center justify-between gap-x-1">
43+
<label
44+
class="cursor-pointer select-none whitespace-nowrap nifi-body"
45+
(click)="toggleFilter()"
46+
data-qa="current-scope-label">
47+
Show current scope only
48+
</label>
49+
<i
50+
class="fa fa-info-circle"
51+
nifiTooltip
52+
[tooltipComponentType]="TextTip"
53+
[tooltipInputData]="getFilterTooltip(serviceState.breadcrumb)"
54+
data-qa="current-scope-help"></i>
55+
</div>
56+
</div>
57+
}
58+
@if (serviceState.breadcrumb.permissions.canWrite) {
59+
<button
60+
mat-icon-button
61+
class="primary-icon-button"
62+
(click)="openNewControllerServiceDialog()">
63+
<i class="fa fa-plus"></i>
64+
</button>
65+
}
66+
</div>
4567
</div>
4668
@if (flowConfiguration$ | async; as flowConfiguration) {
4769
<div class="flex-1">
4870
<controller-service-table
4971
[selectedServiceId]="selectedServiceId$ | async"
50-
[controllerServices]="serviceState.controllerServices"
72+
[controllerServices]="filteredControllerServices()"
5173
[formatScope]="formatScope(serviceState.breadcrumb)"
5274
[definedByCurrentGroup]="definedByCurrentGroup(serviceState.breadcrumb)"
5375
[currentUser]="(currentUser$ | async)!"

nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/ui/controller-service/controller-services.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
18+
.current-scope-only {
19+
.fa-question-circle {
20+
font-size: 14px;
21+
}
22+
}

0 commit comments

Comments
 (0)