chore: commit remaining workspace changes

This commit is contained in:
2026-03-03 19:51:17 +03:00
parent 8406628360
commit a9c0d55ec8
17 changed files with 1679 additions and 580 deletions

View File

@@ -32,7 +32,6 @@
import { addToast } from "$lib/toasts.js";
import Icon from "$lib/ui/Icon.svelte";
import BranchSelector from "../../../components/git/BranchSelector.svelte";
import CommitModal from "../../../components/git/CommitModal.svelte";
import CommitHistory from "../../../components/git/CommitHistory.svelte";
import GitManager from "../../../components/git/GitManager.svelte";
@@ -66,7 +65,6 @@
let isPushingGit = false;
let currentBranch = "main";
let activeTab = "resources";
let showCommitModal = false;
let showGitManager = false;
let gitMeta = getGitStatusMeta();
@@ -308,7 +306,32 @@
function hasGitRepository() {
if (!gitStatus) return false;
if (gitStatus.has_repo === false) return false;
return gitStatus.sync_state !== "NO_REPO" && Boolean(gitStatus.current_branch);
return gitStatus.sync_state !== "NO_REPO" || Boolean(gitStatus.current_branch);
}
function resolveGitSyncState() {
if (!gitStatus || gitStatus.has_repo === false) return "NO_REPO";
const explicitState = String(gitStatus.sync_state || "").toUpperCase();
const changedCount =
(gitStatus?.modified_files?.length || 0) +
(gitStatus?.staged_files?.length || 0) +
(gitStatus?.untracked_files?.length || 0);
const ahead = Number(gitStatus?.ahead_count || 0);
const behind = Number(gitStatus?.behind_count || 0);
if (
explicitState &&
explicitState !== "UNKNOWN" &&
explicitState !== "NO_REPO"
) {
return explicitState;
}
if (changedCount > 0) return "CHANGES";
if (ahead > 0 && behind > 0) return "DIVERGED";
if (ahead > 0) return "AHEAD_REMOTE";
if (behind > 0) return "BEHIND_REMOTE";
if (gitStatus?.current_branch) return "SYNCED";
return "NO_REPO";
}
function allChangedFiles() {
@@ -326,7 +349,7 @@
}
function getGitStatusMeta() {
const syncState = gitStatus?.sync_state || "NO_REPO";
const syncState = resolveGitSyncState();
if (syncState === "SYNCED") {
return {
dotClass: "bg-emerald-500",
@@ -429,7 +452,7 @@
try {
await gitService.sync(gitDashboardRef, envId || null, envId || null);
addToast($t.git?.sync_success || "Dashboard state synced to Git", "success");
showCommitModal = true;
showGitManager = true;
await loadGitStatus();
} catch (err) {
addToast(err.message || "Git sync failed", "error");
@@ -474,6 +497,10 @@
}
$: gitMeta = getGitStatusMeta();
$: gitSyncState = resolveGitSyncState();
$: changedChartsCount = countChangedByAnyPath(["/charts/", "charts/"]);
$: changedDatasetsCount = countChangedByAnyPath(["/datasets/", "datasets/"]);
$: hasChangesToCommit = allChangedFiles().length > 0;
</script>
<div class="mx-auto w-full max-w-7xl space-y-6">
@@ -665,25 +692,33 @@
{gitStatusError}
</div>
{:else if !hasGitRepository()}
<div class="rounded-lg border border-slate-200 bg-slate-50 px-3 py-6 text-sm text-slate-600">
{$t.git?.not_linked || "This dashboard is not yet linked to a Git repository."}
<div class="space-y-3 rounded-lg border border-slate-200 bg-slate-50 px-3 py-6 text-sm text-slate-600">
<div>
{$t.git?.not_linked || "Этот дашборд еще не привязан к Git-репозиторию."}
</div>
<button
class="inline-flex items-center justify-center rounded-lg bg-slate-900 px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-slate-800"
on:click={() => (showGitManager = true)}
>
Инициализировать Git-репозиторий
</button>
</div>
{:else}
<div class="space-y-4">
<p class="text-sm text-slate-700">
{#if gitStatus?.sync_state === "CHANGES"}
Superset configuration changes were detected.
{#if gitSyncState === "CHANGES"}
Обнаружены изменения конфигурации в Superset.
{:else}
Superset configuration matches branch {gitStatus?.current_branch || "main"}.
Конфигурация Superset совпадает с веткой {gitStatus?.current_branch || "main"}.
{/if}
</p>
<div class="flex flex-wrap gap-2 text-xs text-slate-600">
<span class="rounded-full bg-slate-100 px-2 py-1">
charts: {countChangedByAnyPath(["/charts/", "charts/"])}
charts: {changedChartsCount}
</span>
<span class="rounded-full bg-slate-100 px-2 py-1">
datasets: {countChangedByAnyPath(["/datasets/", "datasets/"])}
datasets: {changedDatasetsCount}
</span>
<span class="rounded-full bg-slate-100 px-2 py-1">
files: {allChangedFiles().length}
@@ -694,18 +729,18 @@
<button
class="inline-flex items-center justify-center rounded-lg bg-blue-600 px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:opacity-60"
on:click={runGitSyncAndOpenCommit}
disabled={isSyncingGit}
disabled={isSyncingGit || !hasChangesToCommit}
>
{isSyncingGit
? $t.common?.loading || "Loading..."
: "Sync and commit"}
: "Синхронизировать и зафиксировать"}
</button>
<button
class="inline-flex items-center justify-center rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50 disabled:opacity-60"
on:click={loadGitDiffPreview}
disabled={isGitDiffLoading}
disabled={isGitDiffLoading || !hasChangesToCommit}
>
{isGitDiffLoading ? $t.common?.loading || "Loading..." : "View diff"}
{isGitDiffLoading ? $t.common?.loading || "Loading..." : "Показать diff"}
</button>
</div>
@@ -992,16 +1027,7 @@
{/if}
</div>
{#if gitDashboardRef}
<CommitModal
dashboardId={gitDashboardRef}
envId={envId || null}
bind:show={showCommitModal}
on:commit={loadGitStatus}
/>
{/if}
{#if gitDashboardRef}
{#if showGitManager && gitDashboardRef}
<GitManager
dashboardId={gitDashboardRef}
envId={envId || null}