Commit 262f8ec2 authored by David O'Regan's avatar David O'Regan

Merge branch...

Merge branch '356137-bug-selecting-a-compliance-violation-with-the-same-mr-should-keep-the-drawer-open' into 'master'

Fix compliance report drawer closing incorrectly

See merge request gitlab-org/gitlab!83097
parents a2a64e65 969a24ba
...@@ -60,7 +60,7 @@ export default { ...@@ -60,7 +60,7 @@ export default {
list: [], list: [],
pageInfo: {}, pageInfo: {},
}, },
showDrawer: false, drawerId: null,
drawerMergeRequest: {}, drawerMergeRequest: {},
drawerProject: {}, drawerProject: {},
sortBy, sortBy,
...@@ -108,6 +108,9 @@ export default { ...@@ -108,6 +108,9 @@ export default {
const { hasPreviousPage, hasNextPage } = this.violations.pageInfo || {}; const { hasPreviousPage, hasNextPage } = this.violations.pageInfo || {};
return hasPreviousPage || hasNextPage; return hasPreviousPage || hasNextPage;
}, },
showDrawer() {
return this.drawerId !== null;
},
}, },
methods: { methods: {
handleSortChanged(sortState) { handleSortChanged(sortState) {
...@@ -115,24 +118,21 @@ export default { ...@@ -115,24 +118,21 @@ export default {
this.updateUrlQuery({ ...this.urlQuery, sort: this.sortParam }); this.updateUrlQuery({ ...this.urlQuery, sort: this.sortParam });
}, },
toggleDrawer(rows) { toggleDrawer(rows) {
const { mergeRequest } = rows[0] || {}; const { id, mergeRequest } = rows[0] || {};
if (!mergeRequest || this.isCurrentDrawer(mergeRequest)) { if (!mergeRequest || this.drawerId === id) {
this.closeDrawer(); this.closeDrawer();
} else { } else {
this.openDrawer(mergeRequest); this.openDrawer(id, mergeRequest);
} }
}, },
isCurrentDrawer(mergeRequest) { openDrawer(id, mergeRequest) {
return this.showDrawer && mergeRequest.id === this.drawerMergeRequest.id; this.drawerId = id;
},
openDrawer(mergeRequest) {
this.showDrawer = true;
this.drawerMergeRequest = mergeRequest; this.drawerMergeRequest = mergeRequest;
this.drawerProject = mergeRequest.project; this.drawerProject = mergeRequest.project;
}, },
closeDrawer() { closeDrawer() {
this.showDrawer = false; this.drawerId = null;
// Refs are required by BTable to manipulate the selection // Refs are required by BTable to manipulate the selection
// issue: https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1531 // issue: https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1531
this.$refs.table.$children[0].clearSelected(); this.$refs.table.$children[0].clearSelected();
......
...@@ -237,7 +237,7 @@ describe('ComplianceReport component', () => { ...@@ -237,7 +237,7 @@ describe('ComplianceReport component', () => {
expect(rowTexts).toEqual([ expect(rowTexts).toEqual([
'High', 'High',
'Approved by committer', 'Approved by committer',
`Merge request ${idx}`, violations[idx].mergeRequest.title,
'in 1 year', 'in 1 year',
'View details', 'View details',
]); ]);
...@@ -306,7 +306,7 @@ describe('ComplianceReport component', () => { ...@@ -306,7 +306,7 @@ describe('ComplianceReport component', () => {
expect(findMergeRequestDrawer().props('project')).toStrictEqual({}); expect(findMergeRequestDrawer().props('project')).toStrictEqual({});
}); });
it(`swaps the drawer when another ${eventDescription}`, async () => { it(`keeps the drawer open when another violation's ${eventDescription}`, async () => {
const drawerData = mapViolations(violations)[1]; const drawerData = mapViolations(violations)[1];
await rowAction(0); await rowAction(0);
......
...@@ -107,8 +107,8 @@ export const createComplianceViolation = (id) => ({ ...@@ -107,8 +107,8 @@ export const createComplianceViolation = (id) => ({
__typename: 'UserCore', __typename: 'UserCore',
}, },
mergeRequest: { mergeRequest: {
id: `gid://gitlab/MergeRequest/${id}`, id: `gid://gitlab/MergeRequest/1`,
title: `Merge request ${id}`, title: `Merge request 1`,
mergedAt: '2022-03-06T16:39:12Z', mergedAt: '2022-03-06T16:39:12Z',
webUrl: 'http://gdk.test:3000/gitlab-org/gitlab-shell/-/merge_requests/56', webUrl: 'http://gdk.test:3000/gitlab-org/gitlab-shell/-/merge_requests/56',
author: { author: {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment