Skip to content

Commit

Permalink
#1236 Promotion only if no promotion runs
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Dec 15, 2024
1 parent 65290c7 commit 2cfb3b1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ class BuildPromotionInfoServiceImpl(
.reversed()
// For each promotion level
promotionLevels.forEach { promotionLevel ->
// Promotion level itself
items += buildPromotionInfoItemForPromotionLevel(promotionLevel)
val runs = structureService.getPromotionRunsForBuildAndPromotionLevel(build, promotionLevel)
// Promotion level itself only if no run
if (runs.isEmpty()) {
items += buildPromotionInfoItemForPromotionLevel(promotionLevel)
}
// Promotion runs for this promotion level
items += structureService.getPromotionRunsForBuildAndPromotionLevel(build, promotionLevel).map {
items += runs.map {
buildPromotionInfoItemForPromotionRun(it)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,24 @@ class BuildPromotionInfoServiceIT : AbstractDSLTestSupport() {
val info = buildPromotionInfoService.getBuildPromotionInfo(this)

// Checking each promotion
assertEquals(6, info.items.size)
assertEquals(4, info.items.size)

info.items[0].apply {
assertEquals(gold, promotionLevel)
assertEquals(gold, data)
}

info.items[1].apply {
assertEquals(silver, promotionLevel)
assertEquals(silver, data)
}

info.items[2].apply {
assertEquals(silver, promotionLevel)
assertEquals(runSilver.id, (data as PromotionRun).id)
}

info.items[3].apply {
assertEquals(bronze, promotionLevel)
assertEquals(bronze, data)
}

info.items[4].apply {
info.items[2].apply {
assertEquals(bronze, promotionLevel)
assertEquals(runBronze2.id, (data as PromotionRun).id)
}

info.items[5].apply {
info.items[3].apply {
assertEquals(bronze, promotionLevel)
assertEquals(runBronze1.id, (data as PromotionRun).id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ class GQLBuildPromotionInfoIT : AbstractQLKTITSupport() {
"id" to gold.id.toString()
)
),
mapOf(
"promotionLevel" to mapOf(
"name" to silver.name,
),
"data" to mapOf(
"__typename" to "PromotionLevel",
"id" to silver.id.toString()
)
),
mapOf(
"promotionLevel" to mapOf(
"name" to silver.name,
Expand All @@ -79,15 +70,6 @@ class GQLBuildPromotionInfoIT : AbstractQLKTITSupport() {
"id" to runSilver.id.toString()
)
),
mapOf(
"promotionLevel" to mapOf(
"name" to bronze.name,
),
"data" to mapOf(
"__typename" to "PromotionLevel",
"id" to bronze.id.toString()
)
),
mapOf(
"promotionLevel" to mapOf(
"name" to bronze.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {FaCog} from "react-icons/fa";
import PromotionRunDeleteAction from "@components/promotionRuns/PromotionRunDeleteAction";
import {promotionRunUri} from "@components/common/Links";
import Link from "next/link";
import BuildPromoteAction from "@components/builds/BuildPromoteAction";

export default function PromotionRunBuildPromotionInfoItemActions({item, build, promotionLevel, onChange}) {
return (
Expand All @@ -31,6 +32,16 @@ export default function PromotionRunBuildPromotionInfoItemActions({item, build,
text={<FaCog/>}
/>
}
{/* Repromoting */}
{
isAuthorized(build, 'build', 'promote') ?
<BuildPromoteAction
build={build}
promotionLevel={promotionLevel}
onPromotion={onChange}
/> : undefined

}
{/* Deleting the promotion */}
{
isAuthorized(item, 'promotion_run', 'delete') ?
Expand Down

0 comments on commit 2cfb3b1

Please sign in to comment.