mirror of
https://github.com/open-webui/computer.git
synced 2026-11-29 16:35:22 -05:00
refac
This commit is contained in:
1 parent
422c051544
commit
acd4285dc9
3 files changed
+42
-2
No files matched your search
@@ -55,11 +55,11 @@
|
|||||||
const allStaged = $derived(totalChanges > 0 && unstagedFiles.length === 0);
|
const allStaged = $derived(totalChanges > 0 && unstagedFiles.length === 0);
|
||||||
const someStaged = $derived(stagedFiles.length > 0 && unstagedFiles.length > 0);
|
const someStaged = $derived(stagedFiles.length > 0 && unstagedFiles.length > 0);
|
||||||
|
|
||||||
// Read from centralized store instead of independent polling
|
|
||||||
let gitStatus = $derived(gitStatusStore.status as {
|
let gitStatus = $derived(gitStatusStore.status as {
|
||||||
is_repo: boolean;
|
is_repo: boolean;
|
||||||
branch: string;
|
branch: string;
|
||||||
upstream: string;
|
upstream: string;
|
||||||
|
remote_url: string;
|
||||||
ahead: number;
|
ahead: number;
|
||||||
behind: number;
|
behind: number;
|
||||||
files: GitFile[];
|
files: GitFile[];
|
||||||
@@ -69,6 +69,25 @@
|
|||||||
const needsPublish = $derived(!gitStatus?.upstream);
|
const needsPublish = $derived(!gitStatus?.upstream);
|
||||||
const unpushedCount = $derived(needsPublish ? (commits?.length ?? 0) : (gitStatus?.ahead ?? 0));
|
const unpushedCount = $derived(needsPublish ? (commits?.length ?? 0) : (gitStatus?.ahead ?? 0));
|
||||||
|
|
||||||
|
// Convert git remote URL to browser URL
|
||||||
|
const remoteWebUrl = $derived.by(() => {
|
||||||
|
const url = gitStatus?.remote_url;
|
||||||
|
if (!url) return '';
|
||||||
|
// SSH: git@github.com:user/repo.git
|
||||||
|
const sshMatch = url.match(/^git@([^:]+):(.+?)(\.git)?$/);
|
||||||
|
if (sshMatch) return `https://${sshMatch[1]}/${sshMatch[2]}`;
|
||||||
|
// HTTPS: https://github.com/user/repo.git
|
||||||
|
return url.replace(/\.git$/, '');
|
||||||
|
});
|
||||||
|
|
||||||
|
const remotePlatform = $derived.by(() => {
|
||||||
|
if (!remoteWebUrl) return '';
|
||||||
|
if (remoteWebUrl.includes('github.com')) return 'GitHub';
|
||||||
|
if (remoteWebUrl.includes('gitlab.com') || remoteWebUrl.includes('gitlab')) return 'GitLab';
|
||||||
|
if (remoteWebUrl.includes('bitbucket')) return 'Bitbucket';
|
||||||
|
try { return new URL(remoteWebUrl).hostname; } catch { return 'Remote'; }
|
||||||
|
});
|
||||||
|
|
||||||
// Clear stale selection when file is no longer in the changed list
|
// Clear stale selection when file is no longer in the changed list
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (view === 'changes' && selectedFile) {
|
if (view === 'changes' && selectedFile) {
|
||||||
@@ -605,6 +624,19 @@
|
|||||||
|
|
||||||
<div class="flex-1"></div>
|
<div class="flex-1"></div>
|
||||||
|
|
||||||
|
<!-- View on remote -->
|
||||||
|
{#if remoteWebUrl}
|
||||||
|
<a
|
||||||
|
href={remoteWebUrl}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
class="flex items-center justify-center w-6 h-6 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/6 transition-colors duration-75"
|
||||||
|
use:tooltip={'View on ' + remotePlatform}
|
||||||
|
>
|
||||||
|
<Icon name="external-link" size={12} />
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<!-- Maximize toggle -->
|
<!-- Maximize toggle -->
|
||||||
<button
|
<button
|
||||||
class="flex items-center justify-center w-6 h-6 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/6 transition-colors duration-75"
|
class="flex items-center justify-center w-6 h-6 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/6 transition-colors duration-75"
|
||||||
@@ -875,7 +907,7 @@
|
|||||||
>{$t('git.selectFile')}</span
|
>{$t('git.selectFile')}</span
|
||||||
>
|
>
|
||||||
{:else}
|
{:else}
|
||||||
<span class="text-[11px] text-gray-400 dark:text-gray-600"
|
<span class="text-[11px] text-gray-400 dark:text-gray-600 font-sans"
|
||||||
>{$t('git.noLocalChanges')}</span
|
>{$t('git.noLocalChanges')}</span
|
||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export interface GitStatus {
|
|||||||
is_repo: boolean;
|
is_repo: boolean;
|
||||||
branch: string;
|
branch: string;
|
||||||
upstream?: string;
|
upstream?: string;
|
||||||
|
remote_url?: string;
|
||||||
ahead: number;
|
ahead: number;
|
||||||
behind: number;
|
behind: number;
|
||||||
files: GitFile[];
|
files: GitFile[];
|
||||||
|
|||||||
@@ -117,9 +117,16 @@ async def status(root: str) -> dict[str, Any]:
|
|||||||
if upstream and not has_ab:
|
if upstream and not has_ab:
|
||||||
upstream = ""
|
upstream = ""
|
||||||
|
|
||||||
|
# Get remote URL for "View on GitHub/GitLab" link
|
||||||
|
code, remote_out, _ = await _run(
|
||||||
|
"remote", "get-url", "origin", cwd=root, check=False
|
||||||
|
)
|
||||||
|
remote_url = remote_out.strip() if code == 0 else ""
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"branch": branch,
|
"branch": branch,
|
||||||
"upstream": upstream,
|
"upstream": upstream,
|
||||||
|
"remote_url": remote_url,
|
||||||
"ahead": ahead,
|
"ahead": ahead,
|
||||||
"behind": behind,
|
"behind": behind,
|
||||||
"files": files,
|
"files": files,
|
||||||
|
|||||||
Reference in new issue
Block a user