Commit 4118aa05 authored by Victor Zagorodny's avatar Victor Zagorodny Committed by Kushal Pandya

Add Security Dashboard unavailable empty state

Adds an EE override of groups#show action that
renders groups/security/dashboard#show view and
substitutes the controller_path, controller_name
and action_name to pretend that we're still
rendering groups/show for JS bundles and sidebar
navlinks to display and load correctly
parent 1eac0e59
<script>
import { GlEmptyState } from '@gitlab/ui';
export default {
name: 'UnavailableState',
components: { GlEmptyState },
props: {
svgPath: {
type: String,
required: true,
},
link: {
type: String,
required: true,
},
},
};
</script>
<template>
<gl-empty-state
:svg-path="svgPath"
:title="s__('Security Reports|Oops, something doesn\'t seem right.')"
:description="
s__(
'Security Reports|Either you don\'t have permission to view this dashboard or the dashboard has not been setup. Please check your permission settings with your administrator or check your dashboard configurations to proceed.',
)
"
:primary-button-link="link"
:primary-button-text="s__('Security Reports|Learn more about setting up your dashboard')"
/>
</template>
import Vue from 'vue';
import GroupSecurityDashboardApp from './components/app.vue';
import UnavailableState from './components/unavailable_state.vue';
import createStore from './store';
import router from './store/router';
export default () => {
export default function() {
const el = document.getElementById('js-group-security-dashboard');
const { isUnavailable, dashboardDocumentation, emptyStateSvgPath } = el.dataset;
const store = createStore();
if (isUnavailable) {
return new Vue({
el,
render(createElement) {
return createElement(UnavailableState, {
props: {
link: dashboardDocumentation,
svgPath: emptyStateSvgPath,
},
});
},
});
}
const store = createStore();
return new Vue({
el,
store,
router,
components: {
GroupSecurityDashboardApp,
},
components: { GroupSecurityDashboardApp },
render(createElement) {
return createElement('group-security-dashboard-app', {
props: {
......@@ -29,4 +42,4 @@ export default () => {
});
},
});
};
}
# frozen_string_literal: true
class Groups::Security::DashboardController < Groups::Security::ApplicationController
layout 'group'
skip_before_action :ensure_security_dashboard_feature_enabled!, only: [:show]
skip_before_action :authorize_read_group_security_dashboard!, only: [:show]
def show
render :unavailable unless dashboard_available?
end
private
def dashboard_available?
group.feature_available?(:security_dashboard) &&
helpers.can_read_group_security_dashboard?(group)
end
end
- breadcrumb_title _("Security Dashboard")
- page_title _("Security Dashboard")
#js-group-security-dashboard{ data: { is_unavailable: "true",
empty_state_svg_path: image_path('illustrations/security-dashboard-empty-state.svg'),
dashboard_documentation: help_page_path('user/application_security/security_dashboard/index') } }
---
title: Enabled setting the Security Dashboard as a default view for groups
merge_request: 7889
author:
type: added
......@@ -27,12 +27,14 @@ describe Groups::Security::DashboardController do
end
context 'when user is not allowed to access group security dashboard' do
it { is_expected.to have_gitlab_http_status(403) }
it { is_expected.to have_gitlab_http_status(200) }
it { is_expected.to render_template(:unavailable) }
end
end
context 'when security dashboard feature is disabled' do
it { is_expected.to have_gitlab_http_status(404) }
it { is_expected.to have_gitlab_http_status(200) }
it { is_expected.to render_template(:unavailable) }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'Group overview', :js do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:empty_project) { create(:project, namespace: group) }
before do
group.add_owner(user)
sign_in(user)
end
context 'when the default value of "Group Overview content" preference is used' do
it 'displays the Details view' do
visit group_path(group)
page.within(find('.content')) do
expect(page).to have_content 'Subgroups and projects'
expect(page).to have_content 'Shared projects'
expect(page).to have_content 'Archived projects'
end
end
end
context 'when Security Dashboard view is set as default' do
before do
stub_licensed_features(security_dashboard: true)
enable_namespace_license_check!
create(:gitlab_subscription, hosted_plan: group.plan, namespace: group)
end
let(:user) { create(:user, group_view: :security_dashboard) }
context 'and Security Dashboard feature is available for a group' do
let(:group) { create(:group, plan: :gold_plan) }
it 'displays the Security Dashboard view' do
visit group_path(group)
page.within(find('.content')) do
expect(page).to have_content 'Vulnerability Chart'
expect(page).to have_content 'Vulnerability List'
end
end
end
context 'and Security Dashboard feature is not available for a group' do
let(:group) { create(:group, plan: :bronze_plan) }
it 'displays the "Security Dashboard unavailable" empty state' do
visit group_path(group)
page.within(find('.content')) do
expect(page).to have_content "Either you don't have permission to view this dashboard or "\
'the dashboard has not been setup. Please check your permission settings '\
'with your administrator or check your dashboard configurations to proceed.'
end
end
end
end
end
# frozen_string_literal: true
shared_examples 'ensures security dashboard permissions' do
context 'when security dashboard feature is enabled' do
before do
stub_licensed_features(security_dashboard: true)
end
context 'and user is allowed to access group security dashboard' do
before do
group.add_developer(user)
end
it { is_expected.to have_gitlab_http_status(200) }
end
context 'when user is not allowed to access group security dashboard' do
it { is_expected.to have_gitlab_http_status(403) }
end
end
context 'when security dashboard feature is disabled' do
it { is_expected.to have_gitlab_http_status(404) }
end
end
......@@ -12112,12 +12112,18 @@ msgstr ""
msgid "Security Reports|Dismiss vulnerability"
msgstr ""
msgid "Security Reports|Either you don't have permission to view this dashboard or the dashboard has not been setup. Please check your permission settings with your administrator or check your dashboard configurations to proceed."
msgstr ""
msgid "Security Reports|Learn more about setting up your dashboard"
msgstr ""
msgid "Security Reports|More info"
msgstr ""
msgid "Security Reports|Oops, something doesn't seem right."
msgstr ""
msgid "Security Reports|There was an error creating the issue."
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