mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
ESLint: fix RxJs rule violations (pt. 1)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { combineLatest as observableCombineLatest, Observable, interval } from 'rxjs';
|
||||
import { combineLatest as observableCombineLatest, Observable, interval, SchedulerLike, MonoTypeOperatorFunction } from 'rxjs';
|
||||
import { filter, find, map, switchMap, take, takeWhile, debounce, debounceTime } from 'rxjs/operators';
|
||||
import { hasNoValue, hasValue, hasValueOperator, isNotEmpty } from '../../shared/empty.util';
|
||||
import { SearchResult } from '../../shared/search/models/search-result.model';
|
||||
@@ -9,7 +9,6 @@ import { MetadataSchema } from '../metadata/metadata-schema.model';
|
||||
import { BrowseDefinition } from './browse-definition.model';
|
||||
import { DSpaceObject } from './dspace-object.model';
|
||||
import { InjectionToken } from '@angular/core';
|
||||
import { MonoTypeOperatorFunction, SchedulerLike } from 'rxjs/internal/types';
|
||||
|
||||
/**
|
||||
* Use this method instead of the RxJs debounceTime if you're waiting for debouncing in tests;
|
||||
|
@@ -4,7 +4,7 @@ import { getMockRequestService } from '../../shared/mocks/request.service.mock';
|
||||
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { ClaimedTaskDataService } from './claimed-task-data.service';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { RequestParam } from '../cache/models/request-param.model';
|
||||
import { getTestScheduler } from 'jasmine-marbles';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
|
@@ -7,8 +7,7 @@ import { DsoEditMetadataFieldValuesComponent } from './dso-edit-metadata-field-v
|
||||
import { DsoEditMetadataForm } from '../dso-edit-metadata-form';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { MetadataValue } from '../../../core/shared/metadata.models';
|
||||
import { of } from 'rxjs/internal/observable/of';
|
||||
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
||||
import { of, BehaviorSubject } from 'rxjs';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
describe('DsoEditMetadataFieldValuesComponent', () => {
|
||||
|
@@ -1,9 +1,8 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { DsoEditMetadataChangeType, DsoEditMetadataForm, DsoEditMetadataValue } from '../dso-edit-metadata-form';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
||||
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-dso-edit-metadata-field-values',
|
||||
|
@@ -6,7 +6,7 @@ import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { RelationshipDataService } from '../../../core/data/relationship-data.service';
|
||||
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
||||
import { of } from 'rxjs/internal/observable/of';
|
||||
import { of } from 'rxjs';
|
||||
import { ItemMetadataRepresentation } from '../../../core/shared/metadata-representation/item/item-metadata-representation.model';
|
||||
import { MetadataValue, VIRTUAL_METADATA_PREFIX } from '../../../core/shared/metadata.models';
|
||||
import { DsoEditMetadataChangeType, DsoEditMetadataValue } from '../dso-edit-metadata-form';
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { DsoEditMetadataChangeType, DsoEditMetadataValue } from '../dso-edit-metadata-form';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import {
|
||||
MetadataRepresentation,
|
||||
MetadataRepresentationType
|
||||
@@ -11,7 +10,7 @@ import { ItemMetadataRepresentation } from '../../../core/shared/metadata-repres
|
||||
import { map } from 'rxjs/operators';
|
||||
import { getItemPageRoute } from '../../../item-page/item-page-routing-paths';
|
||||
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
||||
import { EMPTY } from 'rxjs/internal/observable/empty';
|
||||
import { EMPTY, Observable } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-dso-edit-metadata-value',
|
||||
|
@@ -15,7 +15,7 @@ import { ITEM } from '../../core/shared/item.resource-type';
|
||||
import { DATA_SERVICE_FACTORY } from '../../core/data/base/data-service.decorator';
|
||||
import { Operation } from 'fast-json-patch';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
const ADD_BTN = 'add';
|
||||
const REINSTATE_BTN = 'reinstate';
|
||||
|
@@ -4,11 +4,9 @@ import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||
import { DsoEditMetadataForm } from './dso-edit-metadata-form';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ActivatedRoute, Data } from '@angular/router';
|
||||
import { combineLatest as observableCombineLatest } from 'rxjs/internal/observable/combineLatest';
|
||||
import { Subscription } from 'rxjs/internal/Subscription';
|
||||
import { combineLatest as observableCombineLatest, Subscription, BehaviorSubject, Observable } from 'rxjs';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { hasNoValue, hasValue } from '../../shared/empty.util';
|
||||
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
||||
import {
|
||||
getFirstCompletedRemoteData,
|
||||
} from '../../core/shared/operators';
|
||||
@@ -17,7 +15,6 @@ import { ResourceType } from '../../core/shared/resource-type';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { MetadataFieldSelectorComponent } from './metadata-field-selector/metadata-field-selector.component';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { ArrayMoveChangeAnalyzer } from '../../core/data/array-move-change-analyzer.service';
|
||||
import { DATA_SERVICE_FACTORY } from '../../core/data/base/data-service.decorator';
|
||||
import { GenericConstructor } from '../../core/shared/generic-constructor';
|
||||
|
@@ -16,13 +16,10 @@ import {
|
||||
getFirstCompletedRemoteData,
|
||||
metadataFieldsToString
|
||||
} from '../../../core/shared/operators';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { RegistryService } from '../../../core/registry/registry.service';
|
||||
import { UntypedFormControl } from '@angular/forms';
|
||||
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
||||
import { hasValue } from '../../../shared/empty.util';
|
||||
import { Subscription } from 'rxjs/internal/Subscription';
|
||||
import { of } from 'rxjs/internal/observable/of';
|
||||
import { of, Subscription, Observable, BehaviorSubject } from 'rxjs';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
|
@@ -75,7 +75,8 @@ export class AbstractSimpleItemActionComponent implements OnInit {
|
||||
processRestResponse(response: RemoteData<any>) {
|
||||
if (response.hasSucceeded) {
|
||||
this.itemDataService.findById(this.item.id).pipe(
|
||||
findSuccessfulAccordingTo(this.predicate)).subscribe(() => {
|
||||
findSuccessfulAccordingTo((itemRd: RemoteData<Item>) => this.predicate(itemRd))
|
||||
).subscribe(() => {
|
||||
this.notificationsService.success(this.translateService.get('item.edit.' + this.messageKey + '.success'));
|
||||
this.router.navigate([getItemEditRoute(this.item)]);
|
||||
});
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
|
||||
import { filter, take } from 'rxjs/operators';
|
||||
import { BitstreamDataService } from '../../core/data/bitstream-data.service';
|
||||
import { PaginatedList } from '../../core/data/paginated-list.model';
|
||||
@@ -13,7 +13,6 @@ import { hasValue } from '../../shared/empty.util';
|
||||
import { followLink } from '../../shared/utils/follow-link-config.model';
|
||||
import { MediaViewerConfig } from '../../../config/media-viewer-config.interface';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { Subscription } from 'rxjs/internal/Subscription';
|
||||
|
||||
/**
|
||||
* This component renders the media viewers
|
||||
|
@@ -118,7 +118,7 @@ export class ProcessDetailComponent implements OnInit, OnDestroy {
|
||||
return data.process as RemoteData<Process>;
|
||||
}),
|
||||
redirectOn4xx(this.router, this.authService),
|
||||
shareReplay(1)
|
||||
shareReplay({ refCount: false, bufferSize: 1 }),
|
||||
);
|
||||
|
||||
this.filesRD$ = this.processRD$.pipe(
|
||||
@@ -141,7 +141,7 @@ export class ProcessDetailComponent implements OnInit, OnDestroy {
|
||||
this.startRefreshTimer();
|
||||
}
|
||||
}),
|
||||
shareReplay(1)
|
||||
shareReplay({ refCount: false, bufferSize: 1 }),
|
||||
);
|
||||
|
||||
this.filesRD$ = this.processRD$.pipe(
|
||||
|
@@ -7,7 +7,7 @@ import {
|
||||
createSuccessfulRemoteDataObject,
|
||||
} from '../shared/remote-data.utils';
|
||||
import { Registration } from '../core/shared/registration.model';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { RemoteData } from '../core/data/remote-data';
|
||||
|
||||
describe('RegistrationGuard', () => {
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { EpersonRegistrationService } from '../core/data/eperson-registration.service';
|
||||
import { AuthService } from '../core/auth/auth.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { getFirstCompletedRemoteData } from '../core/shared/operators';
|
||||
import { redirectOn4xx } from '../core/shared/authorized.operators';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
@@ -68,7 +68,7 @@ export class AccessControlFormContainerComponent<T extends DSpaceObject> impleme
|
||||
dropdownData$: Observable<BulkAccessConditionOptions> = this.bulkAccessConfigService.findByName('default').pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((configRD: RemoteData<BulkAccessConditionOptions>) => configRD.hasSucceeded ? configRD.payload : null),
|
||||
shareReplay(1)
|
||||
shareReplay({ refCount: false, bufferSize: 1 }),
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -63,19 +63,18 @@ export class ComcolMetadataComponent<TDomain extends Community | Collection> imp
|
||||
}
|
||||
|
||||
if (!isEmpty(event.operations)) {
|
||||
this.dsoDataService.patch(event.dso, event.operations).pipe(getFirstCompletedRemoteData())
|
||||
.subscribe(async (response: RemoteData<DSpaceObject>) => {
|
||||
if (response.hasSucceeded) {
|
||||
if (!newLogo && !deleteLogo) {
|
||||
await this.router.navigate([this.frontendURL + event.dso.uuid]);
|
||||
}
|
||||
this.notificationsService.success(null, this.translate.get(`${this.type.value}.edit.notifications.success`));
|
||||
} else if (response.statusCode === 403) {
|
||||
this.notificationsService.error(null, this.translate.get(`${this.type.value}.edit.notifications.unauthorized`));
|
||||
} else {
|
||||
this.notificationsService.error(null, this.translate.get(`${this.type.value}.edit.notifications.error`));
|
||||
}
|
||||
});
|
||||
this.dsoDataService.patch(event.dso, event.operations).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
).subscribe((response: RemoteData<DSpaceObject>) => {
|
||||
if (response.hasSucceeded) {
|
||||
this.router.navigate([this.frontendURL + event.dso.uuid]); // todo: ok not to await this?
|
||||
this.notificationsService.success(null, this.translate.get(`${this.type.value}.edit.notifications.success`));
|
||||
} else if (response.statusCode === 403) {
|
||||
this.notificationsService.error(null, this.translate.get(`${this.type.value}.edit.notifications.unauthorized`));
|
||||
} else {
|
||||
this.notificationsService.error(null, this.translate.get(`${this.type.value}.edit.notifications.error`));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { ThemedComponent } from '../../theme-support/themed.component';
|
||||
import { SearchFiltersComponent } from './search-filters.component';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { SearchFilterConfig } from '../models/search-filter-config.model';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Themed wrapper for SearchFiltersComponent
|
||||
|
@@ -103,7 +103,7 @@ export class SubscriptionModalComponent implements OnInit {
|
||||
this.authService.getAuthenticatedUserFromStore().pipe(
|
||||
take(1),
|
||||
map((ePerson) => ePerson.uuid),
|
||||
shareReplay(),
|
||||
shareReplay({ refCount: false }), // todo: check if this is ok
|
||||
).subscribe((ePersonId: string) => {
|
||||
this.ePersonId = ePersonId;
|
||||
if (isNotEmpty(this.subscription)) {
|
||||
|
@@ -1,8 +1,7 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { buildPaginatedList, PaginatedList } from '../../core/data/paginated-list.model';
|
||||
import { PageInfo } from '../../core/shared/page-info.model';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { of as observableOf } from 'rxjs/internal/observable/of';
|
||||
import { of as observableOf, Observable } from 'rxjs';
|
||||
import { UnCacheableObject } from '../../core/shared/uncacheable-object.model';
|
||||
import { RequestEntryState } from '../../core/data/request-entry-state.model';
|
||||
import { RequestEntry } from '../../core/data/request-entry.model';
|
||||
|
@@ -11,6 +11,7 @@ import { Subject } from 'rxjs';
|
||||
* Directive for setting a debounce time on an input field
|
||||
* It will emit the input field's value when no changes were made to this value in a given debounce time
|
||||
*/
|
||||
// todo: this class is unused, consider removing it instead of fixing lint
|
||||
export class DebounceDirective implements OnInit, OnDestroy {
|
||||
|
||||
/**
|
||||
@@ -39,10 +40,10 @@ export class DebounceDirective implements OnInit, OnDestroy {
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.model.valueChanges.pipe(
|
||||
takeUntil(this.subject),
|
||||
debounceTime(this.dsDebounce),
|
||||
distinctUntilChanged())
|
||||
.subscribe((modelValue) => {
|
||||
distinctUntilChanged(),
|
||||
takeUntil(this.subject), // todo: check if this is ok
|
||||
).subscribe((modelValue) => {
|
||||
if (this.model.dirty) {
|
||||
this.onDebounce.emit(modelValue);
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Angulartics2 } from 'angulartics2';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { Subscription } from 'rxjs/internal/Subscription';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { hasValue } from '../../../shared/empty.util';
|
||||
import { ReferrerService } from '../../../core/services/referrer.service';
|
||||
|
@@ -69,7 +69,7 @@ export class SubscriptionsPageComponent implements OnInit, OnDestroy {
|
||||
this.ePersonId$ = this.authService.getAuthenticatedUserFromStore().pipe(
|
||||
take(1),
|
||||
map((ePerson: EPerson) => ePerson.id),
|
||||
shareReplay()
|
||||
shareReplay({ refCount: false }),
|
||||
);
|
||||
this.retrieveSubscriptions();
|
||||
}
|
||||
|
Reference in New Issue
Block a user