Commit 7d141c7f authored by Dave Pisek's avatar Dave Pisek

Handle action button visibility

parent 73825ffc
<script> <script>
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import { GlDeprecatedButton, GlSkeletonLoading, GlFormCheckbox } from '@gitlab/ui'; import { GlDeprecatedButton, GlFormCheckbox, GlSkeletonLoading } from '@gitlab/ui';
import SeverityBadge from 'ee/vue_shared/security_reports/components/severity_badge.vue'; import SeverityBadge from 'ee/vue_shared/security_reports/components/severity_badge.vue';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import VulnerabilityActionButtons from './vulnerability_action_buttons.vue'; import VulnerabilityActionButtons from './vulnerability_action_buttons.vue';
...@@ -30,6 +30,11 @@ export default { ...@@ -30,6 +30,11 @@ export default {
default: false, default: false,
}, },
}, },
data() {
return {
shouldShowActionButtons: false,
};
},
computed: { computed: {
...mapState(['dashboardType']), ...mapState(['dashboardType']),
...mapState('vulnerabilities', ['selectedVulnerabilities']), ...mapState('vulnerabilities', ['selectedVulnerabilities']),
...@@ -63,6 +68,10 @@ export default { ...@@ -63,6 +68,10 @@ export default {
return Boolean(this.selectedVulnerabilities[this.vulnerability.id]); return Boolean(this.selectedVulnerabilities[this.vulnerability.id]);
}, },
}, },
mounted() {
// this.$el.addEventListener('focusin', this.showActionButtons);
// this.$el.addEventListener('focusout', this.hideActionButtons);
},
methods: { methods: {
...mapActions('vulnerabilities', ['openModal', 'selectVulnerability', 'deselectVulnerability']), ...mapActions('vulnerabilities', ['openModal', 'selectVulnerability', 'deselectVulnerability']),
toggleVulnerability() { toggleVulnerability() {
...@@ -71,6 +80,12 @@ export default { ...@@ -71,6 +80,12 @@ export default {
} }
return this.selectVulnerability(this.vulnerability); return this.selectVulnerability(this.vulnerability);
}, },
showActionButtons() {
this.shouldShowActionButtons = true;
},
hideActionButtons() {
this.shouldShowActionButtons = false;
},
}, },
}; };
</script> </script>
...@@ -79,6 +94,10 @@ export default { ...@@ -79,6 +94,10 @@ export default {
<div <div
class="gl-responsive-table-row vulnerabilities-row p-2" class="gl-responsive-table-row vulnerabilities-row p-2"
:class="{ dismissed: isDismissed, 'gl-bg-blue-50': isSelected }" :class="{ dismissed: isDismissed, 'gl-bg-blue-50': isSelected }"
@focusin="showActionButtons"
@focusout="hideActionButtons"
@mouseenter="showActionButtons"
@mouseleave="hideActionButtons"
> >
<div class="table-section"> <div class="table-section">
<gl-form-checkbox <gl-form-checkbox
...@@ -91,13 +110,16 @@ export default { ...@@ -91,13 +110,16 @@ export default {
<div class="table-section section-10"> <div class="table-section section-10">
<div class="table-mobile-header" role="rowheader">{{ s__('Reports|Severity') }}</div> <div class="table-mobile-header" role="rowheader">{{ s__('Reports|Severity') }}</div>
<div class="table-mobile-content"><severity-badge :severity="severity" /></div> <div class="table-mobile-content" :style="[isDismissed && { opacity: 0.5 }]">
<severity-badge :severity="severity" />
</div>
</div> </div>
<div class="table-section flex-grow-1"> <div class="table-section flex-grow-1">
<div class="table-mobile-header" role="rowheader">{{ s__('Reports|Vulnerability') }}</div> <div class="table-mobile-header" role="rowheader">{{ s__('Reports|Vulnerability') }}</div>
<div <div
class="table-mobile-content gl-white-space-normal" class="table-mobile-content gl-white-space-normal"
:style="[isDismissed && { opacity: 0.5 }]"
data-qa-selector="vulnerability_info_content" data-qa-selector="vulnerability_info_content"
> >
<gl-skeleton-loading v-if="isLoading" class="mt-2 js-skeleton-loader" :lines="2" /> <gl-skeleton-loading v-if="isLoading" class="mt-2 js-skeleton-loader" :lines="2" />
...@@ -134,7 +156,10 @@ export default { ...@@ -134,7 +156,10 @@ export default {
<div class="table-section section-20"> <div class="table-section section-20">
<div class="table-mobile-header" role="rowheader">{{ s__('Reports|Actions') }}</div> <div class="table-mobile-header" role="rowheader">{{ s__('Reports|Actions') }}</div>
<div class="table-mobile-content action-buttons d-flex justify-content-end"> <div
class="table-mobile-content action-buttons d-flex justify-content-end"
:style="[shouldShowActionButtons ? { opacity: 1 } : { opacity: 0 }]"
>
<vulnerability-action-buttons <vulnerability-action-buttons
v-if="!isLoading" v-if="!isLoading"
:vulnerability="vulnerability" :vulnerability="vulnerability"
...@@ -150,9 +175,9 @@ export default { ...@@ -150,9 +175,9 @@ export default {
<style scoped> <style scoped>
@media (min-width: 768px) { @media (min-width: 768px) {
/* NOTE: Can be removed: border are defined at: line 40, app/assets/stylesheets/framework/responsive_tables.scss*/ /* NOTE: Can be removed: border are defined at: line 40, app/assets/stylesheets/framework/responsive_tables.scss*/
.vulnerabilities-row:last-child { /*.vulnerabilities-row:last-child {*/
border-bottom: 1px solid transparent; /* border-bottom: 1px solid transparent;*/
} /*}*/
/*this should be done by gitlab-ui table and using `.table-hover`*/ /*this should be done by gitlab-ui table and using `.table-hover`*/
.vulnerabilities-row:hover, .vulnerabilities-row:hover,
...@@ -163,14 +188,14 @@ export default { ...@@ -163,14 +188,14 @@ export default {
margin-top: -1px; margin-top: -1px;
} }
.vulnerabilities-row .action-buttons { /*.vulnerabilities-row .action-buttons {*/
opacity: 0; /* opacity: 0;*/
} /*}*/
.vulnerabilities-row:hover .action-buttons, /*.vulnerabilities-row:hover .action-buttons,*/
.vulnerabilities-row:focus-within .action-buttons { /*.vulnerabilities-row:focus-within .action-buttons {*/
opacity: 1; /* opacity: 1;*/
} /*}*/
} }
/*NOTE: replaced by gl-white-space-normal*/ /*NOTE: replaced by gl-white-space-normal*/
...@@ -194,7 +219,7 @@ export default { ...@@ -194,7 +219,7 @@ export default {
/*font-size: 0.8em;*/ /*font-size: 0.8em;*/
} }
.dismissed .table-mobile-content:not(.action-buttons) { /*.dismissed .table-mobile-content:not(.action-buttons) {*/
opacity: 0.5; /* opacity: 0.5;*/
} /*}*/
</style> </style>
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