Skip to content

Commit 5ca28dd

Browse files
committed
Add button to register apps by path
Allow user to register path and stay on app registration page. #close WINDUP-1387
1 parent 88e23d6 commit 5ca28dd

2 files changed

Lines changed: 13 additions & 29 deletions

File tree

ui/src/main/webapp/src/app/registered-application/register-application-form.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ <h1>{{labels.heading}}</h1>
8888
</label>
8989
</div>
9090
</div>
91+
<div class="col-md-12">
92+
<button class="btn btn-primary" [disabled]="!registrationForm.pending && !isValid">Register Path</button>
93+
</div>
9194
</div>
9295
</wu-tab>
9396
</wu-tab-container>
@@ -96,7 +99,7 @@ <h1>{{labels.heading}}</h1>
9699
<div class="col-md-12">
97100
<div class="button-container">
98101
<button *ngIf="isInWizard" (click)="cancelRegistration()" type="button" class="btn btn-default">{{isInWizard ? 'Back' : 'Cancel'}}</button>
99-
<button [disabled]="!registrationForm.pending && !isValid" class="btn btn-primary" type="submit">{{isInWizard ? 'Next' : labels.uploadButton}}</button>
102+
<button [disabled]="!projectHasApplications()" class="btn btn-primary" (click)="navigateOnSuccess()">{{isInWizard ? 'Next' : labels.uploadButton}}</button>
100103
</div>
101104
</div>
102105
</div>

ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class RegisterApplicationFormComponent extends FormComponent implements O
4343

4444
labels = {
4545
heading: 'Add Applications',
46-
uploadButton: 'Upload'
46+
uploadButton: 'Done'
4747
};
4848

4949
constructor(
@@ -138,36 +138,28 @@ export class RegisterApplicationFormComponent extends FormComponent implements O
138138
}
139139

140140
register() {
141+
if (!this.isValid) {
142+
return false;
143+
}
144+
141145
if (this.mode == "PATH") {
142146
this.registerPath();
143147
} else {
144-
this.navigateOnSuccess();
145148
return false;
146149
}
147150
}
148151

149-
private registerPath() {
150-
/**
151-
* If there are already some uploaded applications, we consider form to be valid
152-
* But if user is on Register Path section, clicking submit button triggers registering app by path with invalid
153-
* path.
154-
* To avoid that, treat it as success and do the navigation right away, even when no input path is set.
155-
*/
156-
if ((!this.fileInputPath || this.fileInputPath.length === 0) && this.isValid) {
157-
this.navigateOnSuccess();
158-
return;
159-
}
160-
152+
public registerPath() {
161153
this._fileService.queryServerPathTargetType(this.fileInputPath).subscribe((type_: string) => {
162154
if (type_ === "DIRECTORY" && !this.isDirWithExplodedApp) { //this.isDirWithApps
163155
this._registeredApplicationService.registerApplicationInDirectoryByPath(this.project, this.fileInputPath)
164156
.subscribe(
165-
application => this.navigateOnSuccess(),
157+
() => this.fileInputPath = '',
166158
error => this.handleError(error)
167159
);
168160
} else {
169161
this._registeredApplicationService.registerByPath(this.project, this.fileInputPath, this.isDirWithExplodedApp).subscribe(
170-
application => this.navigateOnSuccess(),
162+
() => this.fileInputPath = '',
171163
error => this.handleError(<any>error)
172164
)
173165
}
@@ -224,7 +216,7 @@ export class RegisterApplicationFormComponent extends FormComponent implements O
224216
this.mode = mode;
225217

226218
if (this.mode === 'PATH') {
227-
this.labels.uploadButton = 'Upload';
219+
this.labels.uploadButton = 'Done';
228220
} else if (this.mode === 'UPLOADED') {
229221
// this is not really nice, but when using UPLOADED mode, upload is done automatically
230222
// so no action is actually being executed, so label is 'Done'
@@ -246,17 +238,6 @@ export class RegisterApplicationFormComponent extends FormComponent implements O
246238
}
247239

248240
public get isValid() {
249-
/**
250-
* If project already has some applications,
251-
* form is always valid for "upload" tab and also for empty path in "server path" tab.
252-
*
253-
* This allows us to have 'Back' step in wizard and not requiring
254-
* user to upload new application.
255-
*/
256-
if (this.isInWizard && this.projectHasApplications() && this.fileInputPath.length === 0) {
257-
return true;
258-
}
259-
260241
if (this.mode === 'PATH') {
261242
const appPathField = this.registrationForm.get('appPathToRegister');
262243

0 commit comments

Comments
 (0)