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
before_action :authorize_read_build!, only: [:index]
before_action :authorize_create_pipeline!, only: [:new, :create]
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]
......
......@@ -88,6 +88,9 @@ export default {
shouldShowCountList() {
return this.isLockedToProject && Boolean(this.vulnerabilitiesCountEndpoint);
},
showHideDismissedToggle() {
return Boolean(gon.features && gon.features.hideDismissedVulnerabilities);
},
},
watch: {
'pageInfo.total': 'emitVulnerabilitiesCountChanged',
......@@ -100,7 +103,9 @@ export default {
});
}
this.setPipelineId(this.pipelineId);
this.setHideDismissedToggleInitialState();
if (this.showHideDismissedToggle) {
this.setHideDismissedToggleInitialState();
}
this.setProjectsEndpoint(this.projectsEndpoint);
this.setVulnerabilitiesEndpoint(this.vulnerabilitiesEndpoint);
this.setVulnerabilitiesCountEndpoint(this.vulnerabilitiesCountEndpoint);
......@@ -143,7 +148,7 @@ export default {
<template>
<section>
<header>
<filters />
<filters :show-hide-dismissed-toggle="showHideDismissedToggle" />
</header>
<vulnerability-count-list v-if="shouldShowCountList" class="mb-0" />
......
......@@ -8,6 +8,13 @@ export default {
DashboardFilter,
GlToggleVuex,
},
props: {
showHideDismissedToggle: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
...mapGetters({
filters: 'filters/visibleFilters',
......@@ -25,7 +32,7 @@ export default {
class="col-sm-6 col-md-4 col-lg-2 p-2 js-filter"
: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>
<gl-toggle-vuex
class="d-block mt-1 js-toggle"
......
......@@ -33,7 +33,9 @@ export const activeFilters = state => {
}, {});
// 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
filters.hide_dismissed = state.hide_dismissed;
if (gon.features && gon.features.hideDismissedVulnerabilities) {
filters.hide_dismissed = state.hide_dismissed;
}
return filters;
};
......
......@@ -2,6 +2,10 @@
class Groups::Security::DashboardController < Groups::ApplicationController
layout 'group'
before_action only: [:show] do
push_frontend_feature_flag(:hide_dismissed_vulnerabilities)
end
def show
render :unavailable unless dashboard_available?
end
......
......@@ -7,6 +7,10 @@ module Projects
alias_method :vulnerable, :project
before_action only: [:show] do
push_frontend_feature_flag(:hide_dismissed_vulnerabilities)
end
def show
@pipeline = @project.latest_pipeline_with_security_reports
&.present(current_user: current_user)
......
......@@ -170,6 +170,8 @@ describe('Security Dashboard app', () => {
describe('dismissed vulnerabilities', () => {
beforeEach(() => {
gon.features = gon.features || {};
gon.features.hideDismissedVulnerabilities = true;
getParameterValues.mockImplementation(() => [true]);
setup();
});
......
......@@ -10,7 +10,12 @@ describe('Filter component', () => {
describe('severity', () => {
beforeEach(() => {
vm = mountComponentWithStore(Component, { store });
vm = mountComponentWithStore(Component, {
store,
props: {
showHideDismissedToggle: true,
},
});
});
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