Merge pull request #294 from jesseduffield/no-monitoring-prompt

This commit is contained in:
Jesse Duffield 2022-01-12 23:18:06 +11:00 committed by GitHub
commit 0d825a49c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 16 additions and 77 deletions

View file

@ -43,11 +43,11 @@ jobs:
# matrix build jobs run on every commit
# building on versioned Go and the latest one
# '<<: *' syntax is a YAML thing for including documents
"golang:1.12":
"golang:1.17":
<<: *env-shared
<<: *build-shared
docker:
- image: circleci/golang:1.12
- image: circleci/golang:1.17
"golang:latest":
<<: *env-shared
<<: *build-shared
@ -57,7 +57,7 @@ jobs:
release:
<<: *env-shared
docker:
- image: circleci/golang:1.12
- image: circleci/golang:1.17
steps:
- checkout
#- run:
@ -88,7 +88,7 @@ workflows:
build:
jobs:
# build matrix
- "golang:1.12"
- "golang:1.17"
- "golang:latest"
release:
jobs:

View file

@ -27,7 +27,6 @@ gui:
- blue
returnImmediately: false
wrapMainPanel: false
reporting: undetermined
commandTemplates:
dockerCompose: docker-compose
restartService: '{{ .DockerCompose }} restart {{ .Service.Name }}'

View file

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package commands

View file

