-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Organization-recommended repositories (#20559)
* [server] implement `recommendedRepositories` API field Tool: gitpod/catfood.gitpod.cloud * [dashboard] implement org-suggested repositories Tool: gitpod/catfood.gitpod.cloud * [dashboard] Spacing and pill labels Tool: gitpod/catfood.gitpod.cloud * update copy Tool: gitpod/catfood.gitpod.cloud * Get rid of debug fluff Tool: gitpod/catfood.gitpod.cloud * Fix onboarding page heading Tool: gitpod/catfood.gitpod.cloud * minor nitfix Tool: gitpod/catfood.gitpod.cloud * Cascade project deletions to repo recommendations Tool: gitpod/catfood.gitpod.cloud * Fix db tests Tool: gitpod/catfood.gitpod.cloud * Fix docs link Tool: gitpod/catfood.gitpod.cloud * add db test Tool: gitpod/catfood.gitpod.cloud * Fix showing suggested repos even with no user contributions Tool: gitpod/catfood.gitpod.cloud * Add organization suggested repositories to RepositoryFinder Tool: gitpod/catfood.gitpod.cloud * Don't add recommended repos to workspace list for now Tool: gitpod/catfood.gitpod.cloud * Regular repo icon for org-suggested repos Tool: gitpod/catfood.gitpod.cloud
- Loading branch information
1 parent
71e2b01
commit 754dc9e
Showing
20 changed files
with
1,318 additions
and
677 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
components/dashboard/src/data/organizations/suggested-repositories-query.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Copyright (c) 2025 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { useQuery, useQueryClient } from "@tanstack/react-query"; | ||
import { useCallback } from "react"; | ||
import { configurationClient, organizationClient } from "../../service/public-api"; | ||
import { useCurrentOrg } from "./orgs-query"; | ||
import { SuggestedRepository } from "@gitpod/public-api/lib/gitpod/v1/scm_pb"; | ||
import { PlainMessage } from "@bufbuild/protobuf"; | ||
import { Configuration } from "@gitpod/public-api/lib/gitpod/v1/configuration_pb"; | ||
|
||
export function useOrgRepoSuggestionsInvalidator() { | ||
const organizationId = useCurrentOrg().data?.id; | ||
const queryClient = useQueryClient(); | ||
return useCallback(() => { | ||
queryClient.invalidateQueries(getQueryKey(organizationId)); | ||
}, [organizationId, queryClient]); | ||
} | ||
|
||
export type SuggestedOrgRepository = PlainMessage<SuggestedRepository> & { | ||
orgSuggested: true; | ||
configuration: Configuration; | ||
}; | ||
|
||
export function useOrgSuggestedRepos() { | ||
const organizationId = useCurrentOrg().data?.id; | ||
const query = useQuery<SuggestedOrgRepository[], Error>( | ||
getQueryKey(organizationId), | ||
async () => { | ||
const response = await organizationClient.getOrganizationSettings({ | ||
organizationId, | ||
}); | ||
const repos = response.settings?.onboardingSettings?.recommendedRepositories ?? []; | ||
|
||
const suggestions: SuggestedOrgRepository[] = []; | ||
for (const configurationId of repos) { | ||
const { configuration } = await configurationClient.getConfiguration({ | ||
configurationId: configurationId, | ||
}); | ||
if (!configuration) { | ||
continue; | ||
} | ||
const suggestion: SuggestedOrgRepository = { | ||
configurationId: configurationId, | ||
configurationName: configuration.name ?? "", | ||
repoName: configuration.name ?? "", | ||
url: configuration.cloneUrl ?? "", | ||
orgSuggested: true, | ||
configuration, | ||
}; | ||
|
||
suggestions.push(suggestion); | ||
} | ||
|
||
return suggestions; | ||
}, | ||
{ | ||
enabled: !!organizationId, | ||
cacheTime: 1000 * 60 * 60 * 24 * 7, // 1 week | ||
staleTime: 1000 * 60 * 5, // 5 minutes | ||
}, | ||
); | ||
return query; | ||
} | ||
|
||
export function getQueryKey(organizationId: string | undefined) { | ||
return ["org-suggested-repositories", organizationId ?? "undefined"]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.