From e94b83fe939d474f34941d980b2ca9330174772c Mon Sep 17 00:00:00 2001 From: Mark Florian Date: Wed, 2 Oct 2019 15:42:54 +0100 Subject: [PATCH 1/2] Update JS and HAML entry points --- .../pages/security/dashboard/show/index.js | 46 +++++++++++++++++++ .../javascripts/pages/security/index.js | 24 ---------- .../security/dashboard_controller.rb | 3 -- .../views/security/dashboard/show.html.haml | 11 +++++ ee/app/views/security/index.html.haml | 4 -- 5 files changed, 57 insertions(+), 31 deletions(-) create mode 100644 ee/app/assets/javascripts/pages/security/dashboard/show/index.js delete mode 100644 ee/app/assets/javascripts/pages/security/index.js create mode 100644 ee/app/views/security/dashboard/show.html.haml delete mode 100644 ee/app/views/security/index.html.haml diff --git a/ee/app/assets/javascripts/pages/security/dashboard/show/index.js b/ee/app/assets/javascripts/pages/security/dashboard/show/index.js new file mode 100644 index 00000000000000..99c95136a943d1 --- /dev/null +++ b/ee/app/assets/javascripts/pages/security/dashboard/show/index.js @@ -0,0 +1,46 @@ +import Vue from 'vue'; +import createRouter from 'ee/security_dashboard/store/router'; +import syncWithRouter from 'ee/security_dashboard/store/plugins/sync_with_router'; +import createStore from 'ee/security_dashboard/store'; +import InstanceSecurityDashboard from 'ee/security_dashboard/components/instance_security_dashboard.vue'; + +if (gon.features && gon.features.securityDashboard) { + document.addEventListener('DOMContentLoaded', () => { + const el = document.querySelector('#js-security'); + const { + dashboardDocumentation, + emptyStateSvgPath, + emptyDashboardStateSvgPath, + projectsEndpoint, + vulnerabilitiesCountEndpoint, + vulnerabilitiesEndpoint, + vulnerabilitiesHistoryEndpoint, + vulnerabilityFeedbackHelpPath, + } = el.dataset; + const router = createRouter(); + const store = createStore({ plugins: [syncWithRouter(router)] }); + + return new Vue({ + el, + router, + store, + components: { + InstanceSecurityDashboard, + }, + render(createElement) { + return createElement(InstanceSecurityDashboard, { + props: { + dashboardDocumentation, + emptyStateSvgPath, + emptyDashboardStateSvgPath, + projectsEndpoint, + vulnerabilitiesCountEndpoint, + vulnerabilitiesEndpoint, + vulnerabilitiesHistoryEndpoint, + vulnerabilityFeedbackHelpPath, + }, + }); + }, + }); + }); +} diff --git a/ee/app/assets/javascripts/pages/security/index.js b/ee/app/assets/javascripts/pages/security/index.js deleted file mode 100644 index db010145eec250..00000000000000 --- a/ee/app/assets/javascripts/pages/security/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import Vue from 'vue'; -import createStore from 'ee/security_dashboard/store'; -import router from 'ee/security_dashboard/store/router'; -import DashboardComponent from 'ee/security_dashboard/components/app.vue'; - -if (gon.features && gon.features.securityDashboard) { - document.addEventListener( - 'DOMContentLoaded', - () => - new Vue({ - el: '#js-security', - store: createStore(), - router, - components: { - DashboardComponent, - }, - render(createElement) { - return createElement(DashboardComponent, { - props: {}, - }); - }, - }), - ); -} diff --git a/ee/app/controllers/security/dashboard_controller.rb b/ee/app/controllers/security/dashboard_controller.rb index 0c3bbbd0772079..a74e08cbecaef2 100644 --- a/ee/app/controllers/security/dashboard_controller.rb +++ b/ee/app/controllers/security/dashboard_controller.rb @@ -2,8 +2,5 @@ module Security class DashboardController < ::Security::ApplicationController - def show - head :ok - end end end diff --git a/ee/app/views/security/dashboard/show.html.haml b/ee/app/views/security/dashboard/show.html.haml new file mode 100644 index 00000000000000..602f93e9cafc69 --- /dev/null +++ b/ee/app/views/security/dashboard/show.html.haml @@ -0,0 +1,11 @@ +- page_title _('Security Dashboard') +- @hide_breadcrumbs = true + +#js-security{ data: { vulnerabilities_endpoint: '/groups/gitlab-org/-/security/vulnerabilities', + vulnerabilities_count_endpoint: '/groups/gitlab-org/-/security/vulnerabilities/summary', + vulnerabilities_history_endpoint: '/groups/gitlab-org/-/security/vulnerabilities/history', + projects_endpoint: '/api/v4/groups/2/projects', + vulnerability_feedback_help_path: help_page_path('user/application_security/index', anchor: 'interacting-with-the-vulnerabilities'), + empty_state_svg_path: image_path('illustrations/operations-dashboard_empty.svg'), + empty_dashboard_state_svg_path: image_path('illustrations/security-dashboard-empty-state.svg'), + dashboard_documentation: help_page_path('user/application_security/security_dashboard/index', anchor: 'instance-security-dashboard') } } diff --git a/ee/app/views/security/index.html.haml b/ee/app/views/security/index.html.haml deleted file mode 100644 index 48a2c63137292d..00000000000000 --- a/ee/app/views/security/index.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -- page_title _('Security Dashboard') -- @hide_breadcrumbs = true - -#js-security -- GitLab From 5fbae48b648282967ee8612fd1b48f175004a795 Mon Sep 17 00:00:00 2001 From: Mark Florian Date: Mon, 14 Oct 2019 19:49:12 +0100 Subject: [PATCH 2/2] hack to make instance security dashboard work Uses Group Security Dashboard and Operations Dashboard endpoints instead of the real ones, which don't exist yet. --- .../javascripts/pages/security/dashboard/show/index.js | 9 ++++++--- ee/app/views/security/dashboard/show.html.haml | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ee/app/assets/javascripts/pages/security/dashboard/show/index.js b/ee/app/assets/javascripts/pages/security/dashboard/show/index.js index 99c95136a943d1..cfe1db5db1bd75 100644 --- a/ee/app/assets/javascripts/pages/security/dashboard/show/index.js +++ b/ee/app/assets/javascripts/pages/security/dashboard/show/index.js @@ -1,5 +1,6 @@ import Vue from 'vue'; import createRouter from 'ee/security_dashboard/store/router'; +import projectSelector from 'ee/security_dashboard/store/plugins/project_selector'; import syncWithRouter from 'ee/security_dashboard/store/plugins/sync_with_router'; import createStore from 'ee/security_dashboard/store'; import InstanceSecurityDashboard from 'ee/security_dashboard/components/instance_security_dashboard.vue'; @@ -11,14 +12,15 @@ if (gon.features && gon.features.securityDashboard) { dashboardDocumentation, emptyStateSvgPath, emptyDashboardStateSvgPath, - projectsEndpoint, + projectAddEndpoint, + projectListEndpoint, vulnerabilitiesCountEndpoint, vulnerabilitiesEndpoint, vulnerabilitiesHistoryEndpoint, vulnerabilityFeedbackHelpPath, } = el.dataset; const router = createRouter(); - const store = createStore({ plugins: [syncWithRouter(router)] }); + const store = createStore({ plugins: [projectSelector, syncWithRouter(router)] }); return new Vue({ el, @@ -33,7 +35,8 @@ if (gon.features && gon.features.securityDashboard) { dashboardDocumentation, emptyStateSvgPath, emptyDashboardStateSvgPath, - projectsEndpoint, + projectAddEndpoint, + projectListEndpoint, vulnerabilitiesCountEndpoint, vulnerabilitiesEndpoint, vulnerabilitiesHistoryEndpoint, diff --git a/ee/app/views/security/dashboard/show.html.haml b/ee/app/views/security/dashboard/show.html.haml index 602f93e9cafc69..44426876021dc4 100644 --- a/ee/app/views/security/dashboard/show.html.haml +++ b/ee/app/views/security/dashboard/show.html.haml @@ -4,7 +4,8 @@ #js-security{ data: { vulnerabilities_endpoint: '/groups/gitlab-org/-/security/vulnerabilities', vulnerabilities_count_endpoint: '/groups/gitlab-org/-/security/vulnerabilities/summary', vulnerabilities_history_endpoint: '/groups/gitlab-org/-/security/vulnerabilities/history', - projects_endpoint: '/api/v4/groups/2/projects', + project_add_endpoint: add_operations_project_path, + project_list_endpoint: operations_list_path, vulnerability_feedback_help_path: help_page_path('user/application_security/index', anchor: 'interacting-with-the-vulnerabilities'), empty_state_svg_path: image_path('illustrations/operations-dashboard_empty.svg'), empty_dashboard_state_svg_path: image_path('illustrations/security-dashboard-empty-state.svg'), -- GitLab