-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SHIBUI-1361 Fixed issue with displaying proper version
- Loading branch information
Showing
20 changed files
with
293 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
ui/src/app/metadata/configuration/action/restore.action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Action } from '@ngrx/store'; | ||
import { Metadata } from '../../domain/domain.type'; | ||
|
||
export enum RestoreActionTypes { | ||
SELECT_VERSION_SUCCESS = '[Restore Version] Select Version Success', | ||
SELECT_VERSION_ERROR = '[Restore Version] Select Version Error', | ||
SELECT_VERSION_REQUEST = '[Restore Version] Select Version Request', | ||
CLEAR_VERSION = '[Restore Version] Clear Versions' | ||
} | ||
|
||
export class SelectVersionRestoreRequest implements Action { | ||
readonly type = RestoreActionTypes.SELECT_VERSION_REQUEST; | ||
|
||
constructor(public payload: { type: string, id: string, version: string }) { } | ||
} | ||
|
||
export class SelectVersionRestoreSuccess implements Action { | ||
readonly type = RestoreActionTypes.SELECT_VERSION_SUCCESS; | ||
|
||
constructor(public payload: Metadata) { } | ||
} | ||
export class SelectVersionRestoreError implements Action { | ||
readonly type = RestoreActionTypes.SELECT_VERSION_ERROR; | ||
|
||
constructor(public payload: any) { } | ||
} | ||
|
||
export class ClearVersionRestore implements Action { | ||
readonly type = RestoreActionTypes.CLEAR_VERSION; | ||
} | ||
|
||
export type RestoreActionsUnion = | ||
| SelectVersionRestoreRequest | ||
| SelectVersionRestoreError | ||
| SelectVersionRestoreSuccess | ||
| ClearVersionRestore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
ui/src/app/metadata/configuration/container/metadata-history.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<div class="container"> | ||
<history-list | ||
[history]="history$ | async" | ||
(compare)="compareVersions($event)"></history-list> | ||
(compare)="compareVersions($event)" | ||
(restore)="restoreVersion($event)"></history-list> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
ui/src/app/metadata/configuration/container/restore.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="d-flex justify-content-center align-items-center"> | ||
<div class="card m-4 w-50"> | ||
<div class="card-body"> | ||
<h3 class="card-title">Create new version from {{ date | date:DATE_FORMAT }} settings</h3> | ||
<p>Restoring this version will copy the configuration from the selected version and create a new version from these settings. You can then edit the configuration before saving the new version.</p> | ||
<a href="#" class="btn btn-light">Cancel</a> <a href="#" class="btn btn-primary">Restore</a> | ||
</div> | ||
</div> | ||
</div> |
31 changes: 31 additions & 0 deletions
31
ui/src/app/metadata/configuration/container/restore.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Component, ChangeDetectionStrategy, OnDestroy } from '@angular/core'; | ||
import { ActivatedRoute, } from '@angular/router'; | ||
import { Store } from '@ngrx/store'; | ||
import { Subject } from 'rxjs'; | ||
|
||
import * as fromConfiguration from '../reducer'; | ||
import { CONFIG_DATE_FORMAT } from '../configuration.values'; | ||
|
||
@Component({ | ||
selector: 'restore-component', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
templateUrl: './restore.component.html', | ||
styleUrls: [] | ||
}) | ||
export class RestoreComponent implements OnDestroy { | ||
private ngUnsubscribe: Subject<void> = new Subject<void>(); | ||
|
||
DATE_FORMAT = CONFIG_DATE_FORMAT; | ||
|
||
date = new Date(); | ||
|
||
constructor( | ||
private store: Store<fromConfiguration.ConfigurationState>, | ||
private routerState: ActivatedRoute | ||
) {} | ||
|
||
ngOnDestroy() { | ||
this.ngUnsubscribe.next(); | ||
this.ngUnsubscribe.complete(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
ui/src/app/metadata/configuration/effect/restore.effect.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Actions, Effect, ofType } from '@ngrx/effects'; | ||
import { map, catchError, switchMap } from 'rxjs/operators'; | ||
|
||
import { | ||
RestoreActionTypes, | ||
SelectVersionRestoreRequest, | ||
SelectVersionRestoreError, | ||
SelectVersionRestoreSuccess | ||
} from '../action/restore.action'; | ||
import { MetadataHistoryService } from '../service/history.service'; | ||
import { of } from 'rxjs'; | ||
|
||
|
||
@Injectable() | ||
export class RestoreVersionEffects { | ||
|
||
@Effect() | ||
restoreVersionFromId$ = this.actions$.pipe( | ||
ofType<SelectVersionRestoreRequest>(RestoreActionTypes.SELECT_VERSION_REQUEST), | ||
map(action => action.payload), | ||
switchMap(({ type, id, version }) => { | ||
return this.historyService.getVersion(id, version, type).pipe( | ||
map(v => new SelectVersionRestoreSuccess(v)), | ||
catchError(err => of(new SelectVersionRestoreError(err))) | ||
); | ||
}) | ||
); | ||
|
||
constructor( | ||
private historyService: MetadataHistoryService, | ||
private actions$: Actions | ||
) { } | ||
} |
Oops, something went wrong.