Skip to content

Commit

Permalink
feat: allow to disable daemon status component in a space
Browse files Browse the repository at this point in the history
  • Loading branch information
d1snin committed Aug 16, 2023
1 parent fa875fa commit 9aeaf14
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ package dev.d1s.beam.commons

public object MetadataKeys {

public object Ui {
public const val UI_SPACE_SHOW_STATUS: MetadataKey = "ui.space.show-status"

public object Block {

public const val ID: MetadataKey = "ui.block.id"
}
}
public const val UI_BLOCK_ID: MetadataKey = "ui.block.id"
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BlockComponent : Component<BlockComponent.Config>(::Config), KoinComponent
}

private fun SimplePanel.setOptionalBlockId(block: Block) {
val blockElementId = block.metadata[MetadataKeys.Ui.Block.ID]
val blockElementId = block.metadata[MetadataKeys.UI_BLOCK_ID]

blockElementId?.let {
if (it.isNotBlank() && !it.contains(" ")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,29 @@

package dev.d1s.beam.ui.component

import dev.d1s.beam.commons.MetadataKeys
import dev.d1s.beam.ui.Qualifier
import dev.d1s.beam.ui.state.CurrentSpaceChange
import dev.d1s.beam.ui.state.Observable
import dev.d1s.exkt.kvision.component.Component
import dev.d1s.exkt.kvision.component.render
import io.kvision.html.div
import io.kvision.panel.SimplePanel
import io.kvision.state.bind
import org.koin.core.component.KoinComponent
import org.koin.core.component.get
import org.koin.core.component.inject

class HeadingComponent : Component<Unit>(), KoinComponent {

private val currentSpaceChangeObservable by inject<Observable<CurrentSpaceChange>>(Qualifier.CurrentSpaceChangeObservable)

private val daemonStatusComponent by inject<Component<Unit>>(Qualifier.DaemonStatusComponent)

override fun SimplePanel.render() {
div(className = "container-fluid mt-3 mb-4 my-5 d-flex flex-column flex-lg-row justify-content-lg-between") {
renderSpaceHeading()

div(className = "align-self-center mt-5 mt-lg-0") {
render(daemonStatusComponent)
}
renderDaemonStatus()
}
}

Expand All @@ -47,4 +50,18 @@ class HeadingComponent : Component<Unit>(), KoinComponent {
includeDescription.value = true
}
}

private fun SimplePanel.renderDaemonStatus() {
div().bind(currentSpaceChangeObservable.state) {
val space = it.space

val showStatus = space?.metadata?.get(MetadataKeys.UI_SPACE_SHOW_STATUS)?.toBooleanStrictOrNull()

if (showStatus != false) {
div(className = "align-self-center mt-5 mt-lg-0") {
render(daemonStatusComponent)
}
}
}
}
}

0 comments on commit 9aeaf14

Please sign in to comment.