Migrate frontend to Svelte 5 runes semantics
This commit is contained in:
@@ -6,12 +6,12 @@
|
||||
@RELATION: CALLS -> gitService.getBranches
|
||||
@RELATION: CALLS -> gitService.checkoutBranch
|
||||
@RELATION: CALLS -> gitService.createBranch
|
||||
@RELATION: DISPATCHES -> change
|
||||
@RELATION: BINDS_TO -> onchange
|
||||
-->
|
||||
|
||||
<script>
|
||||
// [SECTION: IMPORTS]
|
||||
import { onMount, createEventDispatcher } from 'svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { gitService } from '../../services/gitService';
|
||||
import { addToast as toast } from '../../lib/toasts.js';
|
||||
import { t } from '../../lib/i18n';
|
||||
@@ -23,6 +23,7 @@
|
||||
dashboardId,
|
||||
envId = null,
|
||||
currentBranch = $bindable('main'),
|
||||
onchange = () => {},
|
||||
} = $props();
|
||||
|
||||
// [/SECTION]
|
||||
@@ -33,9 +34,6 @@
|
||||
let showCreate = $state(false);
|
||||
let newBranchName = $state('');
|
||||
// [/SECTION]
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
// [DEF:onMount:Function]
|
||||
/**
|
||||
* @purpose Load branches when component is mounted.
|
||||
@@ -83,14 +81,14 @@
|
||||
/**
|
||||
* @purpose Переключает текущую ветку.
|
||||
* @param {string} branchName - Имя ветки.
|
||||
* @post currentBranch обновлен, событие отправлено.
|
||||
* @post currentBranch обновлен, родительский callback вызван.
|
||||
*/
|
||||
async function handleCheckout(branchName) {
|
||||
console.log(`[BranchSelector][Action] Checking out branch ${branchName}`);
|
||||
try {
|
||||
await gitService.checkoutBranch(dashboardId, branchName, envId);
|
||||
currentBranch = branchName;
|
||||
dispatch('change', { branch: branchName });
|
||||
onchange({ branch: branchName });
|
||||
toast($t.git?.switched_to?.replace('{branch}', branchName), 'success');
|
||||
console.log(`[BranchSelector][Coherence:OK] Checked out ${branchName}`);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user