Skip to content

Commit

Permalink
UI - Hide 'Logout' button when auth is disabled (#922)
Browse files Browse the repository at this point in the history
  • Loading branch information
nablaone authored Oct 28, 2024
1 parent f1dcf02 commit 898d937
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions quesma/quesma/ui/console_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (qmc *QuesmaManagementConsole) createRouting() *mux.Router {
if qmc.cfg.Elasticsearch.User == "" && qmc.cfg.Elasticsearch.Password == "" {
logger.Warn().Msg("admin console authentication is disabled")
} else {
qmc.isAuthEnabled = true
authenticatedRoutes.Use(authMiddleware)
}

Expand Down
2 changes: 1 addition & 1 deletion quesma/quesma/ui/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

func (qmc *QuesmaManagementConsole) generateDashboard() []byte {
buffer := newBufferWithHead()
buffer.Write(generateTopNavigation("dashboard"))
buffer.Write(qmc.generateTopNavigation("dashboard"))

buffer.Html(`<main id="dashboard-main">` + "\n")

Expand Down
2 changes: 1 addition & 1 deletion quesma/quesma/ui/data_sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func (qmc *QuesmaManagementConsole) generateDatasourcesPage() []byte {
buffer := newBufferWithHead()
buffer.Write(generateTopNavigation("data-sources"))
buffer.Write(qmc.generateTopNavigation("data-sources"))

buffer.Html(`<main id="data-sources">`)
buffer.Write(qmc.generateDatasources())
Expand Down
8 changes: 6 additions & 2 deletions quesma/quesma/ui/html_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func generateSimpleTop(title string) []byte {
return buffer.Bytes()
}

func generateTopNavigation(target string) []byte {
func (qmc *QuesmaManagementConsole) generateTopNavigation(target string) []byte {
var buffer builder.HtmlBuffer
buffer.Html(`<div class="topnav">` + "\n")
buffer.Html(`<div class="topnav-menu">` + "\n")
Expand Down Expand Up @@ -76,7 +76,11 @@ func generateTopNavigation(target string) []byte {
buffer.Html(` class="active"`)
}
buffer.Html(`><a href="/data-sources">Data sources</a></li>`)
buffer.Html(`<li><a href="/logout">Logout</a></li>`)

if qmc.isAuthEnabled {
buffer.Html(`<li><a href="/logout">Logout</a></li>`)
}

buffer.Html("\n</ul>\n")
buffer.Html("\n</div>\n")

Expand Down
2 changes: 1 addition & 1 deletion quesma/quesma/ui/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func (qmc *QuesmaManagementConsole) generateIngestStatistics() []byte {
buffer := newBufferWithHead()
buffer.Write(generateTopNavigation("statistics"))
buffer.Write(qmc.generateTopNavigation("statistics"))

buffer.Html(`<main id="statistics">`)
buffer.Write(qmc.generateStatistics())
Expand Down
2 changes: 1 addition & 1 deletion quesma/quesma/ui/live_tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

func (qmc *QuesmaManagementConsole) generateLiveTail() []byte {
buffer := newBufferWithHead()
buffer.Write(generateTopNavigation("queries"))
buffer.Write(qmc.generateTopNavigation("queries"))

// This preserves scrolling, but does not work if new queries appear.
buffer.Html(`<script>
Expand Down
2 changes: 2 additions & 0 deletions quesma/quesma/ui/management_console.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ type (
schemasProvider SchemasProvider
totalUnsupportedQueries int
tableResolver table_resolver.TableResolver

isAuthEnabled bool
}
SchemasProvider interface {
AllSchemas() map[schema.TableName]schema.Schema
Expand Down
2 changes: 1 addition & 1 deletion quesma/quesma/ui/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func (qmc *QuesmaManagementConsole) generateRouterStatisticsLiveTail() []byte {
buffer := newBufferWithHead()
buffer.Write(generateTopNavigation("routing-statistics"))
buffer.Write(qmc.generateTopNavigation("routing-statistics"))

buffer.Html(`<main id="routing-statistics">`)
buffer.Write(qmc.generateRouterStatistics())
Expand Down
2 changes: 1 addition & 1 deletion quesma/quesma/ui/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func (qmc *QuesmaManagementConsole) generateSchemas() []byte {
buffer := newBufferWithHead()
buffer.Write(generateTopNavigation("schemas"))
buffer.Write(qmc.generateTopNavigation("schemas"))
buffer.Html(`<main id="schemas">`)

schemas := qmc.schemasProvider.AllSchemas()
Expand Down
2 changes: 1 addition & 1 deletion quesma/quesma/ui/table_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func (qmc *QuesmaManagementConsole) generateTableResolver() []byte {

buffer := newBufferWithHead()
buffer.Write(generateTopNavigation("table_resolver"))
buffer.Write(qmc.generateTopNavigation("table_resolver"))

buffer.Html(`<main id="table_resolver">`)

Expand Down
4 changes: 2 additions & 2 deletions quesma/quesma/ui/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

func (qmc *QuesmaManagementConsole) generateQuesmaAllLogs() []byte {
buffer := newBufferWithHead()
buffer.Write(generateTopNavigation("tables"))
buffer.Write(qmc.generateTopNavigation("tables"))
buffer.Html(`<main id="quesma_all_logs">`)

var schema clickhouse.TableMap
Expand Down Expand Up @@ -182,7 +182,7 @@ func (qmc *QuesmaManagementConsole) generateTables() []byte {
}

buffer := newBufferWithHead()
buffer.Write(generateTopNavigation("tables"))
buffer.Write(qmc.generateTopNavigation("tables"))
buffer.Html(`<main id="tables">`)

var schema clickhouse.TableMap
Expand Down
2 changes: 1 addition & 1 deletion quesma/quesma/ui/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func (qmc *QuesmaManagementConsole) generateTelemetry() []byte {
buffer := newBufferWithHead()
buffer.Write(generateTopNavigation("telemetry"))
buffer.Write(qmc.generateTopNavigation("telemetry"))
buffer.Html(`<main id="telemetry">`)

buffer.Html(`<h2>Telemetry</h2>`)
Expand Down

0 comments on commit 898d937

Please sign in to comment.