Skip to content

Commit

Permalink
SHIBUI-1656 Fixed issue with extra call receiving 404
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Dec 3, 2019
1 parent 3465a58 commit 7a4c9e3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ui/src/app/contention/service/contention.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { removeNulls } from '../../shared/util';
@Injectable()
export class ContentionService {

filterKeys = (key => (['version', 'modifiedDate', 'createdDate'].indexOf(key) === -1));
filterKeys = (key => (['version', 'modifiedDate', 'createdDate', 'createdBy', 'modifiedBy', 'audId'].indexOf(key) === -1));

constructor(
private diffService: DifferentialService
Expand Down
8 changes: 8 additions & 0 deletions ui/src/app/metadata/filter/action/collection.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export enum FilterCollectionActionTypes {
UPDATE_FILTER_REQUEST = '[Metadata Filter Collection] Update Filter Request',
UPDATE_FILTER_SUCCESS = '[Metadata Filter Collection] Update Filter Success',
UPDATE_FILTER_FAIL = '[Metadata Filter Collection] Update Filter Fail',
UPDATE_FILTER_CONFLICT = '[Metadata Filter Collection] Update Filter Conflict',

LOAD_FILTER_REQUEST = '[Metadata Filter Collection] Load Filter Request',
LOAD_FILTER_SUCCESS = '[Metadata Filter Collection] Load Filter Success',
Expand Down Expand Up @@ -90,6 +91,12 @@ export class UpdateFilterSuccess implements Action {
export class UpdateFilterFail implements Action {
readonly type = FilterCollectionActionTypes.UPDATE_FILTER_FAIL;

constructor(public payload: any) { }
}

export class UpdateFilterConflict implements Action {
readonly type = FilterCollectionActionTypes.UPDATE_FILTER_CONFLICT;

constructor(public payload: MetadataFilter) { }
}

Expand Down Expand Up @@ -197,6 +204,7 @@ export type FilterCollectionActionsUnion =
| UpdateFilterRequest
| UpdateFilterSuccess
| UpdateFilterFail
| UpdateFilterConflict
| ClearFilters
| ChangeFilterOrderDown
| ChangeFilterOrderUp
Expand Down
23 changes: 21 additions & 2 deletions ui/src/app/metadata/filter/effect/collection.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import {
ChangeFilterOrderDown,
RemoveFilterRequest,
RemoveFilterSuccess,
RemoveFilterFail
RemoveFilterFail,
UpdateFilterConflict
} from '../action/collection.action';
import { FilterCollectionActionTypes } from '../action/collection.action';
import * as fromFilter from '../reducer';
Expand Down Expand Up @@ -139,6 +140,24 @@ export class FilterCollectionEffects {
})
);

@Effect()
updateFilterFailNotification$ = this.actions$.pipe(
ofType<UpdateFilterFail>(FilterCollectionActionTypes.UPDATE_FILTER_FAIL),
map(action => action.payload.error),
withLatestFrom(this.store.select(fromI18n.getMessages)),
map(([error, messages]) => {
const message = error.errorMessage || error.cause || 'message.filter-fail';
const translated = this.i18nService.translate(message, null, messages);
return new AddNotification(
new Notification(
NotificationType.Danger,
`${error.errorCode}: ${translated}`,
8000
)
);
})
);

@Effect()
updateFilter$ = this.actions$.pipe(
ofType<UpdateFilterRequest>(FilterCollectionActionTypes.UPDATE_FILTER_REQUEST),
Expand All @@ -154,7 +173,7 @@ export class FilterCollectionEffects {
id: p.resourceId,
changes: p
})),
catchError(err => of(new UpdateFilterFail(filter)))
catchError(err => of(err.status === 409 ? new UpdateFilterConflict(filter) : new UpdateFilterFail(err)))
);
})
);
Expand Down
16 changes: 10 additions & 6 deletions ui/src/app/metadata/filter/effect/filter.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as fromProvider from '../../provider/reducer';
import * as fromRoot from '../../../app.reducer';
import {
FilterCollectionActionTypes,
UpdateFilterFail,
UpdateFilterConflict,
UpdateFilterRequest
} from '../action/collection.action';
import {
Expand All @@ -26,6 +26,7 @@ import { MetadataProviderService } from '../../domain/service/provider.service';
import { ShowContentionAction } from '../../../contention/action/contention.action';
import { MetadataFilter } from '../../domain/model';
import { ContentionService } from '../../../contention/service/contention.service';
import { MetadataFilterService } from '../../domain/service/filter.service';

@Injectable()
export class FilterEffects {
Expand All @@ -44,11 +45,14 @@ export class FilterEffects {

@Effect()
openContention$ = this.actions$.pipe(
ofType<UpdateFilterFail>(FilterCollectionActionTypes.UPDATE_FILTER_FAIL),
ofType<UpdateFilterConflict>(FilterCollectionActionTypes.UPDATE_FILTER_CONFLICT),
map(action => action.payload),
withLatestFrom(this.store.select(fromFilter.getSelectedFilter)),
switchMap(([filter, current]) =>
this.resolverService.find(filter.id).pipe(
withLatestFrom(
this.store.select(fromFilter.getSelectedFilter),
this.store.select(fromProvider.getSelectedProviderId)
),
switchMap(([filter, current, providerId]) =>
this.filterService.find(providerId, filter.resourceId).pipe(
map(data => new ShowContentionAction(this.contentionService.getContention(current, filter, data, {
resolve: (obj) => this.store.dispatch(new UpdateFilterRequest(<MetadataFilter>{ ...obj })),
reject: (obj) => this.store.dispatch(new CancelCreateFilter())
Expand All @@ -71,7 +75,7 @@ export class FilterEffects {
private actions$: Actions,
private router: Router,
private idService: EntityIdService,
private resolverService: MetadataProviderService,
private filterService: MetadataFilterService,
private contentionService: ContentionService
) { }
}
1 change: 0 additions & 1 deletion ui/src/app/schema-form/widget/string/string.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export class CustomStringComponent extends StringWidget implements AfterViewInit
if (!this.required) {
this.errorMessages = this.errorMessages.filter(e => e !== REQUIRED_MSG_OVERRIDE);
}
console.log(this.errorMessages.length);
});
}

Expand Down

0 comments on commit 7a4c9e3

Please sign in to comment.