Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/data/git-providers/suggested-repositories-query.ts
2501 views
1
/**
2
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import { useQuery } from "@tanstack/react-query";
8
import { useCurrentOrg } from "../organizations/orgs-query";
9
import { scmClient } from "../../service/public-api";
10
11
type Props = {
12
excludeConfigurations: boolean;
13
};
14
export const useSuggestedRepositories = ({ excludeConfigurations }: Props) => {
15
const { data: org } = useCurrentOrg();
16
17
return useQuery(
18
["suggested-repositories", { orgId: org?.id, excludeConfigurations }],
19
async () => {
20
if (!org) {
21
throw new Error("No org selected");
22
}
23
24
const { repositories } = await scmClient.listSuggestedRepositories({
25
organizationId: org.id,
26
excludeConfigurations,
27
pagination: {
28
pageSize: 100,
29
},
30
});
31
return repositories;
32
},
33
{
34
// Keeps data in cache for 7 days - will still refresh though
35
cacheTime: 1000 * 60 * 60 * 24 * 7,
36
},
37
);
38
};
39
40