Commit 41f960f1 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '223189-remove-deprecated-group-security-dashboard-code' into 'master'

Delete deprecated group security dashboard code

See merge request gitlab-org/gitlab!37749
parents 83314b1f dd01dce7
import initGroupSecurityDashboard from 'ee/security_dashboard/group_init';
import leaveByUrl from '~/namespaces/leave_by_url';
import initGroupDetails from '~/pages/groups/shared/group_details';
import initGroupAnalytics from 'ee/analytics/group_analytics/group_analytics_bundle';
......@@ -7,12 +6,7 @@ import initVueAlerts from '~/vue_alerts';
document.addEventListener('DOMContentLoaded', () => {
leaveByUrl('group');
if (document.querySelector('#js-group-security-dashboard')) {
initGroupSecurityDashboard();
} else {
initGroupDetails();
}
initGroupAnalytics();
initVueAlerts();
});
<script>
import { mapActions } from 'vuex';
import { GlEmptyState } from '@gitlab/ui';
import SecurityDashboard from './security_dashboard_vuex.vue';
export default {
name: 'GroupSecurityDashboard',
components: {
GlEmptyState,
SecurityDashboard,
},
props: {
dashboardDocumentation: {
type: String,
required: true,
},
emptyStateSvgPath: {
type: String,
required: true,
},
projectsEndpoint: {
type: String,
required: true,
},
vulnerabilitiesEndpoint: {
type: String,
required: true,
},
vulnerabilitiesHistoryEndpoint: {
type: String,
required: true,
},
vulnerabilityFeedbackHelpPath: {
type: String,
required: true,
},
vulnerableProjectsEndpoint: {
type: String,
required: true,
},
},
created() {
this.setProjectsEndpoint(this.projectsEndpoint);
this.fetchProjects();
},
methods: {
...mapActions('projects', ['setProjectsEndpoint', 'fetchProjects']),
},
};
</script>
<template>
<security-dashboard
:vulnerabilities-endpoint="vulnerabilitiesEndpoint"
:vulnerabilities-history-endpoint="vulnerabilitiesHistoryEndpoint"
:vulnerability-feedback-help-path="vulnerabilityFeedbackHelpPath"
:vulnerable-projects-endpoint="vulnerableProjectsEndpoint"
>
<template #emptyState>
<gl-empty-state
:title="s__(`SecurityReports|No vulnerabilities found for this group`)"
:svg-path="emptyStateSvgPath"
:description="
s__(
`SecurityReports|While it's rare to have no vulnerabilities for your group, it can happen. In any event, we ask that you double check your settings to make sure you've set up your dashboard correctly.`,
)
"
:primary-button-link="dashboardDocumentation"
:primary-button-text="s__('SecurityReports|Learn more about setting up your dashboard')"
/>
</template>
</security-dashboard>
</template>
import Vue from 'vue';
import GroupSecurityDashboard from './components/group_security_dashboard.vue';
import UnavailableState from './components/unavailable_state.vue';
import createStore from './store';
import { DASHBOARD_TYPES } from './store/constants';
import projectsPlugin from './store/plugins/projects';
export default () => {
const el = document.getElementById('js-group-security-dashboard');
const { isUnavailable, dashboardDocumentation, emptyStateSvgPath } = el.dataset;
if (isUnavailable) {
return new Vue({
el,
render(createElement) {
return createElement(UnavailableState, {
props: {
link: dashboardDocumentation,
svgPath: emptyStateSvgPath,
},
});
},
});
}
const store = createStore({
dashboardType: DASHBOARD_TYPES.GROUP,
plugins: [projectsPlugin],
});
return new Vue({
el,
store,
render(createElement) {
return createElement(GroupSecurityDashboard, {
props: {
dashboardDocumentation: el.dataset.dashboardDocumentation,
emptyStateSvgPath: el.dataset.emptyStateSvgPath,
projectsEndpoint: el.dataset.projectsEndpoint,
vulnerabilityFeedbackHelpPath: el.dataset.vulnerabilityFeedbackHelpPath,
vulnerabilitiesEndpoint: el.dataset.vulnerabilitiesEndpoint,
vulnerabilitiesHistoryEndpoint: el.dataset.vulnerabilitiesHistoryEndpoint,
vulnerableProjectsEndpoint: el.dataset.vulnerableProjectsEndpoint,
},
});
},
});
};
import Vuex from 'vuex';
import { GlEmptyState } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import GroupSecurityDashboard from 'ee/security_dashboard/components/group_security_dashboard.vue';
import SecurityDashboard from 'ee/security_dashboard/components/security_dashboard_vuex.vue';
const localVue = createLocalVue();
localVue.use(Vuex);
const dashboardDocumentation = '/help/docs';
const emptyStateSvgPath = '/svgs/empty/svg';
const projectsEndpoint = '/projects';
const vulnerabilitiesEndpoint = '/vulnerabilities';
const vulnerabilitiesHistoryEndpoint = '/vulnerabilities_history';
const vulnerabilityFeedbackHelpPath = '/vulnerabilities_feedback_help';
const vulnerableProjectsEndpoint = '/vulnerable_projects';
describe('Group Security Dashboard component', () => {
let store;
let wrapper;
const factory = options => {
store = new Vuex.Store({
modules: {
projects: {
namespaced: true,
actions: {
fetchProjects() {},
setProjectsEndpoint() {},
},
},
},
});
jest.spyOn(store, 'dispatch').mockImplementation();
wrapper = shallowMount(GroupSecurityDashboard, {
localVue,
store,
propsData: {
dashboardDocumentation,
emptyStateSvgPath,
projectsEndpoint,
vulnerabilitiesEndpoint,
vulnerabilitiesHistoryEndpoint,
vulnerabilityFeedbackHelpPath,
vulnerableProjectsEndpoint,
},
...options,
});
};
afterEach(() => {
wrapper.destroy();
});
describe('on creation', () => {
beforeEach(() => {
factory();
});
it('dispatches the expected actions', () => {
expect(store.dispatch.mock.calls).toEqual([
['projects/setProjectsEndpoint', projectsEndpoint],
['projects/fetchProjects', undefined],
]);
});
it('renders the security dashboard', () => {
const dashboard = wrapper.find(SecurityDashboard);
expect(dashboard.exists()).toBe(true);
expect(dashboard.props()).toEqual(
expect.objectContaining({
vulnerabilitiesEndpoint,
vulnerabilitiesHistoryEndpoint,
vulnerabilityFeedbackHelpPath,
vulnerableProjectsEndpoint,
}),
);
});
});
describe('with a stubbed dashboard for slot testing', () => {
beforeEach(() => {
factory({
stubs: {
'security-dashboard': { template: '<div><slot name="emptyState"></slot></div>' },
},
});
});
it('renders empty state component with correct props', () => {
const emptyState = wrapper.find(GlEmptyState);
expect(emptyState.attributes('title')).toBe('No vulnerabilities found for this group');
});
});
});
......@@ -21156,9 +21156,6 @@ msgstr ""
msgid "SecurityReports|No vulnerabilities found"
msgstr ""
msgid "SecurityReports|No vulnerabilities found for this group"
msgstr ""
msgid "SecurityReports|No vulnerabilities found for this pipeline"
msgstr ""
......@@ -21261,9 +21258,6 @@ msgstr ""
msgid "SecurityReports|Undo dismiss"
msgstr ""
msgid "SecurityReports|While it's rare to have no vulnerabilities for your group, it can happen. In any event, we ask that you double check your settings to make sure you've set up your dashboard correctly."
msgstr ""
msgid "SecurityReports|While it's rare to have no vulnerabilities for your pipeline, it can happen. In any event, we ask that you double check your settings to make sure all security scanning jobs have passed successfully."
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