Skip to content

Commit 0adf6f7

Browse files
committed
Add organization suggested repositories to RepositoryFinder
Tool: gitpod/catfood.gitpod.cloud
1 parent c8989fd commit 0adf6f7

File tree

3 files changed

+47
-33
lines changed

3 files changed

+47
-33
lines changed

components/dashboard/src/components/RepositoryFinder.tsx

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import { useConfiguration, useListConfigurations } from "../data/configurations/
2525
import { useUserLoader } from "../hooks/use-user-loader";
2626
import { conjunctScmProviders, getDeduplicatedScmProviders } from "../utils";
2727
import { cn } from "@podkit/lib/cn";
28+
import { useOrgSuggestedRepos } from "../data/organizations/suggested-repositories-query";
29+
import { toRemoteURL } from "../projects/render-utils";
2830

2931
const isPredefined = (repo: SuggestedRepository): boolean => {
3032
return PREDEFINED_REPOS.some((predefined) => predefined.url === repo.url) && !repo.configurationId;
@@ -35,7 +37,31 @@ const resolveIcon = (contextUrl?: string): string => {
3537
return PREDEFINED_REPOS.some((repo) => repo.url === contextUrl) ? GitpodRepositoryTemplateSVG : RepositorySVG;
3638
};
3739

38-
interface RepositoryFinderProps {
40+
type PredefinedRepositoryOptionProps = {
41+
repo: typeof PREDEFINED_REPOS[number];
42+
};
43+
const PredefinedRepositoryOption: FC<PredefinedRepositoryOptionProps> = ({ repo }) => {
44+
const prettyUrl = toRemoteURL(repo.url);
45+
46+
return (
47+
<div className="flex flex-col overflow-hidden" aria-label={`Demo: ${repo.url}`}>
48+
<div className="flex items-center">
49+
<GitpodRepositoryTemplate className="w-5 h-5 text-pk-content-secondary mr-2" />
50+
<span className="text-sm font-semibold">{repo.repoName}</span>
51+
<MiddleDot className="px-0.5 text-pk-content-secondary" />
52+
<span
53+
className="text-sm whitespace-nowrap truncate overflow-ellipsis text-pk-content-secondary"
54+
title={prettyUrl}
55+
>
56+
{prettyUrl}
57+
</span>
58+
</div>
59+
<span className="text-xs text-pk-content-secondary ml-7">{repo.description}</span>
60+
</div>
61+
);
62+
};
63+
64+
type RepositoryFinderProps = {
3965
selectedContextURL?: string;
4066
selectedConfigurationId?: string;
4167
disabled?: boolean;
@@ -44,8 +70,7 @@ interface RepositoryFinderProps {
4470
onlyConfigurations?: boolean;
4571
showExamples?: boolean;
4672
onChange?: (repo: SuggestedRepository) => void;
47-
}
48-
73+
};
4974
export default function RepositoryFinder({
5075
selectedContextURL,
5176
selectedConfigurationId,
@@ -70,6 +95,8 @@ export default function RepositoryFinder({
7095
onlyConfigurations,
7196
});
7297

98+
const { data: orgSuggestedRepos } = useOrgSuggestedRepos();
99+
73100
// We search for the current context URL in order to have data for the selected suggestion
74101
const selectedItemSearch = useListConfigurations({
75102
sortBy: "name",
@@ -162,29 +189,6 @@ export default function RepositoryFinder({
162189
const [hasStartedSearching, setHasStartedSearching] = useState(false);
163190
const [isShowingExamples, setIsShowingExamples] = useState(showExamples);
164191

165-
type PredefinedRepositoryOptionProps = {
166-
repo: typeof PREDEFINED_REPOS[number];
167-
};
168-
169-
const PredefinedRepositoryOption: FC<PredefinedRepositoryOptionProps> = ({ repo }) => {
170-
return (
171-
<div className="flex flex-col overflow-hidden" aria-label={`Demo: ${repo.url}`}>
172-
<div className="flex items-center">
173-
<GitpodRepositoryTemplate className="w-5 h-5 text-pk-content-secondary mr-2" />
174-
<span className="text-sm font-semibold">{repo.repoName}</span>
175-
<MiddleDot className="px-0.5 text-pk-content-secondary" />
176-
<span
177-
className="text-sm whitespace-nowrap truncate overflow-ellipsis text-pk-content-secondary"
178-
title={repo.repoPath}
179-
>
180-
{repo.repoPath}
181-
</span>
182-
</div>
183-
<span className="text-xs text-pk-content-secondary ml-7">{repo.description}</span>
184-
</div>
185-
);
186-
};
187-
188192
// Resolve the selected context url & configurationId id props to a suggestion entry
189193
useEffect(() => {
190194
let match = repos?.find((repo) => {
@@ -267,13 +271,21 @@ export default function RepositoryFinder({
267271
};
268272

269273
const filteredPredefinedRepos = useMemo(() => {
274+
if (orgSuggestedRepos?.length) {
275+
return orgSuggestedRepos.map((repo) => ({
276+
url: repo.url,
277+
repoName: repo.repoName,
278+
description: "",
279+
}));
280+
}
281+
270282
return PREDEFINED_REPOS.filter((repo) => {
271283
const url = new URL(repo.url);
272284
const isMatchingAuthProviderAvailable =
273285
authProviders.data?.some((provider) => provider.host === url.host) ?? false;
274286
return isMatchingAuthProviderAvailable;
275287
});
276-
}, [authProviders.data]);
288+
}, [authProviders.data, orgSuggestedRepos]);
277289

278290
const getElements = useCallback(
279291
(searchString: string): ComboboxElement[] => {

components/dashboard/src/data/git-providers/predefined-repos.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ export const PREDEFINED_REPOS = [
99
url: "https://github.com/gitpod-demos/voting-app",
1010
repoName: "demo-docker",
1111
description: "A fully configured demo with Docker Compose, Redis and Postgres",
12-
repoPath: "github.com/gitpod-demos/voting-app",
1312
},
1413
{
1514
url: "https://github.com/gitpod-demos/spring-petclinic",
1615
repoName: "demo-java",
1716
description: "A fully configured demo with Java, Maven and Spring Boot",
18-
repoPath: "github.com/gitpod-demos/spring-petclinic",
1917
},
20-
] as const;
18+
];

components/dashboard/src/workspaces/Workspaces.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Workspace, WorkspacePhase_Phase } from "@gitpod/public-api/lib/gitpod/v
2020
import { Button } from "@podkit/buttons/Button";
2121
import { VideoCarousel } from "./VideoCarousel";
2222
import { BlogBanners } from "./BlogBanners";
23-
import { Book, BookOpen, Building, ChevronRight, Code, GraduationCap } from "lucide-react";
23+
import { Book, BookOpen, Building, ChevronRight, Code, Video } from "lucide-react";
2424
import { ReactComponent as GitpodStrokedSVG } from "../icons/gitpod-stroked.svg";
2525
import PersonalizedContent from "./PersonalizedContent";
2626
import { useListenToWorkspacesWSMessages as useListenToWorkspacesStatusUpdates } from "../data/workspaces/listen-to-workspace-ws-messages";
@@ -211,7 +211,7 @@ const WorkspacesPage: FunctionComponent = () => {
211211
{showGettingStarted && (
212212
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5 lg:px-28 px-4 pb-4">
213213
<Card onClick={() => setVideoModalVisible(true)}>
214-
<GraduationCap className="flex-shrink-0" size={24} />
214+
<Video className="flex-shrink-0" size={24} />
215215
<div className="min-w-0">
216216
<CardTitle>Learn how Gitpod works</CardTitle>
217217
<CardDescription>
@@ -236,7 +236,11 @@ const WorkspacesPage: FunctionComponent = () => {
236236
<div className="min-w-0">
237237
<CardTitle>Open a sample repository</CardTitle>
238238
<CardDescription>
239-
Explore a sample repository to quickly experience Gitpod.
239+
Explore{" "}
240+
{orgSuggestedRepos?.length
241+
? "repositories recommended by your organization"
242+
: "a sample repository"}
243+
to quickly experience Gitpod.
240244
</CardDescription>
241245
</div>
242246
</Card>

0 commit comments

Comments
 (0)