Skip to content

Commit

Permalink
fix: Fix complex update issue
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCizmar committed Jan 31, 2025
1 parent 266672b commit 5596e68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class KeyComplexEditHelper(
return !currentTagsContainAllNewTags || !newTagsContainAllCurrentTags
}

val requireKeyEditPermission
private val requireKeyEditPermission
get() =
isKeyNameModified ||
isNamespaceChanged ||
Expand All @@ -333,7 +333,16 @@ class KeyComplexEditHelper(

private fun prepareModifiedStates() {
modifiedStates =
dto.states?.filter { it.value.translationState != existingTranslations[it.key]?.state }
dto.states?.filter {
// When updating translation, we automatically set it to TRANSLATED state
// While executing complex edit, user can prevent this by setting the state to REVIEWED
// In that case, we have to add it to modified states too
val tryingToKeepReviewState =
modifiedTranslations?.get(languageByTag(it.key).id) != null &&
it.value.translationState == TranslationState.REVIEWED

it.value.translationState != existingTranslations[it.key]?.state || tryingToKeepReviewState
}
?.map { languageByTag(it.key).id to it.value.translationState }?.toMap()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ class KeyControllerComplexEditTest : ProjectAuthControllerTest("/v2/projects/")

private fun verifyStates(statesToVerify: Map<String, TranslationState>) {
executeInNewTransaction {
val key = keyService.find(testData.keyWithReferences.id)
val key = keyService.get(testData.keyWithReferences.id)
assertThat(key).isNotNull
statesToVerify.forEach {
val state = key!!.translations.find { translation -> translation.language.tag == it.key }!!.state
val state = key.translations.find { translation -> translation.language.tag == it.key }!!.state
assertThat(state)
.describedAs("State for ${it.key} is not ${it.value}")
.isEqualTo(it.value)
Expand Down

0 comments on commit 5596e68

Please sign in to comment.