Skip to content

Commit d40b760

Browse files
committed
feat(browser_database): fixed translation and navigation in database
Signed-off-by: olivier dubo <olivier.dubo@ovhcloud.com>
1 parent 1326294 commit d40b760

7 files changed

Lines changed: 264 additions & 251 deletions

File tree

internal/services/browser/api.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,16 +1290,16 @@ func (m Model) handleVolumeActionDone(msg volumeActionDoneMsg) (tea.Model, tea.C
12901290
func (m Model) executeGatewayDelete() tea.Cmd {
12911291
return func() tea.Msg {
12921292
if m.detailData == nil {
1293-
return gwDeletedMsg{err: fmt.Errorf("aucune gateway sélectionnée")}
1293+
return gwDeletedMsg{err: fmt.Errorf("no gateway selected")}
12941294
}
12951295
if m.cloudProject == "" {
1296-
return gwDeletedMsg{err: fmt.Errorf("aucun projet cloud sélectionné")}
1296+
return gwDeletedMsg{err: fmt.Errorf("no cloud project selected")}
12971297
}
12981298
gwID := getString(m.detailData, "id")
12991299
gwName := getString(m.detailData, "name")
13001300
region := getString(m.detailData, "region")
13011301
if gwID == "" || region == "" {
1302-
return gwDeletedMsg{err: fmt.Errorf("ID ou région de la gateway introuvable")}
1302+
return gwDeletedMsg{err: fmt.Errorf("gateway ID or region not found")}
13031303
}
13041304
endpoint := fmt.Sprintf("/v1/cloud/project/%s/region/%s/gateway/%s",
13051305
m.cloudProject, url.PathEscape(region), url.PathEscape(gwID))
@@ -1368,10 +1368,10 @@ func (m Model) fetchLBListeners(lbID, region string) tea.Cmd {
13681368
func (m Model) executeDeleteLBPool() tea.Cmd {
13691369
return func() tea.Msg {
13701370
if m.selectedLBPool == nil {
1371-
return lbPoolDeletedMsg{err: fmt.Errorf("aucun pool sélectionné")}
1371+
return lbPoolDeletedMsg{err: fmt.Errorf("no pool selected")}
13721372
}
13731373
if m.cloudProject == "" {
1374-
return lbPoolDeletedMsg{err: fmt.Errorf("aucun projet cloud sélectionné")}
1374+
return lbPoolDeletedMsg{err: fmt.Errorf("no cloud project selected")}
13751375
}
13761376
poolID := getStringValue(m.selectedLBPool, "id", "")
13771377
poolName := getStringValue(m.selectedLBPool, "name", "")
@@ -1425,7 +1425,7 @@ func (m Model) executeDeleteLBListener() tea.Cmd {
14251425
return lbListenerDeletedMsg{err: fmt.Errorf("no listener selected")}
14261426
}
14271427
if m.cloudProject == "" {
1428-
return lbListenerDeletedMsg{err: fmt.Errorf("aucun projet cloud sélectionné")}
1428+
return lbListenerDeletedMsg{err: fmt.Errorf("no cloud project selected")}
14291429
}
14301430
listenerID := getStringValue(m.selectedLBListener, "id", "")
14311431
listenerName := getStringValue(m.selectedLBListener, "name", "")
@@ -1497,19 +1497,19 @@ func (m Model) executeLBDelete() tea.Cmd {
14971497
func (m Model) executeInstanceBackupDelete() tea.Cmd {
14981498
return func() tea.Msg {
14991499
if m.detailData == nil {
1500-
return instanceBackupDeletedMsg{err: fmt.Errorf("aucun backup sélectionné")}
1500+
return instanceBackupDeletedMsg{err: fmt.Errorf("no backup selected")}
15011501
}
15021502
if m.cloudProject == "" {
1503-
return instanceBackupDeletedMsg{err: fmt.Errorf("aucun projet cloud sélectionné")}
1503+
return instanceBackupDeletedMsg{err: fmt.Errorf("no cloud project selected")}
15041504
}
15051505
snapshotID := getString(m.detailData, "id")
15061506
snapshotName := getString(m.detailData, "name")
15071507
if snapshotID == "" {
1508-
return instanceBackupDeletedMsg{err: fmt.Errorf("ID du backup introuvable")}
1508+
return instanceBackupDeletedMsg{err: fmt.Errorf("backup ID not found")}
15091509
}
15101510
endpoint := fmt.Sprintf("/v1/cloud/project/%s/snapshot/%s", m.cloudProject, url.PathEscape(snapshotID))
15111511
if err := httpLib.Client.Delete(endpoint, nil); err != nil {
1512-
return instanceBackupDeletedMsg{name: snapshotName, err: fmt.Errorf("échec de la suppression: %w", err)}
1512+
return instanceBackupDeletedMsg{name: snapshotName, err: fmt.Errorf("deletion failed: %w", err)}
15131513
}
15141514
return instanceBackupDeletedMsg{name: snapshotName}
15151515
}
@@ -1519,21 +1519,21 @@ func (m Model) executeInstanceBackupDelete() tea.Cmd {
15191519
func (m Model) executeWorkflowDelete() tea.Cmd {
15201520
return func() tea.Msg {
15211521
if m.detailData == nil {
1522-
return workflowDeletedMsg{err: fmt.Errorf("aucun workflow sélectionné")}
1522+
return workflowDeletedMsg{err: fmt.Errorf("no workflow selected")}
15231523
}
15241524
if m.cloudProject == "" {
1525-
return workflowDeletedMsg{err: fmt.Errorf("aucun projet cloud sélectionné")}
1525+
return workflowDeletedMsg{err: fmt.Errorf("no cloud project selected")}
15261526
}
15271527
wfID := getString(m.detailData, "id")
15281528
wfName := getString(m.detailData, "name")
15291529
region := getString(m.detailData, "region")
15301530
if wfID == "" || region == "" {
1531-
return workflowDeletedMsg{err: fmt.Errorf("ID ou région du workflow introuvable")}
1531+
return workflowDeletedMsg{err: fmt.Errorf("workflow ID or region not found")}
15321532
}
15331533
endpoint := fmt.Sprintf("/v1/cloud/project/%s/region/%s/workflow/backup/%s",
15341534
m.cloudProject, url.PathEscape(region), url.PathEscape(wfID))
15351535
if err := httpLib.Client.Delete(endpoint, nil); err != nil {
1536-
return workflowDeletedMsg{name: wfName, err: fmt.Errorf("échec de la suppression: %w", err)}
1536+
return workflowDeletedMsg{name: wfName, err: fmt.Errorf("deletion failed: %w", err)}
15371537
}
15381538
return workflowDeletedMsg{name: wfName}
15391539
}
@@ -1543,18 +1543,18 @@ func (m Model) executeWorkflowDelete() tea.Cmd {
15431543
func (m Model) executePrivNetworkDelete() tea.Cmd {
15441544
return func() tea.Msg {
15451545
if m.detailData == nil {
1546-
return privNetDeletedMsg{err: fmt.Errorf("aucun réseau sélectionné")}
1546+
return privNetDeletedMsg{err: fmt.Errorf("no network selected")}
15471547
}
15481548
networkName := getString(m.detailData, "name")
15491549
if m.cloudProject == "" {
1550-
return privNetDeletedMsg{err: fmt.Errorf("aucun projet cloud sélectionné")}
1550+
return privNetDeletedMsg{err: fmt.Errorf("no cloud project selected")}
15511551
}
15521552

15531553
// The region-based API uses openstackId, not the vRack pn-XXXXX_N id.
15541554
// Each network has regions[].{region, openstackId} — delete from all regions.
15551555
regions, ok := m.detailData["regions"].([]interface{})
15561556
if !ok || len(regions) == 0 {
1557-
return privNetDeletedMsg{networkName: networkName, err: fmt.Errorf("aucune région trouvée pour ce réseau")}
1557+
return privNetDeletedMsg{networkName: networkName, err: fmt.Errorf("no region found for this network")}
15581558
}
15591559

15601560
var lastErr error
@@ -1577,7 +1577,7 @@ func (m Model) executePrivNetworkDelete() tea.Cmd {
15771577
errMsg := err.Error()
15781578
if strings.Contains(errMsg, "409") || strings.Contains(errMsg, "Conflict") || strings.Contains(errMsg, "ports still in use") || strings.Contains(errMsg, "ports") {
15791579
return privNetDeletedMsg{networkName: networkName, err: fmt.Errorf(
1580-
"impossible de supprimer le réseau : des ressources y sont encore attachées (instances, gateway, routeur). Détachez-les d'abord puis réessayez",
1580+
"cannot delete the network: resources are still attached (instances, gateway, router). Detach them first and try again",
15811581
)}
15821582
}
15831583
lastErr = err
@@ -1870,10 +1870,10 @@ func (m Model) fetchFIPInstances() tea.Cmd {
18701870
func (m Model) createStandaloneFloatingIP() tea.Cmd {
18711871
return func() tea.Msg {
18721872
if m.cloudProject == "" {
1873-
return fipCreatedMsg{err: fmt.Errorf("aucun projet cloud sélectionné")}
1873+
return fipCreatedMsg{err: fmt.Errorf("no cloud project selected")}
18741874
}
18751875
if m.wizard.fipInstanceId == "" {
1876-
return fipCreatedMsg{err: fmt.Errorf("veuillez sélectionner une instance pour créer une Floating IP")}
1876+
return fipCreatedMsg{err: fmt.Errorf("please select an instance to create a Floating IP")}
18771877
}
18781878

18791879
// Find the private IPv4 of the selected instance — required by the API.
@@ -1899,7 +1899,7 @@ func (m Model) createStandaloneFloatingIP() tea.Cmd {
18991899
}
19001900
}
19011901
if privateIP == "" {
1902-
return fipCreatedMsg{err: fmt.Errorf("aucune adresse IP privée trouvée pour cette instance")}
1902+
return fipCreatedMsg{err: fmt.Errorf("no private IP address found for this instance")}
19031903
}
19041904

19051905
endpoint := fmt.Sprintf("/v1/cloud/project/%s/region/%s/instance/%s/floatingIp",
@@ -1921,7 +1921,7 @@ func (m Model) createStandaloneFloatingIP() tea.Cmd {
19211921
err = httpLib.Client.Post(endpoint, bodyWithGW, &result)
19221922
}
19231923
if err != nil {
1924-
return fipCreatedMsg{err: fmt.Errorf("échec de la création: %w", err)}
1924+
return fipCreatedMsg{err: fmt.Errorf("creation failed: %w", err)}
19251925
}
19261926
return fipCreatedMsg{floatingIP: result}
19271927
}
@@ -2115,21 +2115,21 @@ func (m Model) executeSubnetDelete() tea.Cmd {
21152115
func (m Model) executeFIPDelete() tea.Cmd {
21162116
return func() tea.Msg {
21172117
if m.detailData == nil {
2118-
return fipDeletedMsg{err: fmt.Errorf("aucune Floating IP sélectionnée")}
2118+
return fipDeletedMsg{err: fmt.Errorf("no Floating IP selected")}
21192119
}
21202120
if m.cloudProject == "" {
2121-
return fipDeletedMsg{err: fmt.Errorf("aucun projet cloud sélectionné")}
2121+
return fipDeletedMsg{err: fmt.Errorf("no cloud project selected")}
21222122
}
21232123
fipID := getString(m.detailData, "id")
21242124
fipIP := getString(m.detailData, "ip")
21252125
region := getString(m.detailData, "region")
21262126
if fipID == "" || region == "" {
2127-
return fipDeletedMsg{err: fmt.Errorf("ID ou région de la Floating IP introuvable")}
2127+
return fipDeletedMsg{err: fmt.Errorf("Floating IP ID or region not found")}
21282128
}
21292129
endpoint := fmt.Sprintf("/v1/cloud/project/%s/region/%s/floatingip/%s",
21302130
m.cloudProject, url.PathEscape(region), url.PathEscape(fipID))
21312131
if err := httpLib.Client.Delete(endpoint, nil); err != nil && !strings.Contains(err.Error(), "404") && !strings.Contains(err.Error(), "NotFound") {
2132-
return fipDeletedMsg{fipIP: fipIP, err: fmt.Errorf("échec de la suppression: %w", err)}
2132+
return fipDeletedMsg{fipIP: fipIP, err: fmt.Errorf("deletion failed: %w", err)}
21332133
}
21342134
return fipDeletedMsg{fipIP: fipIP}
21352135
}
@@ -2139,21 +2139,21 @@ func (m Model) executeFIPDelete() tea.Cmd {
21392139
func (m Model) executeFIPDetach() tea.Cmd {
21402140
return func() tea.Msg {
21412141
if m.detailData == nil {
2142-
return fipDetachedMsg{err: fmt.Errorf("aucune Floating IP sélectionnée")}
2142+
return fipDetachedMsg{err: fmt.Errorf("no Floating IP selected")}
21432143
}
21442144
if m.cloudProject == "" {
2145-
return fipDetachedMsg{err: fmt.Errorf("aucun projet cloud sélectionné")}
2145+
return fipDetachedMsg{err: fmt.Errorf("no cloud project selected")}
21462146
}
21472147
fipID := getString(m.detailData, "id")
21482148
fipIP := getString(m.detailData, "ip")
21492149
region := getString(m.detailData, "region")
21502150
if fipID == "" || region == "" {
2151-
return fipDetachedMsg{err: fmt.Errorf("ID ou région de la Floating IP introuvable")}
2151+
return fipDetachedMsg{err: fmt.Errorf("Floating IP ID or region not found")}
21522152
}
21532153
endpoint := fmt.Sprintf("/v1/cloud/project/%s/region/%s/floatingip/%s/detach",
21542154
m.cloudProject, url.PathEscape(region), url.PathEscape(fipID))
21552155
if err := httpLib.Client.Post(endpoint, nil, nil); err != nil {
2156-
return fipDetachedMsg{fipIP: fipIP, err: fmt.Errorf("échec du détachement: %w", err)}
2156+
return fipDetachedMsg{fipIP: fipIP, err: fmt.Errorf("detachment failed: %w", err)}
21572157
}
21582158
return fipDetachedMsg{fipIP: fipIP}
21592159
}

internal/services/browser/floating_ip_wizard.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ func (m Model) renderFIPWizardRegionStep(width int) string {
5656
}
5757
if len(m.wizard.fipAvailableRegions) > maxVisible {
5858
content.WriteString(lipgloss.NewStyle().Foreground(lipgloss.Color("#666666")).
59-
Render(fmt.Sprintf("\n %d / %d régions", m.wizard.fipRegionIdx+1, len(m.wizard.fipAvailableRegions))))
59+
Render(fmt.Sprintf("\n %d / %d regions", m.wizard.fipRegionIdx+1, len(m.wizard.fipAvailableRegions))))
6060
}
6161
}
6262

6363
content.WriteString("\n" + lipgloss.NewStyle().Foreground(lipgloss.Color("#666666")).
64-
Render("↑↓ Naviguer • Enter : Sélectionner • Esc : Annuler"))
64+
Render("↑↓ Navigate • Enter: Select • Esc: Cancel"))
6565
return content.String()
6666
}
6767

0 commit comments

Comments
 (0)