rfellows commented on code in PR #8225: URL: https://github.com/apache/nifi/pull/8225#discussion_r1450555490
########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/ui/component-access-policies/component-access-policies.component.html: ########## @@ -0,0 +1,152 @@ +<!-- + ~ 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. + --> + +<ng-container *ngIf="accessPolicyState$ | async; let accessPolicyState"> + <div *ngIf="isInitialLoading(accessPolicyState); else loaded"> + <ngx-skeleton-loader count="3"></ngx-skeleton-loader> + </div> + + <ng-template #loaded> + <ng-container *ngIf="policyComponentState$ | async; let policyComponentState"> + <div + class="component-access-policies flex flex-col h-full gap-y-2" + *ngIf="flowConfiguration$ | async; let flowConfiguration"> + <div class="value"> + <div class="mb-2" [ngSwitch]="accessPolicyState.policyStatus"> + <ng-container *ngSwitchCase="PolicyStatus.NotFound"> + No policy for the specified resource. + <ng-container *ngIf="flowConfiguration.supportsConfigurableAuthorizer"> + <a (click)="createNewPolicy()">Create</a> a new policy. + </ng-container> + </ng-container> + <ng-container *ngSwitchCase="PolicyStatus.Inherited"> + <ng-container *ngIf="accessPolicyState.accessPolicy"> + <ng-container + *ngTemplateOutlet=" + getTemplateForInheritedPolicy(accessPolicyState.accessPolicy); + context: { + $implicit: accessPolicyState.accessPolicy, + supportsConfigurableAuthorizer: + flowConfiguration.supportsConfigurableAuthorizer + } + "></ng-container> + </ng-container> + </ng-container> + <ng-container *ngSwitchCase="PolicyStatus.Forbidden"> + Not authorized to access the policy for the specified resource. + </ng-container> + </div> + </div> + <div class="flex justify-between items-center"> + <form [formGroup]="policyForm"> + <div class="flex gap-x-2"> + <div class="flex gap-x-1 -mt-2"> + <div class="operation-context-logo flex flex-col"> + <i class="icon" [class]="getContextIcon()"></i> + </div> + <div class="flex flex-col"> + <div class="operation-context-name">{{ policyComponentState.label }}</div> + <div class="operation-context-type">{{ getContextType() }}</div> + </div> + </div> + <div class="policy-select"> + <mat-form-field> + <mat-label>Policy</mat-label> + <mat-select + formControlName="policyAction" + (selectionChange)="policyActionChanged($event.value)"> + <mat-option + *ngFor="let option of policyActionOptions" + [disabled]="!isComponentPolicy(option, policyComponentState)" + [value]="option.value" + nifiTooltip + [tooltipComponentType]="TextTip" + [tooltipInputData]="getSelectOptionTipData(option)" + [delayClose]="false" + >{{ option.text }} + </mat-option> Review Comment: should we just not show the options that are not selectable? I realize NiFi does it the same way as implemented here, but if the user can't select them why show them? Especially since the dropdown is padded more and there are cases where you have to scroll past disabled items to get to the next available option. ########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/access-policies/ui/global-access-policies/global-access-policies-routing.module.ts: ########## @@ -0,0 +1,50 @@ +/* + * 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 { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { GlobalAccessPolicies } from './global-access-policies.component'; +import { authorizationGuard } from '../../../../service/guard/authorization.guard'; +import { CurrentUser } from '../../../../state/current-user'; + +const routes: Routes = [ + { + path: ':action/:resource', + canMatch: [ + authorizationGuard( + (user: CurrentUser) => + user.tenantsPermissions.canRead && + user.policiesPermissions.canRead && + user.policiesPermissions.canWrite + ) Review Comment: Do we also need to inject the FlowConfiguration here to verify `supportsManagedAuthorizer`? If the user has the url, http://localhost:4200/#/access-policies/global/read/parameter-contexts for example, they can get to the page even though the menu options are not available. Same is true for the users page as well. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
