Fix git/storage workflows: repos-only page, default dev branch, robust pull/push, and storage path resolution
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
dashboardId,
|
||||
envId = null,
|
||||
dashboardTitle = '',
|
||||
show = false,
|
||||
show = $bindable(false),
|
||||
} = $props();
|
||||
// [/SECTION]
|
||||
|
||||
@@ -59,6 +59,8 @@
|
||||
let workspaceLoading = $state(false);
|
||||
let isPulling = $state(false);
|
||||
let isPushing = $state(false);
|
||||
let autoPushAfterCommit = $state(true);
|
||||
let repositoryProvider = $state('');
|
||||
// [/SECTION]
|
||||
|
||||
const hasWorkspaceChanges = $derived.by(() => {
|
||||
@@ -277,7 +279,12 @@
|
||||
committing = true;
|
||||
try {
|
||||
await gitService.commit(dashboardId, commitMessage, [], envId);
|
||||
toast($t.git?.commit_success || 'Коммит успешно создан', 'success');
|
||||
if (autoPushAfterCommit) {
|
||||
await gitService.push(dashboardId, envId);
|
||||
toast($t.git?.commit_and_push_success || 'Коммит создан и отправлен в remote', 'success');
|
||||
} else {
|
||||
toast($t.git?.commit_success || 'Коммит успешно создан', 'success');
|
||||
}
|
||||
commitMessage = '';
|
||||
await loadWorkspace();
|
||||
} catch (e) {
|
||||
@@ -420,6 +427,20 @@
|
||||
}
|
||||
// [/DEF:resolveDefaultConfig:Function]
|
||||
|
||||
// [DEF:resolvePushProviderLabel:Function]
|
||||
/**
|
||||
* @purpose Resolve lower-case provider label for auto-push checkbox.
|
||||
* @post Returns provider label, fallback "git".
|
||||
*/
|
||||
function resolvePushProviderLabel() {
|
||||
const selectedConfig = getSelectedConfig() || resolveDefaultConfig(configs);
|
||||
const provider = String(selectedConfig?.provider || repositoryProvider || '')
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
return provider || 'git';
|
||||
}
|
||||
// [/DEF:resolvePushProviderLabel:Function]
|
||||
|
||||
// [DEF:buildSuggestedRepoName:Function]
|
||||
/**
|
||||
* @purpose Build deterministic repository name from dashboard title/id.
|
||||
@@ -490,6 +511,8 @@
|
||||
await gitService.initRepository(dashboardId, selectedConfigId, remoteUrl, envId);
|
||||
toast($t.git?.init_success || 'Репозиторий инициализирован', 'success');
|
||||
initialized = true;
|
||||
const selectedConfig = getSelectedConfig();
|
||||
repositoryProvider = selectedConfig?.provider || repositoryProvider;
|
||||
await loadWorkspace();
|
||||
} catch (e) {
|
||||
toast(e.message, 'error');
|
||||
@@ -522,7 +545,25 @@
|
||||
// [/DEF:handleBackdropClick:Function]
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
configs = await gitService.getConfigs();
|
||||
const defaultConfig = resolveDefaultConfig(configs);
|
||||
if (defaultConfig?.id) selectedConfigId = defaultConfig.id;
|
||||
} catch (_e) {
|
||||
configs = [];
|
||||
}
|
||||
|
||||
await Promise.all([checkStatus(), loadCurrentEnvironmentStage()]);
|
||||
|
||||
if (initialized) {
|
||||
try {
|
||||
const binding = await gitService.getRepositoryBinding(dashboardId, envId);
|
||||
repositoryProvider = binding?.provider || '';
|
||||
if (binding?.config_id) selectedConfigId = String(binding.config_id);
|
||||
} catch (_e) {
|
||||
repositoryProvider = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -676,6 +717,10 @@
|
||||
>
|
||||
Зафиксировать (Commit)
|
||||
</Button>
|
||||
<label class="flex items-center gap-2 text-xs text-slate-600">
|
||||
<input type="checkbox" bind:checked={autoPushAfterCommit} />
|
||||
{$t.git?.auto_push_after_commit || 'Сделать push после commit в'} {resolvePushProviderLabel()}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="flex min-h-[420px] flex-col overflow-hidden rounded-lg border border-slate-200 bg-slate-50">
|
||||
|
||||
Reference in New Issue
Block a user