Commit af495ea3 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '287681-show-alert-tab' into 'master'

Create feature flag for threat monitoring alerts tab

See merge request gitlab-org/gitlab!48400
parents 1522f7fa 1a02ca79
...@@ -3,6 +3,7 @@ import { mapActions } from 'vuex'; ...@@ -3,6 +3,7 @@ import { mapActions } from 'vuex';
import { GlAlert, GlEmptyState, GlIcon, GlLink, GlPopover, GlTabs, GlTab } from '@gitlab/ui'; import { GlAlert, GlEmptyState, GlIcon, GlLink, GlPopover, GlTabs, GlTab } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import ThreatAlerts from './threat_alerts.vue';
import ThreatMonitoringFilters from './threat_monitoring_filters.vue'; import ThreatMonitoringFilters from './threat_monitoring_filters.vue';
import ThreatMonitoringSection from './threat_monitoring_section.vue'; import ThreatMonitoringSection from './threat_monitoring_section.vue';
import NetworkPolicyList from './network_policy_list.vue'; import NetworkPolicyList from './network_policy_list.vue';
...@@ -17,6 +18,7 @@ export default { ...@@ -17,6 +18,7 @@ export default {
GlPopover, GlPopover,
GlTabs, GlTabs,
GlTab, GlTab,
ThreatAlerts,
ThreatMonitoringFilters, ThreatMonitoringFilters,
ThreatMonitoringSection, ThreatMonitoringSection,
NetworkPolicyList, NetworkPolicyList,
...@@ -74,6 +76,11 @@ export default { ...@@ -74,6 +76,11 @@ export default {
isSetUpMaybe: this.isValidEnvironmentId(this.defaultEnvironmentId), isSetUpMaybe: this.isValidEnvironmentId(this.defaultEnvironmentId),
}; };
}, },
computed: {
showAlertsTab() {
return gon.features.threatMonitoringAlerts;
},
},
created() { created() {
if (this.isSetUpMaybe) { if (this.isSetUpMaybe) {
this.setCurrentEnvironmentId(this.defaultEnvironmentId); this.setCurrentEnvironmentId(this.defaultEnvironmentId);
...@@ -161,6 +168,13 @@ export default { ...@@ -161,6 +168,13 @@ export default {
</header> </header>
<gl-tabs> <gl-tabs>
<gl-tab
v-if="showAlertsTab"
:title="s__('ThreatMonitoring|Alerts')"
data-testid="threat-monitoring-alerts-tab"
>
<threat-alerts />
</gl-tab>
<gl-tab ref="networkPolicyTab" :title="s__('ThreatMonitoring|Policies')"> <gl-tab ref="networkPolicyTab" :title="s__('ThreatMonitoring|Policies')">
<network-policy-list <network-policy-list
:documentation-path="documentationPath" :documentation-path="documentationPath"
......
<script>
export default {
name: 'ThreatAlerts',
};
</script>
<template>
<div></div>
</template>
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
module Projects module Projects
class ThreatMonitoringController < Projects::ApplicationController class ThreatMonitoringController < Projects::ApplicationController
before_action :authorize_read_threat_monitoring! before_action :authorize_read_threat_monitoring!
before_action do
push_frontend_feature_flag(:threat_monitoring_alerts, project)
end
feature_category :web_firewall feature_category :web_firewall
......
---
name: threat_monitoring_alerts
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48400
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/287676
milestone: '13.7'
type: development
group: group::container security
default_enabled: false
import { GlAlert } from '@gitlab/ui'; import { GlAlert } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import ThreatMonitoringAlerts from 'ee/threat_monitoring/components/threat_alerts.vue';
import ThreatMonitoringApp from 'ee/threat_monitoring/components/app.vue'; import ThreatMonitoringApp from 'ee/threat_monitoring/components/app.vue';
import ThreatMonitoringFilters from 'ee/threat_monitoring/components/threat_monitoring_filters.vue'; import ThreatMonitoringFilters from 'ee/threat_monitoring/components/threat_monitoring_filters.vue';
import createStore from 'ee/threat_monitoring/store'; import createStore from 'ee/threat_monitoring/store';
...@@ -23,6 +24,7 @@ const userCalloutsPath = `${TEST_HOST}/user_callouts`; ...@@ -23,6 +24,7 @@ const userCalloutsPath = `${TEST_HOST}/user_callouts`;
describe('ThreatMonitoringApp component', () => { describe('ThreatMonitoringApp component', () => {
let store; let store;
let wrapper; let wrapper;
window.gon = { features: {} };
const factory = ({ propsData, state, options } = {}) => { const factory = ({ propsData, state, options } = {}) => {
store = createStore(); store = createStore();
...@@ -55,13 +57,16 @@ describe('ThreatMonitoringApp component', () => { ...@@ -55,13 +57,16 @@ describe('ThreatMonitoringApp component', () => {
}; };
const findAlert = () => wrapper.find(GlAlert); const findAlert = () => wrapper.find(GlAlert);
const findAlertsView = () => wrapper.find(ThreatMonitoringAlerts);
const findFilters = () => wrapper.find(ThreatMonitoringFilters); const findFilters = () => wrapper.find(ThreatMonitoringFilters);
const findWafSection = () => wrapper.find({ ref: 'wafSection' }); const findWafSection = () => wrapper.find({ ref: 'wafSection' });
const findNetworkPolicySection = () => wrapper.find({ ref: 'networkPolicySection' }); const findNetworkPolicySection = () => wrapper.find({ ref: 'networkPolicySection' });
const findEmptyState = () => wrapper.find({ ref: 'emptyState' }); const findEmptyState = () => wrapper.find({ ref: 'emptyState' });
const findNetworkPolicyTab = () => wrapper.find({ ref: 'networkPolicyTab' }); const findNetworkPolicyTab = () => wrapper.find({ ref: 'networkPolicyTab' });
const findAlertTab = () => wrapper.find('[data-testid="threat-monitoring-alerts-tab"]');
afterEach(() => { afterEach(() => {
window.gon.features = {};
wrapper.destroy(); wrapper.destroy();
wrapper = null; wrapper = null;
}); });
...@@ -124,6 +129,10 @@ describe('ThreatMonitoringApp component', () => { ...@@ -124,6 +129,10 @@ describe('ThreatMonitoringApp component', () => {
expect(findNetworkPolicyTab().element).toMatchSnapshot(); expect(findNetworkPolicyTab().element).toMatchSnapshot();
}); });
it('does not show the alert tab', () => {
expect(findAlertTab().exists()).toBe(false);
});
describe('dismissing the alert', () => { describe('dismissing the alert', () => {
let mockAxios; let mockAxios;
...@@ -162,4 +171,17 @@ describe('ThreatMonitoringApp component', () => { ...@@ -162,4 +171,17 @@ describe('ThreatMonitoringApp component', () => {
expect(findAlert().exists()).toBe(false); expect(findAlert().exists()).toBe(false);
}); });
}); });
describe('alerts tab', () => {
beforeEach(() => {
window.gon.features.threatMonitoringAlerts = true;
factory({});
});
it('shows the alerts tab', () => {
expect(findAlertTab().exists()).toBe(true);
});
it('shows the default alerts component', () => {
expect(findAlertsView().exists()).toBe(true);
});
});
}); });
...@@ -28152,6 +28152,9 @@ msgstr "" ...@@ -28152,6 +28152,9 @@ msgstr ""
msgid "Threat Monitoring" msgid "Threat Monitoring"
msgstr "" msgstr ""
msgid "ThreatMonitoring|Alerts"
msgstr ""
msgid "ThreatMonitoring|All Environments" msgid "ThreatMonitoring|All Environments"
msgstr "" msgstr ""
......
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