@ -29,12 +29,6 @@ type UserConfig struct {
// hide things
Gui GuiConfig `yaml:"gui,omitempty"`
// Reporting determines whether events are reported such as errors (and maybe
// application opens but I'm not decided on that yet because it sounds kinda
// creepy but I also would love to know how many people are using this
// program)
Reporting string `yaml:"reporting,omitempty"`
// ConfirmOnQuit when enabled prompts you to confirm you want to quit when you
// hit esc or q when no confirmation panels are open
ConfirmOnQuit bool `yaml:"confirmOnQuit,omitempty"`
@ -326,7 +320,6 @@ func GetDefaultConfig() UserConfig {
ReturnImmediately: false,
WrapMainPanel: false,
},
Reporting: "undetermined",
ConfirmOnQuit: false,
CommandTemplates: CommandTemplatesConfig{
DockerCompose: "docker-compose",

View file

@ -60,9 +60,9 @@ func TestWritingToConfigFile(t *testing.T) {
t.Fatalf("Unexpected error: %s", err)
}
testFn := func(ac *AppConfig, newReportingValue string, t *testing.T) {
testFn := func(ac *AppConfig, newValue bool, t *testing.T) {
updateFn := func(uc *UserConfig) error {
uc.Reporting = newReportingValue
uc.ConfirmOnQuit = newValue
return nil
}
@ -87,14 +87,14 @@ func TestWritingToConfigFile(t *testing.T) {
t.Fatalf("Unexpected error: %s", err)
}
if sampleUC.Reporting != newReportingValue {
t.Fatalf("Got %s, Expected %s\n", sampleUC.Reporting, newReportingValue)
if sampleUC.ConfirmOnQuit != newValue {
t.Fatalf("Got %v, Expected %v\n", sampleUC.ConfirmOnQuit, newValue)
}
}
// insert value into an empty file
testFn(conf, "on", t)
testFn(conf, true, t)
// modifying an existing file that already has 'Reporting'
testFn(conf, "off", t)
// modifying an existing file that already has 'ConfirmOnQuit'
testFn(conf, false, t)
}

View file

@ -1,3 +1,4 @@
//go:build !windows && !linux
// +build !windows,!linux
package config

View file

@ -8,7 +8,6 @@ package gui
import (
"strings"
"time"
"github.com/fatih/color"
"github.com/jesseduffield/gocui"
@ -151,16 +150,6 @@ func (gui *Gui) setKeyBindings(g *gocui.Gui, handleConfirm, handleClose func(*go
// this function is to be used over the more generic createErrorPanel, with
// willLog set to false
func (gui *Gui) createSpecificErrorPanel(message string, nextView *gocui.View, willLog bool) error {
if willLog {
go func() {
// when reporting is switched on this log call sometimes introduces
// a delay on the error panel popping up. Here I'm adding a second wait
// so that the error is logged while the user is reading the error message
time.Sleep(time.Second)
gui.Log.Error(message)
}()
}
colorFunction := color.New(color.FgRed).SprintFunc()
coloredMessage := colorFunction(strings.TrimSpace(message))
return gui.createConfirmationPanel(gui.g, nextView, gui.Tr.ErrorTitle, coloredMessage, nil, nil)

View file

@ -1,10 +1,11 @@
package gui
import (
"github.com/golang-collections/collections/stack"
"strings"
"sync"
"github.com/golang-collections/collections/stack"
// "io"
// "io/ioutil"
@ -187,33 +188,9 @@ func (gui *Gui) loadNewDirectory() error {
return err
}
if gui.Config.UserConfig.Reporting == "undetermined" {
if err := gui.promptAnonymousReporting(); err != nil {
return err
}
}
return nil
}
func (gui *Gui) promptAnonymousReporting() error {
return gui.createConfirmationPanel(gui.g, nil, gui.Tr.AnonymousReportingTitle, gui.Tr.AnonymousReportingPrompt, func(g *gocui.Gui, v *gocui.View) error {
gui.waitForIntro.Done()
// setting the value here explicitly so that we don't re-request after coming back from a subprocess. The proper solution would be to reload the config but that's tricky because it's loaded at the very top level
gui.Config.UserConfig.Reporting = "on"
return gui.Config.WriteToUserConfig(func(userConfig *config.UserConfig) error {
userConfig.Reporting = "on"
return nil
})
}, func(g *gocui.Gui, v *gocui.View) error {
gui.waitForIntro.Done()
gui.Config.UserConfig.Reporting = "off"
return gui.Config.WriteToUserConfig(func(userConfig *config.UserConfig) error {
userConfig.Reporting = "off"
return nil
})
})
}
func (gui *Gui) renderGlobalOptions() error {
return gui.renderOptionsMap(map[string]string{
"PgUp/PgDn": gui.Tr.Scroll,
@ -261,11 +238,7 @@ func (gui *Gui) Run() error {
return err
}
if gui.Config.UserConfig.Reporting == "undetermined" {
gui.waitForIntro.Add(2)
} else {
gui.waitForIntro.Add(1)
}
gui.waitForIntro.Add(1)
dockerRefreshInterval := gui.Config.UserConfig.Update.DockerRefreshInterval
go func() {

View file

@ -52,9 +52,6 @@ func dutchSet() TranslationSet {
ViewRestartOptions: "bekijk herstart opties",
RunCustomCommand: "draai een vooraf bedacht aangepaste opdracht",
AnonymousReportingTitle: "Help mee met lazydocker beter maken",
AnonymousReportingPrompt: "Zou je anonieme data rapportage willen aanzetten om lazydocker beter te kunnen maken?",
GlobalTitle: "Globaal",
MainTitle: "Hoofd",
ProjectTitle: "Project",

View file

@ -16,8 +16,6 @@ type TranslationSet struct {
NoViewMachingNewLineFocusedSwitchStatement string
OpenConfig string
EditConfig string
AnonymousReportingTitle string
AnonymousReportingPrompt string
ConfirmQuit string
ErrorOccurred string
ConnectionFailed string
@ -155,9 +153,6 @@ func englishSet() TranslationSet {
ViewBulkCommands: "view bulk commands",
OpenInBrowser: "open in browser (first port is http)",
AnonymousReportingTitle: "Help make lazydocker better",
AnonymousReportingPrompt: "Would you like to enable anonymous reporting data to help improve lazydocker?",
GlobalTitle: "Global",
MainTitle: "Main",
ProjectTitle: "Project",

View file

@ -51,9 +51,6 @@ func germanSet() TranslationSet {
ViewRestartOptions: "zeige Neustartoptionen",
RunCustomCommand: "führe vordefinierten benutzerdefinierten Befehl aus",
AnonymousReportingTitle: "Mache dabei mit lazydocker besser zu machen",
AnonymousReportingPrompt: "Möchtest du anonymisierte Datensammlung erlauben, um dabei zu helfen lazydocker zu verbessern?",
GlobalTitle: "Global",
MainTitle: "Haupt",
ProjectTitle: "Projekt",

View file

@ -51,9 +51,6 @@ func polishSet() TranslationSet {
ViewRestartOptions: "pokaż opcje restartu",
RunCustomCommand: "wykonaj predefiniowaną własną komende",
AnonymousReportingTitle: "Pomóż czynić lazydocker lepszym",
AnonymousReportingPrompt: "Czy zechciałbyś włączyć anonimowe raportowanie danych w celu ulepszania programu?",
GlobalTitle: "Globalne",
MainTitle: "Główne",
ProjectTitle: "Projekt",

View file

@ -51,9 +51,6 @@ func turkishSet() TranslationSet {
ViewRestartOptions: "yeniden başlatma seçeneklerini görüntüle",
RunCustomCommand: "önceden tanımlanmış özel komutu çalıştır",
AnonymousReportingTitle: "lazydocker' ı daha iyi hale getirmeye yardımcı olun",
AnonymousReportingPrompt: "lazydocker'ın geliştirilmesine yardımcı olmak için anonim raporlama verilerini etkinleştirmek ister misiniz?",
GlobalTitle: "Global",
MainTitle: "Ana",
ProjectTitle: "Proje",