Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

fix: prevent the user from moving on until a mapping file is produced (1.6.x) #4949

Merged
merged 1 commit into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<button
class="btn btn-primary"
(click)="flowPageService.done()"
[disabled]="flowPageService.doneDisabled"
*ngIf="flowPageService.showDone"
>
Done
Expand Down
3 changes: 3 additions & 0 deletions app/ui/src/app/integration/edit-page/edit-page.models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ export const INTEGRATION_DONE_CLICKED = 'integration-done-clicked';
export const INTEGRATION_DELETE_PROMPT = 'integration-delete-prompt';
export const INTEGRATION_SIDEBAR_EXPAND = 'integration-sidebar-expand';
export const INTEGRATION_SIDEBAR_COLLAPSE = 'integration-sidebar-collapse';
export const INTEGRATION_BUTTON_DISABLE_DONE =
'integration-button-disable-done';
export const INTEGRATION_BUTTON_ENABLE_DONE = 'integration-button-enable-done';
9 changes: 9 additions & 0 deletions app/ui/src/app/integration/edit-page/flow-page.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
INTEGRATION_DONE_CLICKED,
INTEGRATION_UPDATED,
INTEGRATION_SAVED,
INTEGRATION_BUTTON_DISABLE_DONE,
INTEGRATION_BUTTON_ENABLE_DONE,
} from './edit-page.models';

@Injectable()
Expand All @@ -20,6 +22,7 @@ export class FlowPageService {
publishInProgress = false;
showDone = false;
showCancel = true;
doneDisabled = false;

constructor(
public currentFlowService: CurrentFlowService,
Expand All @@ -32,6 +35,12 @@ export class FlowPageService {
case INTEGRATION_SAVED:
this.initialize();
break;
case INTEGRATION_BUTTON_DISABLE_DONE:
this.doneDisabled = true;
break;
case INTEGRATION_BUTTON_ENABLE_DONE:
this.doneDisabled = false;
break;
default:
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<button
class="btn btn-primary"
(click)="flowPageService.done()"
[disabled]="flowPageService.doneDisabled"
*ngIf="flowPageService.showDone"
>
Done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
IndexedStep,
} from '../../edit-page.models';
import { SPLIT, AGGREGATE } from '@syndesis/ui/store';
import { debounceTime } from 'rxjs/operators';
/*
* Example host component:
*
Expand Down Expand Up @@ -378,13 +379,13 @@ export class DataMapperHostComponent implements OnInit, OnDestroy {

private registerSaveMappingHandler(): Subscription {
//subscribe to mapping save callback from data mapper
return this.cfg.mappingService.saveMappingOutput$.subscribe(
(saveHandler: Function) => {
return this.cfg.mappingService.saveMappingOutput$
.pipe(debounceTime(500))
.subscribe((saveHandler: Function) => {
const json = this.cfg.mappingService.serializeMappingsToJSON();
this.mappings.emit(JSON.stringify(json));
this.cfg.mappingService.handleMappingSaveSuccess(saveHandler);
}
);
});
}

private isSupportedDataShape(dataShape: DataShape): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import {
INTEGRATION_CANCEL_CLICKED,
INTEGRATION_DONE_CLICKED,
} from '@syndesis/ui/integration/edit-page';
import {
INTEGRATION_BUTTON_ENABLE_DONE,
INTEGRATION_BUTTON_DISABLE_DONE,
} from '../edit-page.models';

@Component({
selector: 'syndesis-integration-step-configure',
Expand Down Expand Up @@ -71,20 +75,24 @@ export class IntegrationStepConfigureComponent implements OnInit, OnDestroy {

continue(data: any = {}) {
const step = this.step;
if (step.stepKind === DATA_MAPPER) {
this.customProperties = {
atlasmapping: this.mappings,
};
}
if (this.stepStore.isCustomStep(step)) {
if (step.stepKind === DATA_MAPPER) {
this.customProperties = {
atlasmapping: this.mappings,
};
}
data = this.customProperties;
} else {
data = this.formGroup ? this.formGroup.value : {};
}
const properties = this.formFactory.sanitizeValues(
{ ...data },
this.formConfig
);
this.currentFlowService.events.emit({
kind: INTEGRATION_SET_PROPERTIES,
position: this.position,
properties: this.formFactory.sanitizeValues({ ...data }, this.formConfig),
properties,
onSave: () => {
// flag that this step is configured too for consistency
// with how connections are configured
Expand All @@ -105,6 +113,15 @@ export class IntegrationStepConfigureComponent implements OnInit, OnDestroy {

setMappings(mappings: string) {
this.mappings = mappings;
if (typeof this.mappings !== 'undefined') {
this.currentFlowService.events.emit({
kind: INTEGRATION_BUTTON_ENABLE_DONE,
});
} else {
this.currentFlowService.events.emit({
kind: INTEGRATION_BUTTON_DISABLE_DONE,
});
}
}

getToolbarClass() {
Expand Down