Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for undefined destination tag instances in entity merge request UI. #77

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ const versionTagDefResolvable2 = 7772
const idTagInstanceOriginResolvable2 = 'id-instance-origin-resolvable-2'
const versionTagInstanceOriginResolvable2 = 7782
const valueTagInstanceOriginResolvable2 = 'resolvable value origin 2'
const idTagInstanceDestinationResolvable2 = 'id-instance-resolvable-destination-2'
const versionTagInstanceDestinationResolvable2 = 7742
const valueTagInstanceDestinationResolvable2 = 'resolvable value destination 2'
const namePathUnresolvable0 = ['name path', 'unresolvable 0']
const idTagDefUnresolvable0 = 'id-tag-def-unresolvable-0'
const idTagDefParentUnresolvable0 = 'id-tag-def-parent-unresolvable-0'
Expand Down Expand Up @@ -241,11 +238,7 @@ function addSuccessResponse(fetchMock: jest.Mock) {
value: valueTagInstanceOriginResolvable2,
version: versionTagInstanceOriginResolvable2
},
tag_instance_destination: {
id_persistent: idTagInstanceDestinationResolvable2,
value: valueTagInstanceDestinationResolvable2,
version: versionTagInstanceDestinationResolvable2
},
tag_instance_destination: null,
replace: false
}
],
Expand Down Expand Up @@ -312,7 +305,6 @@ test('update conflicts', async () => {
)
expect(textValueDestinationList.length).toEqual(2)
screen.getByText(valueTagInstanceOriginResolvable2)
screen.getByText(valueTagInstanceDestinationResolvable2)
screen.getByText(valueTagInstanceOriginUnresolvable0)
screen.getByText(valueTagInstanceDestinationUnresolvable0)
screen.getByText(valueTagInstanceOriginUnresolvable1)
Expand Down Expand Up @@ -378,11 +370,7 @@ test('update conflicts', async () => {
value: valueTagInstanceOriginResolvable2,
version: versionTagInstanceOriginResolvable2
},
tagInstanceDestination: {
idPersistent: idTagInstanceDestinationResolvable2,
value: valueTagInstanceDestinationResolvable2,
version: versionTagInstanceDestinationResolvable2
},
tagInstanceDestination: undefined,
replace: false
})
)
Expand Down
6 changes: 3 additions & 3 deletions ui/src/merge_request/entity/conflicts/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ export interface TagDefinition {
export interface EntityMergeRequestConflict {
tagDefinition: TagDefinition
tagInstanceOrigin: TagInstance
tagInstanceDestination: TagInstance
tagInstanceDestination?: TagInstance
replace: boolean | undefined
}

export function newEntityMergeRequestConflict({
tagDefinition,
tagInstanceOrigin,
tagInstanceDestination,
tagInstanceDestination = undefined,
replace = undefined
}: {
tagDefinition: TagDefinition
tagInstanceOrigin: TagInstance
tagInstanceDestination: TagInstance
tagInstanceDestination?: TagInstance
replace?: boolean | undefined
}): EntityMergeRequestConflict {
return {
Expand Down
9 changes: 6 additions & 3 deletions ui/src/merge_request/entity/conflicts/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,17 @@ function parseEntityMergeRequestConflictFromJson(conflictJson: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any
}): EntityMergeRequestConflict {
let tagInstanceDestination = undefined
const destinationJson = conflictJson['tag_instance_destination']
if (!(destinationJson === null || destinationJson === undefined)) {
tagInstanceDestination = parseTagInstanceFromJson(destinationJson)
}
return newEntityMergeRequestConflict({
tagDefinition: parseTagDefinitionFromJson(conflictJson['tag_definition']),
tagInstanceOrigin: parseTagInstanceFromJson(
conflictJson['tag_instance_origin']
),
tagInstanceDestination: parseTagInstanceFromJson(
conflictJson['tag_instance_destination']
),
tagInstanceDestination,
replace: conflictJson['replace'] ?? undefined
})
}
Expand Down
Loading