diff --git a/src/sidebar/git-panel.js b/src/sidebar/git-panel.js new file mode 100644 index 0000000..7582929 --- /dev/null +++ b/src/sidebar/git-panel.js @@ -0,0 +1,84 @@ +function renderGitPanel(container, { gitStatus, gitDiff, gitStage, gitCommit, gitLog }) { + container.innerHTML = ` +
Loading...
+${status.error}
`; + return; + } + + const files = [ + ...status.modified.map(f => ({ file: f, status: 'M', color: '#f59e0b' })), + ...status.not_added.map(f => ({ file: f, status: '?', color: '#6b7280' })), + ...status.created.map(f => ({ file: f, status: 'A', color: '#10b981' })), + ...status.deleted.map(f => ({ file: f, status: 'D', color: '#ef4444' })), + ...status.staged.map(f => ({ file: f, status: 'S', color: '#3b82f6' })), + ]; + + if (files.length === 0) { + changesEl.innerHTML = 'No changes
'; + } else { + changesEl.innerHTML = files.map(f => ` +No commits
'; + } + } + + document.getElementById('git-commit-btn')?.addEventListener('click', async () => { + const msg = document.getElementById('git-commit-msg')?.value?.trim(); + if (!msg) return; + await gitCommit(msg); + document.getElementById('git-commit-msg').value = ''; + loadGitStatus(); + }); +} + +module.exports = { renderGitPanel };