(msg tea.KeyMsg)
| 328 | } |
| 329 | |
| 330 | func (m authTabModel) handleEditInput(msg tea.KeyMsg) (authTabModel, tea.Cmd) { |
| 331 | switch msg.String() { |
| 332 | case "enter": |
| 333 | value := m.editInput.Value() |
| 334 | fieldKey := authEditableFields[m.editField].key |
| 335 | fileName := m.editFileName |
| 336 | m.editing = false |
| 337 | m.editInput.Blur() |
| 338 | fields := map[string]any{} |
| 339 | if fieldKey == "priority" { |
| 340 | p, err := strconv.Atoi(value) |
| 341 | if err != nil { |
| 342 | return m, func() tea.Msg { |
| 343 | return authActionMsg{err: fmt.Errorf("%s: %s", T("invalid_int"), value)} |
| 344 | } |
| 345 | } |
| 346 | fields[fieldKey] = p |
| 347 | } else { |
| 348 | fields[fieldKey] = value |
| 349 | } |
| 350 | return m, func() tea.Msg { |
| 351 | err := m.client.PatchAuthFileFields(fileName, fields) |
| 352 | if err != nil { |
| 353 | return authActionMsg{err: err} |
| 354 | } |
| 355 | return authActionMsg{action: fmt.Sprintf(T("updated_field"), fieldKey, fileName)} |
| 356 | } |
| 357 | case "esc": |
| 358 | m.editing = false |
| 359 | m.editInput.Blur() |
| 360 | m.viewport.SetContent(m.renderContent()) |
| 361 | return m, nil |
| 362 | default: |
| 363 | var cmd tea.Cmd |
| 364 | m.editInput, cmd = m.editInput.Update(msg) |
| 365 | m.viewport.SetContent(m.renderContent()) |
| 366 | return m, cmd |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | func (m authTabModel) handleConfirmInput(msg tea.KeyMsg) (authTabModel, tea.Cmd) { |
| 371 | switch msg.String() { |
no test coverage detected