fix: Bug that caused duplicate links (eg Diagnostics and Logs) in the nav bar (#595)

This commit is contained in:
James Read 2025-05-31 20:20:37 +01:00 committed by GitHub
parent 74f0930dcc
commit 7110399d41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 34 additions and 29 deletions

View File

@ -5,8 +5,8 @@ package executor
import ( import (
"context" "context"
"os/exec"
"os" "os"
"os/exec"
) )
func (e *Executor) Kill(execReq *InternalLogEntry) error { func (e *Executor) Kill(execReq *InternalLogEntry) error {

View File

@ -99,6 +99,7 @@ func cdToExecutableDir() {
} }
} }
//gocyclo:ignore
func startServiceHandler(mode string) { func startServiceHandler(mode string) {
cdToExecutableDir() cdToExecutableDir()

View File

@ -2,10 +2,10 @@ package updatecheck
import ( import (
"encoding/json" "encoding/json"
"github.com/Masterminds/semver"
config "github.com/OliveTin/OliveTin/internal/config" config "github.com/OliveTin/OliveTin/internal/config"
"github.com/OliveTin/OliveTin/internal/installationinfo" "github.com/OliveTin/OliveTin/internal/installationinfo"
"github.com/robfig/cron/v3" "github.com/robfig/cron/v3"
"github.com/Masterminds/semver"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"io" "io"
"net/http" "net/http"

View File

@ -1,8 +1,8 @@
package updatecheck package updatecheck
import ( import (
"testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"testing"
) )
func TestVersionLater(t *testing.T) { func TestVersionLater(t *testing.T) {

View File

@ -1,33 +1,37 @@
export class NavigationBar { export class NavigationBar {
constructor() { constructor () {
this.navbar = document.getElementsByTagName('nav')[0] this.navbar = document.getElementsByTagName('nav')[0]
this.mainLinks = document.getElementById('navigation-links') this.mainLinks = document.getElementById('navigation-links')
this.supplementalLinks = document.getElementById('supplemental-links') this.supplementalLinks = document.getElementById('supplemental-links')
} }
createLink(title, url, isSupplemental) { createLink (title, url, isSupplemental) {
const linkA = document.createElement('a') let parent = (isSupplemental) ? this.supplementalLinks : this.mainLinks
linkA.href = url
linkA.innerText = title
const navigationLi = document.createElement('li') const existsAlready = Array.from(parent.querySelectorAll('li')).some(el => el.title === title)
navigationLi.appendChild(linkA)
navigationLi.title = title
if (isSupplemental) { if (existsAlready) {
this.supplementalLinks.appendChild(navigationLi) return
} else { }
this.mainLinks.appendChild(navigationLi)
}
}
refreshSectionPolicyLinks(policy) { const linkA = document.createElement('a')
if (policy.showDiagnostics) { linkA.href = url
this.createLink('Diagnostics', '/diagnostics', true) linkA.innerText = title
}
if (policy.showLogList) { const navigationLi = document.createElement('li')
this.createLink('Logs', '/logs', true) navigationLi.appendChild(linkA)
} navigationLi.title = title
}
parent.appendChild(navigationLi)
}
refreshSectionPolicyLinks (policy) {
if (policy.showDiagnostics) {
this.createLink('Diagnostics', '/diagnostics', true)
}
if (policy.showLogList) {
this.createLink('Logs', '/logs', true)
}
}
} }