diff --git a/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html b/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html
index e72a17aac1..eb06df3630 100644
--- a/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html
+++ b/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html
@@ -5,7 +5,7 @@
-
\ No newline at end of file
+
diff --git a/src/app/+admin/admin-sidebar/admin-sidebar.component.html b/src/app/+admin/admin-sidebar/admin-sidebar.component.html
index 02a25a8227..357ed058d1 100644
--- a/src/app/+admin/admin-sidebar/admin-sidebar.component.html
+++ b/src/app/+admin/admin-sidebar/admin-sidebar.component.html
@@ -25,7 +25,7 @@
+ *ngComponentOutlet="(sectionMap$ | async).get(section.id).component; injector: (sectionMap$ | async).get(section.id).injector;">
@@ -49,4 +49,4 @@
-
\ No newline at end of file
+
diff --git a/src/app/+admin/admin-sidebar/admin-sidebar.component.ts b/src/app/+admin/admin-sidebar/admin-sidebar.component.ts
index 6bd65bb85d..58058f055e 100644
--- a/src/app/+admin/admin-sidebar/admin-sidebar.component.ts
+++ b/src/app/+admin/admin-sidebar/admin-sidebar.component.ts
@@ -1,9 +1,9 @@
import { Component, Injector, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
-import { combineLatest as combineLatestObservable } from 'rxjs';
+import { combineLatest as observableCombineLatest } from 'rxjs';
import { Observable } from 'rxjs/internal/Observable';
import { of } from 'rxjs/internal/observable/of';
-import { first, map, take } from 'rxjs/operators';
+import { first, map, take, tap, filter } from 'rxjs/operators';
import { AuthService } from '../../core/auth/auth.service';
import { ProcessDataService } from '../../core/data/processes/process-data.service';
import { ScriptDataService } from '../../core/data/processes/script-data.service';
@@ -99,7 +99,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
this.sidebarOpen = !collapsed;
this.sidebarClosed = collapsed;
});
- this.sidebarExpanded = combineLatestObservable(this.menuCollapsed, this.menuPreviewCollapsed)
+ this.sidebarExpanded = observableCombineLatest(this.menuCollapsed, this.menuPreviewCollapsed)
.pipe(
map(([collapsed, previewCollapsed]) => (!collapsed || !previewCollapsed))
);
@@ -323,78 +323,81 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
* the export scripts exist and the current user is allowed to execute them
*/
createExportMenuSections() {
- const isAuthorized$: Observable = this.authorizationService.isAuthorized(FeatureID.AdministratorOf);
- isAuthorized$.subscribe((authorized: boolean) => {
- if (authorized) {
- const metadataExportScriptExists$ = this.scriptDataService.scripWithNameExistsAndCanExecute(METADATA_EXPORT_SCRIPT_NAME);
- metadataExportScriptExists$.subscribe((metadataExportScriptExists: boolean) => {
- const menuList = [
- /* Export */
- {
- id: 'export',
- active: false,
- visible: true,
- model: {
- type: MenuItemType.TEXT,
- text: 'menu.section.export'
- } as TextMenuItemModel,
- icon: 'sign-out-alt',
- index: 3
- },
- {
- id: 'export_community',
- parentID: 'export',
- active: false,
- visible: true,
- model: {
- type: MenuItemType.LINK,
- text: 'menu.section.export_community',
- link: ''
- } as LinkMenuItemModel,
- },
- {
- id: 'export_collection',
- parentID: 'export',
- active: false,
- visible: true,
- model: {
- type: MenuItemType.LINK,
- text: 'menu.section.export_collection',
- link: ''
- } as LinkMenuItemModel,
- },
- {
- id: 'export_item',
- parentID: 'export',
- active: false,
- visible: true,
- model: {
- type: MenuItemType.LINK,
- text: 'menu.section.export_item',
- link: ''
- } as LinkMenuItemModel,
- },
- {
- id: 'export_metadata',
- parentID: 'export',
- active: true,
- visible: (authorized && metadataExportScriptExists),
- model: {
- type: MenuItemType.ONCLICK,
- text: 'menu.section.export_metadata',
- function: () => {
- this.modalService.open(ExportMetadataSelectorComponent);
- }
- } as OnClickMenuItemModel,
- },
- ];
- menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, Object.assign(menuSection, {
- shouldPersistOnRouteChange: true
- })));
- });
- }
- });
+ const menuList = [
+ /* Export */
+ {
+ id: 'export',
+ active: false,
+ visible: true,
+ model: {
+ type: MenuItemType.TEXT,
+ text: 'menu.section.export'
+ } as TextMenuItemModel,
+ icon: 'sign-out-alt',
+ index: 3,
+ shouldPersistOnRouteChange: true
+ },
+ {
+ id: 'export_community',
+ parentID: 'export',
+ active: false,
+ visible: true,
+ model: {
+ type: MenuItemType.LINK,
+ text: 'menu.section.export_community',
+ link: ''
+ } as LinkMenuItemModel,
+ shouldPersistOnRouteChange: true
+ },
+ {
+ id: 'export_collection',
+ parentID: 'export',
+ active: false,
+ visible: true,
+ model: {
+ type: MenuItemType.LINK,
+ text: 'menu.section.export_collection',
+ link: ''
+ } as LinkMenuItemModel,
+ shouldPersistOnRouteChange: true
+ },
+ {
+ id: 'export_item',
+ parentID: 'export',
+ active: false,
+ visible: true,
+ model: {
+ type: MenuItemType.LINK,
+ text: 'menu.section.export_item',
+ link: ''
+ } as LinkMenuItemModel,
+ shouldPersistOnRouteChange: true
+ },
+ ];
+ menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, menuSection));
+ observableCombineLatest(
+ this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
+ this.scriptDataService.scriptWithNameExistsAndCanExecute(METADATA_EXPORT_SCRIPT_NAME)
+ ).pipe(
+ filter(([authorized, metadataExportScriptExists]: boolean[]) => authorized && metadataExportScriptExists),
+ take(1)
+ ).subscribe(() => {
+ this.menuService.addSection(this.menuID, {
+ id: 'export_metadata',
+ parentID: 'export',
+ active: true,
+ visible: true,
+ model: {
+ type: MenuItemType.ONCLICK,
+ text: 'menu.section.export_metadata',
+ function: () => {
+ this.modalService.open(ExportMetadataSelectorComponent);
+ }
+ } as OnClickMenuItemModel,
+ shouldPersistOnRouteChange: true
+ });
+ });
}
/**
diff --git a/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.html b/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.html
index 808683910e..d9869ddf1f 100644
--- a/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.html
+++ b/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.html
@@ -12,16 +12,16 @@
(click)="toggleSection($event)">
-
\ No newline at end of file
+
diff --git a/src/app/core/data/processes/script-data.service.ts b/src/app/core/data/processes/script-data.service.ts
index 837d1fb70e..696df8b441 100644
--- a/src/app/core/data/processes/script-data.service.ts
+++ b/src/app/core/data/processes/script-data.service.ts
@@ -1,5 +1,8 @@
import { Injectable } from '@angular/core';
-import { getSucceededRemoteData } from '../../shared/operators';
+import {
+ getSucceededRemoteData,
+ getFirstSucceededRemoteDataPayload
+} from '../../shared/operators';
import { DataService } from '../data.service';
import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.service';
import { Store } from '@ngrx/store';
@@ -11,7 +14,7 @@ import { HttpClient } from '@angular/common/http';
import { DefaultChangeAnalyzer } from '../default-change-analyzer.service';
import { Script } from '../../../process-page/scripts/script.model';
import { ProcessParameter } from '../../../process-page/processes/process-parameter.model';
-import { find, map, switchMap } from 'rxjs/operators';
+import { find, map, switchMap, filter } from 'rxjs/operators';
import { URLCombiner } from '../../url-combiner/url-combiner';
import { RemoteData } from '../remote-data';
import { MultipartPostRequest, RestRequest } from '../request.models';
@@ -20,6 +23,7 @@ import { Observable } from 'rxjs';
import { RequestEntry } from '../request.reducer';
import { dataService } from '../../cache/builders/build-decorators';
import { SCRIPT } from '../../../process-page/scripts/script.resource-type';
+import { hasValue } from '../../../shared/empty.util';
@Injectable()
@dataService(SCRIPT)
@@ -65,11 +69,11 @@ export class ScriptDataService extends DataService