Skip to content

Commit 3651c25

Browse files
committed
Colored suggestions
Tool: gitpod/catfood.gitpod.cloud
1 parent d5a5cbc commit 3651c25

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

components/dashboard/src/components/RepositoryFinder.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ import { useAuthProviderDescriptions } from "../data/auth-providers/auth-provide
1919
import { ReactComponent as Exclamation2 } from "../images/exclamation2.svg";
2020
import { AuthProviderType } from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb";
2121
import { SuggestedRepository } from "@gitpod/public-api/lib/gitpod/v1/scm_pb";
22-
import { PREDEFINED_REPOS } from "../data/git-providers/predefined-repos";
22+
import { PREDEFINED_REPOS, PredefinedRepo } from "../data/git-providers/predefined-repos";
2323
import { useConfiguration, useListConfigurations } from "../data/configurations/configuration-queries";
2424
import { useUserLoader } from "../hooks/use-user-loader";
2525
import { conjunctScmProviders, getDeduplicatedScmProviders } from "../utils";
2626
import { cn } from "@podkit/lib/cn";
2727
import { useOrgSuggestedRepos } from "../data/organizations/suggested-repositories-query";
2828
import { toRemoteURL } from "../projects/render-utils";
2929

30-
type PredefinedRepoOption = typeof PREDEFINED_REPOS[number];
31-
const isPredefined = (repo: SuggestedRepository | PredefinedRepoOption): boolean => {
30+
const isPredefined = (repo: SuggestedRepository | PredefinedRepo): boolean => {
3231
return (
3332
PREDEFINED_REPOS.some((predefined) => predefined.url === repo.url) &&
3433
!(repo as SuggestedRepository).configurationId
@@ -41,7 +40,7 @@ const resolveIcon = (contextUrl?: string): string => {
4140
};
4241

4342
type PredefinedRepositoryOptionProps = {
44-
repo: PredefinedRepoOption;
43+
repo: PredefinedRepo;
4544
};
4645
const PredefinedRepositoryOption: FC<PredefinedRepositoryOptionProps> = ({ repo }) => {
4746
const prettyUrl = toRemoteURL(repo.url);
@@ -50,7 +49,12 @@ const PredefinedRepositoryOption: FC<PredefinedRepositoryOptionProps> = ({ repo
5049
return (
5150
<div className="flex flex-col overflow-hidden" aria-label={`Demo: ${repo.url}`}>
5251
<div className="flex items-center">
53-
<img className={cn("w-5 mr-2 text-pk-content-secondary")} src={icon} alt="" />
52+
{repo.configurationId ? (
53+
<RepositoryIcon className={cn("w-5 mr-2 text-kumquat-ripe")} />
54+
) : (
55+
<img className={cn("w-5 mr-2 text-pk-content-secondary")} src={icon} alt="" />
56+
)}
57+
5458
<span className="text-sm font-semibold">{repo.repoName}</span>
5559
<MiddleDot className="px-0.5 text-pk-content-secondary" />
5660
<span
@@ -280,6 +284,7 @@ export default function RepositoryFinder({
280284
url: repo.url,
281285
repoName: repo.repoName,
282286
description: "",
287+
configurationId: repo.configurationId,
283288
}));
284289
}
285290

@@ -317,11 +322,14 @@ export default function RepositoryFinder({
317322
repo.url.toLowerCase().includes(searchString.toLowerCase()) ||
318323
repo.repoName.toLowerCase().includes(searchString.toLowerCase())
319324
) {
320-
result.push({
321-
id: repo.url,
322-
element: <PredefinedRepositoryOption repo={repo} />,
323-
isSelectable: true,
324-
});
325+
const alreadyPresent = result.find((r) => r.id === repo.configurationId);
326+
if (!alreadyPresent) {
327+
result.push({
328+
id: repo.url,
329+
element: <PredefinedRepositoryOption repo={repo} />,
330+
isSelectable: true,
331+
});
332+
}
325333
}
326334
});
327335
}

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@
44
* See License.AGPL.txt in the project root for license information.
55
*/
66

7-
export const PREDEFINED_REPOS = [
7+
export type PredefinedRepo = {
8+
url: string;
9+
repoName: string;
10+
description: string;
11+
/**
12+
* The configuration ID of the repository.
13+
* This is only set for org-recommended repos.
14+
*/
15+
configurationId?: string;
16+
};
17+
18+
export const PREDEFINED_REPOS: PredefinedRepo[] = [
819
{
920
url: "https://github.com/gitpod-demos/voting-app",
1021
repoName: "demo-docker",

0 commit comments

Comments
 (0)