Skip to content

Commit

Permalink
Fixed issue with contention
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Mar 1, 2021
1 parent a4e52f7 commit d817386
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
1 change: 1 addition & 0 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ message.protocol-support-required=Protocol Support Enumeration is required if an
message.conflict=Conflict
message.data-version-contention=Data Version Contention
message.contention-new-version=A newer version of this metadata source has been saved. Below are a list of changes. You can use your changes or their changes.
message.contention-error=There was a problem saving due to a mismatched version.
message.organization-feedback=These three fields must all be entered if any single field has a value.
message.valid-email=Must be a valid Email Address
message.valid-url=Must be a valid URL
Expand Down
12 changes: 8 additions & 4 deletions ui/src/app/contention/component/contention-dialog.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
<h4 class="modal-title"><translate-i18n key="message.data-version-contention">Data Version Contention</translate-i18n></h4>
</div>
<div class="modal-body">
<div class="d-flex w-100 justify-content-between">
<div class="d-flex w-100 justify-content-start">
<i class="fa fa-fw fa-exclamation-triangle fa-3x text-warning"></i>
<p class="ml-2">
<translate-i18n key="message.contention-new-version">A newer version of this metadata source has been saved. Below are a list of changes. You can use your changes or their changes.</translate-i18n></p>
<p class="ml-2" *ngIf="theirs.length > 0">
<translate-i18n key="message.contention-new-version">A newer version of this metadata source has been saved. Below are a list of changes. You can use your changes or their changes.</translate-i18n>
</p>
<p class="ml-2" *ngIf="theirs.length < 1">
<translate-i18n key="message.contention-error">There was a problem saving due to a mismatched version.</translate-i18n>
</p>
</div>
<div class="row">
<div class="row" *ngIf="theirs.length > 0">
<div class="col col-6">
<div class="card">
<div class="card-header bg-info text-white">
Expand Down
6 changes: 0 additions & 6 deletions ui/src/app/contention/effect/contention.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ export class ContentionEffects {
switchMap(contention => {
const resolutionAction = of(new ResolveContentionAction({ value: contention.resolutionObject, handlers: contention.handlers }));
const rejectionAction = of(new CancelContentionAction({ value: contention.rejectionObject, handlers: contention.handlers }));
/*if (contention.ourChanges.length < 1) {
return rejectionAction;
}
if (contention.theirChanges.length < 1) {
return resolutionAction;
}*/
return this.modal
.open(ContentionDialogComponent, DEFAULT_MODAL_OPTIONS, { contention })
.pipe(
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/metadata/provider/effect/collection.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ import { MetadataProviderService } from '../../domain/service/provider.service';
import * as fromProvider from '../reducer';
import * as fromRoot from '../../../app.reducer';
import { array_move } from '../../../shared/util';
import { ClearProvider, ResetChanges } from '../action/entity.action';
import { ClearProvider } from '../action/entity.action';
import { ShowContentionAction } from '../../../contention/action/contention.action';
import { ContentionService } from '../../../contention/service/contention.service';
import { MetadataProvider } from '../../domain/model';
import { AddNotification } from '../../../notification/action/notification.action';
import { Notification, NotificationType } from '../../../notification/model/notification';
import { WizardActionTypes, SetDisabled } from '../../../wizard/action/wizard.action';
import { SetDisabled } from '../../../wizard/action/wizard.action';
import { I18nService } from '../../../i18n/service/i18n.service';
import * as fromI18n from '../../../i18n/reducer';
import { ClearEditor } from '../action/editor.action';
Expand Down
13 changes: 8 additions & 5 deletions ui/src/app/metadata/provider/effect/editor.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { Injectable } from '@angular/core';
import { Effect, Actions, ofType } from '@ngrx/effects';
import { SchemaService } from '../../../schema-form/service/schema.service';

import {
EditorActionTypes
} from '../action/editor.action';
import { map, switchMap, catchError, withLatestFrom, debounceTime } from 'rxjs/operators';
import { map, switchMap, catchError, debounceTime } from 'rxjs/operators';
import { of } from 'rxjs';
import {
LoadSchemaRequest,
Expand All @@ -18,6 +15,7 @@ import { ResetChanges } from '../action/entity.action';

import * as fromWizard from '../../../wizard/reducer';
import { Store } from '@ngrx/store';
import { CancelContentionAction, ContentionActionTypes } from '../../../contention/action/contention.action';

@Injectable()
export class EditorEffects {
Expand All @@ -43,9 +41,14 @@ export class EditorEffects {
map(() => new ResetChanges())
);

@Effect()
$resetChangesOnContentionFail = this.actions$.pipe(
ofType<CancelContentionAction>(ContentionActionTypes.CANCEL_CONTENTION),
map(() => new ResetChanges())
);

constructor(
private schemaService: SchemaService,
private store: Store<fromWizard.WizardState>,
private actions$: Actions
) { }
} /* istanbul ignore next */
11 changes: 9 additions & 2 deletions ui/src/app/metadata/resolver/effect/entity.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import {
Clear,
Cancel,
UpdateChangesRequest,
UpdateChangesSuccess
UpdateChangesSuccess,
UpdateSaving
} from '../action/entity.action';
import * as provider from '../action/collection.action';

import { ShowContentionAction } from '../../../contention/action/contention.action';
import { CancelContentionAction, ContentionActionTypes, ShowContentionAction } from '../../../contention/action/contention.action';

import { ResolverCollectionActionTypes } from '../action/collection.action';
import { ResolverService } from '../../domain/service/resolver.service';
Expand Down Expand Up @@ -69,6 +70,12 @@ export class EntityEffects {
})
);

@Effect()
$resetChangesOnContentionFail = this.actions$.pipe(
ofType<CancelContentionAction>(ContentionActionTypes.CANCEL_CONTENTION),
map(() => new UpdateSaving(false))
);

constructor(
private store: Store<fromRoot.State>,
private service: ResolverService,
Expand Down

0 comments on commit d817386

Please sign in to comment.