Skip to content

Commit

Permalink
#1320 Build with release result
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Jul 9, 2024
1 parent 174eb95 commit 9ffe59a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class ReleaseSearchExtension(
private val propertyService: PropertyService,
private val structureService: StructureService
) : AbstractExtension(
extensionFeature
extensionFeature
), SearchIndexer<ReleaseSearchItem> {

override val searchResultType = SearchResultType(
extensionFeature.featureDescription,
"build-release",
"Build with Release",
"Release, label or version attached to a build"
extensionFeature.featureDescription,
"build-release",
"Build with Release",
"Release, label or version attached to a build"
)

override val indexerName: String = "Release property"
Expand All @@ -37,11 +37,11 @@ class ReleaseSearchExtension(
override fun indexAll(processor: (ReleaseSearchItem) -> Unit) {
propertyService.forEachEntityWithProperty<ReleasePropertyType, ReleaseProperty> { entityId, property ->
processor(
ReleaseSearchItem(
release = property.name,
entityType = entityId.type,
entityId = entityId.id
)
ReleaseSearchItem(
release = property.name,
entityType = entityId.type,
entityId = entityId.id
)
)
}
}
Expand All @@ -59,15 +59,24 @@ class ReleaseSearchExtension(
// Conversion
return entity?.let {
SearchResult(
title = entity.entityDisplayName,
description = "${entity.entityDisplayName} having version/label/release ${item.release}",
uri = uriBuilder.getEntityURI(entity),
page = uriBuilder.getEntityPage(entity),
accuracy = score,
type = searchResultType
title = entity.entityDisplayName,
description = "${entity.entityDisplayName} having version/label/release ${item.release}",
uri = uriBuilder.getEntityURI(entity),
page = uriBuilder.getEntityPage(entity),
accuracy = score,
type = searchResultType,
data = mapOf(
SearchResult.SEARCH_RESULT_BUILD to entity,
SEARCH_RESULT_RELEASE to item.release,
)
)
}
}

companion object {
const val SEARCH_RESULT_RELEASE = "release"
}

}

/**
Expand All @@ -76,21 +85,21 @@ class ReleaseSearchExtension(
const val RELEASE_SEARCH_INDEX = "releases"

data class ReleaseSearchItem(
val release: String,
val entityType: ProjectEntityType,
val entityId: Int
val release: String,
val entityType: ProjectEntityType,
val entityId: Int
) : SearchItem {

constructor(entity: ProjectEntity, property: ReleaseProperty) : this(
release = property.name,
entityType = entity.projectEntityType,
entityId = entity.id()
release = property.name,
entityType = entity.projectEntityType,
entityId = entity.id()
)

override val id: String = "$entityType::$entityId"
override val fields: Map<String, Any?> = mapOf(
"release" to release,
"entityType" to entityType,
"entityId" to entityId
"release" to release,
"entityType" to entityType,
"entityId" to entityId
)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import SearchResultComponent from "@components/framework/search/SearchResultComponent";
import {Space} from "antd";
import FQBuildLink from "@components/builds/FQBuildLink";
import Display from "@components/framework/properties/general.ReleasePropertyType/Display";

export default function Result({data}) {
return <SearchResultComponent
title="TODO"
description={JSON.stringify(data)}
title={
<Space>
<FQBuildLink build={data.build}/>
<Display property={{value: {name: data.release}}}/>
</Space>
}
description=""
/>
}

0 comments on commit 9ffe59a

Please sign in to comment.