Commit 46cd76e1 authored by Phil Hughes's avatar Phil Hughes

Merge branch '210561-remove-user-callout-code' into 'master'

Remove information alert about waf feature

See merge request gitlab-org/gitlab!55927
parents cd2f34b7 8c7eba69
<script> <script>
import { GlAlert, GlIcon, GlLink, GlPopover, GlTabs, GlTab } from '@gitlab/ui'; import { GlIcon, GlLink, GlPopover, GlTabs, GlTab } from '@gitlab/ui';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import axios from '~/lib/utils/axios_utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import Alerts from './alerts/alerts.vue'; import Alerts from './alerts/alerts.vue';
...@@ -13,7 +12,6 @@ import ThreatMonitoringSection from './threat_monitoring_section.vue'; ...@@ -13,7 +12,6 @@ import ThreatMonitoringSection from './threat_monitoring_section.vue';
export default { export default {
name: 'ThreatMonitoring', name: 'ThreatMonitoring',
components: { components: {
GlAlert,
GlIcon, GlIcon,
GlLink, GlLink,
GlPopover, GlPopover,
...@@ -40,18 +38,6 @@ export default { ...@@ -40,18 +38,6 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
showUserCallout: {
type: Boolean,
required: true,
},
userCalloutId: {
type: String,
required: true,
},
userCalloutsPath: {
type: String,
required: true,
},
newPolicyPath: { newPolicyPath: {
type: String, type: String,
required: true, required: true,
...@@ -59,8 +45,6 @@ export default { ...@@ -59,8 +45,6 @@ export default {
}, },
data() { data() {
return { return {
showAlert: this.showUserCallout,
// We require the project to have at least one available environment. // We require the project to have at least one available environment.
// An invalid default environment id means there there are no available // An invalid default environment id means there there are no available
// environments, therefore infrastructure cannot be set up. A valid default // environments, therefore infrastructure cannot be set up. A valid default
...@@ -84,13 +68,6 @@ export default { ...@@ -84,13 +68,6 @@ export default {
isValidEnvironmentId(id) { isValidEnvironmentId(id) {
return Number.isInteger(id) && id >= 0; return Number.isInteger(id) && id >= 0;
}, },
dismissAlert() {
this.showAlert = false;
axios.post(this.userCalloutsPath, {
feature_name: this.userCalloutId,
});
},
}, },
chartEmptyStateDescription: s__( chartEmptyStateDescription: s__(
`ThreatMonitoring|While it's rare to have no traffic coming to your `ThreatMonitoring|While it's rare to have no traffic coming to your
...@@ -105,29 +82,12 @@ export default { ...@@ -105,29 +82,12 @@ export default {
`ThreatMonitoring|Container Network Policies are not installed or have been disabled. To view `ThreatMonitoring|Container Network Policies are not installed or have been disabled. To view
this data, ensure your Network Policies are installed and enabled for your cluster.`, this data, ensure your Network Policies are installed and enabled for your cluster.`,
), ),
alertText: s__(
`ThreatMonitoring|The graph below is an overview of traffic coming to your
application as tracked by the Web Application Firewall (WAF). View the docs
for instructions on how to access the WAF logs to see what type of
malicious traffic is trying to access your app. The docs link is also
accessible by clicking the "?" icon next to the title below.`,
),
helpPopoverText: s__('ThreatMonitoring|View documentation'), helpPopoverText: s__('ThreatMonitoring|View documentation'),
}; };
</script> </script>
<template> <template>
<section> <section>
<gl-alert
v-if="showAlert"
class="my-3"
variant="info"
:secondary-button-link="documentationPath"
:secondary-button-text="__('View documentation')"
@dismiss="dismissAlert"
>
{{ $options.alertText }}
</gl-alert>
<header class="my-3"> <header class="my-3">
<h2 class="h3 mb-1"> <h2 class="h3 mb-1">
{{ s__('ThreatMonitoring|Threat Monitoring') }} {{ s__('ThreatMonitoring|Threat Monitoring') }}
......
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql'; import createDefaultClient from '~/lib/graphql';
import { parseBoolean } from '~/lib/utils/common_utils';
import ThreatMonitoringApp from './components/app.vue'; import ThreatMonitoringApp from './components/app.vue';
import createStore from './store'; import createStore from './store';
...@@ -25,9 +24,6 @@ export default () => { ...@@ -25,9 +24,6 @@ export default () => {
documentationPath, documentationPath,
defaultEnvironmentId, defaultEnvironmentId,
projectPath, projectPath,
showUserCallout,
userCalloutId,
userCalloutsPath,
} = el.dataset; } = el.dataset;
const store = createStore(); const store = createStore();
...@@ -55,9 +51,6 @@ export default () => { ...@@ -55,9 +51,6 @@ export default () => {
wafNoDataSvgPath, wafNoDataSvgPath,
networkPolicyNoDataSvgPath, networkPolicyNoDataSvgPath,
defaultEnvironmentId: parseInt(defaultEnvironmentId, 10), defaultEnvironmentId: parseInt(defaultEnvironmentId, 10),
showUserCallout: parseBoolean(showUserCallout),
userCalloutId,
userCalloutsPath,
newPolicyPath, newPolicyPath,
}, },
}); });
......
...@@ -11,7 +11,6 @@ module EE ...@@ -11,7 +11,6 @@ module EE
ULTIMATE_TRIAL = 'ultimate_trial' ULTIMATE_TRIAL = 'ultimate_trial'
NEW_USER_SIGNUPS_CAP_REACHED = 'new_user_signups_cap_reached' NEW_USER_SIGNUPS_CAP_REACHED = 'new_user_signups_cap_reached'
PERSONAL_ACCESS_TOKEN_EXPIRY = 'personal_access_token_expiry' PERSONAL_ACCESS_TOKEN_EXPIRY = 'personal_access_token_expiry'
THREAT_MONITORING_INFO = 'threat_monitoring_info'
EOA_BRONZE_PLAN_BANNER = 'eoa_bronze_plan_banner' EOA_BRONZE_PLAN_BANNER = 'eoa_bronze_plan_banner'
def render_enable_hashed_storage_warning def render_enable_hashed_storage_warning
...@@ -62,10 +61,6 @@ module EE ...@@ -62,10 +61,6 @@ module EE
render 'shared/check_recovery_settings' render 'shared/check_recovery_settings'
end end
def show_threat_monitoring_info?
!user_dismissed?(THREAT_MONITORING_INFO)
end
def show_token_expiry_notification? def show_token_expiry_notification?
return false unless current_user return false unless current_user
......
...@@ -14,7 +14,4 @@ ...@@ -14,7 +14,4 @@
new_policy_path: new_project_threat_monitoring_policy_path(@project), new_policy_path: new_project_threat_monitoring_policy_path(@project),
default_environment_id: default_environment_id, default_environment_id: default_environment_id,
project_path: @project.full_path, project_path: @project.full_path,
user_callouts_path: user_callouts_path,
user_callout_id: UserCalloutsHelper::THREAT_MONITORING_INFO,
show_user_callout: false,
} } } }
...@@ -43,21 +43,3 @@ exports[`ThreatMonitoringApp component given there is a default environment with ...@@ -43,21 +43,3 @@ exports[`ThreatMonitoringApp component given there is a default environment with
ylegend="Requests" ylegend="Requests"
/> />
`; `;
exports[`ThreatMonitoringApp component given there is a default environment with data shows the alert 1`] = `
<gl-alert-stub
class="my-3"
dismissible="true"
dismisslabel="Dismiss"
primarybuttonlink=""
primarybuttontext=""
secondarybuttonlink="/docs"
secondarybuttontext="View documentation"
title=""
variant="info"
>
The graph below is an overview of traffic coming to your application as tracked by the Web Application Firewall (WAF). View the docs for instructions on how to access the WAF logs to see what type of malicious traffic is trying to access your app. The docs link is also accessible by clicking the "?" icon next to the title below.
</gl-alert-stub>
`;
import { GlAlert } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter';
import ThreatMonitoringAlerts from 'ee/threat_monitoring/components/alerts/alerts.vue'; import ThreatMonitoringAlerts from 'ee/threat_monitoring/components/alerts/alerts.vue';
import ThreatMonitoringApp from 'ee/threat_monitoring/components/app.vue'; import ThreatMonitoringApp from 'ee/threat_monitoring/components/app.vue';
import NetworkPolicyList from 'ee/threat_monitoring/components/network_policy_list.vue'; import NetworkPolicyList from 'ee/threat_monitoring/components/network_policy_list.vue';
...@@ -9,7 +7,6 @@ import ThreatMonitoringFilters from 'ee/threat_monitoring/components/threat_moni ...@@ -9,7 +7,6 @@ import ThreatMonitoringFilters from 'ee/threat_monitoring/components/threat_moni
import createStore from 'ee/threat_monitoring/store'; import createStore from 'ee/threat_monitoring/store';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import axios from '~/lib/utils/axios_utils';
const defaultEnvironmentId = 3; const defaultEnvironmentId = 3;
const documentationPath = '/docs'; const documentationPath = '/docs';
...@@ -20,8 +17,6 @@ const networkPolicyNoDataSvgPath = '/network-policy-no-data-svg'; ...@@ -20,8 +17,6 @@ const networkPolicyNoDataSvgPath = '/network-policy-no-data-svg';
const environmentsEndpoint = `${TEST_HOST}/environments`; const environmentsEndpoint = `${TEST_HOST}/environments`;
const wafStatisticsEndpoint = `${TEST_HOST}/waf`; const wafStatisticsEndpoint = `${TEST_HOST}/waf`;
const networkPolicyStatisticsEndpoint = `${TEST_HOST}/network_policy`; const networkPolicyStatisticsEndpoint = `${TEST_HOST}/network_policy`;
const userCalloutId = 'threat_monitoring_info';
const userCalloutsPath = `${TEST_HOST}/user_callouts`;
describe('ThreatMonitoringApp component', () => { describe('ThreatMonitoringApp component', () => {
let store; let store;
...@@ -46,9 +41,6 @@ describe('ThreatMonitoringApp component', () => { ...@@ -46,9 +41,6 @@ describe('ThreatMonitoringApp component', () => {
wafNoDataSvgPath, wafNoDataSvgPath,
networkPolicyNoDataSvgPath, networkPolicyNoDataSvgPath,
newPolicyPath, newPolicyPath,
showUserCallout: true,
userCalloutId,
userCalloutsPath,
...propsData, ...propsData,
}, },
provide: { provide: {
...@@ -62,7 +54,6 @@ describe('ThreatMonitoringApp component', () => { ...@@ -62,7 +54,6 @@ describe('ThreatMonitoringApp component', () => {
); );
}; };
const findAlert = () => wrapper.find(GlAlert);
const findAlertsView = () => wrapper.find(ThreatMonitoringAlerts); const findAlertsView = () => wrapper.find(ThreatMonitoringAlerts);
const findNetworkPolicyList = () => wrapper.find(NetworkPolicyList); const findNetworkPolicyList = () => wrapper.find(NetworkPolicyList);
const findFilters = () => wrapper.find(ThreatMonitoringFilters); const findFilters = () => wrapper.find(ThreatMonitoringFilters);
...@@ -125,10 +116,6 @@ describe('ThreatMonitoringApp component', () => { ...@@ -125,10 +116,6 @@ describe('ThreatMonitoringApp component', () => {
]); ]);
}); });
it('shows the alert', () => {
expect(findAlert().element).toMatchSnapshot();
});
it('shows the filter bar', () => { it('shows the filter bar', () => {
expect(findFilters().exists()).toBe(true); expect(findFilters().exists()).toBe(true);
}); });
...@@ -148,44 +135,6 @@ describe('ThreatMonitoringApp component', () => { ...@@ -148,44 +135,6 @@ describe('ThreatMonitoringApp component', () => {
it('does not show the alert tab', () => { it('does not show the alert tab', () => {
expect(findAlertTab().exists()).toBe(false); expect(findAlertTab().exists()).toBe(false);
}); });
describe('dismissing the alert', () => {
let mockAxios;
beforeEach(() => {
mockAxios = new MockAdapter(axios);
mockAxios.onPost(userCalloutsPath, { feature_name: userCalloutId }).reply(200);
findAlert().vm.$emit('dismiss');
return wrapper.vm.$nextTick();
});
afterEach(() => {
mockAxios.restore();
});
it('hides the alert', () => {
expect(findAlert().exists()).toBe(false);
});
it('posts the dismissal to the user callouts endpoint', () => {
expect(mockAxios.history.post).toHaveLength(1);
});
});
});
describe('given showUserCallout is false', () => {
beforeEach(() => {
factory({
propsData: {
showUserCallout: false,
},
});
});
it('does not render the alert', () => {
expect(findAlert().exists()).toBe(false);
});
}); });
describe('alerts tab', () => { describe('alerts tab', () => {
......
...@@ -215,28 +215,6 @@ RSpec.describe EE::UserCalloutsHelper do ...@@ -215,28 +215,6 @@ RSpec.describe EE::UserCalloutsHelper do
end end
end end
describe '.show_threat_monitoring_info?' do
subject { helper.show_threat_monitoring_info? }
let(:user) { create(:user) }
before do
allow(helper).to receive(:current_user).and_return(user)
end
context 'when the threat monitoring info has not been dismissed' do
it { is_expected.to be_truthy }
end
context 'when the threat monitoring info was dismissed' do
before do
create(:user_callout, user: user, feature_name: described_class::THREAT_MONITORING_INFO)
end
it { is_expected.to be_falsy }
end
end
describe '.show_token_expiry_notification?' do describe '.show_token_expiry_notification?' do
subject { helper.show_token_expiry_notification? } subject { helper.show_token_expiry_notification? }
......
...@@ -30946,9 +30946,6 @@ msgstr "" ...@@ -30946,9 +30946,6 @@ msgstr ""
msgid "ThreatMonitoring|The firewall is not installed or has been disabled. To view this data, ensure the web application firewall is installed and enabled for your cluster." msgid "ThreatMonitoring|The firewall is not installed or has been disabled. To view this data, ensure the web application firewall is installed and enabled for your cluster."
msgstr "" msgstr ""
msgid "ThreatMonitoring|The graph below is an overview of traffic coming to your application as tracked by the Web Application Firewall (WAF). View the docs for instructions on how to access the WAF logs to see what type of malicious traffic is trying to access your app. The docs link is also accessible by clicking the \"?\" icon next to the title below."
msgstr ""
msgid "ThreatMonitoring|There was an error displaying the alerts. Confirm your endpoint's configuration details to ensure alerts appear." msgid "ThreatMonitoring|There was an error displaying the alerts. Confirm your endpoint's configuration details to ensure alerts appear."
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