Ver a proveniência

Tell admin that automated check failed when necessary

This keeps track when automated update check fails, and displays a
relevant message to the admin on /admin/updates

Ref T572
admin-dashboard-redesign
Matt Baer há 4 anos
ascendente
cometimento
37b7755c08
4 ficheiros alterados com 15 adições e 2 eliminações
  1. +2
    -0
      admin.go
  2. +5
    -0
      less/core.less
  3. +5
    -1
      templates/user/admin/app-updates.tmpl
  4. +3
    -1
      updates.go

+ 2
- 0
admin.go Ver ficheiro

@@ -612,6 +612,7 @@ func handleViewAdminUpdates(app *App, u *User, w http.ResponseWriter, r *http.Re
LatestVersion string
LatestReleaseURL string
LatestReleaseNotesURL string
CheckFailed bool
}{
UserPage: NewUserPage(app, r, u, "Updates", nil),
AdminPage: NewAdminPage(app),
@@ -624,6 +625,7 @@ func handleViewAdminUpdates(app *App, u *User, w http.ResponseWriter, r *http.Re
p.LatestReleaseURL = app.updates.ReleaseURL()
p.LatestReleaseNotesURL = app.updates.ReleaseNotesURL()
p.UpdateAvailable = app.updates.AreAvailable()
p.CheckFailed = app.updates.checkError != nil
}

showUserPage(w, "app-updates", p)


+ 5
- 0
less/core.less Ver ficheiro

@@ -1350,6 +1350,11 @@ div.row {
color: #71D571;
}

.ex.failure {
font-weight: bold;
color: @dangerCol;
}

@media all and (max-width: 450px) {
body#post {
header {


+ 5
- 1
templates/user/admin/app-updates.tmpl Ver ficheiro

@@ -15,7 +15,11 @@
{{template "admin-header" .}}

{{ if .UpdateChecks }}
{{if not .UpdateAvailable}}
{{if .CheckFailed}}
<p class="intro"><span class="ex failure">&times;</span> Automated update check failed.</p>
<p>Installed version: <strong>{{.Version}}</strong> (<a href="{{.CurReleaseNotesURL}}" target="changelog-wf">release notes</a>).</p>
<p>Learn about latest releases on the <a href="https://blog.writefreely.org/tag:release" target="changelog-wf">WriteFreely blog</a> or <a href="https://discuss.write.as/c/writefreely/updates" target="forum-wf">forum</a>.</p>
{{else if not .UpdateAvailable}}
<p class="intro"><span class="check">&check;</span> WriteFreely is <strong>up to date</strong>.</p>
<p>Installed version: <strong>{{.Version}}</strong> (<a href="{{.LatestReleaseNotesURL}}" target="changelog-wf">release notes</a>).</p>
{{else}}


+ 3
- 1
updates.go Ver ficheiro

@@ -30,6 +30,7 @@ type updatesCache struct {
lastCheck time.Time
latestVersion string
currentVersion string
checkError error
}

// CheckNow asks for the latest released version of writefreely and updates
@@ -38,11 +39,12 @@ type updatesCache struct {
func (uc *updatesCache) CheckNow() error {
uc.mu.Lock()
defer uc.mu.Unlock()
uc.lastCheck = time.Now()
latestRemote, err := newVersionCheck()
if err != nil {
uc.checkError = err
return err
}
uc.lastCheck = time.Now()
if CompareSemver(latestRemote, uc.latestVersion) == 1 {
uc.latestVersion = latestRemote
}


Carregando…
Cancelar
Guardar