rfellows commented on code in PR #10346:
URL: https://github.com/apache/nifi/pull/10346#discussion_r2388694622
##########
nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/state/buckets/buckets.effects.ts:
##########
@@ -16,44 +16,191 @@
*/
import { inject, Injectable } from '@angular/core';
-import { Actions, createEffect, ofType } from '@ngrx/effects';
-import { catchError, from, map, of, switchMap } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
+import { MatDialog } from '@angular/material/dialog';
+import { Actions, createEffect, ofType } from '@ngrx/effects';
+import { from, of } from 'rxjs';
+import { catchError, map, switchMap, tap } from 'rxjs/operators';
import * as BucketsActions from './buckets.actions';
import { BucketsService } from '../../service/buckets.service';
import { ErrorHelper } from '../../service/error-helper.service';
import { ErrorContextKey } from '../error';
-import * as DropletsActions from '../droplets/droplets.actions';
+import * as ErrorActions from '../error/error.actions';
+import { CreateBucketDialogComponent } from
'../../pages/buckets/feature/ui/create-bucket-dialog/create-bucket-dialog.component';
+import { EditBucketDialogComponent } from
'../../pages/buckets/feature/ui/edit-bucket-dialog/edit-bucket-dialog.component';
+import { DeleteBucketDialogComponent } from
'../../pages/buckets/feature/ui/delete-bucket-dialog/delete-bucket-dialog.component';
+import { ManageBucketPoliciesDialogComponent } from
'../../pages/buckets/feature/ui/manage-bucket-policies-dialog/manage-bucket-policies-dialog.component';
+
+import { LARGE_DIALOG, MEDIUM_DIALOG } from '@nifi/shared';
@Injectable()
export class BucketsEffects {
private bucketsService = inject(BucketsService);
private errorHelper = inject(ErrorHelper);
-
- actions$ = inject(Actions);
+ private dialog = inject(MatDialog);
+ private actions$ = inject(Actions);
loadBuckets$ = createEffect(() =>
this.actions$.pipe(
ofType(BucketsActions.loadBuckets),
- switchMap(() => {
- return from(
- this.bucketsService.getBuckets().pipe(
- map((response) =>
- BucketsActions.loadBucketsSuccess({
- response: {
- buckets: response
- }
- })
- ),
- catchError((errorResponse: HttpErrorResponse) =>
of(this.bannerError(errorResponse)))
+ switchMap(() =>
+ from(this.bucketsService.getBuckets()).pipe(
+ map((response) =>
+ BucketsActions.loadBucketsSuccess({
+ response: {
+ buckets: response
+ }
+ })
+ ),
+ catchError((errorResponse: HttpErrorResponse) =>
of(this.bannerError(errorResponse)))
+ )
+ )
+ )
+ );
+
+ openCreateBucketDialog$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(BucketsActions.openCreateBucketDialog),
+ tap(() => {
+ this.dialog.open(CreateBucketDialogComponent, {
+ ...MEDIUM_DIALOG,
+ autoFocus: false
+ });
+ })
+ ),
+ { dispatch: false }
+ );
+
+ createBucket$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(BucketsActions.createBucket),
+ switchMap(({ request, keepDialogOpen }) =>
+ from(this.bucketsService.createBucket(request)).pipe(
+ map((bucket) => BucketsActions.createBucketSuccess({
response: bucket, keepDialogOpen })),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(
+ BucketsActions.createBucketFailure(),
+ this.bannerError(errorResponse,
ErrorContextKey.CREATE_BUCKET)
+ )
+ )
+ )
+ )
+ )
+ );
+
+ createBucketSuccess$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(BucketsActions.createBucketSuccess),
+ tap(({ keepDialogOpen }) => {
+ if (!keepDialogOpen) {
+ this.dialog.closeAll();
+ }
+ })
+ ),
+ { dispatch: false }
+ );
+
+ openEditBucketDialog$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(BucketsActions.openEditBucketDialog),
+ tap(({ request }) => {
+ this.dialog.open(EditBucketDialogComponent, {
+ ...MEDIUM_DIALOG,
+ autoFocus: false,
+ data: { bucket: request.bucket }
+ });
+ })
+ ),
+ { dispatch: false }
+ );
+
+ updateBucket$ = createEffect(() =>
+ this.actions$.pipe(
+ ofType(BucketsActions.updateBucket),
+ switchMap(({ request }) =>
+ from(this.bucketsService.updateBucket(request)).pipe(
+ map((bucket) => BucketsActions.updateBucketSuccess({
response: bucket })),
+ catchError((errorResponse: HttpErrorResponse) =>
+ of(
+ BucketsActions.updateBucketFailure(),
+ this.bannerError(errorResponse,
ErrorContextKey.UPDATE_BUCKET)
+ )
+ )
+ )
+ )
+ )
+ );
+
+ updateBucketSuccess$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(BucketsActions.updateBucketSuccess),
+ tap(() => this.dialog.closeAll())
+ ),
+ { dispatch: false }
+ );
+
+ openDeleteBucketDialog$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(BucketsActions.openDeleteBucketDialog),
+ tap(({ request }) => {
+ this.dialog.open(DeleteBucketDialogComponent, {
+ ...MEDIUM_DIALOG,
+ autoFocus: false,
+ data: { bucket: request.bucket }
+ });
Review Comment:
I'm curious why you implemented a new dialog for this delete confirmation
rather than using the YesNoDialog from shared? Other places in NiFi use that
when confirming a destructive action.
I also question the use of a Banner in this dialog to show an error when
deleting. In NiFi, these are typically bubbled up after the confirmation dialog
closes in a snackbar or other mechanism. The pattern has typically need to keep
a dialog open after a failure if there is some user input that might change the
outcome if re-submitted (like create/edit if there is an invalid value or
something)
##########
nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/pages/buckets/feature/ui/bucket-table/bucket-table.component.spec.ts:
##########
@@ -0,0 +1,127 @@
+/*
+ * 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 { ComponentFixture, TestBed } from '@angular/core/testing';
+import { BucketTableComponent } from './bucket-table.component';
+import { MatTableDataSource } from '@angular/material/table';
+import { Bucket } from '../../../../../state/buckets';
+import { provideMockStore } from '@ngrx/store/testing';
+import { NiFiCommon } from '@nifi/shared';
+import {
+ openDeleteBucketDialog,
+ openEditBucketDialog,
+ openManageBucketPoliciesDialog
+} from '../../../../../state/buckets/buckets.actions';
+import { Store } from '@ngrx/store';
+import { By } from '@angular/platform-browser';
Review Comment:
Unused import
##########
nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/app-routing.module.ts:
##########
@@ -28,13 +28,30 @@ const routes: Routes = [
path: 'explorer',
loadChildren: () =>
import('./pages/resources/feature/resources.module').then((m) =>
m.ResourcesModule)
},
- // Backward compatibility: old app's default route
{
- path: 'nifi-registry',
- redirectTo: 'explorer',
- pathMatch: 'full'
+ path: 'buckets',
+ loadChildren: () =>
import('./pages/buckets/feature/buckets.module').then((m) => m.BucketsModule)
+ },
+ {
+ path: 'administration',
+ children: [
+ {
+ path: 'workflow',
+ children: [
+ {
+ path: '',
+ redirectTo: 'buckets',
+ pathMatch: 'full'
+ },
+ {
+ path: 'manage/bucket/:bucketId',
+ outlet: 'sidenav',
+ redirectTo: 'buckets/:bucketId'
+ }
Review Comment:
Neither one of these seems to work.
`administration/workflow`
<img width="1320" height="691" alt="Screenshot 2025-09-29 at 13 33 39"
src="https://github.com/user-attachments/assets/93d5c336-9aea-42da-b33d-b2695c8228b4"
/>
`administration/workflow(sidenav:manage/bucket/93e353f7-14aa-4371-a456-914d5d99106a)`
```
ERROR RuntimeError: NG04002: Cannot match any routes. URL Segment:
'manage/bucket/93e353f7-14aa-4371-a456-914d5d99106a'
at Recognizer.noMatchError (router2.mjs:3901:12)
at router2.mjs:3940:20
at catchError.js:10:39
at OperatorSubscriber2._this._error (OperatorSubscriber.js:25:21)
at Subscriber2.error (Subscriber.js:43:18)
at Subscriber2._error (Subscriber.js:67:30)
at Subscriber2.error (Subscriber.js:43:18)
at Subscriber2._error (Subscriber.js:67:30)
at Subscriber2.error (Subscriber.js:43:18)
at Subscriber2._error (Subscriber.js:67:30)
```
##########
nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/state/buckets/buckets.effects.ts:
##########
Review Comment:
Can we add some tests for these effects?
--
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]