346f8536f0
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.
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
import { loadSettings, saveSettings } from "./storage.js";
|
|
|
|
const state = {
|
|
settings: loadSettings(),
|
|
selectedRepoPath: "",
|
|
selectedRepoName: "",
|
|
repoSearch: "",
|
|
localRepoPathInput: "",
|
|
localRepoScanRootInput: "",
|
|
localRepoScanResults: [],
|
|
localRepoScanLoading: false,
|
|
localRepoScanError: "",
|
|
cloneUrlInput: "",
|
|
cloneDestinationInput: "",
|
|
commitMessage: "",
|
|
viewer: {
|
|
source: "",
|
|
repoName: "",
|
|
repoPath: "",
|
|
cloneUrl: "",
|
|
defaultBranch: "",
|
|
branch: "",
|
|
branches: [],
|
|
path: "",
|
|
entries: [],
|
|
selectedFile: null,
|
|
readmeFile: null,
|
|
loading: false,
|
|
error: "",
|
|
},
|
|
};
|
|
|
|
export function getState() {
|
|
return state;
|
|
}
|
|
|
|
export function setSettings(nextSettings) {
|
|
state.settings = nextSettings;
|
|
saveSettings(state.settings);
|
|
}
|
|
|
|
export function updateSettings(patch) {
|
|
setSettings({ ...state.settings, ...patch });
|
|
}
|
|
|
|
export function addRecentRepo(path) {
|
|
if (!path) return;
|
|
const current = state.settings.recentRepositories.filter((item) => item !== path);
|
|
const next = [path, ...current].slice(0, 15);
|
|
updateSettings({ recentRepositories: next });
|
|
}
|
|
|
|
export function getActiveServer() {
|
|
const { activeServerId, servers } = state.settings;
|
|
return servers.find((server) => server.id === activeServerId) ?? null;
|
|
}
|