Skip to content

Commit

Permalink
Merge branch 'master' into NOJIRA-lucene-search-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Smith committed Aug 30, 2018
2 parents cfa1903 + 0ad4284 commit 457fe6c
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 19 deletions.
6 changes: 4 additions & 2 deletions ui/src/app/metadata/filter/effect/filter.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ export class FilterEffects {
@Effect({ dispatch: false })
cancelChanges$ = this.actions$.pipe(
ofType<CancelCreateFilter>(FilterActionTypes.CANCEL_CREATE_FILTER),
combineLatest(this.store.select(fromProvider.getSelectedProviderId).pipe(skipWhile(id => !id))),
tap(([filter, provider]) => this.router.navigate(['/', 'metadata', 'provider', provider, 'filters']))
withLatestFrom(this.store.select(fromProvider.getSelectedProviderId).pipe(skipWhile(id => !id))),
tap(([filter, provider]) => {
this.router.navigate(['/', 'metadata', 'provider', provider, 'filters']);
})
);

constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="modal-header">
<h4 class="modal-title" i18n="@@message--delete-source-title">Delete Metadata Filter?</h4>
</div>
<div class="modal-body">
<p i18n="@@message--delete-source-body">You are deleting a metadata filter. This cannot be undone. Continue?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" (click)="this.activeModal.close()" i18n="@@action--delete">Delete</button>
<button type="button" class="btn btn-secondary" (click)="this.activeModal.dismiss()" i18n="@@action--cancel">Cancel</button>
</div>
14 changes: 14 additions & 0 deletions ui/src/app/metadata/provider/component/delete-filter.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component, ChangeDetectionStrategy } from '@angular/core';

import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';

