mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
Use our new hyperlink support in the information view
This commit is contained in:
parent
b411897a5a
commit
bbd779b437
3 changed files with 4 additions and 29 deletions
|
@ -14,8 +14,8 @@ func (gui *Gui) informationStr() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
if gui.g.Mouse {
|
if gui.g.Mouse {
|
||||||
donate := style.FgMagenta.SetUnderline().Sprint(gui.c.Tr.Donate)
|
donate := style.FgMagenta.Sprint(style.PrintHyperlink(gui.c.Tr.Donate, constants.Links.Donate))
|
||||||
askQuestion := style.FgYellow.SetUnderline().Sprint(gui.c.Tr.AskQuestion)
|
askQuestion := style.FgYellow.Sprint(style.PrintHyperlink(gui.c.Tr.AskQuestion, constants.Links.Discussions))
|
||||||
return fmt.Sprintf("%s %s %s", donate, askQuestion, gui.Config.GetVersion())
|
return fmt.Sprintf("%s %s %s", donate, askQuestion, gui.Config.GetVersion())
|
||||||
} else {
|
} else {
|
||||||
return gui.Config.GetVersion()
|
return gui.Config.GetVersion()
|
||||||
|
@ -39,28 +39,5 @@ func (gui *Gui) handleInfoClick() error {
|
||||||
return activeMode.Reset()
|
return activeMode.Reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
var title, url string
|
|
||||||
|
|
||||||
// if we're not in an active mode we show the donate button
|
|
||||||
if cx <= utils.StringWidth(gui.c.Tr.Donate) {
|
|
||||||
url = constants.Links.Donate
|
|
||||||
title = gui.c.Tr.Donate
|
|
||||||
} else if cx <= utils.StringWidth(gui.c.Tr.Donate)+1+utils.StringWidth(gui.c.Tr.AskQuestion) {
|
|
||||||
url = constants.Links.Discussions
|
|
||||||
title = gui.c.Tr.AskQuestion
|
|
||||||
}
|
|
||||||
err := gui.os.OpenLink(url)
|
|
||||||
if err != nil {
|
|
||||||
// Opening the link via the OS failed for some reason. (For example, this
|
|
||||||
// can happen if the `os.openLink` config key references a command that
|
|
||||||
// doesn't exist, or that errors when called.)
|
|
||||||
//
|
|
||||||
// In that case, rather than crash the app, fall back to simply showing a
|
|
||||||
// dialog asking the user to visit the URL.
|
|
||||||
placeholders := map[string]string{"url": url}
|
|
||||||
message := utils.ResolvePlaceholderString(gui.c.Tr.PleaseGoToURL, placeholders)
|
|
||||||
return gui.c.Alert(title, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -785,7 +785,6 @@ type TranslationSet struct {
|
||||||
MarkAsBaseCommitTooltip string
|
MarkAsBaseCommitTooltip string
|
||||||
MarkedCommitMarker string
|
MarkedCommitMarker string
|
||||||
FailedToOpenURL string
|
FailedToOpenURL string
|
||||||
PleaseGoToURL string
|
|
||||||
InvalidLazygitEditURL string
|
InvalidLazygitEditURL string
|
||||||
NoCopiedCommits string
|
NoCopiedCommits string
|
||||||
DisabledMenuItemPrefix string
|
DisabledMenuItemPrefix string
|
||||||
|
@ -1773,7 +1772,6 @@ func EnglishTranslationSet() *TranslationSet {
|
||||||
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.",
|
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.",
|
||||||
MarkedCommitMarker: "↑↑↑ Will rebase from here ↑↑↑",
|
MarkedCommitMarker: "↑↑↑ Will rebase from here ↑↑↑",
|
||||||
FailedToOpenURL: "Failed to open URL %s\n\nError: %v",
|
FailedToOpenURL: "Failed to open URL %s\n\nError: %v",
|
||||||
PleaseGoToURL: "Please go to {{.url}}",
|
|
||||||
InvalidLazygitEditURL: "Invalid lazygit-edit URL format: %s",
|
InvalidLazygitEditURL: "Invalid lazygit-edit URL format: %s",
|
||||||
DisabledMenuItemPrefix: "Disabled: ",
|
DisabledMenuItemPrefix: "Disabled: ",
|
||||||
NoCopiedCommits: "No copied commits",
|
NoCopiedCommits: "No copied commits",
|
||||||
|
|
|
@ -17,8 +17,8 @@ var OpenLinkFailure = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
t.Views().Information().Click(0, 0)
|
t.Views().Information().Click(0, 0)
|
||||||
|
|
||||||
t.ExpectPopup().Confirmation().
|
t.ExpectPopup().Confirmation().
|
||||||
Title(Equals("Donate")).
|
Title(Equals("Error")).
|
||||||
Content(Equals("Please go to https://github.com/sponsors/jesseduffield")).
|
Content(Equals("Failed to open URL https://github.com/sponsors/jesseduffield\n\nError: exit status 42")).
|
||||||
Confirm()
|
Confirm()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue