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

Commit

Permalink
fix: can be undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
edewit authored and ia3andy committed Jul 5, 2018
1 parent 9dd2412 commit 0ee91f5
Showing 1 changed file with 3 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*/
Expand All @@ -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) {
Expand All @@ -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;
}
Expand Down

0 comments on commit 0ee91f5

Please sign in to comment.