Skip to content

Commit

Permalink
Clean up repositoryFinderSearch feature flag (#20399)
Browse files Browse the repository at this point in the history
* Clean up `repositoryFinderSearch`feature flag

* Fix `test_getUserRepos_ok` test
  • Loading branch information
filiptronicek authored Nov 28, 2024
1 parent a5d6488 commit cc6e7a0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 25 deletions.
1 change: 0 additions & 1 deletion components/dashboard/src/data/featureflag-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const featureFlags = {
// Local SSH feature of VS Code Desktop Extension
gitpod_desktop_use_local_ssh_proxy: false,
enabledOrbitalDiscoveries: "",
repositoryFinderSearch: false,
// dummy specified dataops feature, default false
dataops: false,
showBrowserExtensionPromotion: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import { useQuery } from "@tanstack/react-query";
import { useCurrentOrg } from "../organizations/orgs-query";
import { useDebounce } from "../../hooks/use-debounce";
import { useFeatureFlag } from "../featureflag-query";
import { scmClient } from "../../service/public-api";

export const useSearchRepositories = ({ searchString, limit }: { searchString: string; limit: number }) => {
// This disables the search behavior when flag is disabled
const repositoryFinderSearchEnabled = useFeatureFlag("repositoryFinderSearch");
const { data: org } = useCurrentOrg();
const debouncedSearchString = useDebounce(searchString);

Expand All @@ -26,7 +24,7 @@ export const useSearchRepositories = ({ searchString, limit }: { searchString: s
return repositories;
},
{
enabled: repositoryFinderSearchEnabled && !!org && debouncedSearchString.length >= 3,
enabled: !!org && debouncedSearchString.length >= 3,
// Need this to keep previous results while we wait for a new search to complete since debouncedSearchString changes and updates the key
keepPreviousData: true,
// We intentionally don't want to trigger refetches here to avoid a loading state side effect of focusing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ class TestBitbucketServerRepositoryProvider {

@test async test_getUserRepos_ok() {
const result = await this.service.getUserRepos(this.user);
// todo(ft): possibly change to not directly rely on a single returned repository, since the recent repo list for BBS is prone to change
expect(result).to.deep.include({
url: "https://bitbucket.gitpod-dev.com/scm/tes/2k-repos-1076.git",
name: "2k-repos-1076",
url: "https://bitbucket.gitpod-dev.com/scm/~svenefftinge/browser-extension-test.git",
name: "browser-extension-test",
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { RepoURL } from "../repohost";
import { RepositoryProvider } from "../repohost/repository-provider";
import { BitbucketServer, BitbucketServerApi } from "./bitbucket-server-api";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server";
import { getPrimaryEmail } from "@gitpod/public-api-common/lib/user-utils";

@injectable()
export class BitbucketServerRepositoryProvider implements RepositoryProvider {
Expand Down Expand Up @@ -132,24 +130,8 @@ export class BitbucketServerRepositoryProvider implements RepositoryProvider {
}

async getUserRepos(user: User): Promise<RepositoryInfo[]> {
const repoSearchEnabled = await getExperimentsClientForBackend().getValueAsync(
"repositoryFinderSearch",
false,
{
user: {
id: user.id,
email: getPrimaryEmail(user),
},
},
);

try {
const repos = repoSearchEnabled
? // Get up to 100 of the most recent repos if repo searching is enabled
await this.api.getRecentRepos(user, { limit: 100 })
: // Otherwise continue to get up to 10k repos
await this.api.getRepos(user, { maxPages: 10, permission: "REPO_READ" });

const repos = await this.api.getRecentRepos(user, { limit: 100 });
const result: RepositoryInfo[] = [];
repos.forEach((r) => {
const cloneUrl = r.links.clone.find((u) => u.name === "http")?.href;
Expand Down

0 comments on commit cc6e7a0

Please sign in to comment.