+ [translateParams]="{ 'date': date$ | async }">
Create New Version from Version ( date ) Settings
+ [translateParams]="{ 'date': date$ | async }">
Restoring this version will copy the Version ( date ) configuration and create a new Version from the selected version settings. You can then edit the configuration before saving the new version.
Cancel
diff --git a/ui/src/app/metadata/configuration/container/restore.component.ts b/ui/src/app/metadata/configuration/container/restore.component.ts
index 388c5f8d8..0b6faff29 100644
--- a/ui/src/app/metadata/configuration/container/restore.component.ts
+++ b/ui/src/app/metadata/configuration/container/restore.component.ts
@@ -1,11 +1,11 @@
import { Component, ChangeDetectionStrategy, OnDestroy } from '@angular/core';
import { ActivatedRoute, } from '@angular/router';
import { Store } from '@ngrx/store';
-import { Subject } from 'rxjs';
+import { Subject, Observable } from 'rxjs';
import * as fromConfiguration from '../reducer';
import { CONFIG_DATE_FORMAT } from '../configuration.values';
-import { RestoreVersionRequest } from '../action/restore.action';
+import { RestoreVersionRequest, SelectVersionRestoreRequest } from '../action/restore.action';
import { withLatestFrom, map, takeUntil } from 'rxjs/operators';
import { DatePipe } from '@angular/common';
@@ -20,25 +20,36 @@ export class RestoreComponent implements OnDestroy {
readonly subj = new Subject
();
restore$ = this.subj.asObservable();
- date$ = this.store.select(fromConfiguration.getConfigurationVersionDate);
- date: string;
+ date$: Observable;
+ kind$: Observable = this.store.select(fromConfiguration.getConfigurationModelKind);
+ id$: Observable = this.store.select(fromConfiguration.getConfigurationModelId);
constructor(
private store: Store,
- private datePipe: DatePipe
+ private datePipe: DatePipe,
+ private route: ActivatedRoute
) {
this.restore$.pipe(
withLatestFrom(
this.store.select(fromConfiguration.getSelectedVersionId),
- this.store.select(fromConfiguration.getConfigurationModelKind),
- this.store.select(fromConfiguration.getConfigurationModelId)
+ this.kind$,
+ this.id$
),
map(([restore, version, type, id]) => new RestoreVersionRequest({ id, type, version }))
).subscribe(this.store);
- this.date$.pipe(takeUntil(this.subj)).subscribe(
- (date) => this.date = this.datePipe.transform(date, CONFIG_DATE_FORMAT)
- );
+ this.date$ = this.store
+ .select(fromConfiguration.getConfigurationVersionDate)
+ .pipe(
+ map((date) => this.datePipe.transform(date, CONFIG_DATE_FORMAT))
+ );
+
+ this.route.queryParams.pipe(
+ takeUntil(this.subj),
+ map(params => params.version),
+ withLatestFrom(this.id$, this.kind$),
+ map(([version, id, type]) => new SelectVersionRestoreRequest({ version, id, type }))
+ ).subscribe(this.store);
}
restore() {
diff --git a/ui/src/app/metadata/configuration/effect/restore.effect.ts b/ui/src/app/metadata/configuration/effect/restore.effect.ts
index cfdf45057..df5272ced 100644
--- a/ui/src/app/metadata/configuration/effect/restore.effect.ts
+++ b/ui/src/app/metadata/configuration/effect/restore.effect.ts
@@ -28,7 +28,7 @@ export class RestoreVersionEffects {
ofType(RestoreActionTypes.SELECT_VERSION_REQUEST),
map(action => action.payload),
switchMap(({ type, id, version }) => {
- return this.historyService.getVersion(id, version, type).pipe(
+ return this.historyService.getVersion(id, type, version).pipe(
map(v => new SelectVersionRestoreSuccess(v)),
catchError(err => of(new SelectVersionRestoreError(err)))
);
diff --git a/ui/src/app/metadata/configuration/reducer/index.ts b/ui/src/app/metadata/configuration/reducer/index.ts
index 469fe740e..ab217de6d 100644
--- a/ui/src/app/metadata/configuration/reducer/index.ts
+++ b/ui/src/app/metadata/configuration/reducer/index.ts
@@ -183,4 +183,4 @@ export const getConfigurationModelType = createSelector(getConfigurationModel, g
export const getConfigurationHasXml = createSelector(getConfigurationXml, xml => !!xml);
export const getConfigurationFilters = createSelector(getConfigurationModel, model => model.metadataFilters);
-export const getConfigurationVersionDate = createSelector(getConfigurationModel, version => version.modifiedDate);
+export const getConfigurationVersionDate = createSelector(getRestoreModel, version => version && version.modifiedDate);