Commit 26dac477 authored by Daniel Tian's avatar Daniel Tian

Refactor vulnerability header and footer

1. Renamed app.vue to header.vue to match with footer.vue and updated
its component name from VulnerabilityManagementApp to
VulnerabilityHeader to match with VulnerabilityFooter.
2. Fixed some spacing issues and removed some unnecessary wrapper
elements.
3. Moved the issue note from below the horizontal line to above it.
parent 74a0ea92
import Vue from 'vue'; import Vue from 'vue';
import HeaderApp from 'ee/vulnerabilities/components/app.vue'; import HeaderApp from 'ee/vulnerabilities/components/header.vue';
import FooterApp from 'ee/vulnerabilities/components/footer.vue'; import FooterApp from 'ee/vulnerabilities/components/footer.vue';
function createHeaderApp() {
const el = document.getElementById('js-vulnerability-management-app');
const initialVulnerability = JSON.parse(el.dataset.vulnerabilityJson);
const pipeline = JSON.parse(el.dataset.pipelineJson);
const finding = JSON.parse(el.dataset.findingJson);
const { projectFingerprint, createIssueUrl } = el.dataset;
return new Vue({
el,
render: h =>
h(HeaderApp, {
props: {
initialVulnerability,
finding,
pipeline,
projectFingerprint,
createIssueUrl,
},
}),
});
}
function createFooterApp() { function createFooterApp() {
const el = document.getElementById('js-vulnerability-footer'); const el = document.getElementById('js-vulnerability-footer');
...@@ -43,30 +67,6 @@ function createFooterApp() { ...@@ -43,30 +67,6 @@ function createFooterApp() {
}); });
} }
function createHeaderApp() {
const el = document.getElementById('js-vulnerability-management-app');
const initialVulnerability = JSON.parse(el.dataset.vulnerabilityJson);
const pipeline = JSON.parse(el.dataset.pipelineJson);
const finding = JSON.parse(el.dataset.findingJson);
const { projectFingerprint, createIssueUrl } = el.dataset;
return new Vue({
el,
render: h =>
h(HeaderApp, {
props: {
initialVulnerability,
finding,
pipeline,
projectFingerprint,
createIssueUrl,
},
}),
});
}
window.addEventListener('DOMContentLoaded', () => { window.addEventListener('DOMContentLoaded', () => {
createHeaderApp(); createHeaderApp();
createFooterApp(); createFooterApp();
......
...@@ -209,51 +209,51 @@ export default { ...@@ -209,51 +209,51 @@ export default {
:vulnerability-feedback-help-path="vulnerabilityFeedbackHelpPath" :vulnerability-feedback-help-path="vulnerabilityFeedbackHelpPath"
/> />
<ul v-if="canReadIssueFeedback || canReadMergeRequestFeedback" class="notes card my-4"> <div v-if="canReadIssueFeedback || canReadMergeRequestFeedback" class="card my-4">
<li v-if="issueFeedback" class="note"> <issue-note
<div class="card-body"> v-if="issueFeedback"
<issue-note :feedback="issueFeedback" :project="project" /> :feedback="issueFeedback"
</div> :project="project"
</li> class="card-body"
<li v-if="mergeRequestFeedback" class="note"> />
<div class="card-body"> <merge-request-note
<merge-request-note :feedback="mergeRequestFeedback" :project="project" /> v-if="mergeRequestFeedback"
</div> :feedback="mergeRequestFeedback"
</li> :project="project"
</ul> class="card-body"
/>
</div>
<div v-if="dismissalFeedback || modal.isCommentingOnDismissal" class="card my-4"> <div v-if="dismissalFeedback || modal.isCommentingOnDismissal" class="card card-body my-4">
<div class="card-body"> <dismissal-note
<dismissal-note :feedback="dismissalFeedbackObject"
:feedback="dismissalFeedbackObject" :is-commenting-on-dismissal="modal.isCommentingOnDismissal"
:is-commenting-on-dismissal="modal.isCommentingOnDismissal" :is-showing-delete-buttons="modal.isShowingDeleteButtons"
:is-showing-delete-buttons="modal.isShowingDeleteButtons" :project="project"
:project="project" :show-dismissal-comment-actions="
:show-dismissal-comment-actions=" !dismissalFeedback || !dismissalFeedback.comment_details || !isEditingExistingFeedback
!dismissalFeedback || !dismissalFeedback.comment_details || !isEditingExistingFeedback "
" @editVulnerabilityDismissalComment="$emit('editVulnerabilityDismissalComment')"
@editVulnerabilityDismissalComment="$emit('editVulnerabilityDismissalComment')" @showDismissalDeleteButtons="$emit('showDismissalDeleteButtons')"
@showDismissalDeleteButtons="$emit('showDismissalDeleteButtons')" @hideDismissalDeleteButtons="$emit('hideDismissalDeleteButtons')"
@hideDismissalDeleteButtons="$emit('hideDismissalDeleteButtons')" @deleteDismissalComment="$emit('deleteDismissalComment')"
@deleteDismissalComment="$emit('deleteDismissalComment')" />
/> <dismissal-comment-box-toggle
<dismissal-comment-box-toggle v-if="
v-if=" !dismissalFeedback || !dismissalFeedback.comment_details || isEditingExistingFeedback
!dismissalFeedback || !dismissalFeedback.comment_details || isEditingExistingFeedback "
" v-model="localDismissalComment"
v-model="localDismissalComment" :dismissal-comment="
:dismissal-comment=" dismissalFeedback &&
dismissalFeedback && dismissalFeedback.comment_details &&
dismissalFeedback.comment_details && dismissalFeedback.comment_details.comment
dismissalFeedback.comment_details.comment "
" :is-active="modal.isCommentingOnDismissal"
:is-active="modal.isCommentingOnDismissal" :error-message="dismissalCommentErrorMessage"
:error-message="dismissalCommentErrorMessage" @openDismissalCommentBox="$emit('openDismissalCommentBox')"
@openDismissalCommentBox="$emit('openDismissalCommentBox')" @submit="handleDismissalCommentSubmission"
@submit="handleDismissalCommentSubmission" @clearError="clearDismissalError"
@clearError="clearDismissalError" />
/>
</div>
</div> </div>
<div v-if="modal.error" class="alert alert-danger">{{ modal.error }}</div> <div v-if="modal.error" class="alert alert-danger">{{ modal.error }}</div>
......
...@@ -31,17 +31,11 @@ export default { ...@@ -31,17 +31,11 @@ export default {
}; };
</script> </script>
<template> <template>
<ul class="notes"> <div>
<li v-if="hasSolution" class="note"> <solution-card v-if="hasSolution" v-bind="solutionInfo" />
<solution-card v-bind="solutionInfo" /> <div v-if="hasIssue" class="card">
</li> <issue-note :feedback="feedback" :project="project" class="card-body" />
<li> </div>
<hr /> <hr />
</li> </div>
<li v-if="hasIssue" class="note card my-4 border-bottom">
<div class="card-body">
<issue-note :feedback="feedback" :project="project" />
</div>
</li>
</ul>
</template> </template>
...@@ -12,7 +12,7 @@ import StatusDescription from './status_description.vue'; ...@@ -12,7 +12,7 @@ import StatusDescription from './status_description.vue';
import { VULNERABILITY_STATE_OBJECTS } from '../constants'; import { VULNERABILITY_STATE_OBJECTS } from '../constants';
export default { export default {
name: 'VulnerabilityManagementApp', name: 'VulnerabilityHeader',
components: { components: {
GlDeprecatedButton, GlDeprecatedButton,
GlLoadingIcon, GlLoadingIcon,
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
- finding = @vulnerability.finding - finding = @vulnerability.finding
- location = finding.location - location = finding.location
#js-vulnerability-management-app{ data: vulnerability_data(@vulnerability, @pipeline) } #js-vulnerability-header{ data: vulnerability_data(@vulnerability, @pipeline) }
.issue-details.issuable-details .issue-details.issuable-details
.detail-page-description .detail-page-description.p-0.my-3
%h2.title= @vulnerability.title %h2.title= @vulnerability.title
.description .description
.md .md
......
...@@ -2,6 +2,8 @@ import Vue from 'vue'; ...@@ -2,6 +2,8 @@ import Vue from 'vue';
import component from 'ee/vue_shared/security_reports/components/modal.vue'; import component from 'ee/vue_shared/security_reports/components/modal.vue';
import createState from 'ee/vue_shared/security_reports/store/state'; import createState from 'ee/vue_shared/security_reports/store/state';
import SolutionCard from 'ee/vue_shared/security_reports/components/solution_card.vue'; import SolutionCard from 'ee/vue_shared/security_reports/components/solution_card.vue';
import IssueNote from 'ee/vue_shared/security_reports/components/issue_note.vue';
import MergeRequestNote from 'ee/vue_shared/security_reports/components/merge_request_note.vue';
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
describe('Security Reports modal', () => { describe('Security Reports modal', () => {
...@@ -202,8 +204,7 @@ describe('Security Reports modal', () => { ...@@ -202,8 +204,7 @@ describe('Security Reports modal', () => {
}); });
it('displays a link to the issue', () => { it('displays a link to the issue', () => {
const notes = wrapper.find('.notes'); expect(wrapper.contains(IssueNote)).toBe(true);
expect(notes.exists()).toBe(true);
}); });
}); });
...@@ -220,8 +221,8 @@ describe('Security Reports modal', () => { ...@@ -220,8 +221,8 @@ describe('Security Reports modal', () => {
}); });
it('hides the link to the issue', () => { it('hides the link to the issue', () => {
const notes = wrapper.find('.notes'); const note = wrapper.find(IssueNote);
expect(notes.exists()).toBe(false); expect(note.exists()).toBe(false);
}); });
}); });
}); });
...@@ -240,8 +241,7 @@ describe('Security Reports modal', () => { ...@@ -240,8 +241,7 @@ describe('Security Reports modal', () => {
}); });
it('displays a link to the merge request', () => { it('displays a link to the merge request', () => {
const notes = wrapper.find('.notes'); expect(wrapper.contains(MergeRequestNote)).toBe(true);
expect(notes.exists()).toBe(true);
}); });
}); });
...@@ -258,8 +258,8 @@ describe('Security Reports modal', () => { ...@@ -258,8 +258,8 @@ describe('Security Reports modal', () => {
}); });
it('hides the link to the merge request', () => { it('hides the link to the merge request', () => {
const notes = wrapper.find('.notes'); const note = wrapper.find(MergeRequestNote);
expect(notes.exists()).toBe(false); expect(note.exists()).toBe(false);
}); });
}); });
}); });
......
...@@ -6,7 +6,7 @@ import Api from '~/api'; ...@@ -6,7 +6,7 @@ import Api from '~/api';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import * as urlUtility from '~/lib/utils/url_utility'; import * as urlUtility from '~/lib/utils/url_utility';
import createFlash from '~/flash'; import createFlash from '~/flash';
import App from 'ee/vulnerabilities/components/app.vue'; import Header from 'ee/vulnerabilities/components/header.vue';
import StatusDescription from 'ee/vulnerabilities/components/status_description.vue'; import StatusDescription from 'ee/vulnerabilities/components/status_description.vue';
import ResolutionAlert from 'ee/vulnerabilities/components/resolution_alert.vue'; import ResolutionAlert from 'ee/vulnerabilities/components/resolution_alert.vue';
import VulnerabilityStateDropdown from 'ee/vulnerabilities/components/vulnerability_state_dropdown.vue'; import VulnerabilityStateDropdown from 'ee/vulnerabilities/components/vulnerability_state_dropdown.vue';
......
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