Skip to content

Commit

Permalink
In CreateFromBuilder and OrderService wizards, correct error handling…
Browse files Browse the repository at this point in the history
… of ProjectNameTaken
  • Loading branch information
dtaylor113 committed Nov 7, 2017
1 parent 86e18a8 commit 19700be
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 1,126 deletions.
155 changes: 80 additions & 75 deletions dist/origin-web-catalogs.js

Large diffs are not rendered by default.

1,020 changes: 0 additions & 1,020 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export class CreateFromBuilderController implements angular.IController {
onShow: this.showResults
};
this.ctrl.steps = [this.infoStep, this.configStep, this.bindStep, this.reviewStep];
this.ctrl.currentStep = "Information";
this.ctrl.versions = this.getVersions();
this.ctrl.istag = _.head(this.ctrl.versions);
this.ctrl.nameMaxLength = 24;
Expand All @@ -128,6 +129,10 @@ export class CreateFromBuilderController implements angular.IController {
this.onProjectUpdate
);

this.$scope.$watch('$ctrl.selectedProject.metadata.name', () => {
this.ctrl.projectNameTaken = false;
});

if (this.ctrl.showPodPresets) {
// FIXME: We should not need to request these again.
this.getServiceClassesAndPlans();
Expand Down Expand Up @@ -218,6 +223,7 @@ export class CreateFromBuilderController implements angular.IController {
};

private showConfig = () => {
this.ctrl.currentStep = "Configuration";
this.clearValidityWatcher();
this.ctrl.nextTitle = this.bindStep.hidden ? 'Create' : 'Next >';
this.reviewStep.allowed = this.bindStep.hidden && this.configStep.valid;
Expand All @@ -240,6 +246,7 @@ export class CreateFromBuilderController implements angular.IController {
this.clearValidityWatcher();
this.ctrl.nextTitle = 'Close';
this.ctrl.wizardDone = true;
this.ctrl.currentStep = "Results";

this.createApp();
};
Expand Down Expand Up @@ -383,8 +390,14 @@ export class CreateFromBuilderController implements angular.IController {
}, (e: any) => {
this.ctrl.error = e;
});
}, (result) => {
this.ctrl.error = result;
}, (e) => {
if (e.data.reason === 'AlreadyExists') {
this.ctrl.projectNameTaken = true;
this.ctrl.wizardDone = false;
this.ctrl.currentStep = "Configuration";
} else {
this.ctrl.error = e;
}
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
wizard-title="{{$ctrl.imageStream.name}} {{$ctrl.istag.name}}"
hide-sidebar="true"
step-class="order-service-wizard-step"
current-step="$ctrl.currentStep"
wizard-ready="$ctrl.wizardReady"
next-title="$ctrl.nextTitle"
on-finish="$ctrl.closePanel()"
Expand Down
2 changes: 1 addition & 1 deletion src/components/order-service/order-service-configure.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="order-service-config">
<div class="config-top">
<form name="$ctrl.forms.orderConfigureForm" class="config-form">
<select-project selected-project="$ctrl.selectedProject" name-taken="$ctrl.nameTaken" show-divider="$ctrl.parameterSchema.properties.length > 0"></select-project>
<select-project selected-project="$ctrl.selectedProject" name-taken="$ctrl.projectNameTaken" show-divider="$ctrl.parameterSchema.properties.length > 0"></select-project>
<catalog-parameters
ng-if="$ctrl.parameterSchema.properties && !$ctrl.noProjectsCantCreate"
model="$ctrl.parameterData"
Expand Down
19 changes: 16 additions & 3 deletions src/components/order-service/order-service.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ export class OrderServiceController implements angular.IController {
};

this.ctrl.steps = [this.infoStep, this.planStep, this.configStep, this.bindStep, this.bindParametersStep, this.reviewStep];
this.ctrl.nameTaken = false;
this.ctrl.currentStep = "Information";
this.ctrl.projectNameTaken = false;
this.ctrl.wizardDone = false;
this.ctrl.bindType = "none";

Expand All @@ -167,6 +168,10 @@ export class OrderServiceController implements angular.IController {
this.onProjectUpdate
);

this.$scope.$watch('$ctrl.selectedProject.metadata.name', () => {
this.ctrl.projectNameTaken = false;
});

this.bindTypeWatch = this.$scope.$watch("$ctrl.bindType", (current: any, previous: any) => {
if (current === previous) {
return;
Expand Down Expand Up @@ -203,6 +208,7 @@ export class OrderServiceController implements angular.IController {
};

public showConfig = () => {
this.ctrl.currentStep = "Configuration";
this.clearValidityWatcher();
this.ctrl.configPageShown = true;
this.reviewStep.allowed = this.bindStep.hidden && this.configStep.valid;
Expand Down Expand Up @@ -244,6 +250,7 @@ export class OrderServiceController implements angular.IController {
};

public showResults = () => {
this.ctrl.currentStep = "Results";
this.clearValidityWatcher();
this.ctrl.configPageShown = false;
this.ctrl.nextTitle = "Close";
Expand Down Expand Up @@ -276,8 +283,14 @@ export class OrderServiceController implements angular.IController {
this.ctrl.selectedProject = project;
this.ctrl.projectDisplayName = this.$filter('displayName')(project);
this.createService();
}, (result: any) => {
this.ctrl.error = result.data;
}, (e: any) => {
if (e.data.reason === 'AlreadyExists') {
this.ctrl.projectNameTaken = true;
this.ctrl.wizardDone = false;
this.ctrl.currentStep = "Configuration";
} else {
this.ctrl.error = e;
}
});
} else {
this.ctrl.projectDisplayName = this.$filter('displayName')(this.ctrl.selectedProject);
Expand Down
1 change: 1 addition & 0 deletions src/components/order-service/order-service.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
wizard-title="{{$ctrl.serviceName}}"
hide-sidebar="true"
step-class="order-service-wizard-step"
current-step="$ctrl.currentStep"
wizard-ready="$ctrl.wizardReady"
next-title="$ctrl.nextTitle"
on-finish="$ctrl.closePanel()"
Expand Down
6 changes: 0 additions & 6 deletions src/components/select-project/select-project.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export class SelectProjectController implements angular.IController {
}

public $onInit() {
this.ctrl.nameTaken = false;
this.ctrl.noProjectsCantCreate = false;

this.ctrl.noProjectsConfig = {
Expand Down Expand Up @@ -114,11 +113,6 @@ export class SelectProjectController implements angular.IController {
}
}

public onNewProjectNameChange() {
this.ctrl.nameTaken = false;
this.ctrl.forms.createProjectForm.name.$setValidity('nameTaken', !this.ctrl.nameTaken);
}

public isNewProject(): boolean {
return this.projects && this.ctrl.selectedProject && !_.has(this.ctrl.selectedProject, 'metadata.uid');
}
Expand Down
38 changes: 19 additions & 19 deletions src/components/select-project/selectProject.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ <h3 ng-if="$ctrl.canOnlyCreateProject()">Create Project</h3>
ng-if="$ctrl.isNewProject()">
<div class="form-group">
<label for="name" class="control-label required">Project Name</label>
<div ng-class="{'has-error': ($ctrl.forms.createProjectForm.name.$error.pattern && $ctrl.forms.createProjectForm.name.$touched) || $ctrl.nameTaken}">
<div ng-class="{'has-error': ($ctrl.forms.createProjectForm.name.$error.pattern && $ctrl.forms.createProjectForm.name.$touched) ||
$ctrl.nameTaken || $ctrl.forms.createProjectForm.name.$error.oscUnique}">
<input class="form-control"
name="name"
id="name"
Expand All @@ -73,27 +74,26 @@ <h3 ng-if="$ctrl.canOnlyCreateProject()">Create Project</h3>
ng-model="$ctrl.selectedProject.metadata.name"
osc-unique="$ctrl.existingProjectNames"
ng-model-options="{ updateOn: 'default blur' }"
ng-change="$ctrl.onNewProjectNameChange()"
autocorrect="off"
autocapitalize="off"
spellcheck="false">
<div class="help-block">A unique name for the project.</div>
<div class="has-error" ng-if="$ctrl.forms.createProjectForm.name.$error.minlength && $ctrl.forms.createProjectForm.name.$touched">
<span id="nameHelp" class="help-block">
Name must have at least two characters.
</span>
</div>
<div class="has-error" ng-if="$ctrl.forms.createProjectForm.name.$error.pattern && $ctrl.forms.createProjectForm.name.$touched">
<span id="nameHelp" class="help-block">
Project names may only contain lower-case letters, numbers, and dashes.
They may not start or end with a dash.
</span>
</div>
<div class="has-error" ng-if="$ctrl.nameTaken || $ctrl.forms.createProjectForm.name.$error.oscUnique">
<span class="help-block">
This name is already in use. Please choose a different name.
</span>
</div>
</div>
<div class="help-block">A unique name for the project.</div>
<div class="has-error" ng-if="$ctrl.forms.createProjectForm.name.$error.minlength && $ctrl.forms.createProjectForm.name.$touched">
<span id="nameHelp" class="help-block">
Name must have at least two characters.
</span>
</div>
<div class="has-error" ng-if="$ctrl.forms.createProjectForm.name.$error.pattern && $ctrl.forms.createProjectForm.name.$touched">
<span id="nameHelp" class="help-block">
Project names may only contain lower-case letters, numbers, and dashes.
They may not start or end with a dash.
</span>
</div>
<div class="has-error" ng-if="$ctrl.nameTaken || $ctrl.forms.createProjectForm.name.$error.oscUnique">
<span class="help-block">
This name is already in use. Please choose a different name.
</span>
</div>
</div>

Expand Down

0 comments on commit 19700be

Please sign in to comment.