-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocomplete git repository name #3372
Changes from 1 commit
39729f0
61929d7
0fe99a6
c9ebf59
7953677
2d2757c
fd332dd
669af37
273c99a
7ee00e3
8b73103
f4a571a
d252631
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,10 @@ | |
justify-content: flex-end; | ||
} | ||
|
||
&__right-filter { | ||
width: auto; | ||
} | ||
|
||
&__left { | ||
flex: 1; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { GitSCM, SCMIcon } from './scm'; | ||
import { Observable } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
import { map, filter } from 'rxjs/operators'; | ||
import { Http } from '@angular/http'; | ||
import { GitSCMType } from './scm.service'; | ||
import { GitRepo, GitCommit, GitBranch } from '../../../store/types/git.types'; | ||
|
@@ -60,4 +60,19 @@ export class GitHubSCM implements GitSCM { | |
return `https://github.com/${projectName}/compare/${commitSha1}...${commitSha2}`; | ||
} | ||
|
||
getMacthingRepositories(projectName: string): Observable<string[]> { | ||
const prjParts = projectName.split('/'); | ||
let url = `${this.gitHubURL}/search/repositories?q=${projectName}+in:name`; | ||
if (prjParts.length > 1) { | ||
url = `${this.gitHubURL}/search/repositories?q=${prjParts[1]}+in:name+user:${prjParts[0]}`; | ||
} | ||
return this.http.get(url).pipe( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use httpClient (see my review comment below) |
||
map(response => response.json()), | ||
filter(repos => !!repos.items), | ||
map(repos => { | ||
return repos.items.map(item => item.full_name); | ||
}) | ||
); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,20 @@ export class GitLabSCM implements GitSCM { | |
return `https://gitlab.com/${projectName}/compare/${commitSha1}...${commitSha2}`; | ||
} | ||
|
||
getMacthingRepositories(projectName: string): Observable<string[]> { | ||
const prjParts = projectName.split('/'); | ||
let url = `${gitLabAPIUrl}/projects?search=${projectName}`; | ||
if (prjParts.length > 1) { | ||
url = `${gitLabAPIUrl}/users/${prjParts[0]}/projects?search=${prjParts[1]}`; | ||
} | ||
return this.http.get(url).pipe( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use angular's httpClient (https://angular.io/guide/http) as the old Http is deprecated. httpClient removes the need to do response.json() |
||
map(response => response.json()), | ||
map(repos => { | ||
return repos.map(item => item.path_with_namespace); | ||
}) | ||
); | ||
} | ||
|
||
private convertProject(prj: any): GitRepo { | ||
return { | ||
...prj, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be about to do something like
this.suggestedRepos$ = this.sourceSelectionForm.valueChanges.pipe(
map(form => form.projectName),
startWith(''),
pairwise(),
filter(([oldName, newName]) => oldName !=== newName),
switchMap(([oldName, newName]) => this.updateSuggestedRepositories(newName))
)
and avoid the need for the extra subscription and lastProjectName.