chore(scaffolder): use host in GitHub autocompletion
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
This commit is contained in:
@@ -126,7 +126,7 @@ describe('GithubRepoPicker', () => {
|
||||
<GithubRepoPicker
|
||||
onChange={onChange}
|
||||
rawErrors={[]}
|
||||
state={{ repoName: 'repo' }}
|
||||
state={{ host: 'github.com', repoName: 'repo' }}
|
||||
accessToken="foo"
|
||||
/>
|
||||
</TestApiProvider>,
|
||||
@@ -146,7 +146,7 @@ describe('GithubRepoPicker', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should populate owners if owner and accessToken are provided', async () => {
|
||||
it('should populate repositories if owner and accessToken are provided', async () => {
|
||||
const onChange = jest.fn();
|
||||
|
||||
await renderInTestApp(
|
||||
@@ -154,7 +154,7 @@ describe('GithubRepoPicker', () => {
|
||||
<GithubRepoPicker
|
||||
onChange={onChange}
|
||||
rawErrors={[]}
|
||||
state={{ repoName: 'repo', owner: 'spotify' }}
|
||||
state={{ host: 'github.com', owner: 'spotify' }}
|
||||
accessToken="foo"
|
||||
/>
|
||||
</TestApiProvider>,
|
||||
|
||||
@@ -40,7 +40,7 @@ export const GithubRepoPicker = (
|
||||
? allowedOwners.map(i => ({ label: i, value: i }))
|
||||
: [{ label: 'Loading...', value: 'loading' }];
|
||||
|
||||
const { owner } = state;
|
||||
const { host, owner } = state;
|
||||
|
||||
const scaffolderApi = useApi(scaffolderApiRef);
|
||||
|
||||
@@ -49,7 +49,7 @@ export const GithubRepoPicker = (
|
||||
|
||||
// Update available repositories with owner when client is available
|
||||
const updateAvailableRepositoriesWithOwner = useCallback(() => {
|
||||
if (!scaffolderApi.autocomplete || !accessToken) {
|
||||
if (!scaffolderApi.autocomplete || !accessToken || !host) {
|
||||
setAvailableRepositoriesWithOwner([]);
|
||||
return;
|
||||
}
|
||||
@@ -59,6 +59,7 @@ export const GithubRepoPicker = (
|
||||
token: accessToken,
|
||||
resource: 'repositoriesWithOwner',
|
||||
provider: 'github',
|
||||
context: { host },
|
||||
})
|
||||
.then(({ results }) => {
|
||||
setAvailableRepositoriesWithOwner(
|
||||
@@ -71,7 +72,7 @@ export const GithubRepoPicker = (
|
||||
.catch(() => {
|
||||
setAvailableRepositoriesWithOwner([]);
|
||||
});
|
||||
}, [scaffolderApi, accessToken]);
|
||||
}, [scaffolderApi, accessToken, host]);
|
||||
|
||||
useDebounce(updateAvailableRepositoriesWithOwner, 500, [
|
||||
updateAvailableRepositoriesWithOwner,
|
||||
|
||||
Reference in New Issue
Block a user