ignore invalid linear workflow sections that are after the current section

This commit is contained in:
alecmerdler 2017-02-22 16:33:34 -08:00 committed by Joseph Schorr
parent ff07533d80
commit ea9d47ba75
6 changed files with 42 additions and 12 deletions

View file

@ -23,7 +23,7 @@
<td> <td>
<!-- Next sections --> <!-- Next sections -->
<div class="upcoming" <div class="upcoming"
ng-if="$ctrl.currentSection.index != $ctrl.sections.length - 1"> ng-if="$ctrl.currentSection.index < $ctrl.sections.length - 1">
<b>Next:</b> <b>Next:</b>
<ul> <ul>
<li ng-repeat="section in $ctrl.sections" <li ng-repeat="section in $ctrl.sections"

View file

@ -89,12 +89,21 @@ describe("LinearWorkflowComponent", () => {
new LinearWorkflowSectionComponent(), new LinearWorkflowSectionComponent(),
]; ];
sections.forEach((section) => { sections.forEach((section) => {
section.sectionVisible = true; section.sectionVisible = false;
section.isCurrentSection = true; section.isCurrentSection = false;
component.addSection(section); component.addSection(section);
}); });
}); });
it("does nothing if invalid section is after the current section", () => {
sections[sections.length - 1].sectionValid = false;
sections[sections.length - 1].sectionId = "Some Section";
component.onSectionInvalid(sections[sections.length - 1].sectionId);
expect(sections[sections.length - 1].isCurrentSection).toBe(false);
expect(sections[sections.length - 1].sectionVisible).toBe(false);
});
it("sets the section with the given id to be the current section", () => { it("sets the section with the given id to be the current section", () => {
component.onSectionInvalid(invalidSection.sectionId); component.onSectionInvalid(invalidSection.sectionId);
@ -102,6 +111,11 @@ describe("LinearWorkflowComponent", () => {
}); });
it("hides all sections after the section with the given id", () => { it("hides all sections after the section with the given id", () => {
sections.forEach((section) => {
section.sectionVisible = true;
section.isCurrentSection = true;
component.addSection(section);
});
component.onSectionInvalid(invalidSection.sectionId); component.onSectionInvalid(invalidSection.sectionId);
sections.forEach((section) => { sections.forEach((section) => {

View file

@ -45,6 +45,7 @@ export class LinearWorkflowComponent implements ng.IComponentController {
public onSectionInvalid(sectionId: string): void { public onSectionInvalid(sectionId: string): void {
var invalidSection = this.sections.filter(section => section.component.sectionId == sectionId)[0]; var invalidSection = this.sections.filter(section => section.component.sectionId == sectionId)[0];
if (invalidSection.index <= this.currentSection.index) {
invalidSection.component.isCurrentSection = true; invalidSection.component.isCurrentSection = true;
this.currentSection = invalidSection; this.currentSection = invalidSection;
this.sections.forEach((section) => { this.sections.forEach((section) => {
@ -54,6 +55,7 @@ export class LinearWorkflowComponent implements ng.IComponentController {
} }
}); });
} }
}
} }

View file

@ -2,7 +2,7 @@
<linear-workflow <linear-workflow
workflow-state="$ctrl.currentState" workflow-state="$ctrl.currentState"
done-title="Create Trigger" done-title="Create Trigger"
workflow-complete="$ctrl.activateTrigger({'config': $ctrl.config})"> on-workflow-complete="$ctrl.activateTrigger({'config': $ctrl.config})">
<!-- Section: Repository --> <!-- Section: Repository -->
<linear-workflow-section class="row" <linear-workflow-section class="row"
section-id="repo" section-id="repo"

View file

@ -0,0 +1,14 @@
import { ManageTriggerCustomGitComponent } from './manage-trigger-custom-git.component';
describe("ManageTriggerCustomGitComponent", () => {
var component: ManageTriggerCustomGitComponent;
beforeEach(() => {
component = new ManageTriggerCustomGitComponent();
});
describe("$onChanges", () => {
});
});

Binary file not shown.