Commit 4d5e984e authored by Paul Gascou-Vaillancourt's avatar Paul Gascou-Vaillancourt Committed by Clement Ho

Place "Hide dismissed vulnerabilities" toggle behind a feature flag

The toggle has been placed behind the hide_dismissed_vulnerabilities
feature flag while the backend is being completed
parent feb8ac37
...@@ -8,6 +8,9 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -8,6 +8,9 @@ class Projects::PipelinesController < Projects::ApplicationController
before_action :authorize_read_build!, only: [:index] before_action :authorize_read_build!, only: [:index]
before_action :authorize_create_pipeline!, only: [:new, :create] before_action :authorize_create_pipeline!, only: [:new, :create]
before_action :authorize_update_pipeline!, only: [:retry, :cancel] before_action :authorize_update_pipeline!, only: [:retry, :cancel]
before_action do
push_frontend_feature_flag(:hide_dismissed_vulnerabilities)
end
around_action :allow_gitaly_ref_name_caching, only: [:index, :show] around_action :allow_gitaly_ref_name_caching, only: [:index, :show]
......
...@@ -88,6 +88,9 @@ export default { ...@@ -88,6 +88,9 @@ export default {
shouldShowCountList() { shouldShowCountList() {
return this.isLockedToProject && Boolean(this.vulnerabilitiesCountEndpoint); return this.isLockedToProject && Boolean(this.vulnerabilitiesCountEndpoint);
}, },
showHideDismissedToggle() {
return Boolean(gon.features && gon.features.hideDismissedVulnerabilities);
},
}, },
watch: { watch: {
'pageInfo.total': 'emitVulnerabilitiesCountChanged', 'pageInfo.total': 'emitVulnerabilitiesCountChanged',
...@@ -100,7 +103,9 @@ export default { ...@@ -100,7 +103,9 @@ export default {
}); });
} }
this.setPipelineId(this.pipelineId); this.setPipelineId(this.pipelineId);
this.setHideDismissedToggleInitialState(); if (this.showHideDismissedToggle) {
this.setHideDismissedToggleInitialState();
}
this.setProjectsEndpoint(this.projectsEndpoint); this.setProjectsEndpoint(this.projectsEndpoint);
this.setVulnerabilitiesEndpoint(this.vulnerabilitiesEndpoint); this.setVulnerabilitiesEndpoint(this.vulnerabilitiesEndpoint);
this.setVulnerabilitiesCountEndpoint(this.vulnerabilitiesCountEndpoint); this.setVulnerabilitiesCountEndpoint(this.vulnerabilitiesCountEndpoint);
...@@ -143,7 +148,7 @@ export default { ...@@ -143,7 +148,7 @@ export default {
<template> <template>
<section> <section>
<header> <header>
<filters /> <filters :show-hide-dismissed-toggle="showHideDismissedToggle" />
</header> </header>
<vulnerability-count-list v-if="shouldShowCountList" class="mb-0" /> <vulnerability-count-list v-if="shouldShowCountList" class="mb-0" />
......
...@@ -8,6 +8,13 @@ export default { ...@@ -8,6 +8,13 @@ export default {
DashboardFilter, DashboardFilter,
GlToggleVuex, GlToggleVuex,
}, },
props: {
showHideDismissedToggle: {
type: Boolean,
required: false,
default: false,
},
},
computed: { computed: {
...mapGetters({ ...mapGetters({
filters: 'filters/visibleFilters', filters: 'filters/visibleFilters',
...@@ -25,7 +32,7 @@ export default { ...@@ -25,7 +32,7 @@ export default {
class="col-sm-6 col-md-4 col-lg-2 p-2 js-filter" class="col-sm-6 col-md-4 col-lg-2 p-2 js-filter"
:filter-id="filter.id" :filter-id="filter.id"
/> />
<div class="ml-lg-auto p-2"> <div v-if="showHideDismissedToggle" class="ml-lg-auto p-2">
<strong>{{ s__('SecurityDashboard|Hide dismissed') }}</strong> <strong>{{ s__('SecurityDashboard|Hide dismissed') }}</strong>
<gl-toggle-vuex <gl-toggle-vuex
class="d-block mt-1 js-toggle" class="d-block mt-1 js-toggle"
......
...@@ -33,7 +33,9 @@ export const activeFilters = state => { ...@@ -33,7 +33,9 @@ export const activeFilters = state => {
}, {}); }, {});
// hide_dismissed is hardcoded as it currently is an edge-case, more info in the MR: // hide_dismissed is hardcoded as it currently is an edge-case, more info in the MR:
// https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/15333#note_208301144 // https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/15333#note_208301144
filters.hide_dismissed = state.hide_dismissed; if (gon.features && gon.features.hideDismissedVulnerabilities) {
filters.hide_dismissed = state.hide_dismissed;
}
return filters; return filters;
}; };
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
class Groups::Security::DashboardController < Groups::ApplicationController class Groups::Security::DashboardController < Groups::ApplicationController
layout 'group' layout 'group'
before_action only: [:show] do
push_frontend_feature_flag(:hide_dismissed_vulnerabilities)
end
def show def show
render :unavailable unless dashboard_available? render :unavailable unless dashboard_available?
end end
......
...@@ -7,6 +7,10 @@ module Projects ...@@ -7,6 +7,10 @@ module Projects
alias_method :vulnerable, :project alias_method :vulnerable, :project
before_action only: [:show] do
push_frontend_feature_flag(:hide_dismissed_vulnerabilities)
end
def show def show
@pipeline = @project.latest_pipeline_with_security_reports @pipeline = @project.latest_pipeline_with_security_reports
&.present(current_user: current_user) &.present(current_user: current_user)
......
...@@ -170,6 +170,8 @@ describe('Security Dashboard app', () => { ...@@ -170,6 +170,8 @@ describe('Security Dashboard app', () => {
describe('dismissed vulnerabilities', () => { describe('dismissed vulnerabilities', () => {
beforeEach(() => { beforeEach(() => {
gon.features = gon.features || {};
gon.features.hideDismissedVulnerabilities = true;
getParameterValues.mockImplementation(() => [true]); getParameterValues.mockImplementation(() => [true]);
setup(); setup();
}); });
......
...@@ -10,7 +10,12 @@ describe('Filter component', () => { ...@@ -10,7 +10,12 @@ describe('Filter component', () => {
describe('severity', () => { describe('severity', () => {
beforeEach(() => { beforeEach(() => {
vm = mountComponentWithStore(Component, { store }); vm = mountComponentWithStore(Component, {
store,
props: {
showHideDismissedToggle: true,
},
});
}); });
afterEach(() => { afterEach(() => {
......
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