MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / Render

Method Render

internal/tui/branch_warning.go:223–276  ·  view source on GitHub ↗

Render renders the branch warning dialog.

()

Source from the content-addressed store, hash-verified

221
222// Render renders the branch warning dialog.
223func (b *BranchWarning) Render() string {
224 // Modal dimensions
225 modalWidth := min(65, b.width-10)
226 modalHeight := min(20, b.height-6)
227
228 if modalWidth < 40 {
229 modalWidth = 40
230 }
231 if modalHeight < 14 {
232 modalHeight = 14
233 }
234
235 // Build modal content
236 var content strings.Builder
237
238 // Title and message based on context
239 b.renderHeader(&content, modalWidth)
240
241 // Branch name (shown when any option involves a branch)
242 b.renderBranchName(&content)
243
244 // Options
245 b.renderOptions(&content)
246
247 // Footer
248 content.WriteString("\n")
249 content.WriteString(DividerStyle.Render(strings.Repeat("─", modalWidth-4)))
250 content.WriteString("\n")
251
252 footerStyle := lipgloss.NewStyle().Foreground(MutedColor)
253 if b.editMode {
254 content.WriteString(footerStyle.Render("Enter: confirm Esc: cancel edit"))
255 } else {
256 content.WriteString(footerStyle.Render("↑/↓: Navigate Enter: Select e: Edit branch Esc: Cancel"))
257 }
258
259 // Modal box style - use warning color for protected branch, primary for others
260 borderColor := PrimaryColor
261 if b.context == DialogProtectedBranch {
262 borderColor = WarningColor
263 }
264
265 modalStyle := lipgloss.NewStyle().
266 Border(lipgloss.RoundedBorder()).
267 BorderForeground(borderColor).
268 Padding(1, 2).
269 Width(modalWidth).
270 Height(modalHeight)
271
272 modal := modalStyle.Render(content.String())
273
274 // Center the modal on screen
275 return b.centerModal(modal)
276}
277
278// renderHeader renders the dialog title and message.
279func (b *BranchWarning) renderHeader(content *strings.Builder, modalWidth int) {

Callers 4

TestBranchWarningRenderFunction · 0.95
renderHeaderMethod · 0.45
renderBranchNameMethod · 0.45
renderOptionsMethod · 0.45

Calls 6

renderHeaderMethod · 0.95
renderBranchNameMethod · 0.95
renderOptionsMethod · 0.95
centerModalMethod · 0.95
minFunction · 0.85
StringMethod · 0.45

Tested by 1

TestBranchWarningRenderFunction · 0.76