@alauda-fe/dynamic-plugin-shared 0.0.4-alpha.23 → 0.0.4-alpha.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import { rgbColor, ThemeService, coerceAttrBoolean, FormItemControlDirective, ob
3
3
  import { last, cloneDeep, has, unset, get, isBoolean, sortBy, set, trim, isFunction, range, debounce, uniq, identity, first, isString, isEmpty, isObjectLike, throttle, min, clamp, round, add, subtract } from 'lodash-es';
4
4
  import * as i3 from '@alauda-fe/dynamic-plugin-sdk';
5
5
  import { parseBase64Type, isBlank, publishRef, TOKEN_BASE_DOMAIN, stringify as stringify$1, isEqual, TimeService, TranslateService, isZhLang, FALLBACK_LANGUAGE, TranslatePipe, ObservableInput, FeatureGateService, FieldNotAvailablePipe, ValueHook, LoadingMaskComponent, PurePipe, StandardTimePipe, RelativeTimePipe, skipError, CURR_ESCAPE_DEACTIVATE_GUARD, ESCAPE_DEACTIVATE_GUARD, parseAll, FIELD_NOT_AVAILABLE_PLACEHOLDER, noop, SafePipe, WatchEvent, K8sUtilService, NAMESPACE as NAMESPACE$1, isFieldNotAvailable, K8S_UTIL_PIPES_MODULE, ResourceSelectorPopupService, ProjectService, ConfigurableField, API_GATEWAY as API_GATEWAY$1, ClusterListComponent, K8sApiService, TRANSLATE_MODULE, KubernetesSchemaService, NOTIFY_DURATION_HEADER as NOTIFY_DURATION_HEADER$1, EMPTY as EMPTY$2, FALSE as FALSE$1, isMac } from '@alauda-fe/dynamic-plugin-sdk';
6
- import { Observable, finalize, map, startWith, catchError, of, isObservable, switchMap, animationFrameScheduler, fromEvent, auditTime, Subject, takeUntil, distinctUntilChanged, combineLatest, filter, debounceTime, take, merge, pairwise, tap, BehaviorSubject, from, timer, ReplaySubject, delay, withLatestFrom, scan, takeWhile, concat, exhaustMap, EMPTY as EMPTY$1, interval, NEVER, switchScan, shareReplay, mapTo, throwError } from 'rxjs';
6
+ import { Observable, finalize, map, startWith, catchError, of, isObservable, switchMap, animationFrameScheduler, fromEvent, auditTime, Subject, takeUntil, distinctUntilChanged, combineLatest, filter, debounceTime, take, merge, pairwise, tap, BehaviorSubject, from, timer, ReplaySubject, delay, withLatestFrom, mergeMap, EMPTY as EMPTY$1, scan, takeWhile, concat, exhaustMap, interval, NEVER, switchScan, shareReplay, mapTo, throwError } from 'rxjs';
7
7
  import { ActivatedRoute, Router, RouterLink } from '@angular/router';
8
8
  import { dissocPath, converge, mergeAll, mergeDeepRight, path, assocPath, identity as identity$1, equals, mergeRight } from 'ramda';
9
9
  import { compare } from 'compare-versions';
@@ -6639,6 +6639,17 @@ class InterceptDeactivateService {
6639
6639
  cancelText: this.translate.get('cancel'),
6640
6640
  })).pipe(map(() => true), skipError(errorFallback));
6641
6641
  }
6642
+ interceptCurrentRoute() {
6643
+ let route = this.router.routerState.snapshot.root;
6644
+ while (route.firstChild) {
6645
+ route = route.firstChild;
6646
+ }
6647
+ return this.intercept({
6648
+ title: this.getData(route, 'interceptDeactivateTitle'),
6649
+ content: this.getData(route, 'interceptDeactivateContent'),
6650
+ errorFallback: false,
6651
+ });
6652
+ }
6642
6653
  async back(escape) {
6643
6654
  if (escape) {
6644
6655
  await this.escape();
@@ -6667,6 +6678,9 @@ class InterceptDeactivateService {
6667
6678
  queryParams: this.searchParamsToQueryParams(url.searchParams),
6668
6679
  });
6669
6680
  }
6681
+ getData(route, key) {
6682
+ return route.data?.[key];
6683
+ }
6670
6684
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: InterceptDeactivateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
6671
6685
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: InterceptDeactivateService, providedIn: 'root' }); }
6672
6686
  }
@@ -6720,9 +6734,16 @@ class InterceptDeactivateDirective {
6720
6734
  ngAfterViewInit() {
6721
6735
  fromEvent(this.elRef.nativeElement, 'click')
6722
6736
  .pipe(withLatestFrom(this.enabled$), takeUntil(this.destroy$$))
6723
- .subscribe(([, enabled]) => {
6724
- this.interceptDeactivate.back(!enabled);
6725
- });
6737
+ .pipe(mergeMap(([, enabled]) => {
6738
+ if (!enabled) {
6739
+ this.interceptDeactivate.back(true);
6740
+ return EMPTY$1;
6741
+ }
6742
+ return this.interceptDeactivate.interceptCurrentRoute().pipe(filter(Boolean), tap(() => {
6743
+ this.interceptDeactivate.back(true);
6744
+ }));
6745
+ }))
6746
+ .subscribe();
6726
6747
  }
6727
6748
  ngOnDestroy() {
6728
6749
  this.destroy$$.next();