Skip to content

Commit 782eb8d

Browse files
committed
Use our new hyperlink support in the information view
1 parent 1f8709e commit 782eb8d

File tree

3 files changed

+4
-29
lines changed

3 files changed

+4
-29
lines changed

pkg/gui/information_panel.go

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ func (gui *Gui) informationStr() string {
1414
}
1515

1616
if gui.g.Mouse {
17-
donate := style.FgMagenta.SetUnderline().Sprint(gui.c.Tr.Donate)
18-
askQuestion := style.FgYellow.SetUnderline().Sprint(gui.c.Tr.AskQuestion)
17+
donate := style.FgMagenta.Sprint(style.PrintHyperlink(gui.c.Tr.Donate, constants.Links.Donate))
18+
askQuestion := style.FgYellow.Sprint(style.PrintHyperlink(gui.c.Tr.AskQuestion, constants.Links.Discussions))
1919
return fmt.Sprintf("%s %s %s", donate, askQuestion, gui.Config.GetVersion())
2020
} else {
2121
return gui.Config.GetVersion()
@@ -39,28 +39,5 @@ func (gui *Gui) handleInfoClick() error {
3939
return activeMode.Reset()
4040
}
4141

42-
var title, url string
43-
44-
// if we're not in an active mode we show the donate button
45-
if cx <= utils.StringWidth(gui.c.Tr.Donate) {
46-
url = constants.Links.Donate
47-
title = gui.c.Tr.Donate
48-
} else if cx <= utils.StringWidth(gui.c.Tr.Donate)+1+utils.StringWidth(gui.c.Tr.AskQuestion) {
49-
url = constants.Links.Discussions
50-
title = gui.c.Tr.AskQuestion
51-
}
52-
err := gui.os.OpenLink(url)
53-
if err != nil {
54-
// Opening the link via the OS failed for some reason. (For example, this
55-
// can happen if the `os.openLink` config key references a command that
56-
// doesn't exist, or that errors when called.)
57-
//
58-
// In that case, rather than crash the app, fall back to simply showing a
59-
// dialog asking the user to visit the URL.
60-
placeholders := map[string]string{"url": url}
61-
message := utils.ResolvePlaceholderString(gui.c.Tr.PleaseGoToURL, placeholders)
62-
return gui.c.Alert(title, message)
63-
}
64-
6542
return nil
6643
}

pkg/i18n/english.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,6 @@ type TranslationSet struct {
783783
MarkAsBaseCommitTooltip string
784784
MarkedCommitMarker string
785785
FailedToOpenURL string
786-
PleaseGoToURL string
787786
NoCopiedCommits string
788787
DisabledMenuItemPrefix string
789788
QuickStartInteractiveRebase string
@@ -1764,7 +1763,6 @@ func EnglishTranslationSet() *TranslationSet {
17641763
MarkAsBaseCommitTooltip: "Select a base commit for the next rebase. When you rebase onto a branch, only commits above the base commit will be brought across. This uses the `git rebase --onto` command.",
17651764
MarkedCommitMarker: "↑↑↑ Will rebase from here ↑↑↑",
17661765
FailedToOpenURL: "Failed to open URL %s\n\nError: %v",
1767-
PleaseGoToURL: "Please go to {{.url}}",
17681766
DisabledMenuItemPrefix: "Disabled: ",
17691767
NoCopiedCommits: "No copied commits",
17701768
QuickStartInteractiveRebase: "Start interactive rebase",

pkg/integration/tests/ui/open_link_failure.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ var OpenLinkFailure = NewIntegrationTest(NewIntegrationTestArgs{
1717
t.Views().Information().Click(0, 0)
1818

1919
t.ExpectPopup().Confirmation().
20-
Title(Equals("Donate")).
21-
Content(Equals("Please go to https://github.com/sponsors/jesseduffield")).
20+
Title(Equals("Error")).
21+
Content(Equals("Failed to open URL https://github.com/sponsors/jesseduffield\n\nError: exit status 42")).
2222
Confirm()
2323
},
2424
})

0 commit comments

Comments
 (0)