diff --git a/backend/infrahub/graphql/queries/diff/tree.py b/backend/infrahub/graphql/queries/diff/tree.py index d7de246295..8e4512f29f 100644 --- a/backend/infrahub/graphql/queries/diff/tree.py +++ b/backend/infrahub/graphql/queries/diff/tree.py @@ -8,6 +8,7 @@ from infrahub.core import registry from infrahub.core.constants import DiffAction, RelationshipCardinality +from infrahub.core.constants.database import DatabaseEdgeType from infrahub.core.diff.model.path import NameTrackingId from infrahub.core.diff.repository.repository import DiffRepository from infrahub.core.query.diff import DiffCountChanges @@ -75,6 +76,7 @@ class DiffAttribute(DiffSummaryCounts): path_identifier = String(required=True) properties = List(DiffProperty) contains_conflict = Boolean(required=True) + conflict = Field(ConflictDetails, required=False) class DiffSingleRelationship(DiffSummaryCounts): @@ -207,6 +209,11 @@ def to_diff_attribute( diff_properties = [ self.to_diff_property(enriched_property=e_prop, context=context) for e_prop in enriched_attribute.properties ] + conflict = None + for diff_prop in diff_properties: + if diff_prop.property_type == DatabaseEdgeType.HAS_VALUE.value and diff_prop.conflict: + conflict = diff_prop.conflict + diff_prop.conflict = None return DiffAttribute( name=enriched_attribute.name, last_changed_at=enriched_attribute.changed_at.obj, @@ -214,6 +221,7 @@ def to_diff_attribute( path_identifier=enriched_attribute.path_identifier, properties=diff_properties, contains_conflict=enriched_attribute.contains_conflict, + conflict=conflict, num_added=enriched_attribute.num_added, num_updated=enriched_attribute.num_updated, num_removed=enriched_attribute.num_removed, diff --git a/backend/tests/unit/graphql/test_diff_tree_query.py b/backend/tests/unit/graphql/test_diff_tree_query.py index 31c65fc0df..b8159b38f9 100644 --- a/backend/tests/unit/graphql/test_diff_tree_query.py +++ b/backend/tests/unit/graphql/test_diff_tree_query.py @@ -69,6 +69,18 @@ num_updated num_conflicts contains_conflict + conflict { + uuid + base_branch_action + base_branch_value + base_branch_changed_at + base_branch_label + diff_branch_action + diff_branch_value + diff_branch_changed_at + diff_branch_label + selected_branch + } properties { property_type last_changed_at @@ -353,6 +365,18 @@ async def test_diff_tree_one_attr_change( "num_conflicts": 1, "status": UPDATED_ACTION, "contains_conflict": True, + "conflict": { + "uuid": enriched_conflict.uuid, + "base_branch_action": UPDATED_ACTION, + "base_branch_value": "#fedcba", + "base_branch_changed_at": enriched_conflict.base_branch_changed_at.to_string(with_z=False), + "base_branch_label": None, + "diff_branch_action": UPDATED_ACTION, + "diff_branch_value": "#abcdef", + "diff_branch_changed_at": enriched_conflict.diff_branch_changed_at.to_string(with_z=False), + "diff_branch_label": None, + "selected_branch": GraphQLConfictSelection.DIFF_BRANCH.name, + }, "properties": [ { "property_type": "HAS_VALUE", @@ -362,22 +386,7 @@ async def test_diff_tree_one_attr_change( "previous_label": None, "new_label": None, "status": UPDATED_ACTION, - "conflict": { - "uuid": enriched_conflict.uuid, - "base_branch_action": UPDATED_ACTION, - "base_branch_value": "#fedcba", - "base_branch_changed_at": enriched_conflict.base_branch_changed_at.to_string( - with_z=False - ), - "base_branch_label": None, - "diff_branch_action": UPDATED_ACTION, - "diff_branch_value": "#abcdef", - "diff_branch_changed_at": enriched_conflict.diff_branch_changed_at.to_string( - with_z=False - ), - "diff_branch_label": None, - "selected_branch": GraphQLConfictSelection.DIFF_BRANCH.name, - }, + "conflict": None, } ], } diff --git a/frontend/app/src/components/buttons/toggle-buttons.tsx b/frontend/app/src/components/buttons/toggle-buttons.tsx index a3d587b693..0c7b204dc6 100644 --- a/frontend/app/src/components/buttons/toggle-buttons.tsx +++ b/frontend/app/src/components/buttons/toggle-buttons.tsx @@ -20,7 +20,8 @@ export const ToggleButtons = ({ tabs, ...props }: TabsProps) => {