mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
Merge remote-tracking branch '4Science-github/main' into CST-5668
This commit is contained in:
9
.github/workflows/docker.yml
vendored
9
.github/workflows/docker.yml
vendored
@@ -31,6 +31,10 @@ jobs:
|
||||
# We turn off 'latest' tag by default.
|
||||
TAGS_FLAVOR: |
|
||||
latest=false
|
||||
# Architectures / Platforms for which we will build Docker images
|
||||
# If this is a PR, we ONLY build for AMD64. For PRs we only do a sanity check test to ensure Docker builds work.
|
||||
# If this is NOT a PR (e.g. a tag or merge commit), also build for ARM64.
|
||||
PLATFORMS: linux/amd64${{ github.event_name != 'pull_request' && ', linux/arm64' || '' }}
|
||||
|
||||
steps:
|
||||
# https://github.com/actions/checkout
|
||||
@@ -41,6 +45,10 @@ jobs:
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
# https://github.com/docker/setup-qemu-action
|
||||
- name: Set up QEMU emulation to build for multiple architectures
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
# https://github.com/docker/login-action
|
||||
- name: Login to DockerHub
|
||||
# Only login if not a PR, as PRs only trigger a Docker build and not a push
|
||||
@@ -70,6 +78,7 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: ${{ env.PLATFORMS }}
|
||||
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
|
||||
# but we ONLY do an image push to DockerHub if it's NOT a PR
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
|
@@ -9,10 +9,11 @@
|
||||
"start:dev": "nodemon --exec \"cross-env NODE_ENV=development yarn run serve\"",
|
||||
"start:prod": "yarn run build:prod && cross-env NODE_ENV=production yarn run serve:ssr",
|
||||
"start:mirador:prod": "yarn run build:mirador && yarn run start:prod",
|
||||
"serve": "ng serve -c development",
|
||||
"preserve": "yarn base-href",
|
||||
"serve": "ng serve --configuration development",
|
||||
"serve:ssr": "node dist/server/main",
|
||||
"analyze": "webpack-bundle-analyzer dist/browser/stats.json",
|
||||
"build": "ng build -c development",
|
||||
"build": "ng build --configuration development",
|
||||
"build:stats": "ng build --stats-json",
|
||||
"build:prod": "yarn run build:ssr",
|
||||
"build:ssr": "ng build --configuration production && ng run dspace-angular:server:production",
|
||||
@@ -37,6 +38,7 @@
|
||||
"cypress:open": "cypress open",
|
||||
"cypress:run": "cypress run",
|
||||
"env:yaml": "ts-node --project ./tsconfig.ts-node.json scripts/env-to-yaml.ts",
|
||||
"base-href": "ts-node --project ./tsconfig.ts-node.json scripts/base-href.ts",
|
||||
"check-circ-deps": "npx madge --exclude '(bitstream|bundle|collection|config-submission-form|eperson|item|version)\\.model\\.ts$' --circular --extensions ts ./"
|
||||
},
|
||||
"browser": {
|
||||
@@ -104,7 +106,7 @@
|
||||
"mirador": "^3.3.0",
|
||||
"mirador-dl-plugin": "^0.13.0",
|
||||
"mirador-share-plugin": "^0.11.0",
|
||||
"moment": "^2.29.1",
|
||||
"moment": "^2.29.2",
|
||||
"morgan": "^1.10.0",
|
||||
"ng-mocks": "^13.1.1",
|
||||
"ng2-file-upload": "1.4.0",
|
||||
|
36
scripts/base-href.ts
Normal file
36
scripts/base-href.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import * as fs from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { AppConfig } from '../src/config/app-config.interface';
|
||||
import { buildAppConfig } from '../src/config/config.server';
|
||||
|
||||
/**
|
||||
* Script to set baseHref as `ui.nameSpace` for development mode. Adds `baseHref` to angular.json build options.
|
||||
*
|
||||
* Usage (see package.json):
|
||||
*
|
||||
* yarn base-href
|
||||
*/
|
||||
|
||||
const appConfig: AppConfig = buildAppConfig();
|
||||
|
||||
const angularJsonPath = join(process.cwd(), 'angular.json');
|
||||
|
||||
if (!fs.existsSync(angularJsonPath)) {
|
||||
console.error(`Error:\n${angularJsonPath} does not exist\n`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
const angularJson = require(angularJsonPath);
|
||||
|
||||
const baseHref = `${appConfig.ui.nameSpace}${appConfig.ui.nameSpace.endsWith('/') ? '' : '/'}`;
|
||||
|
||||
console.log(`Setting baseHref to ${baseHref} in angular.json`);
|
||||
|
||||
angularJson.projects['dspace-angular'].architect.build.options.baseHref = baseHref;
|
||||
|
||||
fs.writeFileSync(angularJsonPath, JSON.stringify(angularJson, null, 2) + '\n');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
import { projectRoot} from '../webpack/helpers';
|
||||
import { projectRoot } from '../webpack/helpers';
|
||||
|
||||
const commander = require('commander');
|
||||
const fs = require('fs');
|
||||
const JSON5 = require('json5');
|
||||
@@ -119,7 +120,7 @@ function syncFileWithSource(pathToTargetFile, pathToOutputFile) {
|
||||
outputChunks.forEach(function (chunk) {
|
||||
progressBar.increment();
|
||||
chunk.split("\n").forEach(function (line) {
|
||||
file.write(" " + line + "\n");
|
||||
file.write((line === '' ? '' : ` ${line}`) + "\n");
|
||||
});
|
||||
});
|
||||
file.write("\n}");
|
||||
@@ -192,7 +193,10 @@ function createNewChunkComparingSourceAndTarget(correspondingTargetChunk, source
|
||||
|
||||
const targetList = correspondingTargetChunk.split("\n");
|
||||
const oldKeyValueInTargetComments = getSubStringWithRegex(correspondingTargetChunk, "\\s*\\/\\/\\s*\".*");
|
||||
const keyValueTarget = targetList[targetList.length - 1];
|
||||
let keyValueTarget = targetList[targetList.length - 1];
|
||||
if (!keyValueTarget.endsWith(",")) {
|
||||
keyValueTarget = keyValueTarget + ",";
|
||||
}
|
||||
|
||||
if (oldKeyValueInTargetComments != null) {
|
||||
const oldKeyValueUncommented = getSubStringWithRegex(oldKeyValueInTargetComments[0], "\".*")[0];
|
||||
|
32
server.ts
32
server.ts
@@ -67,6 +67,8 @@ extendEnvironmentWithAppConfig(environment, appConfig);
|
||||
// The Express app is exported so that it can be used by serverless Functions.
|
||||
export function app() {
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
/*
|
||||
* Create a new express application
|
||||
*/
|
||||
@@ -138,7 +140,11 @@ export function app() {
|
||||
/**
|
||||
* Proxy the sitemaps
|
||||
*/
|
||||
server.use('/sitemap**', createProxyMiddleware({ target: `${environment.rest.baseUrl}/sitemaps`, changeOrigin: true }));
|
||||
router.use('/sitemap**', createProxyMiddleware({
|
||||
target: `${environment.rest.baseUrl}/sitemaps`,
|
||||
pathRewrite: path => path.replace(environment.ui.nameSpace, '/'),
|
||||
changeOrigin: true
|
||||
}));
|
||||
|
||||
/**
|
||||
* Checks if the rateLimiter property is present
|
||||
@@ -157,7 +163,7 @@ export function app() {
|
||||
* Serve static resources (images, i18n messages, …)
|
||||
* Handle pre-compressed files with [express-static-gzip](https://github.com/tkoenig89/express-static-gzip)
|
||||
*/
|
||||
server.get('*.*', cacheControl, expressStaticGzip(DIST_FOLDER, {
|
||||
router.get('*.*', cacheControl, expressStaticGzip(DIST_FOLDER, {
|
||||
index: false,
|
||||
enableBrotli: true,
|
||||
orderPreference: ['br', 'gzip'],
|
||||
@@ -166,10 +172,12 @@ export function app() {
|
||||
/*
|
||||
* Fallthrough to the IIIF viewer (must be included in the build).
|
||||
*/
|
||||
server.use('/iiif', express.static(IIIF_VIEWER, {index:false}));
|
||||
router.use('/iiif', express.static(IIIF_VIEWER, { index: false }));
|
||||
|
||||
// Register the ngApp callback function to handle incoming requests
|
||||
server.get('*', ngApp);
|
||||
router.get('*', ngApp);
|
||||
|
||||
server.use(environment.ui.nameSpace, router);
|
||||
|
||||
return server;
|
||||
}
|
||||
@@ -203,13 +211,25 @@ function ngApp(req, res) {
|
||||
if (hasValue(err)) {
|
||||
console.warn('Error details : ', err);
|
||||
}
|
||||
res.sendFile(DIST_FOLDER + '/index.html');
|
||||
res.render(indexHtml, {
|
||||
req,
|
||||
providers: [{
|
||||
provide: APP_BASE_HREF,
|
||||
useValue: req.baseUrl
|
||||
}]
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// If preboot is disabled, just serve the client
|
||||
console.log('Universal off, serving for direct CSR');
|
||||
res.sendFile(DIST_FOLDER + '/index.html');
|
||||
res.render(indexHtml, {
|
||||
req,
|
||||
providers: [{
|
||||
provide: APP_BASE_HREF,
|
||||
useValue: req.baseUrl
|
||||
}]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,8 +2,8 @@ import { CommonModule } from '@angular/common';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { FormsModule, ReactiveFormsModule, FormArray, FormControl, FormGroup,Validators, NG_VALIDATORS, NG_ASYNC_VALIDATORS } from '@angular/forms';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { BrowserModule, By } from '@angular/platform-browser';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Store } from '@ngrx/store';
|
||||
@@ -35,6 +35,7 @@ import { RouterMock } from '../../../shared/mocks/router.mock';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||
import { Operation } from 'fast-json-patch';
|
||||
import { ValidateGroupExists } from './validators/group-exists.validator';
|
||||
import { NoContent } from '../../../core/shared/NoContent.model';
|
||||
|
||||
describe('GroupFormComponent', () => {
|
||||
let component: GroupFormComponent;
|
||||
@@ -87,6 +88,9 @@ describe('GroupFormComponent', () => {
|
||||
patch(group: Group, operations: Operation[]) {
|
||||
return null;
|
||||
},
|
||||
delete(objectId: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
|
||||
return createSuccessfulRemoteDataObject$({});
|
||||
},
|
||||
cancelEditGroup(): void {
|
||||
this.activeGroup = null;
|
||||
},
|
||||
@@ -348,4 +352,46 @@ describe('GroupFormComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('delete', () => {
|
||||
let deleteButton;
|
||||
|
||||
beforeEach(() => {
|
||||
component.initialisePage();
|
||||
|
||||
component.canEdit$ = observableOf(true);
|
||||
component.groupBeingEdited = {
|
||||
permanent: false
|
||||
} as Group;
|
||||
|
||||
fixture.detectChanges();
|
||||
deleteButton = fixture.debugElement.query(By.css('.delete-button')).nativeElement;
|
||||
|
||||
spyOn(groupsDataServiceStub, 'delete').and.callThrough();
|
||||
spyOn(groupsDataServiceStub, 'getActiveGroup').and.returnValue(observableOf({ id: 'active-group' }));
|
||||
});
|
||||
|
||||
describe('if confirmed via modal', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
deleteButton.click();
|
||||
fixture.detectChanges();
|
||||
(document as any).querySelector('.modal-footer .confirm').click();
|
||||
}));
|
||||
|
||||
it('should call GroupDataService.delete', () => {
|
||||
expect(groupsDataServiceStub.delete).toHaveBeenCalledWith('active-group');
|
||||
});
|
||||
});
|
||||
|
||||
describe('if canceled via modal', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
deleteButton.click();
|
||||
fixture.detectChanges();
|
||||
(document as any).querySelector('.modal-footer .cancel').click();
|
||||
}));
|
||||
|
||||
it('should not call GroupDataService.delete', () => {
|
||||
expect(groupsDataServiceStub.delete).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -426,7 +426,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
||||
.subscribe((rd: RemoteData<NoContent>) => {
|
||||
if (rd.hasSucceeded) {
|
||||
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.deleted.success', { name: group.name }));
|
||||
this.reset();
|
||||
this.onCancel();
|
||||
} else {
|
||||
this.notificationsService.error(
|
||||
this.translateService.get(this.messagePrefix + '.notification.deleted.failure.title', { name: group.name }),
|
||||
@@ -439,16 +439,6 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will ensure that the page gets reset and that the cache is cleared
|
||||
*/
|
||||
reset() {
|
||||
this.groupDataService.getBrowseEndpoint().pipe(take(1)).subscribe((href: string) => {
|
||||
this.requestService.removeByHrefSubstring(href);
|
||||
});
|
||||
this.onCancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the current edit when component is destroyed & unsub all subscriptions
|
||||
*/
|
||||
|
@@ -79,7 +79,7 @@
|
||||
</button>
|
||||
</ng-container>
|
||||
<button *ngIf="!groupDto.group?.permanent && groupDto.ableToDelete"
|
||||
(click)="deleteGroup(groupDto)" class="btn btn-outline-danger btn-sm"
|
||||
(click)="deleteGroup(groupDto)" class="btn btn-outline-danger btn-sm btn-delete"
|
||||
title="{{messagePrefix + 'table.edit.buttons.remove' | translate: {name: groupDto.group.name} }}">
|
||||
<i class="fas fa-trash-alt fa-fw"></i>
|
||||
</button>
|
||||
|
@@ -31,6 +31,7 @@ import { RouterMock } from '../../shared/mocks/router.mock';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
||||
import { NoContent } from '../../core/shared/NoContent.model';
|
||||
|
||||
describe('GroupRegistryComponent', () => {
|
||||
let component: GroupsRegistryComponent;
|
||||
@@ -145,7 +146,10 @@ describe('GroupRegistryComponent', () => {
|
||||
totalPages: 1,
|
||||
currentPage: 1
|
||||
}), [result]));
|
||||
}
|
||||
},
|
||||
delete(objectId: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
|
||||
return createSuccessfulRemoteDataObject$({});
|
||||
},
|
||||
};
|
||||
dsoDataServiceStub = {
|
||||
findByHref(href: string): Observable<RemoteData<DSpaceObject>> {
|
||||
@@ -301,4 +305,29 @@ describe('GroupRegistryComponent', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('delete', () => {
|
||||
let deleteButton;
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
spyOn(groupsDataServiceStub, 'delete').and.callThrough();
|
||||
|
||||
setIsAuthorized(true, true);
|
||||
|
||||
// force rerender after setup changes
|
||||
component.search({ query: '' });
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
|
||||
// only mockGroup[0] is deletable, so we should only get one button
|
||||
deleteButton = fixture.debugElement.query(By.css('.btn-delete')).nativeElement;
|
||||
}));
|
||||
|
||||
it('should call GroupDataService.delete', () => {
|
||||
deleteButton.click();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(groupsDataServiceStub.delete).toHaveBeenCalledWith(mockGroups[0].id);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -9,7 +9,7 @@ import {
|
||||
of as observableOf,
|
||||
Subscription
|
||||
} from 'rxjs';
|
||||
import { catchError, map, switchMap, take, tap } from 'rxjs/operators';
|
||||
import { catchError, map, switchMap, tap } from 'rxjs/operators';
|
||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
||||
@@ -199,7 +199,6 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
|
||||
if (rd.hasSucceeded) {
|
||||
this.deletedGroupsIds = [...this.deletedGroupsIds, group.group.id];
|
||||
this.notificationsService.success(this.translateService.get(this.messagePrefix + 'notification.deleted.success', { name: group.group.name }));
|
||||
this.reset();
|
||||
} else {
|
||||
this.notificationsService.error(
|
||||
this.translateService.get(this.messagePrefix + 'notification.deleted.failure.title', { name: group.group.name }),
|
||||
@@ -209,17 +208,6 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will set everything to stale, which will cause the lists on this page to update.
|
||||
*/
|
||||
reset() {
|
||||
this.groupService.getBrowseEndpoint().pipe(
|
||||
take(1)
|
||||
).subscribe((href: string) => {
|
||||
this.requestService.setStaleByHrefSubstring(href);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the members (epersons embedded value of a group)
|
||||
* @param group
|
||||
|
@@ -128,7 +128,6 @@ export class MetadataRegistryComponent {
|
||||
* Delete all the selected metadata schemas
|
||||
*/
|
||||
deleteSchemas() {
|
||||
this.registryService.clearMetadataSchemaRequests().subscribe();
|
||||
this.registryService.getSelectedMetadataSchemas().pipe(take(1)).subscribe(
|
||||
(schemas) => {
|
||||
const tasks$ = [];
|
||||
@@ -148,7 +147,6 @@ export class MetadataRegistryComponent {
|
||||
}
|
||||
this.registryService.deselectAllMetadataSchema();
|
||||
this.registryService.cancelEditMetadataSchema();
|
||||
this.forceUpdateSchemas();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@@ -174,15 +174,12 @@ export class MetadataSchemaComponent implements OnInit {
|
||||
const failedResponses = responses.filter((response: RemoteData<NoContent>) => response.hasFailed);
|
||||
if (successResponses.length > 0) {
|
||||
this.showNotification(true, successResponses.length);
|
||||
this.registryService.clearMetadataFieldRequests();
|
||||
|
||||
}
|
||||
if (failedResponses.length > 0) {
|
||||
this.showNotification(false, failedResponses.length);
|
||||
}
|
||||
this.registryService.deselectAllMetadataField();
|
||||
this.registryService.cancelEditMetadataField();
|
||||
this.forceUpdateFields();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@@ -187,7 +187,7 @@ describe('App component', () => {
|
||||
link.setAttribute('rel', 'stylesheet');
|
||||
link.setAttribute('type', 'text/css');
|
||||
link.setAttribute('class', 'theme-css');
|
||||
link.setAttribute('href', '/custom-theme.css');
|
||||
link.setAttribute('href', 'custom-theme.css');
|
||||
|
||||
expect(headSpy.appendChild).toHaveBeenCalledWith(link);
|
||||
});
|
||||
|
@@ -268,7 +268,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||
link.setAttribute('rel', 'stylesheet');
|
||||
link.setAttribute('type', 'text/css');
|
||||
link.setAttribute('class', 'theme-css');
|
||||
link.setAttribute('href', `/${encodeURIComponent(themeName)}-theme.css`);
|
||||
link.setAttribute('href', `${encodeURIComponent(themeName)}-theme.css`);
|
||||
// wait for the new css to download before removing the old one to prevent a
|
||||
// flash of unstyled content
|
||||
link.onload = () => {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { APP_BASE_HREF, CommonModule } from '@angular/common';
|
||||
import { APP_BASE_HREF, CommonModule, DOCUMENT } from '@angular/common';
|
||||
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
|
||||
import { APP_INITIALIZER, NgModule } from '@angular/core';
|
||||
import { AbstractControl } from '@angular/forms';
|
||||
@@ -42,9 +42,11 @@ export function getConfig() {
|
||||
return environment;
|
||||
}
|
||||
|
||||
export function getBase(appConfig: AppConfig) {
|
||||
return appConfig.ui.nameSpace;
|
||||
}
|
||||
const getBaseHref = (document: Document, appConfig: AppConfig): string => {
|
||||
const baseTag = document.querySelector('head > base');
|
||||
baseTag.setAttribute('href', `${appConfig.ui.nameSpace}${appConfig.ui.nameSpace.endsWith('/') ? '' : '/'}`);
|
||||
return baseTag.getAttribute('href');
|
||||
};
|
||||
|
||||
export function getMetaReducers(appConfig: AppConfig): MetaReducer<AppState>[] {
|
||||
return appConfig.debug ? [...appMetaReducers, ...debugMetaReducers] : appMetaReducers;
|
||||
@@ -84,8 +86,8 @@ const PROVIDERS = [
|
||||
},
|
||||
{
|
||||
provide: APP_BASE_HREF,
|
||||
useFactory: getBase,
|
||||
deps: [APP_CONFIG]
|
||||
useFactory: getBaseHref,
|
||||
deps: [DOCUMENT, APP_CONFIG]
|
||||
},
|
||||
{
|
||||
provide: USER_PROVIDED_META_REDUCERS,
|
||||
|
@@ -5,7 +5,6 @@ import { NotificationsService } from '../../shared/notifications/notifications.s
|
||||
import { CollectionDataService } from '../../core/data/collection-data.service';
|
||||
import { Collection } from '../../core/shared/collection.model';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { RequestService } from '../../core/data/request.service';
|
||||
|
||||
/**
|
||||
* Component that represents the page where a user can delete an existing Collection
|
||||
@@ -24,8 +23,7 @@ export class DeleteCollectionPageComponent extends DeleteComColPageComponent<Col
|
||||
protected route: ActivatedRoute,
|
||||
protected notifications: NotificationsService,
|
||||
protected translate: TranslateService,
|
||||
protected requestService: RequestService
|
||||
) {
|
||||
super(dsoDataService, router, route, notifications, translate, requestService);
|
||||
super(dsoDataService, router, route, notifications, translate);
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,6 @@ import { NotificationsService } from '../../../shared/notifications/notification
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { ItemTemplateDataService } from '../../../core/data/item-template-data.service';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||
import { getCollectionItemTemplateRoute } from '../../collection-page-routing-paths';
|
||||
@@ -49,9 +48,6 @@ describe('CollectionMetadataComponent', () => {
|
||||
success: {},
|
||||
error: {}
|
||||
});
|
||||
const objectCache = jasmine.createSpyObj('objectCache', {
|
||||
remove: {}
|
||||
});
|
||||
const requestService = jasmine.createSpyObj('requestService', {
|
||||
setStaleByHrefSubstring: {}
|
||||
});
|
||||
@@ -65,8 +61,7 @@ describe('CollectionMetadataComponent', () => {
|
||||
{ provide: ItemTemplateDataService, useValue: itemTemplateServiceStub },
|
||||
{ provide: ActivatedRoute, useValue: { parent: { data: observableOf({ dso: createSuccessfulRemoteDataObject(collection) }) } } },
|
||||
{ provide: NotificationsService, useValue: notificationsService },
|
||||
{ provide: ObjectCacheService, useValue: objectCache },
|
||||
{ provide: RequestService, useValue: requestService }
|
||||
{ provide: RequestService, useValue: requestService },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
@@ -95,21 +90,19 @@ describe('CollectionMetadataComponent', () => {
|
||||
});
|
||||
|
||||
describe('deleteItemTemplate', () => {
|
||||
describe('when delete returns a success', () => {
|
||||
beforeEach(() => {
|
||||
(itemTemplateService.deleteByCollectionID as jasmine.Spy).and.returnValue(observableOf(true));
|
||||
comp.deleteItemTemplate();
|
||||
});
|
||||
beforeEach(() => {
|
||||
(itemTemplateService.deleteByCollectionID as jasmine.Spy).and.returnValue(observableOf(true));
|
||||
comp.deleteItemTemplate();
|
||||
});
|
||||
|
||||
it('should call ItemTemplateService.deleteByCollectionID', () => {
|
||||
expect(itemTemplateService.deleteByCollectionID).toHaveBeenCalledWith(template, 'collection-id');
|
||||
});
|
||||
|
||||
describe('when delete returns a success', () => {
|
||||
it('should display a success notification', () => {
|
||||
expect(notificationsService.success).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reset related object and request cache', () => {
|
||||
expect(requestService.setStaleByHrefSubstring).toHaveBeenCalledWith(collectionTemplateHref);
|
||||
expect(requestService.setStaleByHrefSubstring).toHaveBeenCalledWith(template.self);
|
||||
expect(requestService.setStaleByHrefSubstring).toHaveBeenCalledWith(collection.self);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when delete returns a failure', () => {
|
||||
|
@@ -8,10 +8,9 @@ import { combineLatest as combineLatestObservable, Observable } from 'rxjs';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators';
|
||||
import { switchMap, tap } from 'rxjs/operators';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { getCollectionItemTemplateRoute } from '../../collection-page-routing-paths';
|
||||
|
||||
@@ -38,8 +37,7 @@ export class CollectionMetadataComponent extends ComcolMetadataComponent<Collect
|
||||
protected route: ActivatedRoute,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected translate: TranslateService,
|
||||
protected objectCache: ObjectCacheService,
|
||||
protected requestService: RequestService
|
||||
protected requestService: RequestService,
|
||||
) {
|
||||
super(collectionDataService, router, route, notificationsService, translate);
|
||||
}
|
||||
@@ -93,23 +91,9 @@ export class CollectionMetadataComponent extends ComcolMetadataComponent<Collect
|
||||
getFirstSucceededRemoteDataPayload(),
|
||||
)),
|
||||
);
|
||||
const templateHref$ = collection$.pipe(
|
||||
switchMap((collection) => this.itemTemplateService.getCollectionEndpoint(collection.id)),
|
||||
);
|
||||
|
||||
combineLatestObservable(collection$, template$, templateHref$).pipe(
|
||||
switchMap(([collection, template, templateHref]) => {
|
||||
return this.itemTemplateService.deleteByCollectionID(template, collection.uuid).pipe(
|
||||
tap((success: boolean) => {
|
||||
if (success) {
|
||||
this.objectCache.remove(templateHref);
|
||||
this.objectCache.remove(template.self);
|
||||
this.requestService.setStaleByHrefSubstring(template.self);
|
||||
this.requestService.setStaleByHrefSubstring(templateHref);
|
||||
this.requestService.setStaleByHrefSubstring(collection.self);
|
||||
}
|
||||
})
|
||||
);
|
||||
combineLatestObservable(collection$, template$).pipe(
|
||||
switchMap(([collection, template]) => {
|
||||
return this.itemTemplateService.deleteByCollectionID(template, collection.uuid);
|
||||
})
|
||||
).subscribe((success: boolean) => {
|
||||
if (success) {
|
||||
|
@@ -13,6 +13,8 @@ import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { ComcolModule } from '../../../shared/comcol/comcol.module';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||
|
||||
describe('CollectionRolesComponent', () => {
|
||||
|
||||
@@ -79,6 +81,7 @@ describe('CollectionRolesComponent', () => {
|
||||
{ provide: ActivatedRoute, useValue: route },
|
||||
{ provide: RequestService, useValue: requestService },
|
||||
{ provide: GroupDataService, useValue: groupDataService },
|
||||
{ provide: NotificationsService, useClass: NotificationsServiceStub }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
|
@@ -5,7 +5,6 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { DeleteComColPageComponent } from '../../shared/comcol/comcol-forms/delete-comcol-page/delete-comcol-page.component';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { RequestService } from '../../core/data/request.service';
|
||||
|
||||
/**
|
||||
* Component that represents the page where a user can delete an existing Community
|
||||
@@ -24,9 +23,8 @@ export class DeleteCommunityPageComponent extends DeleteComColPageComponent<Comm
|
||||
protected route: ActivatedRoute,
|
||||
protected notifications: NotificationsService,
|
||||
protected translate: TranslateService,
|
||||
protected requestService: RequestService
|
||||
) {
|
||||
super(dsoDataService, router, route, notifications, translate, requestService);
|
||||
super(dsoDataService, router, route, notifications, translate);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,6 +13,8 @@ import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { ComcolModule } from '../../../shared/comcol/comcol.module';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||
|
||||
describe('CommunityRolesComponent', () => {
|
||||
|
||||
@@ -64,6 +66,7 @@ describe('CommunityRolesComponent', () => {
|
||||
{ provide: ActivatedRoute, useValue: route },
|
||||
{ provide: RequestService, useValue: requestService },
|
||||
{ provide: GroupDataService, useValue: groupDataService },
|
||||
{ provide: NotificationsService, useClass: NotificationsServiceStub }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
|
@@ -377,25 +377,25 @@ describe('AuthService test', () => {
|
||||
it('should redirect to reload with redirect url', () => {
|
||||
authService.navigateToRedirectUrl('/collection/123');
|
||||
// Reload with redirect URL set to /collection/123
|
||||
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('/reload/[0-9]*\\?redirect=' + encodeURIComponent('/collection/123'))));
|
||||
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('reload/[0-9]*\\?redirect=' + encodeURIComponent('/collection/123'))));
|
||||
});
|
||||
|
||||
it('should redirect to reload with /home', () => {
|
||||
authService.navigateToRedirectUrl('/home');
|
||||
// Reload with redirect URL set to /home
|
||||
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('/reload/[0-9]*\\?redirect=' + encodeURIComponent('/home'))));
|
||||
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('reload/[0-9]*\\?redirect=' + encodeURIComponent('/home'))));
|
||||
});
|
||||
|
||||
it('should redirect to regular reload and not to /login', () => {
|
||||
authService.navigateToRedirectUrl('/login');
|
||||
// Reload without a redirect URL
|
||||
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('/reload/[0-9]*(?!\\?)$')));
|
||||
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('reload/[0-9]*(?!\\?)$')));
|
||||
});
|
||||
|
||||
it('should redirect to regular reload when no redirect url is found', () => {
|
||||
authService.navigateToRedirectUrl(undefined);
|
||||
// Reload without a redirect URL
|
||||
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('/reload/[0-9]*(?!\\?)$')));
|
||||
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('reload/[0-9]*(?!\\?)$')));
|
||||
});
|
||||
|
||||
describe('impersonate', () => {
|
||||
|
@@ -468,8 +468,8 @@ export class AuthService {
|
||||
*/
|
||||
public navigateToRedirectUrl(redirectUrl: string) {
|
||||
// Don't do redirect if already on reload url
|
||||
if (!hasValue(redirectUrl) || !redirectUrl.includes('/reload/')) {
|
||||
let url = `/reload/${new Date().getTime()}`;
|
||||
if (!hasValue(redirectUrl) || !redirectUrl.includes('reload/')) {
|
||||
let url = `reload/${new Date().getTime()}`;
|
||||
if (isNotEmpty(redirectUrl) && !redirectUrl.startsWith(LOGIN_ROUTE)) {
|
||||
url += `?redirect=${encodeURIComponent(redirectUrl)}`;
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ describe('objectCacheReducer', () => {
|
||||
alternativeLinks: [altLink1, altLink2],
|
||||
timeCompleted: new Date().getTime(),
|
||||
msToLive: 900000,
|
||||
requestUUID: requestUUID1,
|
||||
requestUUIDs: [requestUUID1],
|
||||
patches: [],
|
||||
isDirty: false,
|
||||
},
|
||||
@@ -55,7 +55,7 @@ describe('objectCacheReducer', () => {
|
||||
alternativeLinks: [altLink3, altLink4],
|
||||
timeCompleted: new Date().getTime(),
|
||||
msToLive: 900000,
|
||||
requestUUID: selfLink2,
|
||||
requestUUIDs: [selfLink2],
|
||||
patches: [],
|
||||
isDirty: false
|
||||
}
|
||||
|
10
src/app/core/cache/object-cache.reducer.ts
vendored
10
src/app/core/cache/object-cache.reducer.ts
vendored
@@ -63,9 +63,11 @@ export class ObjectCacheEntry implements CacheEntry {
|
||||
msToLive: number;
|
||||
|
||||
/**
|
||||
* The UUID of the request that caused this entry to be added
|
||||
* The UUIDs of the requests that caused this entry to be added
|
||||
* New UUIDs should be added to the front of the array
|
||||
* to make retrieving the latest UUID easier.
|
||||
*/
|
||||
requestUUID: string;
|
||||
requestUUIDs: string[];
|
||||
|
||||
/**
|
||||
* An array of patches that were made on the client side to this entry, but haven't been sent to the server yet
|
||||
@@ -156,11 +158,11 @@ function addToObjectCache(state: ObjectCacheState, action: AddToObjectCacheActio
|
||||
data: action.payload.objectToCache,
|
||||
timeCompleted: action.payload.timeCompleted,
|
||||
msToLive: action.payload.msToLive,
|
||||
requestUUID: action.payload.requestUUID,
|
||||
requestUUIDs: [action.payload.requestUUID, ...(existing.requestUUIDs || [])],
|
||||
isDirty: isNotEmpty(existing.patches),
|
||||
patches: existing.patches || [],
|
||||
alternativeLinks: [...(existing.alternativeLinks || []), ...newAltLinks]
|
||||
}
|
||||
} as ObjectCacheEntry
|
||||
});
|
||||
}
|
||||
|
||||
|
66
src/app/core/cache/object-cache.service.spec.ts
vendored
66
src/app/core/cache/object-cache.service.spec.ts
vendored
@@ -211,25 +211,69 @@ describe('ObjectCacheService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('has', () => {
|
||||
describe('hasByHref', () => {
|
||||
describe('with requestUUID not specified', () => {
|
||||
describe('getByHref emits an object', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service, 'getByHref').and.returnValue(observableOf(cacheEntry));
|
||||
});
|
||||
|
||||
describe('getByHref emits an object', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service, 'getByHref').and.returnValue(observableOf(cacheEntry));
|
||||
it('should return true', () => {
|
||||
expect(service.hasByHref(selfLink)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return true', () => {
|
||||
expect(service.hasByHref(selfLink)).toBe(true);
|
||||
describe('getByHref emits nothing', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service, 'getByHref').and.returnValue(empty());
|
||||
});
|
||||
|
||||
it('should return false', () => {
|
||||
expect(service.hasByHref(selfLink)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getByHref emits nothing', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service, 'getByHref').and.returnValue(empty());
|
||||
describe('with requestUUID specified', () => {
|
||||
describe('getByHref emits an object that includes the specified requestUUID', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service, 'getByHref').and.returnValue(observableOf(Object.assign(cacheEntry, {
|
||||
requestUUIDs: [
|
||||
'something',
|
||||
'something-else',
|
||||
'specific-request',
|
||||
]
|
||||
})));
|
||||
});
|
||||
|
||||
it('should return true', () => {
|
||||
expect(service.hasByHref(selfLink, 'specific-request')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return false', () => {
|
||||
expect(service.hasByHref(selfLink)).toBe(false);
|
||||
describe('getByHref emits an object that doesn\'t include the specified requestUUID', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service, 'getByHref').and.returnValue(observableOf(Object.assign(cacheEntry, {
|
||||
requestUUIDs: [
|
||||
'something',
|
||||
'something-else',
|
||||
]
|
||||
})));
|
||||
});
|
||||
|
||||
it('should return true', () => {
|
||||
expect(service.hasByHref(selfLink, 'specific-request')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getByHref emits nothing', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service, 'getByHref').and.returnValue(empty());
|
||||
});
|
||||
|
||||
it('should return false', () => {
|
||||
expect(service.hasByHref(selfLink, 'specific-request')).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
4
src/app/core/cache/object-cache.service.ts
vendored
4
src/app/core/cache/object-cache.service.ts
vendored
@@ -197,7 +197,7 @@ export class ObjectCacheService {
|
||||
*/
|
||||
getRequestUUIDBySelfLink(selfLink: string): Observable<string> {
|
||||
return this.getByHref(selfLink).pipe(
|
||||
map((entry: ObjectCacheEntry) => entry.requestUUID),
|
||||
map((entry: ObjectCacheEntry) => entry.requestUUIDs[0]),
|
||||
distinctUntilChanged());
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ export class ObjectCacheService {
|
||||
let result = false;
|
||||
this.getByHref(href).subscribe((entry: ObjectCacheEntry) => {
|
||||
if (isNotEmpty(requestUUID)) {
|
||||
result = entry.requestUUID === requestUUID;
|
||||
result = entry.requestUUIDs.includes(requestUUID);
|
||||
} else {
|
||||
result = true;
|
||||
}
|
||||
|
@@ -37,7 +37,12 @@ describe('BitstreamFormatDataService', () => {
|
||||
}
|
||||
} as Store<CoreState>;
|
||||
|
||||
const objectCache = {} as ObjectCacheService;
|
||||
const requestUUIDs = ['some', 'uuid'];
|
||||
|
||||
const objectCache = jasmine.createSpyObj('objectCache', {
|
||||
getByHref: observableOf({ requestUUIDs })
|
||||
}) as ObjectCacheService;
|
||||
|
||||
const halEndpointService = {
|
||||
getEndpoint(linkPath: string): Observable<string> {
|
||||
return cold('a', { a: bitstreamFormatsEndpoint });
|
||||
@@ -76,6 +81,7 @@ describe('BitstreamFormatDataService', () => {
|
||||
send: {},
|
||||
getByHref: observableOf(responseCacheEntry),
|
||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||
setStaleByUUID: observableOf(true),
|
||||
generateRequestId: 'request-id',
|
||||
removeByHrefSubstring: {}
|
||||
});
|
||||
@@ -96,6 +102,7 @@ describe('BitstreamFormatDataService', () => {
|
||||
send: {},
|
||||
getByHref: observableOf(responseCacheEntry),
|
||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||
setStaleByUUID: observableOf(true),
|
||||
generateRequestId: 'request-id',
|
||||
removeByHrefSubstring: {}
|
||||
});
|
||||
@@ -118,6 +125,7 @@ describe('BitstreamFormatDataService', () => {
|
||||
send: {},
|
||||
getByHref: observableOf(responseCacheEntry),
|
||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||
setStaleByUUID: observableOf(true),
|
||||
generateRequestId: 'request-id',
|
||||
removeByHrefSubstring: {}
|
||||
});
|
||||
@@ -139,6 +147,7 @@ describe('BitstreamFormatDataService', () => {
|
||||
send: {},
|
||||
getByHref: observableOf(responseCacheEntry),
|
||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||
setStaleByUUID: observableOf(true),
|
||||
generateRequestId: 'request-id',
|
||||
removeByHrefSubstring: {}
|
||||
});
|
||||
@@ -163,6 +172,7 @@ describe('BitstreamFormatDataService', () => {
|
||||
send: {},
|
||||
getByHref: observableOf(responseCacheEntry),
|
||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||
setStaleByUUID: observableOf(true),
|
||||
generateRequestId: 'request-id',
|
||||
removeByHrefSubstring: {}
|
||||
});
|
||||
@@ -186,6 +196,7 @@ describe('BitstreamFormatDataService', () => {
|
||||
send: {},
|
||||
getByHref: observableOf(responseCacheEntry),
|
||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||
setStaleByUUID: observableOf(true),
|
||||
generateRequestId: 'request-id',
|
||||
removeByHrefSubstring: {}
|
||||
});
|
||||
@@ -209,6 +220,7 @@ describe('BitstreamFormatDataService', () => {
|
||||
send: {},
|
||||
getByHref: observableOf(responseCacheEntry),
|
||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||
setStaleByUUID: observableOf(true),
|
||||
generateRequestId: 'request-id',
|
||||
removeByHrefSubstring: {}
|
||||
});
|
||||
@@ -231,6 +243,7 @@ describe('BitstreamFormatDataService', () => {
|
||||
send: {},
|
||||
getByHref: observableOf(responseCacheEntry),
|
||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||
setStaleByUUID: observableOf(true),
|
||||
generateRequestId: 'request-id',
|
||||
removeByHrefSubstring: {}
|
||||
});
|
||||
@@ -253,6 +266,7 @@ describe('BitstreamFormatDataService', () => {
|
||||
send: {},
|
||||
getByHref: observableOf(responseCacheEntry),
|
||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||
setStaleByUUID: observableOf(true),
|
||||
generateRequestId: 'request-id',
|
||||
removeByHrefSubstring: {}
|
||||
});
|
||||
@@ -273,6 +287,7 @@ describe('BitstreamFormatDataService', () => {
|
||||
send: {},
|
||||
getByHref: observableOf(responseCacheEntry),
|
||||
getByUUID: hot('a', { a: responseCacheEntry }),
|
||||
setStaleByUUID: observableOf(true),
|
||||
generateRequestId: 'request-id',
|
||||
removeByHrefSubstring: {}
|
||||
});
|
||||
|
@@ -22,6 +22,7 @@ import {
|
||||
import { BitstreamDataService } from './bitstream-data.service';
|
||||
import { CoreState } from '../core-state.model';
|
||||
import { FindListOptions } from './find-list-options.model';
|
||||
import { Bitstream } from '../shared/bitstream.model';
|
||||
|
||||
const LINK_NAME = 'test';
|
||||
|
||||
@@ -244,4 +245,75 @@ describe('ComColDataService', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('deleteLogo', () => {
|
||||
let dso;
|
||||
|
||||
beforeEach(() => {
|
||||
dso = {
|
||||
_links: {
|
||||
logo: {
|
||||
href: 'logo-href'
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
describe('when DSO has no logo', () => {
|
||||
beforeEach(() => {
|
||||
dso.logo = undefined;
|
||||
});
|
||||
|
||||
it('should return a failed RD', (done) => {
|
||||
service.deleteLogo(dso).subscribe(rd => {
|
||||
expect(rd.hasFailed).toBeTrue();
|
||||
expect(bitstreamDataService.deleteByHref).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when DSO has a logo', () => {
|
||||
let logo;
|
||||
|
||||
beforeEach(() => {
|
||||
logo = Object.assign(new Bitstream, {
|
||||
id: 'logo-id',
|
||||
_links: {
|
||||
self: {
|
||||
href: 'logo-href',
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('that can be retrieved', () => {
|
||||
beforeEach(() => {
|
||||
dso.logo = createSuccessfulRemoteDataObject$(logo);
|
||||
});
|
||||
|
||||
it('should call BitstreamDataService.deleteByHref', (done) => {
|
||||
service.deleteLogo(dso).subscribe(rd => {
|
||||
expect(rd.hasSucceeded).toBeTrue();
|
||||
expect(bitstreamDataService.deleteByHref).toHaveBeenCalledWith('logo-href');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('that cannot be retrieved', () => {
|
||||
beforeEach(() => {
|
||||
dso.logo = createFailedRemoteDataObject$(logo);
|
||||
});
|
||||
|
||||
it('should not call BitstreamDataService.deleteByHref', (done) => {
|
||||
service.deleteLogo(dso).subscribe(rd => {
|
||||
expect(rd.hasFailed).toBeTrue();
|
||||
expect(bitstreamDataService.deleteByHref).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -11,7 +11,11 @@ import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { Item } from '../shared/item.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||
import {
|
||||
createFailedRemoteDataObject,
|
||||
createSuccessfulRemoteDataObject,
|
||||
createSuccessfulRemoteDataObject$,
|
||||
} from '../../shared/remote-data.utils';
|
||||
import { ChangeAnalyzer } from './change-analyzer';
|
||||
import { DataService } from './data.service';
|
||||
import { PatchRequest } from './request.models';
|
||||
@@ -25,9 +29,12 @@ import { RemoteData } from './remote-data';
|
||||
import { RequestEntryState } from './request-entry-state.model';
|
||||
import { CoreState } from '../core-state.model';
|
||||
import { FindListOptions } from './find-list-options.model';
|
||||
import { fakeAsync, tick } from '@angular/core/testing';
|
||||
|
||||
const endpoint = 'https://rest.api/core';
|
||||
|
||||
const BOOLEAN = { f: false, t: true };
|
||||
|
||||
class TestService extends DataService<any> {
|
||||
|
||||
constructor(
|
||||
@@ -86,6 +93,9 @@ describe('DataService', () => {
|
||||
},
|
||||
getObjectBySelfLink: () => {
|
||||
/* empty */
|
||||
},
|
||||
getByHref: () => {
|
||||
/* empty */
|
||||
}
|
||||
} as any;
|
||||
store = {} as Store<CoreState>;
|
||||
@@ -833,4 +843,149 @@ describe('DataService', () => {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe('invalidateByHref', () => {
|
||||
let getByHrefSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
getByHrefSpy = spyOn(objectCache, 'getByHref').and.returnValue(observableOf({
|
||||
requestUUIDs: ['request1', 'request2', 'request3']
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
it('should call setStaleByUUID for every request associated with this DSO', (done) => {
|
||||
service.invalidateByHref('some-href').subscribe((ok) => {
|
||||
expect(ok).toBeTrue();
|
||||
expect(getByHrefSpy).toHaveBeenCalledWith('some-href');
|
||||
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request1');
|
||||
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request2');
|
||||
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request3');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should call setStaleByUUID even if not subscribing to returned Observable', fakeAsync(() => {
|
||||
service.invalidateByHref('some-href');
|
||||
tick();
|
||||
|
||||
expect(getByHrefSpy).toHaveBeenCalledWith('some-href');
|
||||
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request1');
|
||||
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request2');
|
||||
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request3');
|
||||
}));
|
||||
|
||||
it('should return an Observable that only emits true once all requests are stale', () => {
|
||||
testScheduler.run(({ cold, expectObservable }) => {
|
||||
requestService.setStaleByUUID.and.callFake((uuid) => {
|
||||
switch (uuid) { // fake requests becoming stale at different times
|
||||
case 'request1':
|
||||
return cold('--(t|)', BOOLEAN);
|
||||
case 'request2':
|
||||
return cold('----(t|)', BOOLEAN);
|
||||
case 'request3':
|
||||
return cold('------(t|)', BOOLEAN);
|
||||
}
|
||||
});
|
||||
|
||||
const done$ = service.invalidateByHref('some-href');
|
||||
|
||||
// emit true as soon as the final request is stale
|
||||
expectObservable(done$).toBe('------(t|)', BOOLEAN);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('delete', () => {
|
||||
let MOCK_SUCCEEDED_RD;
|
||||
let MOCK_FAILED_RD;
|
||||
|
||||
let invalidateByHrefSpy: jasmine.Spy;
|
||||
let buildFromRequestUUIDSpy: jasmine.Spy;
|
||||
let getIDHrefObsSpy: jasmine.Spy;
|
||||
let deleteByHrefSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
invalidateByHrefSpy = spyOn(service, 'invalidateByHref').and.returnValue(observableOf(true));
|
||||
buildFromRequestUUIDSpy = spyOn(rdbService, 'buildFromRequestUUID').and.callThrough();
|
||||
getIDHrefObsSpy = spyOn(service, 'getIDHrefObs').and.callThrough();
|
||||
deleteByHrefSpy = spyOn(service, 'deleteByHref').and.callThrough();
|
||||
|
||||
MOCK_SUCCEEDED_RD = createSuccessfulRemoteDataObject({});
|
||||
MOCK_FAILED_RD = createFailedRemoteDataObject('something went wrong');
|
||||
});
|
||||
|
||||
it('should retrieve href by ID and call deleteByHref', () => {
|
||||
getIDHrefObsSpy.and.returnValue(observableOf('some-href'));
|
||||
buildFromRequestUUIDSpy.and.returnValue(createSuccessfulRemoteDataObject$({}));
|
||||
|
||||
service.delete('some-id', ['a', 'b', 'c']).subscribe(rd => {
|
||||
expect(getIDHrefObsSpy).toHaveBeenCalledWith('some-id');
|
||||
expect(deleteByHrefSpy).toHaveBeenCalledWith('some-href', ['a', 'b', 'c']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('deleteByHref', () => {
|
||||
it('should call invalidateByHref if the DELETE request succeeds', (done) => {
|
||||
buildFromRequestUUIDSpy.and.returnValue(observableOf(MOCK_SUCCEEDED_RD));
|
||||
|
||||
service.deleteByHref('some-href').subscribe(rd => {
|
||||
expect(rd).toBe(MOCK_SUCCEEDED_RD);
|
||||
expect(invalidateByHrefSpy).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should call invalidateByHref even if not subscribing to returned Observable', fakeAsync(() => {
|
||||
buildFromRequestUUIDSpy.and.returnValue(observableOf(MOCK_SUCCEEDED_RD));
|
||||
|
||||
service.deleteByHref('some-href');
|
||||
tick();
|
||||
|
||||
expect(invalidateByHrefSpy).toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
it('should not call invalidateByHref if the DELETE request fails', (done) => {
|
||||
buildFromRequestUUIDSpy.and.returnValue(observableOf(MOCK_FAILED_RD));
|
||||
|
||||
service.deleteByHref('some-href').subscribe(rd => {
|
||||
expect(rd).toBe(MOCK_FAILED_RD);
|
||||
expect(invalidateByHrefSpy).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should wait for invalidateByHref before emitting', () => {
|
||||
testScheduler.run(({ cold, expectObservable }) => {
|
||||
buildFromRequestUUIDSpy.and.returnValue(
|
||||
cold('(r|)', { r: MOCK_SUCCEEDED_RD}) // RD emits right away
|
||||
);
|
||||
invalidateByHrefSpy.and.returnValue(
|
||||
cold('----(t|)', BOOLEAN) // but we pretend that setting requests to stale takes longer
|
||||
);
|
||||
|
||||
const done$ = service.deleteByHref('some-href');
|
||||
expectObservable(done$).toBe(
|
||||
'----(r|)', { r: MOCK_SUCCEEDED_RD} // ...and expect the returned Observable to wait until that's done
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should wait for the DELETE request to resolve before emitting', () => {
|
||||
testScheduler.run(({ cold, expectObservable }) => {
|
||||
buildFromRequestUUIDSpy.and.returnValue(
|
||||
cold('----(r|)', { r: MOCK_SUCCEEDED_RD}) // the request takes a while
|
||||
);
|
||||
invalidateByHrefSpy.and.returnValue(
|
||||
cold('(t|)', BOOLEAN) // but we pretend that setting to stale happens sooner
|
||||
); // e.g.: maybe already stale before this call?
|
||||
|
||||
const done$ = service.deleteByHref('some-href');
|
||||
expectObservable(done$).toBe(
|
||||
'----(r|)', { r: MOCK_SUCCEEDED_RD} // ...and expect the returned Observable to wait for the request
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Operation } from 'fast-json-patch';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { AsyncSubject, combineLatest, from as observableFrom, Observable, of as observableOf } from 'rxjs';
|
||||
import {
|
||||
distinctUntilChanged,
|
||||
filter,
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
takeWhile,
|
||||
switchMap,
|
||||
tap,
|
||||
skipWhile,
|
||||
skipWhile, toArray
|
||||
} from 'rxjs/operators';
|
||||
import { hasValue, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util';
|
||||
import { NotificationOptions } from '../../shared/notifications/models/notification-options.model';
|
||||
@@ -21,11 +21,12 @@ import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||
import { getClassForType } from '../cache/builders/build-decorators';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { RequestParam } from '../cache/models/request-param.model';
|
||||
import { ObjectCacheEntry } from '../cache/object-cache.reducer';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { DSpaceSerializer } from '../dspace-rest/dspace.serializer';
|
||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { getRemoteDataPayload, getFirstSucceededRemoteData, } from '../shared/operators';
|
||||
import { getRemoteDataPayload, getFirstSucceededRemoteData, getFirstCompletedRemoteData } from '../shared/operators';
|
||||
import { URLCombiner } from '../url-combiner/url-combiner';
|
||||
import { ChangeAnalyzer } from './change-analyzer';
|
||||
import { PaginatedList } from './paginated-list.model';
|
||||
@@ -579,6 +580,38 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
||||
return result$;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate an existing DSpaceObject by marking all requests it is included in as stale
|
||||
* @param objectId The id of the object to be invalidated
|
||||
* @return An Observable that will emit `true` once all requests are stale
|
||||
*/
|
||||
invalidate(objectId: string): Observable<boolean> {
|
||||
return this.getIDHrefObs(objectId).pipe(
|
||||
switchMap((href: string) => this.invalidateByHref(href))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate an existing DSpaceObject by marking all requests it is included in as stale
|
||||
* @param href The self link of the object to be invalidated
|
||||
* @return An Observable that will emit `true` once all requests are stale
|
||||
*/
|
||||
invalidateByHref(href: string): Observable<boolean> {
|
||||
const done$ = new AsyncSubject<boolean>();
|
||||
|
||||
this.objectCache.getByHref(href).pipe(
|
||||
switchMap((oce: ObjectCacheEntry) => observableFrom(oce.requestUUIDs).pipe(
|
||||
mergeMap((requestUUID: string) => this.requestService.setStaleByUUID(requestUUID)),
|
||||
toArray(),
|
||||
)),
|
||||
).subscribe(() => {
|
||||
done$.next(true);
|
||||
done$.complete();
|
||||
});
|
||||
|
||||
return done$;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an existing DSpace Object on the server
|
||||
* @param objectId The id of the object to be removed
|
||||
@@ -600,6 +633,7 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
||||
* metadata should be saved as real metadata
|
||||
* @return A RemoteData observable with an empty payload, but still representing the state of the request: statusCode,
|
||||
* errorMessage, timeCompleted, etc
|
||||
* Only emits once all request related to the DSO has been invalidated.
|
||||
*/
|
||||
deleteByHref(href: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
@@ -618,7 +652,27 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
||||
}
|
||||
this.requestService.send(request);
|
||||
|
||||
return this.rdbService.buildFromRequestUUID(requestId);
|
||||
const response$ = this.rdbService.buildFromRequestUUID(requestId);
|
||||
|
||||
const invalidated$ = new AsyncSubject<boolean>();
|
||||
response$.pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
switchMap((rd: RemoteData<NoContent>) => {
|
||||
if (rd.hasSucceeded) {
|
||||
return this.invalidateByHref(href);
|
||||
} else {
|
||||
return [true];
|
||||
}
|
||||
})
|
||||
).subscribe(() => {
|
||||
invalidated$.next(true);
|
||||
invalidated$.complete();
|
||||
});
|
||||
|
||||
return combineLatest([response$, invalidated$]).pipe(
|
||||
filter(([_, invalidated]) => invalidated),
|
||||
map(([response, _]) => response),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -8,7 +8,7 @@ import { defaultUUID, getMockUUIDService } from '../../shared/mocks/uuid.service
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { coreReducers} from '../core.reducers';
|
||||
import { UUIDService } from '../shared/uuid.service';
|
||||
import { RequestConfigureAction, RequestExecuteAction } from './request.actions';
|
||||
import { RequestConfigureAction, RequestExecuteAction, RequestStaleAction } from './request.actions';
|
||||
import {
|
||||
DeleteRequest,
|
||||
GetRequest,
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
PutRequest
|
||||
} from './request.models';
|
||||
import { RequestService } from './request.service';
|
||||
import { TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { fakeAsync, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { storeModuleConfig } from '../../app.reducer';
|
||||
import { MockStore, provideMockStore } from '@ngrx/store/testing';
|
||||
import { RequestEntryState } from './request-entry-state.model';
|
||||
@@ -426,7 +426,7 @@ describe('RequestService', () => {
|
||||
describe('and it is cached', () => {
|
||||
describe('in the ObjectCache', () => {
|
||||
beforeEach(() => {
|
||||
(objectCache.getByHref as any).and.returnValue(observableOf({ requestUUID: 'some-uuid' }));
|
||||
(objectCache.getByHref as any).and.returnValue(observableOf({ requestUUIDs: ['some-uuid'] }));
|
||||
spyOn(serviceAsAny, 'hasByHref').and.returnValue(false);
|
||||
spyOn(serviceAsAny, 'hasByUUID').and.returnValue(true);
|
||||
});
|
||||
@@ -596,4 +596,33 @@ describe('RequestService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('setStaleByUUID', () => {
|
||||
let dispatchSpy: jasmine.Spy;
|
||||
let getByUUIDSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
dispatchSpy = spyOn(store, 'dispatch');
|
||||
getByUUIDSpy = spyOn(service, 'getByUUID').and.callThrough();
|
||||
});
|
||||
|
||||
it('should dispatch a RequestStaleAction', () => {
|
||||
service.setStaleByUUID('something');
|
||||
const firstAction = dispatchSpy.calls.argsFor(0)[0];
|
||||
expect(firstAction).toBeInstanceOf(RequestStaleAction);
|
||||
expect(firstAction.payload).toEqual({ uuid: 'something' });
|
||||
});
|
||||
|
||||
it('should return an Observable that emits true as soon as the request is stale', fakeAsync(() => {
|
||||
dispatchSpy.and.callFake(() => { /* empty */ }); // don't actually set as stale
|
||||
getByUUIDSpy.and.returnValue(cold('a-b--c--d-', { // but fake the state in the cache
|
||||
a: { state: RequestEntryState.ResponsePending },
|
||||
b: { state: RequestEntryState.Success },
|
||||
c: { state: RequestEntryState.SuccessStale },
|
||||
d: { state: RequestEntryState.Error },
|
||||
}));
|
||||
|
||||
const done$ = service.setStaleByUUID('something');
|
||||
expect(done$).toBeObservable(cold('-----(t|)', { t: true }));
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
@@ -311,6 +311,21 @@ export class RequestService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a request as stale
|
||||
* @param uuid the UUID of the request
|
||||
* @return an Observable that will emit true once the Request becomes stale
|
||||
*/
|
||||
setStaleByUUID(uuid: string): Observable<boolean> {
|
||||
this.store.dispatch(new RequestStaleAction(uuid));
|
||||
|
||||
return this.getByUUID(uuid).pipe(
|
||||
map((request: RequestEntry) => isStale(request.state)),
|
||||
filter((stale: boolean) => stale),
|
||||
take(1),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a GET request is in the cache or if it's still pending
|
||||
* @param {GetRequest} request The request to check
|
||||
@@ -339,7 +354,7 @@ export class RequestService {
|
||||
.subscribe((entry: ObjectCacheEntry) => {
|
||||
// if the object cache has a match, check if the request that the object came with is
|
||||
// still valid
|
||||
inObjCache = this.hasByUUID(entry.requestUUID);
|
||||
inObjCache = this.hasByUUID(entry.requestUUIDs[0]);
|
||||
}).unsubscribe();
|
||||
|
||||
// we should send the request if it isn't cached
|
||||
|
@@ -21,7 +21,7 @@ import { EPersonDataService } from './eperson-data.service';
|
||||
import { EPerson } from './models/eperson.model';
|
||||
import { EPersonMock, EPersonMock2 } from '../../shared/testing/eperson.mock';
|
||||
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||
import { createNoContentRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||
import { getMockRemoteDataBuildServiceHrefMap } from '../../shared/mocks/remote-data-build.service.mock';
|
||||
import { TranslateLoaderMock } from '../../shared/mocks/translate-loader.mock';
|
||||
import { getMockRequestService } from '../../shared/mocks/request.service.mock';
|
||||
@@ -287,13 +287,12 @@ describe('EPersonDataService', () => {
|
||||
|
||||
describe('deleteEPerson', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(service, 'findById').and.returnValue(createSuccessfulRemoteDataObject$(EPersonMock));
|
||||
spyOn(service, 'delete').and.returnValue(createNoContentRemoteDataObject$());
|
||||
service.deleteEPerson(EPersonMock).subscribe();
|
||||
});
|
||||
|
||||
it('should send DeleteRequest', () => {
|
||||
const expected = new DeleteRequest(requestService.generateRequestId(), epersonsEndpoint + '/' + EPersonMock.uuid);
|
||||
expect(requestService.send).toHaveBeenCalledWith(expected);
|
||||
it('should call DataService.delete with the EPerson\'s UUID', () => {
|
||||
expect(service.delete).toHaveBeenCalledWith(EPersonMock.id);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -192,7 +192,7 @@ export class LocaleService {
|
||||
this.routeService.getCurrentUrl().pipe(take(1)).subscribe((currentURL) => {
|
||||
// Hard redirect to the reload page with a unique number behind it
|
||||
// so that all state is definitely lost
|
||||
this._window.nativeWindow.location.href = `/reload/${new Date().getTime()}?redirect=` + encodeURIComponent(currentURL);
|
||||
this._window.nativeWindow.location.href = `reload/${new Date().getTime()}?redirect=` + encodeURIComponent(currentURL);
|
||||
});
|
||||
|
||||
}
|
||||
|
@@ -386,6 +386,10 @@ describe('RegistryService', () => {
|
||||
result = registryService.deleteMetadataSchema(mockSchemasList[0].id);
|
||||
});
|
||||
|
||||
it('should defer to MetadataSchemaDataService.delete', () => {
|
||||
expect(metadataSchemaService.delete).toHaveBeenCalledWith(`${mockSchemasList[0].id}`);
|
||||
});
|
||||
|
||||
it('should return a successful response', () => {
|
||||
result.subscribe((response: RemoteData<NoContent>) => {
|
||||
expect(response.hasSucceeded).toBe(true);
|
||||
@@ -400,6 +404,10 @@ describe('RegistryService', () => {
|
||||
result = registryService.deleteMetadataField(mockFieldsList[0].id);
|
||||
});
|
||||
|
||||
it('should defer to MetadataFieldDataService.delete', () => {
|
||||
expect(metadataFieldService.delete).toHaveBeenCalledWith(`${mockFieldsList[0].id}`);
|
||||
});
|
||||
|
||||
it('should return a successful response', () => {
|
||||
result.subscribe((response: RemoteData<NoContent>) => {
|
||||
expect(response.hasSucceeded).toBe(true);
|
||||
|
@@ -1,13 +1,17 @@
|
||||
import { ReloadGuard } from './reload.guard';
|
||||
import { Router } from '@angular/router';
|
||||
import { AppConfig } from '../../../config/app-config.interface';
|
||||
import { DefaultAppConfig } from '../../../config/default-app-config';
|
||||
import { ReloadGuard } from './reload.guard';
|
||||
|
||||
describe('ReloadGuard', () => {
|
||||
let guard: ReloadGuard;
|
||||
let router: Router;
|
||||
let appConfig: AppConfig;
|
||||
|
||||
beforeEach(() => {
|
||||
router = jasmine.createSpyObj('router', ['parseUrl', 'createUrlTree']);
|
||||
guard = new ReloadGuard(router);
|
||||
appConfig = new DefaultAppConfig();
|
||||
guard = new ReloadGuard(router, appConfig);
|
||||
});
|
||||
|
||||
describe('canActivate', () => {
|
||||
@@ -27,7 +31,7 @@ describe('ReloadGuard', () => {
|
||||
|
||||
it('should create a UrlTree with the redirect URL', () => {
|
||||
guard.canActivate(route, undefined);
|
||||
expect(router.parseUrl).toHaveBeenCalledWith(redirectUrl);
|
||||
expect(router.parseUrl).toHaveBeenCalledWith(redirectUrl.substring(1));
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface';
|
||||
import { isNotEmpty } from '../../shared/empty.util';
|
||||
|
||||
/**
|
||||
@@ -8,7 +9,10 @@ import { isNotEmpty } from '../../shared/empty.util';
|
||||
*/
|
||||
@Injectable()
|
||||
export class ReloadGuard implements CanActivate {
|
||||
constructor(private router: Router) {
|
||||
constructor(
|
||||
private router: Router,
|
||||
@Inject(APP_CONFIG) private appConfig: AppConfig,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18,7 +22,10 @@ export class ReloadGuard implements CanActivate {
|
||||
*/
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): UrlTree {
|
||||
if (isNotEmpty(route.queryParams.redirect)) {
|
||||
return this.router.parseUrl(route.queryParams.redirect);
|
||||
const url = route.queryParams.redirect.startsWith(this.appConfig.ui.nameSpace)
|
||||
? route.queryParams.redirect.substring(this.appConfig.ui.nameSpace.length)
|
||||
: route.queryParams.redirect;
|
||||
return this.router.parseUrl(url);
|
||||
} else {
|
||||
return this.router.createUrlTree(['home']);
|
||||
}
|
||||
|
@@ -19,6 +19,8 @@ import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils
|
||||
import { RestResponse } from '../cache/response.models';
|
||||
import { RequestEntry } from '../data/request-entry.model';
|
||||
import { FindListOptions } from '../data/find-list-options.model';
|
||||
import { EPersonDataService } from '../eperson/eperson-data.service';
|
||||
import { GroupDataService } from '../eperson/group-data.service';
|
||||
|
||||
describe('ResourcePolicyService', () => {
|
||||
let scheduler: TestScheduler;
|
||||
@@ -28,6 +30,8 @@ describe('ResourcePolicyService', () => {
|
||||
let objectCache: ObjectCacheService;
|
||||
let halService: HALEndpointService;
|
||||
let responseCacheEntry: RequestEntry;
|
||||
let ePersonService: EPersonDataService;
|
||||
let groupService: GroupDataService;
|
||||
|
||||
const resourcePolicy: any = {
|
||||
id: '1',
|
||||
@@ -88,6 +92,8 @@ describe('ResourcePolicyService', () => {
|
||||
const resourcePolicyRD = createSuccessfulRemoteDataObject(resourcePolicy);
|
||||
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
|
||||
|
||||
const ePersonEndpoint = 'EPERSON_EP';
|
||||
|
||||
beforeEach(() => {
|
||||
scheduler = getTestScheduler();
|
||||
|
||||
@@ -105,6 +111,7 @@ describe('ResourcePolicyService', () => {
|
||||
removeByHrefSubstring: {},
|
||||
getByHref: observableOf(responseCacheEntry),
|
||||
getByUUID: observableOf(responseCacheEntry),
|
||||
setStaleByHrefSubstring: {},
|
||||
});
|
||||
rdbService = jasmine.createSpyObj('rdbService', {
|
||||
buildSingle: hot('a|', {
|
||||
@@ -117,6 +124,11 @@ describe('ResourcePolicyService', () => {
|
||||
a: resourcePolicyRD
|
||||
})
|
||||
});
|
||||
ePersonService = jasmine.createSpyObj('ePersonService', {
|
||||
getBrowseEndpoint: hot('a', {
|
||||
a: ePersonEndpoint
|
||||
}),
|
||||
});
|
||||
objectCache = {} as ObjectCacheService;
|
||||
const notificationsService = {} as NotificationsService;
|
||||
const http = {} as HttpClient;
|
||||
@@ -129,7 +141,9 @@ describe('ResourcePolicyService', () => {
|
||||
halService,
|
||||
notificationsService,
|
||||
http,
|
||||
comparator
|
||||
comparator,
|
||||
ePersonService,
|
||||
groupService
|
||||
);
|
||||
|
||||
spyOn((service as any).dataService, 'create').and.callThrough();
|
||||
@@ -320,4 +334,17 @@ describe('ResourcePolicyService', () => {
|
||||
expect(result).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('updateTarget', () => {
|
||||
it('should create a new PUT request for eperson', () => {
|
||||
const targetType = 'eperson';
|
||||
|
||||
const result = service.updateTarget(resourcePolicyId, requestURL, epersonUUID, targetType);
|
||||
const expected = cold('a|', {
|
||||
a: resourcePolicyRD
|
||||
});
|
||||
expect(result).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable max-classes-per-file */
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Observable } from 'rxjs';
|
||||
@@ -23,11 +23,19 @@ import { PaginatedList } from '../data/paginated-list.model';
|
||||
import { ActionType } from './models/action-type.model';
|
||||
import { RequestParam } from '../cache/models/request-param.model';
|
||||
import { isNotEmpty } from '../../shared/empty.util';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
import { NoContent } from '../shared/NoContent.model';
|
||||
import { getFirstCompletedRemoteData } from '../shared/operators';
|
||||
import { CoreState } from '../core-state.model';
|
||||
import { FindListOptions } from '../data/find-list-options.model';
|
||||
import { HttpOptions } from '../dspace-rest/dspace-rest.service';
|
||||
import { PutRequest } from '../data/request.models';
|
||||
import { GenericConstructor } from '../shared/generic-constructor';
|
||||
import { ResponseParsingService } from '../data/parsing.service';
|
||||
import { StatusCodeOnlyResponseParsingService } from '../data/status-code-only-response-parsing.service';
|
||||
import { HALLink } from '../shared/hal-link.model';
|
||||
import { EPersonDataService } from '../eperson/eperson-data.service';
|
||||
import { GroupDataService } from '../eperson/group-data.service';
|
||||
|
||||
|
||||
/**
|
||||
@@ -44,7 +52,8 @@ class DataServiceImpl extends DataService<ResourcePolicy> {
|
||||
protected halService: HALEndpointService,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected http: HttpClient,
|
||||
protected comparator: ChangeAnalyzer<ResourcePolicy>) {
|
||||
protected comparator: ChangeAnalyzer<ResourcePolicy>,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -68,7 +77,10 @@ export class ResourcePolicyService {
|
||||
protected halService: HALEndpointService,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected http: HttpClient,
|
||||
protected comparator: DefaultChangeAnalyzer<ResourcePolicy>) {
|
||||
protected comparator: DefaultChangeAnalyzer<ResourcePolicy>,
|
||||
protected ePersonService: EPersonDataService,
|
||||
protected groupService: GroupDataService,
|
||||
) {
|
||||
this.dataService = new DataServiceImpl(requestService, rdbService, null, objectCache, halService, notificationsService, http, comparator);
|
||||
}
|
||||
|
||||
@@ -221,4 +233,44 @@ export class ResourcePolicyService {
|
||||
return this.dataService.searchBy(this.searchByResourceMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the target of the resource policy
|
||||
* @param resourcePolicyId the ID of the resource policy
|
||||
* @param resourcePolicyHref the link to the resource policy
|
||||
* @param targetUUID the UUID of the target to which the permission is being granted
|
||||
* @param targetType the type of the target (eperson or group) to which the permission is being granted
|
||||
*/
|
||||
updateTarget(resourcePolicyId: string, resourcePolicyHref: string, targetUUID: string, targetType: string): Observable<RemoteData<any>> {
|
||||
|
||||
const targetService = targetType === 'eperson' ? this.ePersonService : this.groupService;
|
||||
|
||||
const targetEndpoint$ = targetService.getBrowseEndpoint().pipe(
|
||||
take(1),
|
||||
map((endpoint: string) =>`${endpoint}/${targetUUID}`),
|
||||
);
|
||||
|
||||
const options: HttpOptions = Object.create({});
|
||||
let headers = new HttpHeaders();
|
||||
headers = headers.append('Content-Type', 'text/uri-list');
|
||||
options.headers = headers;
|
||||
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
|
||||
this.requestService.setStaleByHrefSubstring(`${this.dataService.getLinkPath()}/${resourcePolicyId}/${targetType}`);
|
||||
|
||||
targetEndpoint$.subscribe((targetEndpoint) => {
|
||||
const resourceEndpoint = resourcePolicyHref + '/' + targetType;
|
||||
const request = new PutRequest(requestId, resourceEndpoint, targetEndpoint, options);
|
||||
Object.assign(request, {
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return StatusCodeOnlyResponseParsingService;
|
||||
}
|
||||
});
|
||||
this.requestService.send(request);
|
||||
});
|
||||
|
||||
return this.rdbService.buildFromRequestUUID(requestId);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -147,7 +147,6 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme
|
||||
// Perform the setup actions from above in order and display notifications
|
||||
removedResponses$.pipe(take(1)).subscribe((responses: RemoteData<NoContent>[]) => {
|
||||
this.displayNotifications('item.edit.bitstreams.notifications.remove', responses);
|
||||
this.reset();
|
||||
this.submitting = false;
|
||||
});
|
||||
}
|
||||
@@ -242,27 +241,6 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* De-cache the current item (it should automatically reload due to itemUpdateSubscription)
|
||||
*/
|
||||
reset() {
|
||||
this.refreshItemCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the current item's cache from object- and request-cache
|
||||
*/
|
||||
refreshItemCache() {
|
||||
this.bundles$.pipe(take(1)).subscribe((bundles: Bundle[]) => {
|
||||
bundles.forEach((bundle: Bundle) => {
|
||||
this.objectCache.remove(bundle.self);
|
||||
this.requestService.removeByHrefSubstring(bundle.self);
|
||||
});
|
||||
this.objectCache.remove(this.item.self);
|
||||
this.requestService.removeByHrefSubstring(this.item.self);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe from open subscriptions whenever the component gets destroyed
|
||||
*/
|
||||
|
87
src/app/item-page/item-page.resolver.spec.ts
Normal file
87
src/app/item-page/item-page.resolver.spec.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import { ItemPageResolver } from './item-page.resolver';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils';
|
||||
import { DSpaceObject } from '../core/shared/dspace-object.model';
|
||||
import { MetadataValueFilter } from '../core/shared/metadata.models';
|
||||
import { first } from 'rxjs/operators';
|
||||
import { Router } from '@angular/router';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
describe('ItemPageResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [RouterTestingModule.withRoutes([{
|
||||
path: 'entities/:entity-type/:id',
|
||||
component: {} as any
|
||||
}])]
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolve', () => {
|
||||
let resolver: ItemPageResolver;
|
||||
let itemService: any;
|
||||
let store: any;
|
||||
let router: any;
|
||||
|
||||
const uuid = '1234-65487-12354-1235';
|
||||
let item: DSpaceObject;
|
||||
|
||||
function runTestsWithEntityType(entityType: string) {
|
||||
beforeEach(() => {
|
||||
router = TestBed.inject(Router);
|
||||
item = Object.assign(new DSpaceObject(), {
|
||||
uuid: uuid,
|
||||
firstMetadataValue(_keyOrKeys: string | string[], _valueFilter?: MetadataValueFilter): string {
|
||||
return entityType;
|
||||
}
|
||||
});
|
||||
itemService = {
|
||||
findById: (_id: string) => createSuccessfulRemoteDataObject$(item)
|
||||
};
|
||||
store = jasmine.createSpyObj('store', {
|
||||
dispatch: {},
|
||||
});
|
||||
resolver = new ItemPageResolver(itemService, store, router);
|
||||
});
|
||||
|
||||
it('should redirect to the correct route for the entity type', (done) => {
|
||||
spyOn(item, 'firstMetadataValue').and.returnValue(entityType);
|
||||
spyOn(router, 'navigateByUrl').and.callThrough();
|
||||
|
||||
resolver.resolve({ params: { id: uuid } } as any, { url: router.parseUrl(`/items/${uuid}`).toString() } as any)
|
||||
.pipe(first())
|
||||
.subscribe(
|
||||
() => {
|
||||
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl(`/entities/${entityType}/${uuid}`).toString());
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should not redirect if we’re already on the correct route', (done) => {
|
||||
spyOn(item, 'firstMetadataValue').and.returnValue(entityType);
|
||||
spyOn(router, 'navigateByUrl').and.callThrough();
|
||||
|
||||
resolver.resolve({ params: { id: uuid } } as any, { url: router.parseUrl(`/entities/${entityType}/${uuid}`).toString() } as any)
|
||||
.pipe(first())
|
||||
.subscribe(
|
||||
() => {
|
||||
expect(router.navigateByUrl).not.toHaveBeenCalled();
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
describe('when normal entity type is provided', () => {
|
||||
runTestsWithEntityType('publication');
|
||||
});
|
||||
|
||||
describe('when entity type contains a special character', () => {
|
||||
runTestsWithEntityType('alligator,loki');
|
||||
runTestsWithEntityType('🐊');
|
||||
runTestsWithEntityType(' ');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { RemoteData } from '../core/data/remote-data';
|
||||
import { ItemDataService } from '../core/data/item-data.service';
|
||||
@@ -35,8 +35,14 @@ export class ItemPageResolver extends ItemResolver {
|
||||
return super.resolve(route, state).pipe(
|
||||
map((rd: RemoteData<Item>) => {
|
||||
if (rd.hasSucceeded && hasValue(rd.payload)) {
|
||||
const itemRoute = getItemPageRoute(rd.payload);
|
||||
const thisRoute = state.url;
|
||||
|
||||
// Angular uses a custom function for encodeURIComponent, (e.g. it doesn't encode commas
|
||||
// or semicolons) and thisRoute has been encoded with that function. If we want to compare
|
||||
// it with itemRoute, we have to run itemRoute through Angular's version as well to ensure
|
||||
// the same characters are encoded the same way.
|
||||
const itemRoute = this.router.parseUrl(getItemPageRoute(rd.payload)).toString();
|
||||
|
||||
if (!thisRoute.startsWith(itemRoute)) {
|
||||
const itemId = rd.payload.uuid;
|
||||
const subRoute = thisRoute.substring(thisRoute.indexOf(itemId) + itemId.length, thisRoute.length);
|
||||
|
@@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { VersionedItemComponent } from './versioned-item.component';
|
||||
import { VersionHistoryDataService } from '../../../../core/data/version-history-data.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
import { VersionDataService } from '../../../../core/data/version-data.service';
|
||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||
import { ItemVersionsSharedService } from '../../../../shared/item/item-versions/item-versions-shared.service';
|
||||
@@ -19,6 +19,7 @@ import { SearchService } from '../../../../core/shared/search/search.service';
|
||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||
import { Version } from '../../../../core/shared/version.model';
|
||||
import { RouteService } from '../../../../core/services/route.service';
|
||||
import { TranslateLoaderMock } from '../../../../shared/testing/translate-loader.mock';
|
||||
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
bundles: createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [])),
|
||||
@@ -57,10 +58,17 @@ describe('VersionedItemComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [VersionedItemComponent, DummyComponent],
|
||||
imports: [RouterTestingModule],
|
||||
imports: [
|
||||
RouterTestingModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderMock,
|
||||
}
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
{ provide: VersionHistoryDataService, useValue: versionHistoryServiceSpy },
|
||||
{ provide: TranslateService, useValue: {} },
|
||||
{ provide: VersionDataService, useValue: versionServiceSpy },
|
||||
{ provide: NotificationsService, useValue: {} },
|
||||
{ provide: ItemVersionsSharedService, useValue: {} },
|
||||
|
@@ -5,6 +5,6 @@
|
||||
<p>{{"500.help" | translate}}</p>
|
||||
<br/>
|
||||
<p class="text-center">
|
||||
<a href="/home" class="btn btn-primary">{{"500.link.home-page" | translate}}</a>
|
||||
<a href="home" class="btn btn-primary">{{"500.link.home-page" | translate}}</a>
|
||||
</p>
|
||||
</div>
|
||||
|
@@ -55,6 +55,9 @@ describe('ComColFormComponent', () => {
|
||||
})
|
||||
];
|
||||
|
||||
const logo = {
|
||||
id: 'logo'
|
||||
};
|
||||
const logoEndpoint = 'rest/api/logo/endpoint';
|
||||
const dsoService = Object.assign({
|
||||
getLogoEndpoint: () => observableOf(logoEndpoint),
|
||||
@@ -207,7 +210,7 @@ describe('ComColFormComponent', () => {
|
||||
beforeEach(() => {
|
||||
initComponent(Object.assign(new Community(), {
|
||||
id: 'community-id',
|
||||
logo: createSuccessfulRemoteDataObject$({}),
|
||||
logo: createSuccessfulRemoteDataObject$(logo),
|
||||
_links: {
|
||||
self: { href: 'community-self' },
|
||||
logo: { href: 'community-logo' },
|
||||
@@ -225,28 +228,31 @@ describe('ComColFormComponent', () => {
|
||||
|
||||
describe('submit with logo marked for deletion', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(dsoService, 'deleteLogo').and.callThrough();
|
||||
comp.markLogoForDeletion = true;
|
||||
});
|
||||
|
||||
it('should call dsoService.deleteLogo on the DSO', () => {
|
||||
comp.onSubmit();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(dsoService.deleteLogo).toHaveBeenCalledWith(comp.dso);
|
||||
});
|
||||
|
||||
describe('when dsoService.deleteLogo returns a successful response', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(dsoService, 'deleteLogo').and.returnValue(createSuccessfulRemoteDataObject$({}));
|
||||
dsoService.deleteLogo.and.returnValue(createSuccessfulRemoteDataObject$({}));
|
||||
comp.onSubmit();
|
||||
});
|
||||
|
||||
it('should display a success notification', () => {
|
||||
expect(notificationsService.success).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should remove the object\'s cache', () => {
|
||||
expect(requestServiceStub.removeByHrefSubstring).toHaveBeenCalled();
|
||||
expect(objectCacheStub.remove).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when dsoService.deleteLogo returns an error response', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(dsoService, 'deleteLogo').and.returnValue(createFailedRemoteDataObject$('Error', 500));
|
||||
dsoService.deleteLogo.and.returnValue(createFailedRemoteDataObject$('Error', 500));
|
||||
comp.onSubmit();
|
||||
});
|
||||
|
||||
|
@@ -184,7 +184,6 @@ export class ComColFormComponent<T extends Collection | Community> implements On
|
||||
}
|
||||
this.dso.logo = undefined;
|
||||
this.uploadFilesOptions.method = RestRequestMethod.POST;
|
||||
this.refreshCache();
|
||||
this.finish.emit();
|
||||
});
|
||||
}
|
||||
|
@@ -68,7 +68,6 @@ describe('DeleteComColPageComponent', () => {
|
||||
{
|
||||
delete: createNoContentRemoteDataObject$(),
|
||||
findByHref: jasmine.createSpy('findByHref'),
|
||||
refreshCache: jasmine.createSpy('refreshCache')
|
||||
});
|
||||
|
||||
routerStub = {
|
||||
@@ -79,10 +78,6 @@ describe('DeleteComColPageComponent', () => {
|
||||
data: observableOf(community)
|
||||
};
|
||||
|
||||
requestServiceStub = jasmine.createSpyObj('RequestService', {
|
||||
removeByHrefSubstring: jasmine.createSpy('removeByHrefSubstring')
|
||||
});
|
||||
|
||||
translateServiceStub = jasmine.createSpyObj('TranslateService', {
|
||||
instant: jasmine.createSpy('instant')
|
||||
});
|
||||
@@ -99,7 +94,6 @@ describe('DeleteComColPageComponent', () => {
|
||||
{ provide: ActivatedRoute, useValue: routeStub },
|
||||
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
|
||||
{ provide: TranslateService, useValue: translateServiceStub },
|
||||
{ provide: RequestService, useValue: requestServiceStub }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
@@ -159,7 +153,6 @@ describe('DeleteComColPageComponent', () => {
|
||||
scheduler.flush();
|
||||
fixture.detectChanges();
|
||||
expect(notificationsService.error).toHaveBeenCalled();
|
||||
expect(dsoDataService.refreshCache).not.toHaveBeenCalled();
|
||||
expect(router.navigate).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -169,7 +162,6 @@ describe('DeleteComColPageComponent', () => {
|
||||
scheduler.flush();
|
||||
fixture.detectChanges();
|
||||
expect(notificationsService.success).toHaveBeenCalled();
|
||||
expect(dsoDataService.refreshCache).toHaveBeenCalled();
|
||||
expect(router.navigate).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
@@ -7,7 +7,6 @@ import { NotificationsService } from '../../../notifications/notifications.servi
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { getFirstCompletedRemoteData } from '../../../../core/shared/operators';
|
||||
import { NoContent } from '../../../../core/shared/NoContent.model';
|
||||
import { RequestService } from '../../../../core/data/request.service';
|
||||
import { ComColDataService } from '../../../../core/data/comcol-data.service';
|
||||
import { Community } from '../../../../core/shared/community.model';
|
||||
import { Collection } from '../../../../core/shared/collection.model';
|
||||
@@ -41,7 +40,6 @@ export class DeleteComColPageComponent<TDomain extends Community | Collection> i
|
||||
protected route: ActivatedRoute,
|
||||
protected notifications: NotificationsService,
|
||||
protected translate: TranslateService,
|
||||
protected requestService: RequestService
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -61,7 +59,6 @@ export class DeleteComColPageComponent<TDomain extends Community | Collection> i
|
||||
if (response.hasSucceeded) {
|
||||
const successMessage = this.translate.instant((dso as any).type + '.delete.notification.success');
|
||||
this.notifications.success(successMessage);
|
||||
this.dsoDataService.refreshCache(dso);
|
||||
} else {
|
||||
const errorMessage = this.translate.instant((dso as any).type + '.delete.notification.fail');
|
||||
this.notifications.error(errorMessage);
|
||||
|
@@ -4,7 +4,7 @@
|
||||
*ngVar="group$ | async as group">
|
||||
|
||||
<h5 class="w-100">
|
||||
{{'comcol-role.edit.' + (comcolRole$ | async)?.name + '.name' | translate}}
|
||||
{{ roleName$ | async }}
|
||||
</h5>
|
||||
|
||||
<div class="mt-2 mb-2">
|
||||
|
@@ -10,6 +10,8 @@ import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../../../../remote-data.utils';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { ComcolModule } from '../../../comcol.module';
|
||||
import { NotificationsService } from '../../../../notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../../../testing/notifications-service.stub';
|
||||
|
||||
describe('ComcolRoleComponent', () => {
|
||||
|
||||
@@ -20,6 +22,7 @@ describe('ComcolRoleComponent', () => {
|
||||
let group;
|
||||
let statusCode;
|
||||
let comcolRole;
|
||||
let notificationsService;
|
||||
|
||||
const requestService = { hasByHref$: () => observableOf(true) };
|
||||
|
||||
@@ -40,6 +43,7 @@ describe('ComcolRoleComponent', () => {
|
||||
providers: [
|
||||
{ provide: GroupDataService, useValue: groupService },
|
||||
{ provide: RequestService, useValue: requestService },
|
||||
{ provide: NotificationsService, useClass: NotificationsServiceStub }
|
||||
], schemas: [
|
||||
NO_ERRORS_SCHEMA
|
||||
]
|
||||
@@ -59,12 +63,14 @@ describe('ComcolRoleComponent', () => {
|
||||
fixture = TestBed.createComponent(ComcolRoleComponent);
|
||||
comp = fixture.componentInstance;
|
||||
de = fixture.debugElement;
|
||||
notificationsService = TestBed.inject(NotificationsService);
|
||||
|
||||
comcolRole = {
|
||||
name: 'test role name',
|
||||
href: 'test role link',
|
||||
};
|
||||
comp.comcolRole = comcolRole;
|
||||
comp.roleName$ = observableOf(comcolRole.name);
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
@@ -101,6 +107,18 @@ describe('ComcolRoleComponent', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when a group cannot be created', () => {
|
||||
beforeEach(() => {
|
||||
groupService.createComcolGroup.and.returnValue(createFailedRemoteDataObject$());
|
||||
de.query(By.css('.btn.create')).nativeElement.click();
|
||||
});
|
||||
|
||||
it('should show an error notification', (done) => {
|
||||
expect(notificationsService.error).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the related group is the Anonymous group', () => {
|
||||
@@ -169,5 +187,17 @@ describe('ComcolRoleComponent', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when a group cannot be deleted', () => {
|
||||
beforeEach(() => {
|
||||
groupService.deleteComcolGroup.and.returnValue(createFailedRemoteDataObject$());
|
||||
de.query(By.css('.btn.delete')).nativeElement.click();
|
||||
});
|
||||
|
||||
it('should show an error notification', (done) => {
|
||||
expect(notificationsService.error).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -12,6 +12,8 @@ import { HALLink } from '../../../../../core/shared/hal-link.model';
|
||||
import { getGroupEditRoute } from '../../../../../access-control/access-control-routing-paths';
|
||||
import { hasNoValue, hasValue } from '../../../../empty.util';
|
||||
import { NoContent } from '../../../../../core/shared/NoContent.model';
|
||||
import { NotificationsService } from '../../../../notifications/notifications.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
/**
|
||||
* Component for managing a community or collection role.
|
||||
@@ -64,9 +66,16 @@ export class ComcolRoleComponent implements OnInit {
|
||||
*/
|
||||
hasCustomGroup$: Observable<boolean>;
|
||||
|
||||
/**
|
||||
* The human-readable name of this role
|
||||
*/
|
||||
roleName$: Observable<string>;
|
||||
|
||||
constructor(
|
||||
protected requestService: RequestService,
|
||||
protected groupService: GroupDataService,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected translateService: TranslateService,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -101,7 +110,12 @@ export class ComcolRoleComponent implements OnInit {
|
||||
this.groupService.clearGroupsRequests();
|
||||
this.requestService.setStaleByHrefSubstring(this.comcolRole.href);
|
||||
} else {
|
||||
// TODO show error notification
|
||||
this.notificationsService.error(
|
||||
this.roleName$.pipe(
|
||||
switchMap(role => this.translateService.get('comcol-role.edit.create.error.title', { role }))
|
||||
),
|
||||
`${rd.statusCode} ${rd.errorMessage}`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -117,7 +131,12 @@ export class ComcolRoleComponent implements OnInit {
|
||||
this.groupService.clearGroupsRequests();
|
||||
this.requestService.setStaleByHrefSubstring(this.comcolRole.href);
|
||||
} else {
|
||||
// TODO show error notification
|
||||
this.notificationsService.error(
|
||||
this.roleName$.pipe(
|
||||
switchMap(role => this.translateService.get('comcol-role.edit.delete.error.title', { role }))
|
||||
),
|
||||
rd.errorMessage
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -154,5 +173,7 @@ export class ComcolRoleComponent implements OnInit {
|
||||
this.hasCustomGroup$ = this.group$.pipe(
|
||||
map((group: Group) => hasValue(group) && group.name !== 'Anonymous'),
|
||||
);
|
||||
|
||||
this.roleName$ = this.translateService.get(`comcol-role.edit.${this.comcolRole.name}.name`);
|
||||
}
|
||||
}
|
||||
|
@@ -46,27 +46,27 @@ describe('ConfirmationModalComponent', () => {
|
||||
|
||||
describe('confirmPressed', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(component.response, 'next');
|
||||
spyOn(component.response, 'emit');
|
||||
component.confirmPressed();
|
||||
});
|
||||
it('should call the close method on the active modal', () => {
|
||||
expect(modalStub.close).toHaveBeenCalled();
|
||||
});
|
||||
it('behaviour subject should have true as next', () => {
|
||||
expect(component.response.next).toHaveBeenCalledWith(true);
|
||||
it('behaviour subject should emit true', () => {
|
||||
expect(component.response.emit).toHaveBeenCalledWith(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('cancelPressed', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(component.response, 'next');
|
||||
spyOn(component.response, 'emit');
|
||||
component.cancelPressed();
|
||||
});
|
||||
it('should call the close method on the active modal', () => {
|
||||
expect(modalStub.close).toHaveBeenCalled();
|
||||
});
|
||||
it('behaviour subject should have false as next', () => {
|
||||
expect(component.response.next).toHaveBeenCalledWith(false);
|
||||
it('behaviour subject should emit false', () => {
|
||||
expect(component.response.emit).toHaveBeenCalledWith(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -88,7 +88,7 @@ describe('ConfirmationModalComponent', () => {
|
||||
describe('when the click method emits on cancel button', () => {
|
||||
beforeEach(fakeAsync(() => {
|
||||
spyOn(component, 'close');
|
||||
spyOn(component.response, 'next');
|
||||
spyOn(component.response, 'emit');
|
||||
debugElement.query(By.css('button.cancel')).triggerEventHandler('click', {
|
||||
preventDefault: () => {/**/
|
||||
}
|
||||
@@ -99,15 +99,15 @@ describe('ConfirmationModalComponent', () => {
|
||||
it('should call the close method on the component', () => {
|
||||
expect(component.close).toHaveBeenCalled();
|
||||
});
|
||||
it('behaviour subject should have false as next', () => {
|
||||
expect(component.response.next).toHaveBeenCalledWith(false);
|
||||
it('behaviour subject should emit false', () => {
|
||||
expect(component.response.emit).toHaveBeenCalledWith(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the click method emits on confirm button', () => {
|
||||
beforeEach(fakeAsync(() => {
|
||||
spyOn(component, 'close');
|
||||
spyOn(component.response, 'next');
|
||||
spyOn(component.response, 'emit');
|
||||
debugElement.query(By.css('button.confirm')).triggerEventHandler('click', {
|
||||
preventDefault: () => {/**/
|
||||
}
|
||||
@@ -118,8 +118,8 @@ describe('ConfirmationModalComponent', () => {
|
||||
it('should call the close method on the component', () => {
|
||||
expect(component.close).toHaveBeenCalled();
|
||||
});
|
||||
it('behaviour subject should have true as next', () => {
|
||||
expect(component.response.next).toHaveBeenCalledWith(true);
|
||||
it('behaviour subject should emit false', () => {
|
||||
expect(component.response.emit).toHaveBeenCalledWith(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { Component, Input, Output } from '@angular/core';
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Subject } from 'rxjs';
|
||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||
|
||||
@Component({
|
||||
@@ -24,7 +23,7 @@ export class ConfirmationModalComponent {
|
||||
* An event fired when the cancel or confirm button is clicked, with respectively false or true
|
||||
*/
|
||||
@Output()
|
||||
response: Subject<boolean> = new Subject();
|
||||
response = new EventEmitter<boolean>();
|
||||
|
||||
constructor(protected activeModal: NgbActiveModal) {
|
||||
}
|
||||
@@ -33,7 +32,7 @@ export class ConfirmationModalComponent {
|
||||
* Confirm the action that led to the modal
|
||||
*/
|
||||
confirmPressed() {
|
||||
this.response.next(true);
|
||||
this.response.emit(true);
|
||||
this.close();
|
||||
}
|
||||
|
||||
@@ -41,7 +40,7 @@ export class ConfirmationModalComponent {
|
||||
* Cancel the action that led to the modal and close modal
|
||||
*/
|
||||
cancelPressed() {
|
||||
this.response.next(false);
|
||||
this.response.emit(false);
|
||||
this.close();
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ describe('IdleModalComponent', () => {
|
||||
|
||||
describe('extendSessionPressed', () => {
|
||||
beforeEach(fakeAsync(() => {
|
||||
spyOn(component.response, 'next');
|
||||
spyOn(component.response, 'emit');
|
||||
component.extendSessionPressed();
|
||||
}));
|
||||
it('should set idle to false', () => {
|
||||
@@ -55,8 +55,8 @@ describe('IdleModalComponent', () => {
|
||||
it('should close the modal', () => {
|
||||
expect(modalStub.close).toHaveBeenCalled();
|
||||
});
|
||||
it('response \'closed\' should have true as next', () => {
|
||||
expect(component.response.next).toHaveBeenCalledWith(true);
|
||||
it('response \'closed\' should emit true', () => {
|
||||
expect(component.response.emit).toHaveBeenCalledWith(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -74,7 +74,7 @@ describe('IdleModalComponent', () => {
|
||||
|
||||
describe('closePressed', () => {
|
||||
beforeEach(fakeAsync(() => {
|
||||
spyOn(component.response, 'next');
|
||||
spyOn(component.response, 'emit');
|
||||
component.closePressed();
|
||||
}));
|
||||
it('should set idle to false', () => {
|
||||
@@ -83,8 +83,8 @@ describe('IdleModalComponent', () => {
|
||||
it('should close the modal', () => {
|
||||
expect(modalStub.close).toHaveBeenCalled();
|
||||
});
|
||||
it('response \'closed\' should have true as next', () => {
|
||||
expect(component.response.next).toHaveBeenCalledWith(true);
|
||||
it('response \'closed\' should emit true', () => {
|
||||
expect(component.response.emit).toHaveBeenCalledWith(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -1,8 +1,7 @@
|
||||
import { Component, OnInit, Output } from '@angular/core';
|
||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { AuthService } from '../../core/auth/auth.service';
|
||||
import { Subject } from 'rxjs';
|
||||
import { hasValue } from '../empty.util';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppState } from '../../app.reducer';
|
||||
@@ -29,7 +28,7 @@ export class IdleModalComponent implements OnInit {
|
||||
* An event fired when the modal is closed
|
||||
*/
|
||||
@Output()
|
||||
response: Subject<boolean> = new Subject();
|
||||
response = new EventEmitter<boolean>();
|
||||
|
||||
constructor(private activeModal: NgbActiveModal,
|
||||
private authService: AuthService,
|
||||
@@ -84,6 +83,6 @@ export class IdleModalComponent implements OnInit {
|
||||
*/
|
||||
closeModal() {
|
||||
this.activeModal.close();
|
||||
this.response.next(true);
|
||||
this.response.emit(true);
|
||||
}
|
||||
}
|
||||
|
@@ -8,12 +8,12 @@
|
||||
<p class="pb-2">{{ "item.version.delete.modal.text" | translate : {version: versionNumber} }}</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-outline-secondary btn-sm"
|
||||
<button class="btn btn-outline-secondary btn-sm cancel"
|
||||
(click)="onModalClose()"
|
||||
title="{{'item.version.delete.modal.button.cancel.tooltip' | translate}}">
|
||||
<i class="fas fa-times fa-fw"></i> {{'item.version.delete.modal.button.cancel' | translate}}
|
||||
</button>
|
||||
<button class="btn btn-danger btn-sm"
|
||||
<button class="btn btn-danger btn-sm confirm"
|
||||
(click)="onModalSubmit()"
|
||||
title="{{'item.version.delete.modal.button.confirm.tooltip' | translate}}">
|
||||
<i class="fas fa-check fa-fw"></i> {{'item.version.delete.modal.button.confirm' | translate}}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, EventEmitter, Output } from '@angular/core';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
@Component({
|
||||
@@ -7,6 +7,11 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
styleUrls: ['./item-versions-delete-modal.component.scss']
|
||||
})
|
||||
export class ItemVersionsDeleteModalComponent {
|
||||
/**
|
||||
* An event fired when the cancel or confirm button is clicked, with respectively false or true
|
||||
*/
|
||||
@Output()
|
||||
response = new EventEmitter<boolean>();
|
||||
|
||||
versionNumber: number;
|
||||
|
||||
@@ -15,10 +20,12 @@ export class ItemVersionsDeleteModalComponent {
|
||||
}
|
||||
|
||||
onModalClose() {
|
||||
this.response.emit(false);
|
||||
this.activeModal.dismiss();
|
||||
}
|
||||
|
||||
onModalSubmit() {
|
||||
this.response.emit(true);
|
||||
this.activeModal.close();
|
||||
}
|
||||
|
||||
|
@@ -1,14 +1,15 @@
|
||||
import { ItemVersionsComponent } from './item-versions.component';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import {
|
||||
ComponentFixture, TestBed, waitForAsync
|
||||
} from '@angular/core/testing';
|
||||
import { VarDirective } from '../../utils/var.directive';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { Version } from '../../../core/shared/version.model';
|
||||
import { VersionHistory } from '../../../core/shared/version-history.model';
|
||||
import { VersionHistoryDataService } from '../../../core/data/version-history-data.service';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { BrowserModule, By } from '@angular/platform-browser';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils';
|
||||
import { createPaginatedList } from '../../testing/utils.test';
|
||||
import { EMPTY, of, of as observableOf } from 'rxjs';
|
||||
@@ -17,7 +18,7 @@ import { PaginationServiceStub } from '../../testing/pagination-service.stub';
|
||||
import { AuthService } from '../../../core/auth/auth.service';
|
||||
import { VersionDataService } from '../../../core/data/version-data.service';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
import { FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { NotificationsService } from '../../notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../testing/notifications-service.stub';
|
||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
@@ -25,6 +26,9 @@ import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
|
||||
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
|
||||
import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
describe('ItemVersionsComponent', () => {
|
||||
let component: ItemVersionsComponent;
|
||||
@@ -70,6 +74,7 @@ describe('ItemVersionsComponent', () => {
|
||||
versionHistory.versions = createSuccessfulRemoteDataObject$(createPaginatedList(versions));
|
||||
|
||||
const item1 = Object.assign(new Item(), { // is a workspace item
|
||||
id: 'item-identifier-1',
|
||||
uuid: 'item-identifier-1',
|
||||
handle: '123456789/1',
|
||||
version: createSuccessfulRemoteDataObject$(version1),
|
||||
@@ -80,6 +85,7 @@ describe('ItemVersionsComponent', () => {
|
||||
}
|
||||
});
|
||||
const item2 = Object.assign(new Item(), {
|
||||
id: 'item-identifier-2',
|
||||
uuid: 'item-identifier-2',
|
||||
handle: '123456789/2',
|
||||
version: createSuccessfulRemoteDataObject$(version2),
|
||||
@@ -95,6 +101,8 @@ describe('ItemVersionsComponent', () => {
|
||||
|
||||
const versionHistoryServiceSpy = jasmine.createSpyObj('versionHistoryService', {
|
||||
getVersions: createSuccessfulRemoteDataObject$(createPaginatedList(versions)),
|
||||
getVersionHistoryFromVersion$: of(versionHistory),
|
||||
getLatestVersionItemFromHistory$: of(item1), // called when version2 is deleted
|
||||
});
|
||||
const authenticationServiceSpy = jasmine.createSpyObj('authenticationService', {
|
||||
isAuthenticated: observableOf(true),
|
||||
@@ -117,11 +125,19 @@ describe('ItemVersionsComponent', () => {
|
||||
findByPropertyName: of(true),
|
||||
});
|
||||
|
||||
const itemDataServiceSpy = jasmine.createSpyObj('itemDataService', {
|
||||
delete: createSuccessfulRemoteDataObject$({}),
|
||||
});
|
||||
|
||||
const routerSpy = jasmine.createSpyObj('router', {
|
||||
navigateByUrl: null,
|
||||
});
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ItemVersionsComponent, VarDirective],
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])],
|
||||
imports: [TranslateModule.forRoot(), CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule],
|
||||
providers: [
|
||||
{provide: PaginationService, useValue: new PaginationServiceStub()},
|
||||
{provide: FormBuilder, useValue: new FormBuilder()},
|
||||
@@ -129,11 +145,12 @@ describe('ItemVersionsComponent', () => {
|
||||
{provide: AuthService, useValue: authenticationServiceSpy},
|
||||
{provide: AuthorizationDataService, useValue: authorizationServiceSpy},
|
||||
{provide: VersionHistoryDataService, useValue: versionHistoryServiceSpy},
|
||||
{provide: ItemDataService, useValue: {}},
|
||||
{provide: ItemDataService, useValue: itemDataServiceSpy},
|
||||
{provide: VersionDataService, useValue: versionServiceSpy},
|
||||
{provide: WorkspaceitemDataService, useValue: workspaceItemDataServiceSpy},
|
||||
{provide: WorkflowItemDataService, useValue: workflowItemDataServiceSpy},
|
||||
{provide: ConfigurationDataService, useValue: configurationServiceSpy},
|
||||
{ provide: Router, useValue: routerSpy },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
@@ -277,4 +294,43 @@ describe('ItemVersionsComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when deleting a version', () => {
|
||||
let deleteButton;
|
||||
|
||||
beforeEach(() => {
|
||||
const canDelete = (featureID: FeatureID, url: string ) => of(featureID === FeatureID.CanDeleteVersion);
|
||||
authorizationServiceSpy.isAuthorized.and.callFake(canDelete);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
// delete the last version in the table (version2 → item2)
|
||||
deleteButton = fixture.debugElement.queryAll(By.css('.version-row-element-delete'))[1].nativeElement;
|
||||
|
||||
itemDataServiceSpy.delete.calls.reset();
|
||||
});
|
||||
|
||||
describe('if confirmed via modal', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
deleteButton.click();
|
||||
fixture.detectChanges();
|
||||
(document as any).querySelector('.modal-footer .confirm').click();
|
||||
}));
|
||||
|
||||
it('should call ItemService.delete', () => {
|
||||
expect(itemDataServiceSpy.delete).toHaveBeenCalledWith(item2.id);
|
||||
});
|
||||
});
|
||||
|
||||
describe('if canceled via modal', () => {
|
||||
beforeEach(waitForAsync(() => {
|
||||
deleteButton.click();
|
||||
fixture.detectChanges();
|
||||
(document as any).querySelector('.modal-footer .cancel').click();
|
||||
}));
|
||||
|
||||
it('should not call ItemService.delete', () => {
|
||||
expect(itemDataServiceSpy.delete).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -283,44 +283,42 @@ export class ItemVersionsComponent implements OnInit {
|
||||
activeModal.componentInstance.firstVersion = false;
|
||||
|
||||
// On modal submit/dismiss
|
||||
activeModal.result.then(() => {
|
||||
versionItem$.pipe(
|
||||
getFirstSucceededRemoteDataPayload<Item>(),
|
||||
// Retrieve version history and invalidate cache
|
||||
mergeMap((item: Item) => combineLatest([
|
||||
of(item),
|
||||
this.versionHistoryService.getVersionHistoryFromVersion$(version).pipe(
|
||||
tap((versionHistory: VersionHistory) => {
|
||||
this.versionHistoryService.invalidateVersionHistoryCache(versionHistory.id);
|
||||
})
|
||||
)
|
||||
])),
|
||||
// Delete item
|
||||
mergeMap(([item, versionHistory]: [Item, VersionHistory]) => combineLatest([
|
||||
this.deleteItemAndGetResult$(item),
|
||||
of(versionHistory)
|
||||
])),
|
||||
// Retrieve new latest version
|
||||
mergeMap(([deleteItemResult, versionHistory]: [boolean, VersionHistory]) => combineLatest([
|
||||
of(deleteItemResult),
|
||||
this.versionHistoryService.getLatestVersionItemFromHistory$(versionHistory).pipe(
|
||||
tap(() => {
|
||||
this.getAllVersions(of(versionHistory));
|
||||
}),
|
||||
)
|
||||
])),
|
||||
).subscribe(([deleteHasSucceeded, newLatestVersionItem]: [boolean, Item]) => {
|
||||
// Notify operation result and redirect to latest item
|
||||
if (deleteHasSucceeded) {
|
||||
this.notificationsService.success(null, this.translateService.get(successMessageKey, {'version': versionNumber}));
|
||||
} else {
|
||||
this.notificationsService.error(null, this.translateService.get(failureMessageKey, {'version': versionNumber}));
|
||||
}
|
||||
if (redirectToLatest) {
|
||||
const path = getItemEditVersionhistoryRoute(newLatestVersionItem);
|
||||
this.router.navigateByUrl(path);
|
||||
}
|
||||
});
|
||||
activeModal.componentInstance.response.pipe(take(1)).subscribe((ok) => {
|
||||
if (ok) {
|
||||
versionItem$.pipe(
|
||||
getFirstSucceededRemoteDataPayload<Item>(),
|
||||
// Retrieve version history
|
||||
mergeMap((item: Item) => combineLatest([
|
||||
of(item),
|
||||
this.versionHistoryService.getVersionHistoryFromVersion$(version)
|
||||
])),
|
||||
// Delete item
|
||||
mergeMap(([item, versionHistory]: [Item, VersionHistory]) => combineLatest([
|
||||
this.deleteItemAndGetResult$(item),
|
||||
of(versionHistory)
|
||||
])),
|
||||
// Retrieve new latest version
|
||||
mergeMap(([deleteItemResult, versionHistory]: [boolean, VersionHistory]) => combineLatest([
|
||||
of(deleteItemResult),
|
||||
this.versionHistoryService.getLatestVersionItemFromHistory$(versionHistory).pipe(
|
||||
tap(() => {
|
||||
this.getAllVersions(of(versionHistory));
|
||||
}),
|
||||
)
|
||||
])),
|
||||
).subscribe(([deleteHasSucceeded, newLatestVersionItem]: [boolean, Item]) => {
|
||||
// Notify operation result and redirect to latest item
|
||||
if (deleteHasSucceeded) {
|
||||
this.notificationsService.success(null, this.translateService.get(successMessageKey, {'version': versionNumber}));
|
||||
} else {
|
||||
this.notificationsService.error(null, this.translateService.get(failureMessageKey, {'version': versionNumber}));
|
||||
}
|
||||
if (redirectToLatest) {
|
||||
const path = getItemEditVersionhistoryRoute(newLatestVersionItem);
|
||||
this.router.navigateByUrl(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,6 @@ import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { LinkMenuItemComponent } from './link-menu-item.component';
|
||||
import { RouterLinkDirectiveStub } from '../../testing/router-link-directive.stub';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
import { QueryParamsDirectiveStub } from '../../testing/query-params-directive.stub';
|
||||
import { RouterStub } from '../../testing/router.stub';
|
||||
import { Router } from '@angular/router';
|
||||
@@ -58,7 +57,7 @@ describe('LinkMenuItemComponent', () => {
|
||||
const routerLinkQuery = linkDes.map((de) => de.injector.get(RouterLinkDirectiveStub));
|
||||
|
||||
expect(routerLinkQuery.length).toBe(1);
|
||||
expect(routerLinkQuery[0].routerLink).toBe(environment.ui.nameSpace + link);
|
||||
expect(routerLinkQuery[0].routerLink).toBe(link);
|
||||
});
|
||||
|
||||
it('should have the right queryParams attribute', () => {
|
||||
|
@@ -2,7 +2,6 @@ import { Component, Inject, Input, OnInit } from '@angular/core';
|
||||
import { LinkMenuItemModel } from './models/link.model';
|
||||
import { rendersMenuItemForType } from '../menu-item.decorator';
|
||||
import { isNotEmpty } from '../../empty.util';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@@ -30,7 +29,7 @@ export class LinkMenuItemComponent implements OnInit {
|
||||
|
||||
getRouterLink() {
|
||||
if (this.hasLink) {
|
||||
return environment.ui.nameSpace + this.item.link;
|
||||
return this.item.link;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ export function getMockRequestService(requestEntry$: Observable<RequestEntry> =
|
||||
isCachedOrPending: false,
|
||||
removeByHrefSubstring: observableOf(true),
|
||||
setStaleByHrefSubstring: observableOf(true),
|
||||
setStaleByUUID: observableOf(true),
|
||||
hasByHref$: observableOf(false)
|
||||
});
|
||||
}
|
||||
|
@@ -98,7 +98,7 @@ describe('NotificationComponent', () => {
|
||||
it('should have html content', () => {
|
||||
fixture = TestBed.createComponent(NotificationComponent);
|
||||
comp = fixture.componentInstance;
|
||||
const htmlContent = '<a class="btn btn-link p-0 m-0 pb-1" href="/test"><strong>test</strong></a>';
|
||||
const htmlContent = '<a class="btn btn-link p-0 m-0 pb-1" href="test"><strong>test</strong></a>';
|
||||
comp.notification = {
|
||||
id: '1',
|
||||
type: NotificationType.Info,
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { BehaviorSubject, Observable, of, combineLatest as observableCombineLatest, } from 'rxjs';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
@@ -88,16 +88,33 @@ export class ResourcePolicyEditComponent implements OnInit {
|
||||
type: RESOURCE_POLICY.value,
|
||||
_links: this.resourcePolicy._links
|
||||
});
|
||||
this.resourcePolicyService.update(updatedObject).pipe(
|
||||
|
||||
const updateTargetSucceeded$ = event.updateTarget ? this.resourcePolicyService.updateTarget(
|
||||
this.resourcePolicy.id, this.resourcePolicy._links.self.href, event.target.uuid, event.target.type
|
||||
).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
).subscribe((responseRD: RemoteData<ResourcePolicy>) => {
|
||||
this.processing$.next(false);
|
||||
if (responseRD && responseRD.hasSucceeded) {
|
||||
this.notificationsService.success(null, this.translate.get('resource-policies.edit.page.success.content'));
|
||||
this.redirectToAuthorizationsPage();
|
||||
} else {
|
||||
this.notificationsService.error(null, this.translate.get('resource-policies.edit.page.failure.content'));
|
||||
map((responseRD) => responseRD && responseRD.hasSucceeded)
|
||||
) : of(true);
|
||||
|
||||
const updateResourcePolicySucceeded$ = this.resourcePolicyService.update(updatedObject).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((responseRD) => responseRD && responseRD.hasSucceeded)
|
||||
);
|
||||
|
||||
observableCombineLatest([updateTargetSucceeded$, updateResourcePolicySucceeded$]).subscribe(
|
||||
([updateTargetSucceeded, updateResourcePolicySucceeded]) => {
|
||||
this.processing$.next(false);
|
||||
if (updateTargetSucceeded && updateResourcePolicySucceeded) {
|
||||
this.notificationsService.success(null, this.translate.get('resource-policies.edit.page.success.content'));
|
||||
this.redirectToAuthorizationsPage();
|
||||
} else if (updateResourcePolicySucceeded) { // everything except target has been updated
|
||||
this.notificationsService.error(null, this.translate.get('resource-policies.edit.page.target-failure.content'));
|
||||
} else if (updateTargetSucceeded) { // only target has been updated
|
||||
this.notificationsService.error(null, this.translate.get('resource-policies.edit.page.other-failure.content'));
|
||||
} else { // nothing has been updated
|
||||
this.notificationsService.error(null, this.translate.get('resource-policies.edit.page.failure.content'));
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -7,25 +7,23 @@
|
||||
[displayCancel]="false"></ds-form>
|
||||
<div class="container-fluid">
|
||||
<label for="ResourcePolicyObject">{{'resource-policies.form.eperson-group-list.label' | translate}}</label>
|
||||
<input id="ResourcePolicyObject" class="form-control mb-3" type="text" readonly [value]="resourcePolicyTargetName$ | async">
|
||||
<ng-container *ngIf="canSetGrant()">
|
||||
<ul ngbNav #nav="ngbNav" class="nav-pills">
|
||||
<li ngbNavItem>
|
||||
<a ngbNavLink>{{'resource-policies.form.eperson-group-list.tab.eperson' | translate}}</a>
|
||||
<ng-template ngbNavContent>
|
||||
<ds-eperson-group-list (select)="updateObjectSelected($event, true)"></ds-eperson-group-list>
|
||||
</ng-template>
|
||||
</li>
|
||||
<li ngbNavItem>
|
||||
<a ngbNavLink>{{'resource-policies.form.eperson-group-list.tab.group' | translate}}</a>
|
||||
<ng-template ngbNavContent>
|
||||
<ds-eperson-group-list [isListOfEPerson]="false"
|
||||
(select)="updateObjectSelected($event, false)"></ds-eperson-group-list>
|
||||
</ng-template>
|
||||
</li>
|
||||
</ul>
|
||||
<div [ngbNavOutlet]="nav"></div>
|
||||
</ng-container>
|
||||
<input id="ResourcePolicyObject" class="form-control mb-3" type="text" [value]="resourcePolicyTargetName$ | async">
|
||||
<ul ngbNav #nav="ngbNav" class="nav-pills" [(activeId)]="navActiveId" (navChange)="onNavChange($event)">
|
||||
<li [ngbNavItem]="'eperson'">
|
||||
<a ngbNavLink>{{'resource-policies.form.eperson-group-list.tab.eperson' | translate}}</a>
|
||||
<ng-template ngbNavContent>
|
||||
<ds-eperson-group-list (select)="updateObjectSelected($event, true)"></ds-eperson-group-list>
|
||||
</ng-template>
|
||||
</li>
|
||||
<li [ngbNavItem]="'group'">
|
||||
<a ngbNavLink>{{'resource-policies.form.eperson-group-list.tab.group' | translate}}</a>
|
||||
<ng-template ngbNavContent>
|
||||
<ds-eperson-group-list [isListOfEPerson]="false"
|
||||
(select)="updateObjectSelected($event, false)"></ds-eperson-group-list>
|
||||
</ng-template>
|
||||
</li>
|
||||
</ul>
|
||||
<div [ngbNavOutlet]="nav"></div>
|
||||
<div>
|
||||
<hr>
|
||||
<div class="form-group row">
|
||||
@@ -51,3 +49,28 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<ng-template #content let-modal>
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="modal-basic-title">{{ 'resource-policies.form.eperson-group-list.modal.header' | translate }}</h4>
|
||||
<button type="button" class="close" aria-label="Close" (click)="modal.close()">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="d-flex flex-row">
|
||||
<div class="mr-3">
|
||||
<i class="fas fa-info-circle fa-2x text-info"></i>
|
||||
</div>
|
||||
<div>
|
||||
<p [innerHTML]="(navActiveId === 'eperson' ? 'resource-policies.form.eperson-group-list.modal.text1.toGroup' :
|
||||
'resource-policies.form.eperson-group-list.modal.text1.toEPerson') | translate" class="font-weight-bold"></p>
|
||||
<p [innerHTML]="'resource-policies.form.eperson-group-list.modal.text2' | translate"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" (click)="modal.close()">{{ 'resource-policies.form.eperson-group-list.modal.close' | translate }}</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
@@ -242,6 +242,7 @@ describe('ResourcePolicyFormComponent test suite', () => {
|
||||
fixture = TestBed.createComponent(ResourcePolicyFormComponent);
|
||||
comp = fixture.componentInstance;
|
||||
compAsAny = fixture.componentInstance;
|
||||
compAsAny.resourcePolicy = resourcePolicy;
|
||||
comp.isProcessing = observableOf(false);
|
||||
});
|
||||
|
||||
@@ -253,6 +254,8 @@ describe('ResourcePolicyFormComponent test suite', () => {
|
||||
});
|
||||
|
||||
it('should init form model properly', () => {
|
||||
epersonService.findByHref.and.returnValue(observableOf(undefined));
|
||||
groupService.findByHref.and.returnValue(observableOf(undefined));
|
||||
spyOn(compAsAny, 'isFormValid').and.returnValue(observableOf(false));
|
||||
spyOn(compAsAny, 'initModelsValue').and.callThrough();
|
||||
spyOn(compAsAny, 'buildResourcePolicyForm').and.callThrough();
|
||||
@@ -261,12 +264,12 @@ describe('ResourcePolicyFormComponent test suite', () => {
|
||||
expect(compAsAny.buildResourcePolicyForm).toHaveBeenCalled();
|
||||
expect(compAsAny.initModelsValue).toHaveBeenCalled();
|
||||
expect(compAsAny.formModel.length).toBe(5);
|
||||
expect(compAsAny.subs.length).toBe(0);
|
||||
expect(compAsAny.subs.length).toBe(1);
|
||||
|
||||
});
|
||||
|
||||
it('should can set grant', () => {
|
||||
expect(comp.canSetGrant()).toBeTruthy();
|
||||
expect(comp.isBeingEdited()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not have a target name', () => {
|
||||
@@ -279,7 +282,7 @@ describe('ResourcePolicyFormComponent test suite', () => {
|
||||
expect(compAsAny.reset.emit).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should update resource policy grant object properly', () => {
|
||||
it('should update resource policy grant object properly', () => {
|
||||
comp.updateObjectSelected(EPersonMock, true);
|
||||
|
||||
expect(comp.resourcePolicyGrant).toEqual(EPersonMock);
|
||||
@@ -301,6 +304,7 @@ describe('ResourcePolicyFormComponent test suite', () => {
|
||||
comp = fixture.componentInstance;
|
||||
compAsAny = fixture.componentInstance;
|
||||
comp.resourcePolicy = resourcePolicy;
|
||||
compAsAny.resourcePolicy = resourcePolicy;
|
||||
comp.isProcessing = observableOf(false);
|
||||
compAsAny.ePersonService.findByHref.and.returnValue(
|
||||
observableOf(createSuccessfulRemoteDataObject({})).pipe(delay(100))
|
||||
@@ -343,8 +347,8 @@ describe('ResourcePolicyFormComponent test suite', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not can set grant', () => {
|
||||
expect(comp.canSetGrant()).toBeFalsy();
|
||||
it('should be being edited', () => {
|
||||
expect(comp.isBeingEdited()).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have a target name', () => {
|
||||
@@ -398,6 +402,7 @@ describe('ResourcePolicyFormComponent test suite', () => {
|
||||
type: 'group',
|
||||
uuid: GroupMock.id
|
||||
};
|
||||
eventPayload.updateTarget = false;
|
||||
|
||||
scheduler = getTestScheduler();
|
||||
scheduler.schedule(() => comp.onSubmit());
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
|
||||
import { Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core';
|
||||
|
||||
import {
|
||||
Observable,
|
||||
@@ -41,6 +41,7 @@ import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
|
||||
import { GroupDataService } from '../../../core/eperson/group-data.service';
|
||||
import { getFirstSucceededRemoteData } from '../../../core/shared/operators';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { NgbModal, NgbNavChangeEvent } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
export interface ResourcePolicyEvent {
|
||||
object: ResourcePolicy;
|
||||
@@ -48,6 +49,7 @@ export interface ResourcePolicyEvent {
|
||||
type: string,
|
||||
uuid: string
|
||||
};
|
||||
updateTarget: boolean;
|
||||
}
|
||||
|
||||
@Component({
|
||||
@@ -83,6 +85,8 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
@Output() submit: EventEmitter<ResourcePolicyEvent> = new EventEmitter<ResourcePolicyEvent>();
|
||||
|
||||
@ViewChild('content') content: ElementRef;
|
||||
|
||||
/**
|
||||
* The form id
|
||||
* @type {string}
|
||||
@@ -125,6 +129,10 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
private subs: Subscription[] = [];
|
||||
|
||||
navActiveId: string;
|
||||
|
||||
resourcePolicyTargetUpdated = false;
|
||||
|
||||
/**
|
||||
* Initialize instance variables
|
||||
*
|
||||
@@ -133,6 +141,7 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
* @param {FormService} formService
|
||||
* @param {GroupDataService} groupService
|
||||
* @param {RequestService} requestService
|
||||
* @param modalService
|
||||
*/
|
||||
constructor(
|
||||
private dsoNameService: DSONameService,
|
||||
@@ -140,6 +149,7 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
private formService: FormService,
|
||||
private groupService: GroupDataService,
|
||||
private requestService: RequestService,
|
||||
private modalService: NgbModal,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -151,7 +161,7 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
this.formId = this.formService.getUniqueId('resource-policy-form');
|
||||
this.formModel = this.buildResourcePolicyForm();
|
||||
|
||||
if (!this.canSetGrant()) {
|
||||
if (this.isBeingEdited()) {
|
||||
const epersonRD$ = this.ePersonService.findByHref(this.resourcePolicy._links.eperson.href, false).pipe(
|
||||
getFirstSucceededRemoteData()
|
||||
);
|
||||
@@ -169,6 +179,7 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
filter(() => this.isActive),
|
||||
).subscribe((dsoRD: RemoteData<DSpaceObject>) => {
|
||||
this.resourcePolicyGrant = dsoRD.payload;
|
||||
this.navActiveId = String(dsoRD.payload.type);
|
||||
this.resourcePolicyTargetName$.next(this.getResourcePolicyTargetName());
|
||||
})
|
||||
);
|
||||
@@ -193,19 +204,12 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
private buildResourcePolicyForm(): DynamicFormControlModel[] {
|
||||
const formModel: DynamicFormControlModel[] = [];
|
||||
// TODO to be removed when https://jira.lyrasis.org/browse/DS-4477 will be implemented
|
||||
const policyTypeConf = Object.assign({}, RESOURCE_POLICY_FORM_POLICY_TYPE_CONFIG, {
|
||||
disabled: isNotEmpty(this.resourcePolicy)
|
||||
});
|
||||
// TODO to be removed when https://jira.lyrasis.org/browse/DS-4477 will be implemented
|
||||
const actionConf = Object.assign({}, RESOURCE_POLICY_FORM_ACTION_TYPE_CONFIG, {
|
||||
disabled: isNotEmpty(this.resourcePolicy)
|
||||
});
|
||||
|
||||
formModel.push(
|
||||
new DsDynamicInputModel(RESOURCE_POLICY_FORM_NAME_CONFIG),
|
||||
new DsDynamicTextAreaModel(RESOURCE_POLICY_FORM_DESCRIPTION_CONFIG),
|
||||
new DynamicSelectModel(policyTypeConf),
|
||||
new DynamicSelectModel(actionConf)
|
||||
new DynamicSelectModel(RESOURCE_POLICY_FORM_POLICY_TYPE_CONFIG),
|
||||
new DynamicSelectModel(RESOURCE_POLICY_FORM_ACTION_TYPE_CONFIG)
|
||||
);
|
||||
|
||||
const startDateModel = new DynamicDatePickerModel(
|
||||
@@ -255,8 +259,8 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
*
|
||||
* @return true if is possible, false otherwise
|
||||
*/
|
||||
canSetGrant(): boolean {
|
||||
return isEmpty(this.resourcePolicy);
|
||||
isBeingEdited(): boolean {
|
||||
return !isEmpty(this.resourcePolicy);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,8 +276,10 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
* Update reference to the eperson or group that will be granted the permission
|
||||
*/
|
||||
updateObjectSelected(object: DSpaceObject, isEPerson: boolean): void {
|
||||
this.resourcePolicyTargetUpdated = true;
|
||||
this.resourcePolicyGrant = object;
|
||||
this.resourcePolicyGrantType = isEPerson ? 'eperson' : 'group';
|
||||
this.resourcePolicyTargetName$.next(this.getResourcePolicyTargetName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,6 +303,7 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
type: this.resourcePolicyGrantType,
|
||||
uuid: this.resourcePolicyGrant.id
|
||||
};
|
||||
eventPayload.updateTarget = this.resourcePolicyTargetUpdated;
|
||||
this.submit.emit(eventPayload);
|
||||
});
|
||||
}
|
||||
@@ -329,4 +336,12 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
.filter((subscription) => hasValue(subscription))
|
||||
.forEach((subscription) => subscription.unsubscribe());
|
||||
}
|
||||
|
||||
onNavChange(changeEvent: NgbNavChangeEvent) {
|
||||
// if a policy is being edited it should not be possible to switch between group and eperson
|
||||
if (this.isBeingEdited()) {
|
||||
changeEvent.preventDefault();
|
||||
this.modalService.open(this.content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -343,6 +343,16 @@ describe('ResourcePoliciesComponent test suite', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should call ResourcePolicyService.delete for the checked policies', () => {
|
||||
resourcePolicyService.delete.and.returnValue(observableOf(true));
|
||||
scheduler = getTestScheduler();
|
||||
scheduler.schedule(() => comp.deleteSelectedResourcePolicies());
|
||||
scheduler.flush();
|
||||
|
||||
// only the first one is checked
|
||||
expect(resourcePolicyService.delete).toHaveBeenCalledWith(resourcePolicy.id);
|
||||
});
|
||||
|
||||
it('should notify success when delete is successful', () => {
|
||||
|
||||
resourcePolicyService.delete.and.returnValue(observableOf(true));
|
||||
|
@@ -157,7 +157,6 @@ export class ResourcePoliciesComponent implements OnInit, OnDestroy {
|
||||
} else {
|
||||
this.notificationsService.error(null, this.translate.get('resource-policies.delete.failure.content'));
|
||||
}
|
||||
this.requestService.setStaleByHrefSubstring(this.resourceUUID);
|
||||
this.processingDelete$.next(false);
|
||||
})
|
||||
);
|
||||
|
@@ -84,7 +84,7 @@ describe('SearchSwitchConfigurationComponent', () => {
|
||||
expect(childElements.length).toEqual(comp.configurationList.length);
|
||||
});
|
||||
|
||||
it('should call onSelect method when selecting an option', () => {
|
||||
it('should call onSelect method when selecting an option', waitForAsync(() => {
|
||||
fixture.whenStable().then(() => {
|
||||
spyOn(comp, 'onSelect');
|
||||
select = fixture.debugElement.query(By.css('select'));
|
||||
@@ -94,8 +94,7 @@ describe('SearchSwitchConfigurationComponent', () => {
|
||||
fixture.detectChanges();
|
||||
expect(comp.onSelect).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
}));
|
||||
|
||||
it('should navigate to the route when selecting an option', () => {
|
||||
spyOn((comp as any), 'getSearchLinkParts').and.returnValue([MYDSPACE_ROUTE]);
|
||||
|
@@ -1115,10 +1115,14 @@
|
||||
|
||||
"comcol-role.edit.create": "Create",
|
||||
|
||||
"comcol-role.edit.create.error.title": "Failed to create a group for the '{{ role }}' role",
|
||||
|
||||
"comcol-role.edit.restrict": "Restrict",
|
||||
|
||||
"comcol-role.edit.delete": "Delete",
|
||||
|
||||
"comcol-role.edit.delete.error.title": "Failed to delete the '{{ role }}' role's group",
|
||||
|
||||
|
||||
"comcol-role.edit.community-admin.name": "Administrators",
|
||||
|
||||
@@ -2184,6 +2188,22 @@
|
||||
|
||||
"item.preview.dc.title": "Title:",
|
||||
|
||||
"item.preview.dc.type": "Type:",
|
||||
|
||||
"item.preview.oaire.citation.issue" : "Issue",
|
||||
|
||||
"item.preview.oaire.citation.volume" : "Volume",
|
||||
|
||||
"item.preview.dc.relation.issn" : "ISSN",
|
||||
|
||||
"item.preview.dc.identifier.isbn" : "ISBN",
|
||||
|
||||
"item.preview.dc.identifier": "Identifier:",
|
||||
|
||||
"item.preview.dc.relation.ispartof" : "Journal or Serie",
|
||||
|
||||
"item.preview.dc.identifier.doi" : "DOI",
|
||||
|
||||
"item.preview.person.familyName": "Surname:",
|
||||
|
||||
"item.preview.person.givenName": "Name:",
|
||||
@@ -3162,6 +3182,10 @@
|
||||
|
||||
"resource-policies.edit.page.failure.content": "An error occurred while editing the resource policy.",
|
||||
|
||||
"resource-policies.edit.page.target-failure.content": "An error occurred while editing the target (ePerson or group) of the resource policy.",
|
||||
|
||||
"resource-policies.edit.page.other-failure.content": "An error occurred while editing the resource policy. The target (ePerson or group) has been successfully updated.",
|
||||
|
||||
"resource-policies.edit.page.success.content": "Operation successful",
|
||||
|
||||
"resource-policies.edit.page.title": "Edit resource policy",
|
||||
@@ -3184,6 +3208,16 @@
|
||||
|
||||
"resource-policies.form.eperson-group-list.table.headers.name": "Name",
|
||||
|
||||
"resource-policies.form.eperson-group-list.modal.header": "Cannot change type",
|
||||
|
||||
"resource-policies.form.eperson-group-list.modal.text1.toGroup": "It is not possible to replace an ePerson with a group.",
|
||||
|
||||
"resource-policies.form.eperson-group-list.modal.text1.toEPerson": "It is not possible to replace a group with an ePerson.",
|
||||
|
||||
"resource-policies.form.eperson-group-list.modal.text2": "Delete the current resource policy and create a new one with the desired type.",
|
||||
|
||||
"resource-policies.form.eperson-group-list.modal.close": "Ok",
|
||||
|
||||
"resource-policies.form.date.end.label": "End Date",
|
||||
|
||||
"resource-policies.form.date.start.label": "Start Date",
|
||||
@@ -3598,6 +3632,22 @@
|
||||
|
||||
"submission.import-external.source.arxiv": "arXiv",
|
||||
|
||||
"submission.import-external.source.ads": "NASA/ADS",
|
||||
|
||||
"submission.import-external.source.cinii": "CiNii",
|
||||
|
||||
"submission.import-external.source.crossref": "CrossRef",
|
||||
|
||||
"submission.import-external.source.scielo": "SciELO",
|
||||
|
||||
"submission.import-external.source.scopus": "Scopus",
|
||||
|
||||
"submission.import-external.source.vufind": "VuFind",
|
||||
|
||||
"submission.import-external.source.wos": "Web Of Science",
|
||||
|
||||
"submission.import-external.source.epo": "European Patent Office (EPO)",
|
||||
|
||||
"submission.import-external.source.loading": "Loading ...",
|
||||
|
||||
"submission.import-external.source.sherpaJournal": "SHERPA Journals",
|
||||
@@ -3612,10 +3662,24 @@
|
||||
|
||||
"submission.import-external.source.pubmed": "Pubmed",
|
||||
|
||||
"submission.import-external.source.pubmedeu": "Pubmed Europe",
|
||||
|
||||
"submission.import-external.source.lcname": "Library of Congress Names",
|
||||
|
||||
"submission.import-external.preview.title": "Item Preview",
|
||||
|
||||
"submission.import-external.preview.title.Publication": "Publication Preview",
|
||||
|
||||
"submission.import-external.preview.title.none": "Item Preview",
|
||||
|
||||
"submission.import-external.preview.title.Journal": "Journal Preview",
|
||||
|
||||
"submission.import-external.preview.title.OrgUnit": "Organizational Unit Preview",
|
||||
|
||||
"submission.import-external.preview.title.Person": "Person Preview",
|
||||
|
||||
"submission.import-external.preview.title.Project": "Project Preview",
|
||||
|
||||
"submission.import-external.preview.subtitle": "The metadata below was imported from an external source. It will be pre-filled when you start the submission.",
|
||||
|
||||
"submission.import-external.preview.button.import": "Start submission",
|
||||
@@ -3638,6 +3702,26 @@
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-button-title.isProjectOfPublication": "Project",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-button-title.none": "Import remote item",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-button-title.Event": "Import remote event",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-button-title.Product": "Import remote product",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-button-title.Equipment": "Import remote equipment",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-button-title.OrgUnit": "Import remote organizational unit",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-button-title.Funding": "Import remote fund",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-button-title.Person": "Import remote person",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-button-title.Patent": "Import remote patent",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-button-title.Project": "Import remote project",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-button-title.Publication": "Import remote publication",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-modal.isProjectOfPublication.added.new-entity": "New Entity Added!",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.external-source.import-modal.isProjectOfPublication.title": "Project",
|
||||
@@ -3854,6 +3938,18 @@
|
||||
|
||||
"submission.sections.describe.relationship-lookup.selection-tab.title.arxiv": "Search Results",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.selection-tab.title.crossref": "Search Results",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.selection-tab.title.epo": "Search Results",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.selection-tab.title.scopus": "Search Results",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.selection-tab.title.scielo": "Search Results",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.selection-tab.title.wos": "Search Results",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.selection-tab.title": "Search Results",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.name-variant.notification.content": "Would you like to save \"{{ value }}\" as a name variant for this person so you and others can reuse it for future submissions? If you don\'t you can still use it for this submission.",
|
||||
|
||||
"submission.sections.describe.relationship-lookup.name-variant.notification.confirm": "Save a new name variant",
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,6 @@
|
||||
</body>
|
||||
|
||||
<!-- this is needed for CSR fallback -->
|
||||
<script async src="/client.js"></script>
|
||||
<script async src="client.js"></script>
|
||||
|
||||
</html>
|
||||
|
@@ -6,7 +6,9 @@ $sidebar-items-width: 250px !default;
|
||||
$total-sidebar-width: $collapsed-sidebar-width + $sidebar-items-width !default;
|
||||
|
||||
/* Fonts */
|
||||
$fa-font-path: "/assets/fonts" !default;
|
||||
// Starting this url with a caret (^) allows it to be a relative path based on UI's deployment path
|
||||
// See https://github.com/angular/angular-cli/issues/12797#issuecomment-598534241
|
||||
$fa-font-path: "^assets/fonts" !default;
|
||||
/* Images */
|
||||
$image-path: "../assets/images" !default;
|
||||
|
||||
|
@@ -7,6 +7,7 @@ import {
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting
|
||||
} from '@angular/platform-browser-dynamic/testing';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
declare const require: any;
|
||||
|
||||
@@ -17,9 +18,11 @@ getTestBed().initTestEnvironment(
|
||||
{ teardown: { destroyAfterEach: false } }
|
||||
);
|
||||
|
||||
// If store is mocked, reset state after each test (see https://ngrx.io/guide/migration/v13)
|
||||
jasmine.getEnv().afterEach(() => {
|
||||
// If store is mocked, reset state after each test (see https://ngrx.io/guide/migration/v13)
|
||||
getTestBed().inject(MockStore, null)?.resetSelectors();
|
||||
// Close any leftover modals
|
||||
getTestBed().inject(NgbModal, null)?.dismissAll?.();
|
||||
});
|
||||
|
||||
// Then we find all the tests.
|
||||
|
69
yarn.lock
69
yarn.lock
@@ -3155,11 +3155,6 @@ async-each-series@0.1.1:
|
||||
resolved "https://registry.yarnpkg.com/async-each-series/-/async-each-series-0.1.1.tgz#7617c1917401fd8ca4a28aadce3dbae98afeb432"
|
||||
integrity sha1-dhfBkXQB/Yykooqtzj266Yr+tDI=
|
||||
|
||||
async@0.9.x:
|
||||
version "0.9.2"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d"
|
||||
integrity sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=
|
||||
|
||||
async@1.5.2:
|
||||
version "1.5.2"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
|
||||
@@ -3172,7 +3167,7 @@ async@^2.6.2:
|
||||
dependencies:
|
||||
lodash "^4.17.14"
|
||||
|
||||
async@^3.2.0:
|
||||
async@^3.2.0, async@^3.2.3:
|
||||
version "3.2.3"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9"
|
||||
integrity sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==
|
||||
@@ -3460,6 +3455,13 @@ brace-expansion@^1.1.7:
|
||||
balanced-match "^1.0.0"
|
||||
concat-map "0.0.1"
|
||||
|
||||
brace-expansion@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae"
|
||||
integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==
|
||||
dependencies:
|
||||
balanced-match "^1.0.0"
|
||||
|
||||
braces@^2.3.1:
|
||||
version "2.3.2"
|
||||
resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729"
|
||||
@@ -4135,7 +4137,7 @@ compression@^1.7.4:
|
||||
concat-map@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
||||
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
|
||||
|
||||
configstore@^5.0.1:
|
||||
version "5.0.1"
|
||||
@@ -5139,11 +5141,11 @@ ee-first@1.1.1:
|
||||
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
|
||||
|
||||
ejs@^3.1.5:
|
||||
version "3.1.6"
|
||||
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.6.tgz#5bfd0a0689743bb5268b3550cceeebbc1702822a"
|
||||
integrity sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw==
|
||||
version "3.1.8"
|
||||
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.8.tgz#758d32910c78047585c7ef1f92f9ee041c1c190b"
|
||||
integrity sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==
|
||||
dependencies:
|
||||
jake "^10.6.1"
|
||||
jake "^10.8.5"
|
||||
|
||||
electron-to-chromium@^1.4.71:
|
||||
version "1.4.75"
|
||||
@@ -6025,11 +6027,11 @@ file-saver@^2.0.5:
|
||||
integrity sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==
|
||||
|
||||
filelist@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/filelist/-/filelist-1.0.2.tgz#80202f21462d4d1c2e214119b1807c1bc0380e5b"
|
||||
integrity sha512-z7O0IS8Plc39rTCq6i6iHxk43duYOn8uFJiWSewIq0Bww1RNybVHSCjahmcC87ZqAm4OTvFzlzeGu3XAzG1ctQ==
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/filelist/-/filelist-1.0.4.tgz#f78978a1e944775ff9e62e744424f215e58352b5"
|
||||
integrity sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==
|
||||
dependencies:
|
||||
minimatch "^3.0.4"
|
||||
minimatch "^5.0.1"
|
||||
|
||||
filesize@^6.1.0:
|
||||
version "6.4.0"
|
||||
@@ -7524,12 +7526,12 @@ istanbul-reports@^3.0.2:
|
||||
html-escaper "^2.0.0"
|
||||
istanbul-lib-report "^3.0.0"
|
||||
|
||||
jake@^10.6.1:
|
||||
version "10.8.4"
|
||||
resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.4.tgz#f6a8b7bf90c6306f768aa82bb7b98bf4ca15e84a"
|
||||
integrity sha512-MtWeTkl1qGsWUtbl/Jsca/8xSoK3x0UmS82sNbjqxxG/de/M/3b1DntdjHgPMC50enlTNwXOCRqPXLLt5cCfZA==
|
||||
jake@^10.8.5:
|
||||
version "10.8.5"
|
||||
resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.5.tgz#f2183d2c59382cb274226034543b9c03b8164c46"
|
||||
integrity sha512-sVpxYeuAhWt0OTWITwT98oyV0GsXyMlXCF+3L1SuafBVUIr/uILGRB+NqwkzhgXKvoJpDIpQvqkUALgdmQsQxw==
|
||||
dependencies:
|
||||
async "0.9.x"
|
||||
async "^3.2.3"
|
||||
chalk "^4.0.2"
|
||||
filelist "^1.0.1"
|
||||
minimatch "^3.0.4"
|
||||
@@ -8562,10 +8564,17 @@ minimatch@^3.0.2, minimatch@^3.0.4:
|
||||
dependencies:
|
||||
brace-expansion "^1.1.7"
|
||||
|
||||
minimatch@^5.0.1:
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.0.tgz#1717b464f4971b144f6aabe8f2d0b8e4511e09c7"
|
||||
integrity sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==
|
||||
dependencies:
|
||||
brace-expansion "^2.0.1"
|
||||
|
||||
minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6:
|
||||
version "1.2.5"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
||||
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
|
||||
version "1.2.6"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
|
||||
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
|
||||
|
||||
minipass-collect@^1.0.2:
|
||||
version "1.0.2"
|
||||
@@ -8724,10 +8733,10 @@ mkdirp@^1.0.3, mkdirp@^1.0.4:
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
|
||||
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
|
||||
|
||||
moment@^2.29.1:
|
||||
version "2.29.1"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3"
|
||||
integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==
|
||||
moment@^2.29.2:
|
||||
version "2.29.2"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.2.tgz#00910c60b20843bcba52d37d58c628b47b1f20e4"
|
||||
integrity sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==
|
||||
|
||||
morgan@^1.10.0:
|
||||
version "1.10.0"
|
||||
@@ -8926,9 +8935,9 @@ node-fetch@^2.6.1:
|
||||
whatwg-url "^5.0.0"
|
||||
|
||||
node-forge@^1.2.0:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.2.1.tgz#82794919071ef2eb5c509293325cec8afd0fd53c"
|
||||
integrity sha512-Fcvtbb+zBcZXbTTVwqGA5W+MKBj56UjVRevvchv5XrcyXbmNdesfZL37nlcWOfpgHhgmxApw3tQbTr4CqNmX4w==
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3"
|
||||
integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==
|
||||
|
||||
node-gyp-build@^4.2.2:
|
||||
version "4.3.0"
|
||||
|
Reference in New Issue
Block a user