Skip to content

Commit

Permalink
feat: allow metadata modification on root space
Browse files Browse the repository at this point in the history
  • Loading branch information
d1snin committed Aug 16, 2023
1 parent 146dc46 commit fa875fa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ internal annotation class BuilderDsl
@BuilderDsl
public class RootSpaceModificationBuilder {

private var metadata: Metadata = metadataOf()

private var view: ViewConfiguration? = null

public fun view(build: ViewConfigurationBuilder.() -> Unit) {
Expand All @@ -32,6 +34,7 @@ public class RootSpaceModificationBuilder {

internal fun build() =
RootSpaceModification(
metadata,
view ?: error("View is undefined")
)
}
Expand All @@ -41,7 +44,7 @@ public class SpaceModificationBuilder {

public var slug: SpaceSlug? = null

public var metadata: Metadata? = null
public var metadata: Metadata = metadataOf()

private var view: ViewConfiguration? = null

Expand All @@ -52,7 +55,7 @@ public class SpaceModificationBuilder {
internal fun build() =
SpaceModification(
slug ?: error("Space slug is undefined"),
metadata ?: error("Space metadata is undefined"),
metadata,
view ?: error("View is undefined")
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public typealias SpaceToken = String

public sealed interface ModifiedRootSpace {

public val metadata: Metadata

public val view: ViewConfiguration
}

public sealed interface ModifiedSpace : ModifiedRootSpace {

public val slug: SpaceSlug

public val metadata: Metadata
}

public sealed interface IdentifiedSpace : ModifiedSpace {
Expand Down Expand Up @@ -67,6 +67,7 @@ public data class SpaceModification(

@Serializable
public data class RootSpaceModification(
override val metadata: Metadata,
override val view: ViewConfiguration
) : ModifiedRootSpace

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class RootSpaceModificationDtoConverter : DtoConverter<SpaceEntity, RootSpaceMod

override suspend fun convertToEntity(dto: RootSpaceModification) =
SpaceEntity {
metadata = dto.metadata
view = dto.view
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class DefaultSpaceService : SpaceService, KoinComponent {

val rootSpace = SpaceEntity {
slug = SpaceEntity.ROOT_SPACE_SLUG
metadata = metadataOf()
metadata = space.metadata
view = space.view
role = Role.ROOT
}
Expand Down Expand Up @@ -230,6 +230,7 @@ class DefaultSpaceService : SpaceService, KoinComponent {
requireNotNull(originalSpaceDto)

originalSpace.apply {
this.metadata = modification.metadata
this.view = modification.view
}

Expand Down

0 comments on commit fa875fa

Please sign in to comment.