refactor: centralize remaining error paths and popout strings via formatError + getStrings (final polish pass)

This commit is contained in:
Vybe (Coding Agent) 2026-05-22 10:20:47 +00:00
parent 2b3b45ccfa
commit 740bc81cea

View file

@ -35,8 +35,8 @@ PluginComponent {
onExited: (code, status) => { onExited: (code, status) => {
if (code !== 0) { if (code !== 0) {
var action = root.isConnected ? "disconnect" : "connect" var action = root.isConnected ? "disconnect" : "connect"
var detail = toggleProcess.stderr.text.trim().slice(0, 120) var detail = toggleProcess.stderr.text.trim()
ToastService.showError("tailscalectl", TailscaleLib.errorMessage(action) + (detail ? " — " + detail : "")) ToastService.showError("tailscalectl", TailscaleLib.formatError(action, detail))
} }
statusCheck.running = true statusCheck.running = true
} }
@ -68,8 +68,8 @@ PluginComponent {
onExited: (code, status) => { onExited: (code, status) => {
if (code !== 0) { if (code !== 0) {
var detail = exitNodeProcess.stderr.text.trim().slice(0, 120) var detail = exitNodeProcess.stderr.text.trim()
ToastService.showError("tailscalectl", TailscaleLib.errorMessage("set") + (detail ? " — " + detail : "")) ToastService.showError("tailscalectl", TailscaleLib.formatError("set", detail))
} }
statusCheck.running = true statusCheck.running = true
} }
@ -94,7 +94,7 @@ PluginComponent {
root.tailscaleIP = "" root.tailscaleIP = ""
root.currentExitNode = "" root.currentExitNode = ""
root.peers = [] root.peers = []
ToastService.showError("tailscalectl", TailscaleLib.errorMessage("status")) ToastService.showError("tailscalectl", TailscaleLib.formatError("status"))
} }
// Post-action verification: if a toggle was requested, use the fresh state we just received. // Post-action verification: if a toggle was requested, use the fresh state we just received.
@ -137,7 +137,7 @@ PluginComponent {
popoutContent: Component { popoutContent: Component {
PopoutComponent { PopoutComponent {
headerText: "Tailscale" headerText: "Tailscale"
detailsText: root.isConnected ? "Connected" : "Disconnected" detailsText: root.isConnected ? TailscaleLib.getStrings().connected : TailscaleLib.getStrings().disconnected
showCloseButton: true showCloseButton: true
Item { Item {
@ -184,7 +184,7 @@ PluginComponent {
Item { width: 1; height: 1; Layout.fillWidth: true } Item { width: 1; height: 1; Layout.fillWidth: true }
StyledText { StyledText {
text: "Exit node: " + (root.currentExitNode || "None") text: TailscaleLib.getStrings().exitNodePrefix + (root.currentExitNode || TailscaleLib.getStrings().none)
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText color: Theme.surfaceVariantText
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter