Add local repository scanning and UI
Implement local repository scanning end-to-end. Frontend: add UI (toolbar, local-scan panel, list/cards), CSS styles, icons, new state fields, and templates; convert recent repo items to buttons and wire up actions to select, view and open scanned repos. JS: add helper utilities (repoNameFromPath, normalizeRemoteUrl, serverRepoRemoteUrls), scanForLocalRepos/selectLocalRepo functions, render template for scan results, and call scanLocalRepos via tauri-api. Tauri API: expose scan_local_repos (tauri command) in tauri-api.js. Backend (Rust): add LocalRepoCandidate type and a scanner implementation that walks configurable/default roots, deduplicates paths, matches local remotes against allowed server URLs, enforces depth/result limits, and returns matched candidates; register scan_local_repos in the command list. Includes error handling and user-facing messages for missing roots or remotes.
This commit is contained in:
+158
-8
@@ -338,17 +338,25 @@
|
||||
}
|
||||
|
||||
.recent-item {
|
||||
display: block;
|
||||
width: 100%;
|
||||
border: 0;
|
||||
border-radius: var(--radius-md);
|
||||
background: transparent;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
color: var(--text-muted);
|
||||
padding: 4px 0;
|
||||
padding: 4px 6px;
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.recent-item:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--accent);
|
||||
border: 0;
|
||||
}
|
||||
|
||||
/* ── Git output ───────────────────────────────────── */
|
||||
@@ -380,15 +388,157 @@
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* ── Local repo indicator ─────────────────────────── */
|
||||
.selected-repo {
|
||||
font-size: 13px;
|
||||
padding: 6px 10px;
|
||||
background: rgba(47, 129, 247, 0.06);
|
||||
border: 1px solid rgba(47, 129, 247, 0.2);
|
||||
/* ── GitHub Desktop style toolbar ─────────────────── */
|
||||
.gd-toolbar {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr) minmax(0, 1.5fr);
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
height: 56px;
|
||||
margin: -16px -16px 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: var(--bg-panel);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.main > .gd-toolbar {
|
||||
margin: 0 0 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
word-break: break-all;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.gd-toolbar-cell {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0 14px;
|
||||
border: 0;
|
||||
border-right: 1px solid var(--border);
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
color: var(--text-main);
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
transition: background 0.1s ease;
|
||||
}
|
||||
|
||||
.gd-toolbar-cell:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.gd-toolbar-cell:hover:not(:disabled):not(.gd-toolbar-cell-empty) {
|
||||
background: rgba(177, 186, 196, 0.08);
|
||||
border-color: var(--border);
|
||||
}
|
||||
|
||||
.gd-toolbar-cell:disabled,
|
||||
.gd-toolbar-cell-empty {
|
||||
cursor: default;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.gd-cell-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
color: var(--text-muted);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.gd-cell-copy {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.gd-cell-label {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--text-muted);
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.gd-cell-value {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
margin-top: 2px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.gd-cell-value-muted {
|
||||
color: var(--text-muted);
|
||||
font-weight: 400;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.gd-cell-caret {
|
||||
color: var(--text-muted);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.selected-repo-path-line {
|
||||
margin-top: -6px;
|
||||
font-size: 12px;
|
||||
font-family: ui-monospace, "Cascadia Code", "Fira Code", Consolas, monospace;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.local-scan-panel {
|
||||
padding: 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
background: rgba(33, 38, 45, 0.35);
|
||||
}
|
||||
|
||||
.local-scan-title {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.local-repo-list {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
max-height: 320px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.local-repo-card {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--bg-panel);
|
||||
}
|
||||
|
||||
.local-repo-info {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.local-repo-info span {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.local-scan-empty {
|
||||
padding: 24px 12px;
|
||||
}
|
||||
|
||||
/* ── Empty state ──────────────────────────────────── */
|
||||
|
||||
+211
-18
@@ -9,6 +9,7 @@ import {
|
||||
runGitPull,
|
||||
runGitPush,
|
||||
runGitStatus,
|
||||
scanLocalRepos,
|
||||
testGiteaConnection,
|
||||
} from "./tauri-api.js";
|
||||
|
||||
@@ -34,6 +35,9 @@ const maxPreviewBytes = 256 * 1024;
|
||||
|
||||
const FOLDER_ICON = `<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path fill="#54aeff" d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"/></svg>`;
|
||||
const FILE_ICON = `<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path fill="#848d97" d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"/></svg>`;
|
||||
const LOCAL_REPO_ICON = `<svg width="20" height="20" viewBox="0 0 16 16" aria-hidden="true" fill="none"><rect x="1.5" y="3" width="13" height="8.5" rx="1.25" stroke="currentColor" stroke-width="1.3"/><path d="M6 13.75h4M8 11.5v2.25" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg>`;
|
||||
const BRANCH_ICON = `<svg width="18" height="18" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"/></svg>`;
|
||||
const SYNC_ICON = `<svg width="18" height="18" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7 7 0 0 1 14.95 7.16a.75.75 0 1 1-1.49.178A5.501 5.501 0 0 0 8 2.5ZM1.705 8.005a.75.75 0 0 1 .834.656 5.501 5.501 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7 7 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834Z"/></svg>`;
|
||||
|
||||
function uid() {
|
||||
return `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
||||
@@ -60,6 +64,24 @@ function parentPath(path = "") {
|
||||
return parts.join("/");
|
||||
}
|
||||
|
||||
function repoNameFromPath(path = "") {
|
||||
return path.split(/[/\\]/).filter(Boolean).pop() || path;
|
||||
}
|
||||
|
||||
function normalizeRemoteUrl(value = "") {
|
||||
return value.trim().replace(/\/+$/, "").replace(/\.git$/i, "").toLowerCase();
|
||||
}
|
||||
|
||||
function serverRepoRemoteUrls() {
|
||||
const urls = repositories.flatMap((repo) => [
|
||||
repo.clone_url,
|
||||
repo.ssh_url,
|
||||
repo.html_url,
|
||||
repo.original_url,
|
||||
]);
|
||||
return [...new Set(urls.map((url) => normalizeRemoteUrl(url || "")).filter(Boolean))];
|
||||
}
|
||||
|
||||
function languageForPath(path = "") {
|
||||
const extension = path.split(".").pop()?.toLowerCase();
|
||||
const names = {
|
||||
@@ -383,6 +405,46 @@ function repoCardTemplate(repo) {
|
||||
`;
|
||||
}
|
||||
|
||||
function localRepoScanTemplate() {
|
||||
const state = getState();
|
||||
const results = state.localRepoScanResults || [];
|
||||
|
||||
if (state.localRepoScanLoading) {
|
||||
return `<div class="viewer-loading">Scanning local folders for repositories from the selected Gitea server...</div>`;
|
||||
}
|
||||
|
||||
if (state.localRepoScanError) {
|
||||
return `<div class="viewer-error">${escapeHtml(state.localRepoScanError)}</div>`;
|
||||
}
|
||||
|
||||
if (!results.length) {
|
||||
return `<div class="empty-state local-scan-empty">
|
||||
<div>No local repositories scanned yet</div>
|
||||
<div class="muted">Only local repos with remotes from the selected Gitea server will be shown.</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
return `<div class="local-repo-list">
|
||||
${results
|
||||
.map(
|
||||
(repo) => `
|
||||
<article class="local-repo-card">
|
||||
<div class="local-repo-info">
|
||||
<strong>${escapeHtml(repo.name || repoNameFromPath(repo.path))}</strong>
|
||||
<span class="muted" title="${escapeHtml(repo.path)}">${escapeHtml(repo.path)}</span>
|
||||
${repo.matchedRemoteUrl ? `<span class="muted" title="${escapeHtml(repo.matchedRemoteUrl)}">Remote: ${escapeHtml(repo.matchedRemoteUrl)}</span>` : ""}
|
||||
</div>
|
||||
<div class="row wrap">
|
||||
<button class="use-scanned-repo-btn" data-repo-path="${escapeHtml(repo.path)}" data-repo-name="${escapeHtml(repo.name || repoNameFromPath(repo.path))}" type="button">Use</button>
|
||||
<button class="view-scanned-repo-btn primary-blue" data-repo-path="${escapeHtml(repo.path)}" data-repo-name="${escapeHtml(repo.name || repoNameFromPath(repo.path))}" type="button">View files</button>
|
||||
</div>
|
||||
</article>
|
||||
`
|
||||
)
|
||||
.join("")}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function breadcrumbTemplate(repoName, path = "") {
|
||||
const parts = path.split("/").filter(Boolean);
|
||||
const crumbs = [`<button class="viewer-crumb-btn" data-viewer-path="" type="button">${escapeHtml(repoName)}</button>`];
|
||||
@@ -525,7 +587,12 @@ function dashboardView() {
|
||||
<ul class="list">
|
||||
${state.settings.recentRepositories.length
|
||||
? state.settings.recentRepositories
|
||||
.map((path) => `<li class="recent-item" title="${escapeHtml(path)}">${escapeHtml(path.split(/[/\\]/).filter(Boolean).pop() || path)}</li>`)
|
||||
.map((path) => `
|
||||
<li>
|
||||
<button class="recent-item" data-recent-repo-path="${escapeHtml(path)}" type="button" title="${escapeHtml(path)}">
|
||||
${escapeHtml(repoNameFromPath(path))}
|
||||
</button>
|
||||
</li>`)
|
||||
.join("")
|
||||
: "<li class='muted'>No recent repositories.</li>"}
|
||||
</ul>
|
||||
@@ -544,6 +611,23 @@ function dashboardView() {
|
||||
|
||||
${activeMainTab === "repos" ? `
|
||||
<section class="panel stack">
|
||||
<div class="local-scan-panel stack">
|
||||
<div class="section-header">
|
||||
<div>
|
||||
<h4 class="title local-scan-title">Find local repositories</h4>
|
||||
<p class="subtitle">Shows only local repos that belong to the selected Gitea server.</p>
|
||||
</div>
|
||||
<button id="scan-local-repos-btn" class="primary" type="button" ${state.localRepoScanLoading ? "disabled" : ""}>
|
||||
${state.localRepoScanLoading ? "Scanning..." : "Scan for repos"}
|
||||
</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<input id="local-repo-scan-root-input" placeholder="Folder to scan, e.g. F:\\Repos" value="${escapeHtml(state.localRepoScanRootInput || state.settings.defaultCloneDirectory)}" />
|
||||
<input id="local-repo-path-input" placeholder="Or paste a repo path…" value="${escapeHtml(state.localRepoPathInput)}" />
|
||||
<button id="open-local-repo-btn" type="button">Open</button>
|
||||
</div>
|
||||
${localRepoScanTemplate()}
|
||||
</div>
|
||||
<div class="section-header">
|
||||
<h3 class="title">Repositories</h3>
|
||||
<span class="muted">${visibleRepos.length} shown</span>
|
||||
@@ -582,15 +666,48 @@ function dashboardView() {
|
||||
</div>`}
|
||||
</section>
|
||||
` : activeMainTab === "local" ? `
|
||||
<section class="panel stack">
|
||||
<h3 class="title">Local Repository</h3>
|
||||
<div class="row">
|
||||
<input id="local-repo-path-input" placeholder="Path to local repository…" value="${escapeHtml(state.localRepoPathInput)}" />
|
||||
<button id="open-local-repo-btn" type="button">Open</button>
|
||||
</div>
|
||||
<div class="gd-toolbar">
|
||||
${state.selectedRepoName
|
||||
? `<div class="selected-repo"><span class="label">Active: </span>${escapeHtml(state.selectedRepoName)}</div>`
|
||||
: ""}
|
||||
? `<button class="gd-toolbar-cell selected-repo-tab" type="button" title="${escapeHtml(state.selectedRepoPath)}">
|
||||
<span class="gd-cell-icon">${LOCAL_REPO_ICON}</span>
|
||||
<span class="gd-cell-copy">
|
||||
<span class="gd-cell-label">Current repository</span>
|
||||
<span class="gd-cell-value">${escapeHtml(state.selectedRepoName)}</span>
|
||||
</span>
|
||||
<svg class="gd-cell-caret" viewBox="0 0 16 16" width="10" height="10" aria-hidden="true"><path fill="currentColor" d="M4.427 7.427l3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"/></svg>
|
||||
</button>`
|
||||
: `<div class="gd-toolbar-cell gd-toolbar-cell-empty">
|
||||
<span class="gd-cell-icon">${LOCAL_REPO_ICON}</span>
|
||||
<span class="gd-cell-copy">
|
||||
<span class="gd-cell-label">Current repository</span>
|
||||
<span class="gd-cell-value gd-cell-value-muted">No repository selected</span>
|
||||
</span>
|
||||
</div>`}
|
||||
<button class="gd-toolbar-cell" type="button" disabled title="Branch switching coming soon">
|
||||
<span class="gd-cell-icon">${BRANCH_ICON}</span>
|
||||
<span class="gd-cell-copy">
|
||||
<span class="gd-cell-label">Current branch</span>
|
||||
<span class="gd-cell-value">${escapeHtml(state.selectedRepoName ? "main" : "—")}</span>
|
||||
</span>
|
||||
<svg class="gd-cell-caret" viewBox="0 0 16 16" width="10" height="10" aria-hidden="true"><path fill="currentColor" d="M4.427 7.427l3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"/></svg>
|
||||
</button>
|
||||
<button class="gd-toolbar-cell" id="git-pull-btn-toolbar" type="button" ${state.selectedRepoName ? "" : "disabled"}>
|
||||
<span class="gd-cell-icon">${SYNC_ICON}</span>
|
||||
<span class="gd-cell-copy">
|
||||
<span class="gd-cell-label">Fetch origin</span>
|
||||
<span class="gd-cell-value">Sync changes</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<section class="panel stack">
|
||||
<h3 class="title">${escapeHtml(state.selectedRepoName || "Local Repository")}</h3>
|
||||
${state.selectedRepoName
|
||||
? `<div class="muted selected-repo-path-line" title="${escapeHtml(state.selectedRepoPath)}">${escapeHtml(state.selectedRepoPath)}</div>`
|
||||
: `<div class="empty-state">
|
||||
<div>No repository selected</div>
|
||||
<div class="muted">Pick a repository from <strong>Recent repositories</strong> on the left, or scan for local repos on the <strong>Repositories</strong> tab.</div>
|
||||
</div>`}
|
||||
${state.selectedRepoName ? `
|
||||
<div class="row wrap">
|
||||
<button id="git-status-btn" type="button">Status</button>
|
||||
<button id="git-branch-btn" type="button">Branch</button>
|
||||
@@ -606,6 +723,7 @@ function dashboardView() {
|
||||
${gitOutput
|
||||
? `<pre class="git-output">${escapeHtml(gitOutput)}</pre>`
|
||||
: `<p class="muted git-output-placeholder">Run a git command to see output here.</p>`}
|
||||
` : ""}
|
||||
</section>
|
||||
` : viewerTemplate()}
|
||||
</main>
|
||||
@@ -810,6 +928,59 @@ async function autoLoadReadme() {
|
||||
}
|
||||
}
|
||||
|
||||
function selectLocalRepo(path, name = "") {
|
||||
const state = getState();
|
||||
state.localRepoPathInput = path;
|
||||
state.selectedRepoPath = path;
|
||||
state.selectedRepoName = name || repoNameFromPath(path);
|
||||
addRecentRepo(path);
|
||||
}
|
||||
|
||||
async function scanForLocalRepos() {
|
||||
const state = getState();
|
||||
const rootInput = document.getElementById("local-repo-scan-root-input")?.value?.trim() || "";
|
||||
state.localRepoScanRootInput = rootInput;
|
||||
|
||||
if (!getActiveServer()) {
|
||||
state.localRepoScanResults = [];
|
||||
state.localRepoScanError = "Select a Gitea server before scanning local repositories.";
|
||||
render();
|
||||
return;
|
||||
}
|
||||
|
||||
const allowedRemoteUrls = serverRepoRemoteUrls();
|
||||
if (!allowedRemoteUrls.length) {
|
||||
state.localRepoScanResults = [];
|
||||
state.localRepoScanError = "No repository clone URLs are loaded for the selected Gitea server. Refresh repositories and try again.";
|
||||
render();
|
||||
return;
|
||||
}
|
||||
|
||||
state.localRepoScanLoading = true;
|
||||
state.localRepoScanError = "";
|
||||
render();
|
||||
|
||||
const roots = [rootInput, state.settings.defaultCloneDirectory].filter(Boolean);
|
||||
try {
|
||||
state.localRepoScanResults = await scanLocalRepos(
|
||||
[...new Set(roots)],
|
||||
allowedRemoteUrls,
|
||||
state.settings.gitExecutablePath,
|
||||
4,
|
||||
200
|
||||
);
|
||||
if (!state.localRepoScanResults.length) {
|
||||
state.localRepoScanError = "No local repositories from the selected Gitea server were found in the scanned folders.";
|
||||
}
|
||||
} catch (error) {
|
||||
state.localRepoScanResults = [];
|
||||
state.localRepoScanError = `Repo scan failed: ${error.message}`;
|
||||
} finally {
|
||||
state.localRepoScanLoading = false;
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
async function loadViewerPath(path = "") {
|
||||
const state = getState();
|
||||
const viewer = state.viewer;
|
||||
@@ -1008,6 +1179,14 @@ function bindDashboardEvents() {
|
||||
render();
|
||||
});
|
||||
|
||||
document.querySelectorAll(".recent-item").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
selectLocalRepo(button.dataset.recentRepoPath || "");
|
||||
activeMainTab = "local";
|
||||
render();
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll("[data-right-tab]").forEach((btn) => {
|
||||
btn.addEventListener("click", () => {
|
||||
activeRightTab = btn.dataset.rightTab;
|
||||
@@ -1054,22 +1233,33 @@ function bindDashboardEvents() {
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById("scan-local-repos-btn")?.addEventListener("click", () => {
|
||||
scanForLocalRepos();
|
||||
});
|
||||
|
||||
document.querySelectorAll(".use-scanned-repo-btn").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
selectLocalRepo(button.dataset.repoPath || "", button.dataset.repoName || "");
|
||||
render();
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll(".view-scanned-repo-btn").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
selectLocalRepo(button.dataset.repoPath || "", button.dataset.repoName || "");
|
||||
openLocalViewer();
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById("open-local-repo-btn")?.addEventListener("click", () => {
|
||||
// MVP local detection is user-driven path entry; folder picker can be added next.
|
||||
const value = document.getElementById("local-repo-path-input")?.value?.trim() || "";
|
||||
state.localRepoPathInput = value;
|
||||
state.selectedRepoPath = value;
|
||||
state.selectedRepoName = value.split(/[/\\]/).filter(Boolean).pop() || value;
|
||||
addRecentRepo(value);
|
||||
selectLocalRepo(value);
|
||||
render();
|
||||
});
|
||||
|
||||
document.getElementById("view-local-repo-btn")?.addEventListener("click", () => {
|
||||
const value = document.getElementById("local-repo-path-input")?.value?.trim() || state.selectedRepoPath;
|
||||
state.localRepoPathInput = value;
|
||||
state.selectedRepoPath = value;
|
||||
state.selectedRepoName = value.split(/[/\\]/).filter(Boolean).pop() || value;
|
||||
if (value) addRecentRepo(value);
|
||||
if (value) selectLocalRepo(value);
|
||||
openLocalViewer();
|
||||
});
|
||||
|
||||
@@ -1106,6 +1296,9 @@ function bindDashboardEvents() {
|
||||
document.getElementById("git-pull-btn")?.addEventListener("click", () => {
|
||||
runRepoCommand("Pull", () => runGitPull(state.selectedRepoPath, state.settings.gitExecutablePath));
|
||||
});
|
||||
document.getElementById("git-pull-btn-toolbar")?.addEventListener("click", () => {
|
||||
runRepoCommand("Pull", () => runGitPull(state.selectedRepoPath, state.settings.gitExecutablePath));
|
||||
});
|
||||
document.getElementById("git-push-btn")?.addEventListener("click", () => {
|
||||
runRepoCommand("Push", () => runGitPush(state.selectedRepoPath, state.settings.gitExecutablePath));
|
||||
});
|
||||
|
||||
@@ -6,6 +6,10 @@ const state = {
|
||||
selectedRepoName: "",
|
||||
repoSearch: "",
|
||||
localRepoPathInput: "",
|
||||
localRepoScanRootInput: "",
|
||||
localRepoScanResults: [],
|
||||
localRepoScanLoading: false,
|
||||
localRepoScanError: "",
|
||||
cloneUrlInput: "",
|
||||
cloneDestinationInput: "",
|
||||
commitMessage: "",
|
||||
|
||||
@@ -35,6 +35,17 @@ export async function runGitBranch(repoPath, gitPath) {
|
||||
return invoke("git_branch", { repoPath, gitPath: gitPath || null });
|
||||
}
|
||||
|
||||
export async function scanLocalRepos(roots = [], allowedRemoteUrls = [], gitPath = "", maxDepth = 4, maxResults = 200) {
|
||||
ensureInvoke();
|
||||
return invoke("scan_local_repos", {
|
||||
roots,
|
||||
allowedRemoteUrls,
|
||||
gitPath: gitPath || null,
|
||||
maxDepth,
|
||||
maxResults,
|
||||
});
|
||||
}
|
||||
|
||||
export async function listLocalRepoBranches(repoPath, gitPath) {
|
||||
ensureInvoke();
|
||||
return invoke("local_repo_branches", { repoPath, gitPath: gitPath || null });
|
||||
|
||||
Reference in New Issue
Block a user