Commit 600a6b52 authored by Filipa Lacerda's avatar Filipa Lacerda

Document computed properties

parent 6781c46d
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import Modal from '~/vue_shared/components/gl_modal.vue'; import Modal from '~/vue_shared/components/gl_modal.vue';
import LoadingButton from '~/vue_shared/components/loading_button.vue'; import LoadingButton from '~/vue_shared/components/loading_button.vue';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import ExpandButton from '~/vue_shared/components/expand_button.vue'; import ExpandButton from '~/vue_shared/components/expand_button.vue';
export default { export default {
components: { components: {
Modal, Modal,
LoadingButton, LoadingButton,
ExpandButton, ExpandButton,
Icon, Icon,
},
computed: {
...mapState([
'modal',
'vulnerabilityFeedbackHelpPath',
'canCreateIssuePermission',
'canCreateFeedbackPermission',
]),
revertTitle() {
return this.modal.vulnerability.isDismissed
? s__('ciReport|Revert dismissal')
: s__('ciReport|Dismiss vulnerability');
}, },
hasDismissedBy() { computed: {
return ( ...mapState([
this.modal.vulnerability.dismissalFeedback && 'modal',
this.modal.vulnerability.dismissalFeedback.pipeline && 'vulnerabilityFeedbackHelpPath',
this.modal.vulnerability.dismissalFeedback.author 'canCreateIssuePermission',
); 'canCreateFeedbackPermission',
]),
revertTitle() {
return this.modal.vulnerability.isDismissed
? s__('ciReport|Revert dismissal')
: s__('ciReport|Dismiss vulnerability');
},
hasDismissedBy() {
return (
this.modal.vulnerability.dismissalFeedback &&
this.modal.vulnerability.dismissalFeedback.pipeline &&
this.modal.vulnerability.dismissalFeedback.author
);
},
/**
* The slot for the footer should be rendered if any of the conditions is true.
*/
shouldRenderFooterSection() {
return (
!this.modal.isResolved &&
(this.canCreateFeedbackPermission || this.canCreateIssuePermission)
);
},
}, },
shouldHideModalFooter() { methods: {
return ( ...mapActions(['dismissIssue', 'revertDismissIssue', 'createNewIssue']),
this.modal.isResolved || handleDismissClick() {
(!this.canCreateFeedbackPermission && !this.canCreateIssuePermission) if (this.modal.vulnerability.isDismissed) {
); this.revertDismissIssue();
} else {
this.dismissIssue();
}
},
isLastValue(index, values) {
return index < values.length - 1;
},
hasValue(field) {
return field.value && field.value.length > 0;
},
hasInstances(field, key) {
return key === 'instances' && this.hasValue(field);
},
hasIdentifiers(field, key) {
return key === 'identifiers' && this.hasValue(field);
},
hasLinks(field, key) {
return key === 'links' && this.hasValue(field);
},
}, },
}, };
methods: {
...mapActions(['dismissIssue', 'revertDismissIssue', 'createNewIssue']),
handleDismissClick() {
if (this.modal.vulnerability.isDismissed) {
this.revertDismissIssue();
} else {
this.dismissIssue();
}
},
isLastValue(index, values) {
return index < values.length - 1;
},
hasValue(field) {
return field.value && field.value.length > 0;
},
hasInstances(field, key) {
return key === 'instances' && this.hasValue(field);
},
hasIdentifiers(field, key) {
return key === 'identifiers' && this.hasValue(field);
},
hasLinks(field, key) {
return key === 'links' && this.hasValue(field);
},
},
};
</script> </script>
<template> <template>
<modal <modal
id="modal-mrwidget-security-issue" id="modal-mrwidget-security-issue"
:header-title-text="modal.title" :header-title-text="modal.title"
:class="{ 'modal-hide-footer': shouldHideModalFooter }" :class="{ 'modal-hide-footer': !shouldRenderFooterSection }"
class="modal-security-report-dast" class="modal-security-report-dast"
> >
<slot> <slot>
...@@ -209,7 +212,7 @@ export default { ...@@ -209,7 +212,7 @@ export default {
</div> </div>
</slot> </slot>
<div slot="footer"> <div slot="footer">
<template v-if="!modal.isResolved && (canCreateFeedbackPermission || canCreateIssuePermission)"> <template v-if="shouldRenderFooterSection">
<button <button
type="button" type="button"
class="btn btn-default" class="btn btn-default"
......
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