From 0ee91f5c2ae413c94406e0922f76b5eea52c0191 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 22 May 2018 16:31:50 +0200 Subject: [PATCH] fix: can be undefined --- .../gitprovider-createapp-step.component.ts | 83 +------------------ 1 file changed, 3 insertions(+), 80 deletions(-) diff --git a/src/app/launcher/create-app/gitprovider-createapp-step/gitprovider-createapp-step.component.ts b/src/app/launcher/create-app/gitprovider-createapp-step/gitprovider-createapp-step.component.ts index 8db62854..ee493c9c 100644 --- a/src/app/launcher/create-app/gitprovider-createapp-step/gitprovider-createapp-step.component.ts +++ b/src/app/launcher/create-app/gitprovider-createapp-step/gitprovider-createapp-step.component.ts @@ -39,7 +39,9 @@ export class GitproviderCreateappStepComponent extends LauncherStep implements A ngAfterViewInit() { if (this.launcherComponent.summary.gitHubDetails.authenticated === true) { setTimeout(() => { - this.versionSelect.nativeElement.focus(); + if (this.versionSelect) { + this.versionSelect.nativeElement.focus(); + } }, 10); } } @@ -67,30 +69,6 @@ export class GitproviderCreateappStepComponent extends LauncherStep implements A // Accessors - /** - * Returns duplicate name message for when repo exists - * - * @returns {string} - */ - get duplicateNameMessage(): string { - let repo: string = ''; - let repoList: any[] = []; - this.isGitHubRepoNameDup = false; - if (this.launcherComponent && this.launcherComponent.summary && - this.launcherComponent.summary.gitHubDetails) { - repo = this.launcherComponent.summary.gitHubDetails.repository; - repoList = this.launcherComponent.summary.gitHubDetails.repositoryList; - repoList.indexOf(repo) !== -1 ? this.isGitHubRepoNameDup = true : this.isGitHubRepoNameDup = false; - } - if (this.isGitHubRepoNameDup) { - return 'Duplicate Name: ' + '\'' + repo + '\' is already in use as ' + - this.launcherComponent.summary.gitHubDetails.organization + '/' + repo + '.'; - } else { - return '\'' + repo + - '\' is not a valid name, only alphanumeric characters are allowed with "-", "_" or "." '; - } - } - /** * Returns indicator that step is completed * @@ -132,13 +110,6 @@ export class GitproviderCreateappStepComponent extends LauncherStep implements A this.gitProviderService.connectGitHubAccount(url); } - /** - * Update selection - */ - updateGitHubSelection(): void { - this.initCompleted(); - } - /** * get all repos List for the selected organization */ @@ -165,42 +136,10 @@ export class GitproviderCreateappStepComponent extends LauncherStep implements A if (val !== undefined && this.launcherComponent && this.launcherComponent.summary && this.launcherComponent.summary.gitHubDetails) { this.launcherComponent.summary.gitHubDetails.repositoryList = val; - this.validateRepo(); } }); } - /** - * Ensure repo name is available for the selected organization - */ - validateRepo(): void { - let repoName = ''; - let repoList = []; - // gitRepository should consist only alphanumeric characters, '-', '_' or '.'" - const pattern = /^[a-zA-Z0-9][a-zA-Z0-9-._]{1,63}$/; - this.isGitHubRepoNameDup = false; - if (this.launcherComponent && this.launcherComponent.summary && - this.launcherComponent.summary.gitHubDetails) { - repoName = this.launcherComponent.summary.gitHubDetails.repository; - repoList = this.launcherComponent.summary.gitHubDetails.repositoryList; - } - if (!pattern.test(repoName)) { - this.launcherComponent.summary.gitHubDetails.repositoryAvailable = false; - } else if (repoList.indexOf(repoName) !== -1) { - this.isGitHubRepoNameDup = true; - this.launcherComponent.summary.gitHubDetails.repositoryAvailable = false; - } else { - this.launcherComponent.summary.gitHubDetails.repositoryAvailable = true; - if (this.launcherComponent.flow === 'osio') { - if (this.launcherComponent.summary.gitHubDetails.repository) { - this.launcherComponent.summary.gitHubDetails.repository = - this.launcherComponent.summary.gitHubDetails.repository.toLowerCase(); - } - } - } - this.initCompleted(); - } - // Private private getParams(selection: Selection) { @@ -210,22 +149,6 @@ export class GitproviderCreateappStepComponent extends LauncherStep implements A return '?selection=' + encodeURI(JSON.stringify(selection)); } - /** - * Helper to retrieve request parameters - * - * @param name The request parameter to retrieve - * @returns {any} The request parameter value or null - */ - private getRequestParam(name: string): string { - let search = (window.location.search !== undefined && window.location.search.length > 0) - ? window.location.search : window.location.href; - let param = (new RegExp('[?&]' + encodeURIComponent(name) + '=([^&]*)')).exec(search); - if (param !== null) { - return decodeURIComponent(param[1]); - } - return null; - } - private initCompleted(): void { this.completed = this.stepCompleted; }