From 81bf3b9e5d5edd8c12a7c331e24232ca45fd1c7d Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Thu, 11 Jun 2026 17:23:08 +0530 Subject: [PATCH] add custom branch selector with search and load more --- src/lib/components/git/branchSelector.svelte | 290 ++++++++++++++++++ src/lib/components/git/index.ts | 1 + .../git/productionBranchFieldset.svelte | 60 +--- 3 files changed, 301 insertions(+), 50 deletions(-) create mode 100644 src/lib/components/git/branchSelector.svelte diff --git a/src/lib/components/git/branchSelector.svelte b/src/lib/components/git/branchSelector.svelte new file mode 100644 index 000000000..9bc00990b --- /dev/null +++ b/src/lib/components/git/branchSelector.svelte @@ -0,0 +1,290 @@ + + +
{ + if (!e.currentTarget.contains(e.relatedTarget)) { + open = false; + searchQuery = ''; + searchResults = []; + } +}}> + + + {#if open} +
+ + +
    + {#if searching} +
  • Searching...
  • + {:else if displayBranches.length === 0} +
  • No branches found
  • + {:else} + {#each displayBranches as branch} +
  • select(branch)} + on:keydown={(e) => e.key === 'Enter' && select(branch)}> + {branch} +
  • + {/each} + {#if !searchQuery && hasMore} +
  • + +
  • + {/if} + {/if} +
+
+ {/if} +
+ + diff --git a/src/lib/components/git/index.ts b/src/lib/components/git/index.ts index a5cab5eed..ddec8646b 100644 --- a/src/lib/components/git/index.ts +++ b/src/lib/components/git/index.ts @@ -7,5 +7,6 @@ export { default as DeploymentSource } from './deploymentSource.svelte'; export { default as DeploymentDomains } from './deploymentDomains.svelte'; export { default as ConnectBehaviour } from './connectBehaviour.svelte'; export { default as ProductionBranchFieldset } from './productionBranchFieldset.svelte'; +export { default as BranchSelector } from './branchSelector.svelte'; export { default as RepositoryCard } from './repositoryCard.svelte'; export { default as ConnectRepoModal } from './connectRepoModal.svelte'; diff --git a/src/lib/components/git/productionBranchFieldset.svelte b/src/lib/components/git/productionBranchFieldset.svelte index 6785d6499..fbd98f81e 100644 --- a/src/lib/components/git/productionBranchFieldset.svelte +++ b/src/lib/components/git/productionBranchFieldset.svelte @@ -1,10 +1,9 @@
- {#await loadBranches()} + {#await loadDefaultBranch()} - - - - - - - - - - - - - + - {:then branches} - {@const options = - branches - ?.map((branch) => { - return { - value: branch.name, - label: branch.name - }; - }) - ?.sort((a, b) => { - return a.label > b.label ? 1 : -1; - }) ?? []} + {:then} - { - branch = event.detail.value; - }} - {options} /> + {installationId} + {repositoryId} + on:select={(e) => (branch = e.detail)} />