|
1 | 1 | <script lang="ts">
|
2 | 2 | import { Service } from 'services/Service';
|
3 | 3 | import { clientAuthenticated } from 'shared/stores/authentication.store';
|
4 |
| - import { isFetchingData, isLoading } from 'shared/stores/default.store'; |
| 4 | + import { isLoading } from 'shared/stores/default.store'; |
5 | 5 | import { authorize } from 'shared/token';
|
6 | 6 | import { ProviderEnum } from 'models/skizzle/ProviderEnum';
|
7 | 7 | import AccountTitle from 'components/AccountTitle';
|
|
14 | 14 |
|
15 | 15 | let search: string = '';
|
16 | 16 |
|
17 |
| - const onSearchSubmit = (profile: ProfileType) => async ( |
18 |
| - query: string, |
19 |
| - ) => { |
| 17 | + let isLoadingRepositories = false; |
| 18 | + const onSearchSubmit = (profile: ProfileType) => async (query: string) => { |
20 | 19 | search = query;
|
21 | 20 |
|
22 |
| - const result = await Service.getRepositories(ProviderEnum.AzureDevOps, { profile }); |
| 21 | + isLoadingRepositories = true; |
| 22 | + const result = await Service.getRepositories(ProviderEnum.AzureDevOps, { |
| 23 | + profile, |
| 24 | + }); |
23 | 25 |
|
24 | 26 | fetchedAzureDevOpsRepositories = result.filter(
|
25 | 27 | ({ projectName, name }) =>
|
26 | 28 | name.toLocaleLowerCase().includes(search.toLocaleLowerCase()) ||
|
27 | 29 | projectName.toLocaleLowerCase().includes(search.toLocaleLowerCase()),
|
28 | 30 | );
|
| 31 | +
|
| 32 | + isLoadingRepositories = false; |
29 | 33 | };
|
30 | 34 |
|
31 | 35 | const onSearchCancel = (): void => {
|
|
48 | 52 | <div class="content">
|
49 | 53 | <section>
|
50 | 54 | <AccountTitle>Suivre un nouveau repository</AccountTitle>
|
51 |
| - <p class="intro"> |
52 |
| - Cherchez le nom de son projet et/ou repository associé. |
53 |
| - </p> |
| 55 | + <p class="intro">Cherchez le nom de son projet et/ou repository associé.</p> |
54 | 56 | <Search
|
55 | 57 | onSubmit={onSearchSubmit(profile)}
|
56 | 58 | onCancel={onSearchCancel}
|
57 |
| - disabled={$isFetchingData} |
| 59 | + disabled={isLoadingRepositories} |
58 | 60 | placeholder="Rechercher un projet ou un repos"
|
59 | 61 | />
|
60 | 62 |
|
61 | 63 | {#if search}
|
62 |
| - {#if $isFetchingData} |
| 64 | + {#if isLoadingRepositories} |
63 | 65 | <p>Recherche en cours...</p>
|
64 | 66 | {:else}
|
65 | 67 | <SearchResults {search} repos={fetchedAzureDevOpsRepositories} />
|
|
0 commit comments