Skip to content

Commit

Permalink
Merged in feature/SHIBUI-1361 (pull request #357)
Browse files Browse the repository at this point in the history
SHIBUI-1361 Fixed issue with displaying proper version

Approved-by: Ryan Mathis <rmathis@unicon.net>
  • Loading branch information
rmathis committed Aug 14, 2019
2 parents 001580f + f123cb6 commit a102134
Show file tree
Hide file tree
Showing 29 changed files with 331 additions and 75 deletions.
11 changes: 9 additions & 2 deletions ui/src/app/metadata/configuration/action/configuration.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ export enum ConfigurationActionTypes {
LOAD_XML_SUCCESS = '[Metadata Configuration] Load XML Success',
LOAD_XML_ERROR = '[Metadata Configuration] Load XML Error',

SET_METADATA = '[Metadata Configuration] Set Metadata Model',
SET_METADATA = '[Metadata Configuration] Set Metadata Attributes',
SET_DEFINITION = '[Metadata Configuration] Set Metadata Definition',
SET_SCHEMA = '[Metadata Configuration] Set Metadata Schema',
SET_XML = '[Metadata Configuration] Set Metadata Xml',
SET_METADATA_MODEL = '[Metadata Configuration] Set Metadata Model',

DOWNLOAD_XML = '[Metadata Configuration] Download Metadata Xml',

Expand Down Expand Up @@ -61,7 +62,13 @@ export class LoadXmlError implements Action {
export class SetMetadata implements Action {
readonly type = ConfigurationActionTypes.SET_METADATA;

constructor(public payload: { id: string, type: string }) { }
constructor(public payload: { id: string, type: string, version?: string }) { }
}

export class SetMetadataModel implements Action {
readonly type = ConfigurationActionTypes.SET_METADATA_MODEL;

constructor(public payload: Metadata) { }
}

export class SetDefinition implements Action {
Expand Down
36 changes: 36 additions & 0 deletions ui/src/app/metadata/configuration/action/restore.action.ts
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;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<th scope="col">
<span class="sr-only" translate="label.select-version">Select Version</span>
</th>
<th scope="col" translate="label.version">Version</th>
<th scope="col" translate="label.save-date">Save Date</th>
<th scope="col" translate="label.changed-by">Changed By</th>
<th scope="col" translate="label.actions">Actions</th>
Expand All @@ -21,12 +20,19 @@
</label>
</div>
</td>
<td *ngIf="i === 0"><translate-i18n key="label.current">Current</translate-i18n> (v{{ history.length - i }})</td>
<td *ngIf="i > 0">v{{ history.length - (i) }}</td>
<td>{{ version.date | date:DATE_FORMAT }}</td>
<td>
<a [routerLink]="['../', 'options']" [queryParams]="{'version': version.id}">
<ng-container>
{{ version.date | date:DATE_FORMAT }}&nbsp;
<ng-container *ngIf="i === 0">
(<translate-i18n key="label.current">Current</translate-i18n>)
</ng-container>
</ng-container>
</a>
</td>
<td>{{ version.creator }}</td>
<td>
<button class="btn btn-link" (click)="restore.emit(version)">
<button class="btn btn-text btn-link" (click)="restore.emit(version)" *ngIf="i > 0">
<i class="fa fa-undo"></i>&nbsp;
<translate-i18n key="label.restore">Restore</translate-i18n>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MockI18nModule } from '../../../../testing/i18n.stub';
import { HistoryListComponent } from './history-list.component';
import { MetadataHistory } from '../model/history';
import { MetadataVersion } from '../model/version';
import { RouterTestingModule } from '@angular/router/testing';

export const TestData = {
versions: [
Expand Down Expand Up @@ -37,7 +38,8 @@ describe('Metadata History List Component', () => {
TestBed.configureTestingModule({
providers: [],
imports: [
MockI18nModule
MockI18nModule,
RouterTestingModule
],
declarations: [
HistoryListComponent,
Expand Down
8 changes: 6 additions & 2 deletions ui/src/app/metadata/configuration/configuration.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { FilterConfigurationListComponent } from './component/filter-configurati
import { FilterConfigurationListItemComponent } from './component/filter-configuration-list-item.component';
import { SharedModule } from '../../shared/shared.module';
import { FilterTargetPropertyComponent } from './component/filter-target-property.component';
import { RestoreComponent } from './container/restore.component';
import { RestoreVersionEffects } from './effect/restore.effect';

@NgModule({
declarations: [
Expand All @@ -47,7 +49,8 @@ import { FilterTargetPropertyComponent } from './component/filter-target-propert
MetadataComparisonComponent,
FilterConfigurationListComponent,
FilterConfigurationListItemComponent,
FilterTargetPropertyComponent
FilterTargetPropertyComponent,
RestoreComponent
],
entryComponents: [],
imports: [
Expand Down Expand Up @@ -82,7 +85,8 @@ export class MetadataConfigurationModule {
[
MetadataConfigurationEffects,
MetadataHistoryEffects,
CompareVersionEffects
CompareVersionEffects,
RestoreVersionEffects
])
],
providers: []
Expand Down
5 changes: 5 additions & 0 deletions ui/src/app/metadata/configuration/configuration.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MetadataOptionsComponent } from './container/metadata-options.component
import { MetadataXmlComponent } from './container/metadata-xml.component';
import { MetadataHistoryComponent } from './container/metadata-history.component';
import { MetadataComparisonComponent } from './container/metadata-comparison.component';
import { RestoreComponent } from './container/restore.component';

export const ConfigurationRoutes: Routes = [
{
Expand All @@ -29,6 +30,10 @@ export const ConfigurationRoutes: Routes = [
{
path: 'compare',
component: MetadataComparisonComponent
},
{
path: 'restore',
component: RestoreComponent
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
</li>
</ol>
</nav>
<h2 class="mb-4" [ngSwitch]="type$ | async">
<ng-container *ngSwitchCase="'resolver'" translate="label.source">Source</ng-container>
<ng-container *ngSwitchDefault translate="label.provider">Provider</ng-container>
Configuration
</h2>
<ng-container *ngIf="name$ | async">
<router-outlet></router-outlet>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { Component, ChangeDetectionStrategy, OnDestroy, HostListener } from '@an
import { ActivatedRoute, Router, Scroll, Event } from '@angular/router';
import { takeUntil, map, withLatestFrom, filter, timeout, delay } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { Observable, Subject, interval } from 'rxjs';
import { Observable, Subject, interval, combineLatest } from 'rxjs';

import * as fromConfiguration from '../reducer';

import { ClearConfiguration, SetMetadata } from '../action/configuration.action';
import { LoadHistoryRequest, ClearHistory, SelectVersion } from '../action/history.action';
import * as fromReducer from '../reducer';
import { ViewportScroller } from '@angular/common';

@Component({
selector: 'configuration-page',
Expand All @@ -27,9 +26,17 @@ export class ConfigurationComponent implements OnDestroy {
private store: Store<fromConfiguration.ConfigurationState>,
private routerState: ActivatedRoute
) {
this.routerState.params.pipe(

combineLatest(
this.routerState.params,
this.routerState.queryParams
).pipe(
takeUntil(this.ngUnsubscribe),
map(params => new SetMetadata({id: params.id, type: params.type}))
map(([{ id, type }, { version }]) => new SetMetadata({
id,
type,
version
}))
).subscribe(store);

this.routerState.params.pipe(
Expand All @@ -38,20 +45,14 @@ export class ConfigurationComponent implements OnDestroy {
).subscribe(store);

this.store.select(fromReducer.getVersionCollection).pipe(
filter(collection => collection && collection.length > 0),
takeUntil(this.ngUnsubscribe),
withLatestFrom(
this.routerState.queryParams
),
map(([collection, params]) => {
if (collection && collection.length) {
return params.version || collection[0].id;
}
return null;
})
map(([collection, params]) => params.version || collection && collection.length ? collection[0].id : null)
).subscribe(version => {
if (version) {
this.store.dispatch(new SelectVersion(version));
}
this.store.dispatch(new SelectVersion(version));
});

this.name$ = this.store.select(fromReducer.getConfigurationModelName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<h2 class="mb-4" [ngSwitch]="type$ | async">
Compare
<ng-container *ngSwitchCase="'resolver'" translate="label.source">Source</ng-container>
<ng-container *ngSwitchDefault translate="label.provider">Provider</ng-container>
Configuration
</h2>
<div class="" [ngClass]="{
'container-fluid': (numVersions$ | async) > 2,
'container': (numVersions$ | async) <= 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Store } from '@ngrx/store';
import { ActivatedRoute } from '@angular/router';
import { map } from 'rxjs/operators';
import { ConfigurationState, getVersionConfigurations, getVersionConfigurationCount } from '../reducer';
import { Metadata } from '../../domain/domain.type';
import { CompareVersionRequest } from '../action/compare.action';
import { MetadataConfiguration } from '../model/metadata-configuration';
import * as fromReducer from '../reducer';

@Component({
selector: 'metadata-comparison',
Expand All @@ -18,6 +18,7 @@ export class MetadataComparisonComponent {

versions$: Observable<MetadataConfiguration>;
numVersions$: Observable<number>;
type$: Observable<string>;

constructor(
private store: Store<ConfigurationState>,
Expand All @@ -30,5 +31,6 @@ export class MetadataComparisonComponent {

this.versions$ = this.store.select(getVersionConfigurations);
this.numVersions$ = this.store.select(getVersionConfigurationCount);
this.type$ = this.store.select(fromReducer.getConfigurationModelType);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<h2 class="mb-4">
Version History
</h2>
<div class="container">
<history-list
[history]="history$ | async"
(compare)="compareVersions($event)"></history-list>
(compare)="compareVersions($event)"
(restore)="restoreVersion($event)"></history-list>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,13 @@ export class MetadataHistoryComponent {
}
);
}

restoreVersion(version: MetadataVersion): void {
this.router.navigate(
[ '../', 'restore' ],
{
relativeTo: this.route
}
);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<h2 class="mb-4" [ngSwitch]="type$ | async">
<ng-container *ngSwitchCase="'resolver'" translate="label.source">Source</ng-container>
<ng-container *ngSwitchDefault translate="label.provider">Provider</ng-container>
Configuration
</h2>
<div class="container" id="header">
<metadata-header
[isEnabled]="isEnabled$ | async"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Store } from '@ngrx/store';
import { Component, ChangeDetectionStrategy, OnDestroy } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { Router, Event, Scroll } from '@angular/router';
import { Router } from '@angular/router';
import { ViewportScroller } from '@angular/common';
import { takeUntil, filter, delay } from 'rxjs/operators';
import { takeUntil, filter } from 'rxjs/operators';

import {
ConfigurationState,
Expand All @@ -15,7 +15,8 @@ import {
getConfigurationModelEnabled,
getConfigurationHasXml,
getConfigurationModel,
getConfigurationDefinition
getConfigurationDefinition,
getConfigurationModelType
} from '../reducer';
import { MetadataConfiguration } from '../model/metadata-configuration';
import { MetadataVersion } from '../model/version';
Expand All @@ -32,7 +33,6 @@ import {
import { Metadata } from '../../domain/domain.type';
import { DeleteFilterComponent } from '../../provider/component/delete-filter.component';
import { Wizard } from '../../../wizard/model';
import { PreviewEntity } from '../../domain/action/entity.action';

@Component({
selector: 'metadata-options-page',
Expand All @@ -53,6 +53,7 @@ export class MetadataOptionsComponent implements OnDestroy {
filters$: Observable<unknown[]>;
model$: Observable<Metadata>;
definition: Wizard<any>;
type$: Observable<string>;
id: string;
kind: string;

Expand All @@ -73,6 +74,7 @@ export class MetadataOptionsComponent implements OnDestroy {
this.isCurrent$ = this.store.select(getSelectedIsCurrent);
this.hasXml$ = this.store.select(getConfigurationHasXml);
this.filters$ = this.store.select(getAdditionalFilters);
this.type$ = this.store.select(getConfigurationModelType);

this.model$
.pipe(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<h2 class="mb-4" [ngSwitch]="type$ | async">
<ng-container *ngSwitchCase="'resolver'" translate="label.source">Source</ng-container>
<ng-container *ngSwitchDefault translate="label.provider">Provider</ng-container>
Configuration
</h2>
<div class="container-fluid">
<div class="px-3 my-3 d-flex justify-content-end">
<div class="btn-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ describe('Metadata Xml Page Component', () => {

it('should load metadata objects', async(() => {
expect(app).toBeTruthy();
expect(store.select).toHaveBeenCalledTimes(2);
expect(store.select).toHaveBeenCalledTimes(3);
}));
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Store } from '@ngrx/store';
import { Component } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { Observable } from 'rxjs';

import * as fromConfiguration from '../reducer';
import { Metadata } from '../../domain/domain.type';
Expand All @@ -17,12 +17,14 @@ export class MetadataXmlComponent {
entity$: Observable<Metadata>;
xml: string;
xml$: Observable<string>;
type$: Observable<string>;

constructor(
private store: Store<fromConfiguration.ConfigurationState>
) {
this.xml$ = this.store.select(fromConfiguration.getConfigurationXml);
this.entity$ = this.store.select(fromConfiguration.getConfigurationModel);
this.type$ = this.store.select(fromConfiguration.getConfigurationModelType);
}

preview(): void {
Expand Down
Loading

0 comments on commit a102134

Please sign in to comment.