@Component({
selector: 'delete-filter-dialog',
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './delete-filter.component.html'
})
export class DeleteFilterComponent {
constructor(
public activeModal: NgbActiveModal
) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { Component, ViewChild } from '@angular/core';
import { TestBed, async, ComponentFixture } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { StoreModule, Store, combineReducers } from '@ngrx/store';
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
import { NgbDropdownModule, NgbModalModule, NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ProviderFilterListComponent } from './provider-filter-list.component';
import * as fromRoot from '../reducer';
import * as fromWizard from '../../../wizard/reducer';
import { ProviderEditorNavComponent } from '../component/provider-editor-nav.component';
import { I18nTextComponent } from '../../../shared/component/i18n-text.component';
import { ValidFormIconComponent } from '../../../shared/component/valid-form-icon.component';
import { DeleteFilterComponent } from '../component/delete-filter.component';
import { NgbModalStub } from '../../../../testing/modal.stub';

@Component({
template: `
Expand Down Expand Up @@ -42,9 +44,12 @@ describe('Provider Filter List Component', () => {
ProviderEditorNavComponent,
I18nTextComponent,
ValidFormIconComponent,
DeleteFilterComponent,
TestHostComponent
],
providers: []
providers: [
{ provide: NgbModal, useClass: NgbModalStub }
]
}).compileComponents();

store = TestBed.get(Store);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Component, OnDestroy } from '@angular/core';
import { Store } from '@ngrx/store';
import { Observable, Subject } from 'rxjs';
import { skipWhile, takeUntil, withLatestFrom } from 'rxjs/operators';
import { skipWhile, takeUntil } from 'rxjs/operators';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';

import * as fromProvider from '../reducer';
import * as fromFilter from '../../filter/reducer';
import { MetadataFilter, MetadataProvider } from '../../domain/model';
Expand All @@ -16,6 +18,7 @@ import {
RemoveFilterRequest,
ClearFilters
} from '../../filter/action/collection.action';
import { DeleteFilterComponent } from '../component/delete-filter.component';

@Component({
selector: 'provider-filter-list',
Expand All @@ -33,7 +36,8 @@ export class ProviderFilterListComponent implements OnDestroy {
formats = NAV_FORMATS;

constructor(
private store: Store<fromProvider.ProviderState>
private store: Store<fromProvider.ProviderState>,
private modalService: NgbModal
) {
this.filters$ = this.store.select(fromFilter.getAdditionalFilters) as Observable<MetadataFilter[]>;
this.provider$ = this.store.select(fromProvider.getSelectedProvider).pipe(skipWhile(p => !p));
Expand Down Expand Up @@ -63,7 +67,17 @@ export class ProviderFilterListComponent implements OnDestroy {
}

remove(id: string): void {
this.store.dispatch(new RemoveFilterRequest(id));
this.modalService
.open(DeleteFilterComponent)
.result
.then(
success => {
this.store.dispatch(new RemoveFilterRequest(id));
},
err => {
console.log('Cancelled');
}
);
}

ngOnDestroy(): void {
Expand Down
12 changes: 8 additions & 4 deletions ui/src/app/metadata/provider/provider.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { RouterModule } from '@angular/router';
import { StoreModule } from '@ngrx/store';

import { EffectsModule } from '@ngrx/effects';
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
import { NgbDropdownModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';

import { ProviderWizardComponent } from './container/provider-wizard.component';
import { ProviderWizardStepComponent } from './container/provider-wizard-step.component';
Expand All @@ -30,6 +30,7 @@ import { ProviderFilterListComponent } from './container/provider-filter-list.co
import { ProviderEditorNavComponent } from './component/provider-editor-nav.component';
import { UnsavedProviderComponent } from './component/unsaved-provider.dialog';
import { ContentionModule } from '../../contention/contention.module';
import { DeleteFilterComponent } from './component/delete-filter.component';

@NgModule({
declarations: [
Expand All @@ -43,10 +44,12 @@ import { ContentionModule } from '../../contention/contention.module';
ProviderFilterListComponent,
SummaryPropertyComponent,
ProviderEditorNavComponent,
UnsavedProviderComponent
UnsavedProviderComponent,
DeleteFilterComponent
],
entryComponents: [
UnsavedProviderComponent
UnsavedProviderComponent,
DeleteFilterComponent
],
imports: [
ReactiveFormsModule,
Expand All @@ -57,7 +60,8 @@ import { ContentionModule } from '../../contention/contention.module';
FormModule,
RouterModule,
ContentionModule,
NgbDropdownModule
NgbDropdownModule,
NgbModalModule
],
exports: []
})
Expand Down
134 changes: 132 additions & 2 deletions ui/src/app/schema-form/service/schema.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,140 @@ describe(`Schema Service`, () => {
type: 'string'
}
},
required: 'foo'
required: ['foo']
} },
path: ''
path: '/foo'
})).toBe(true);
}));

it(`should return true if the property is currently required based on anyOf`,
inject([SchemaService], (service: SchemaService) => {
expect(service.isRequired({
parent: {
schema: {
properties: {
foo: { type: 'string' },
bar: { type: 'string' }
},
anyOf: [
{
properties: {
foo: { enum: [ true ] }
},
required: [ 'bar' ]
},
{
properties: {
foo: { enum: [ false ] }
}
}
]
},
value: { foo: true }
},
path: '/bar'
})).toBe(true);
})
);

it(`should return true if the property is NOT currently required based on anyOf`,
inject([SchemaService], (service: SchemaService) => {
expect(service.isRequired({
parent: {
schema: {
properties: {
foo: { type: 'string' },
bar: { type: 'string' }
},
anyOf: [
{
properties: {
foo: { enum: [true] }
},
required: ['bar']
},
{
properties: {
foo: { enum: [false] }
}
}
]
},
value: { foo: false }
},
path: '/bar'
})).toBe(false);
})
);

it(`should return false if the property is NOT currently in any values`,
inject([SchemaService], (service: SchemaService) => {
expect(service.isRequired({
parent: {
schema: {
properties: {
foo: { type: 'string' },
bar: { type: 'string' }
},
anyOf: [
{
properties: {
foo: { enum: [true] }
},
required: ['bar']
},
{
properties: {
foo: { enum: [false] }
}
}
]
},
value: {}
},
path: '/bar'
})).toBe(false);
})
);

it(`should return true if dependant on multiple values and any is true`,
inject([SchemaService], (service: SchemaService) => {
expect(service.isRequired({
parent: {
schema: {
properties: {
foo: { type: 'string' },
bar: { type: 'string' },
baz: { type: 'string' }
},
anyOf: [
{
properties: {
foo: { enum: [true] }
},
required: ['bar']
},
{
properties: {
baz: { enum: [true] }
},
required: ['bar']
},
{
properties: {
foo: { enum: [false] }
}
}
]
},
value: {
foo: true,
baz: true
}
},
path: '/bar'
})).toBe(true);
})
);
});
});
10 changes: 9 additions & 1 deletion ui/src/app/schema-form/service/schema.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ export class SchemaService {

if (!required) {
const conditions = formProperty.parent.schema.anyOf || [];
conditions.forEach(el => {
const values = formProperty.parent.value;
const currentConditions = conditions.filter(condition =>
Object
.keys(condition.properties)
.some(
key => values.hasOwnProperty(key) ? condition.properties[key].enum[0] === values[key] : false
)
);
currentConditions.forEach(el => {
requiredFields = el.required || [];
required = !required ? requiredFields.indexOf(controlName) > -1 : required;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export class FilterTargetComponent extends ObjectWidget implements OnDestroy, Af
search: FormControl = new FormControl(
'',
[],
[
EntityValidators.existsInCollection(this.store.select(fromFilters.getEntityCollection))
]
[]
);

script: FormControl = new FormControl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
]
},
{
"title": "Unused Attributes",
"title": "",
"type": "hidden",
"fields": [
"tlsTrustEngineRef",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,25 @@
"default": ""
}
},
"required": ["certificateFile"]
"anyOf": [
{
"properties": {
"requireSignedRoot": {
"enum": [ true ]
}
},
"required": [
"certificateFile"
]
},
{
"properties": {
"requireSignedRoot": {
"enum": [ false ]
}
}
}
]
},
"EntityRoleWhiteList": {
"title": "Entity Role Whitelist Filter",
Expand Down

0 comments on commit 457fe6c

Please sign in to comment.