rfellows commented on code in PR #8305:
URL: https://github.com/apache/nifi/pull/8305#discussion_r1468061938
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/ui/common/message/message.component.ts:
##########
@@ -16,15 +16,19 @@
*/
import { Component, Input } from '@angular/core';
-import { AuthStorage } from '../../../../service/auth-storage.service';
-import { AuthService } from '../../../../service/auth.service';
+import { AuthStorage } from '../../../service/auth-storage.service';
+import { AuthService } from '../../../service/auth.service';
+import { RouterLink } from '@angular/router';
+import { NgIf } from '@angular/common';
@Component({
- selector: 'login-message',
- templateUrl: './login-message.component.html',
- styleUrls: ['./login-message.component.scss']
+ selector: 'message',
+ standalone: true,
+ templateUrl: './message.component.html',
+ imports: [RouterLink, NgIf],
+ styleUrls: ['./message.component.scss']
})
-export class LoginMessage {
+export class Message {
Review Comment:
We should probably rename this one too, Its not really a generic message
component.
Also...
I think we should allow the "message" to be `ng-content` instead of a basic
`@Input()`.
That way we could provide whatever we want in the message
```
<message title="My Title">
<i class="fa fa-warn"></i>
<span>{{someMessageHere}}</span>
</message>
```
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/ui/common/banner/banner.component.ts:
##########
@@ -17,28 +17,25 @@
import { Component } from '@angular/core';
import { Store } from '@ngrx/store';
-import { CanvasState } from '../../../state';
-import { selectApiError } from '../../../state/flow/flow.selectors';
-import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
-import { NgClass, NgIf } from '@angular/common';
+import { AsyncPipe, NgForOf, NgIf } from '@angular/common';
+import { MatButtonModule } from '@angular/material/button';
+import { NiFiState } from '../../../state';
+import { selectBannerErrors } from '../../../state/error/error.selectors';
+import { clearBannerErrors } from '../../../state/error/error.actions';
@Component({
selector: 'banner',
standalone: true,
- imports: [NgClass, NgIf],
+ imports: [NgIf, NgForOf, MatButtonModule, AsyncPipe],
templateUrl: './banner.component.html',
styleUrls: ['./banner.component.scss']
})
export class Banner {
Review Comment:
Banner is a generic term that implies broader re-use capabilities than this
provides. Maybe we should rename it to be more specific to what it does, like
`ErrorBanner` or something.
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/error/error.effects.ts:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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 { Injectable } from '@angular/core';
+import { Actions, createEffect, ofType } from '@ngrx/effects';
+import * as ErrorActions from './error.actions';
+import { map, tap } from 'rxjs';
+import { Router } from '@angular/router';
+import { MatSnackBar } from '@angular/material/snack-bar';
+
+@Injectable()
+export class ErrorEffects {
+ constructor(
+ private actions$: Actions,
+ private router: Router,
+ private snackBar: MatSnackBar
+ ) {}
+
+ fullScreenError$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(ErrorActions.fullScreenError),
+ tap(() => {
+ this.router.navigate(['/error']);
+ })
+ ),
+ { dispatch: false }
+ );
+
+ snackBarError$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(ErrorActions.snackBarError),
+ map((action) => action.error),
+ tap((error) => {
+ this.snackBar.open(error, 'Dismiss');
Review Comment:
We might want to consider putting an auto-close duration on these. The
snackbar remains until dismissed... even if the user navigates away from the
page/route where the error originated.
Maybe this is a reason to use an inline banner rather than a snackbar.
Thoughts?
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/error/error.effects.ts:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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 { Injectable } from '@angular/core';
+import { Actions, createEffect, ofType } from '@ngrx/effects';
+import * as ErrorActions from './error.actions';
+import { map, tap } from 'rxjs';
+import { Router } from '@angular/router';
+import { MatSnackBar } from '@angular/material/snack-bar';
+
+@Injectable()
+export class ErrorEffects {
+ constructor(
+ private actions$: Actions,
+ private router: Router,
+ private snackBar: MatSnackBar
+ ) {}
+
+ fullScreenError$ = createEffect(
+ () =>
+ this.actions$.pipe(
+ ofType(ErrorActions.fullScreenError),
+ tap(() => {
+ this.router.navigate(['/error']);
Review Comment:
I think we need to remove the error'd route from browser history. If you
encounter a full screen error and hit the back button, it attempts to load the
route that caused the error. I _think_ we should go back to the last good route.
```suggestion
this.router.navigate(['/error'], { replaceUrl: true });
```
--
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]