Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
91b24336
Commit
91b24336
authored
May 05, 2021
by
Olena Horal-Koretska
Committed by
Etienne Baqué
May 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Escalation policy Empty state [RUN ALL RSPEC] [RUN AS-IF-FOSS]
parent
92c4930b
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
441 additions
and
0 deletions
+441
-0
config/feature_flags/development/escalation_policies_mvc.yml
config/feature_flags/development/escalation_policies_mvc.yml
+8
-0
ee/app/assets/javascripts/escalation_policies/components/escalation_policies_wrapper.vue
...ation_policies/components/escalation_policies_wrapper.vue
+42
-0
ee/app/assets/javascripts/escalation_policies/index.js
ee/app/assets/javascripts/escalation_policies/index.js
+20
-0
ee/app/assets/javascripts/pages/projects/incident_management/escalation_policies/index/index.js
...ts/incident_management/escalation_policies/index/index.js
+3
-0
ee/app/controllers/projects/incident_management/escalation_policies_controller.rb
...cts/incident_management/escalation_policies_controller.rb
+14
-0
ee/app/helpers/incident_management/escalation_policy_helper.rb
...p/helpers/incident_management/escalation_policy_helper.rb
+11
-0
ee/app/models/license.rb
ee/app/models/license.rb
+1
-0
ee/app/policies/ee/project_policy.rb
ee/app/policies/ee/project_policy.rb
+7
-0
ee/app/views/projects/incident_management/escalation_policies/index.html.haml
...s/incident_management/escalation_policies/index.html.haml
+3
-0
ee/app/views/projects/sidebar/_escalation_policies.html.haml
ee/app/views/projects/sidebar/_escalation_policies.html.haml
+6
-0
ee/config/routes/project.rb
ee/config/routes/project.rb
+1
-0
ee/lib/ee/sidebars/projects/menus/operations_menu.rb
ee/lib/ee/sidebars/projects/menus/operations_menu.rb
+12
-0
ee/lib/gitlab/incident_management.rb
ee/lib/gitlab/incident_management.rb
+6
-0
ee/spec/controllers/projects/incident_management/escalation_policies_controller_spec.rb
...ncident_management/escalation_policies_controller_spec.rb
+94
-0
ee/spec/frontend/escalation_policy/escalation_policy_wrapper_spec.js
...ntend/escalation_policy/escalation_policy_wrapper_spec.js
+39
-0
ee/spec/helpers/incident_management/escalation_policy_helper_spec.rb
...pers/incident_management/escalation_policy_helper_spec.rb
+15
-0
ee/spec/lib/ee/sidebars/projects/menus/operations_menu_spec.rb
...ec/lib/ee/sidebars/projects/menus/operations_menu_spec.rb
+16
-0
ee/spec/lib/gitlab/incident_management_spec.rb
ee/spec/lib/gitlab/incident_management_spec.rb
+35
-0
ee/spec/policies/project_policy_spec.rb
ee/spec/policies/project_policy_spec.rb
+70
-0
ee/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
ee/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+23
-0
locale/gitlab.pot
locale/gitlab.pot
+15
-0
No files found.
config/feature_flags/development/escalation_policies_mvc.yml
0 → 100644
View file @
91b24336
---
name
:
escalation_policies_mvc
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60524
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/329347
milestone
:
'
13.12'
type
:
development
group
:
group::monitor
default_enabled
:
false
ee/app/assets/javascripts/escalation_policies/components/escalation_policies_wrapper.vue
0 → 100644
View file @
91b24336
<
script
>
import
{
GlEmptyState
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
s__
}
from
'
~/locale
'
;
export
const
i18n
=
{
emptyState
:
{
title
:
s__
(
'
EscalationPolicies|Create an escalation policy in GitLab
'
),
description
:
s__
(
"
EscalationPolicies|Set up escalation policies to define who is paged, and when, in the event the first users paged don't respond.
"
,
),
button
:
s__
(
'
EscalationPolicies|Add an escalation policy
'
),
},
};
export
default
{
i18n
,
components
:
{
GlEmptyState
,
GlButton
,
},
inject
:
[
'
emptyEscalationPoliciesSvgPath
'
],
methods
:
{
addEscalationPolicy
()
{
// TODO: Add method as part of https://gitlab.com/gitlab-org/gitlab/-/issues/268356
},
},
};
</
script
>
<
template
>
<gl-empty-state
:title=
"$options.i18n.emptyState.title"
:description=
"$options.i18n.emptyState.description"
:svg-path=
"emptyEscalationPoliciesSvgPath"
>
<template
#actions
>
<gl-button
variant=
"info"
@
click=
"addEscalationPolicy"
>
{{
$options
.
i18n
.
emptyState
.
button
}}
</gl-button>
</
template
>
</gl-empty-state>
</template>
ee/app/assets/javascripts/escalation_policies/index.js
0 → 100644
View file @
91b24336
import
Vue
from
'
vue
'
;
import
EscalationPoliciesWrapper
from
'
./components/escalation_policies_wrapper.vue
'
;
export
default
()
=>
{
const
el
=
document
.
querySelector
(
'
.js-escalation-policies
'
);
if
(
!
el
)
return
null
;
const
{
emptyEscalationPoliciesSvgPath
}
=
el
.
dataset
;
return
new
Vue
({
el
,
provide
:
{
emptyEscalationPoliciesSvgPath
,
},
render
(
createElement
)
{
return
createElement
(
EscalationPoliciesWrapper
);
},
});
};
ee/app/assets/javascripts/pages/projects/incident_management/escalation_policies/index/index.js
0 → 100644
View file @
91b24336
import
initOnCallScheduleManagement
from
'
ee/escalation_policies
'
;
initOnCallScheduleManagement
();
ee/app/controllers/projects/incident_management/escalation_policies_controller.rb
0 → 100644
View file @
91b24336
# frozen_string_literal: true
module
Projects
module
IncidentManagement
class
EscalationPoliciesController
<
Projects
::
ApplicationController
before_action
:authorize_read_incident_management_escalation_policy!
feature_category
:incident_management
def
index
end
end
end
end
ee/app/helpers/incident_management/escalation_policy_helper.rb
0 → 100644
View file @
91b24336
# frozen_string_literal: true
module
IncidentManagement
module
EscalationPolicyHelper
def
escalation_policy_data
{
'empty_escalation_policies_svg_path'
=>
image_path
(
'illustrations/empty-state/empty-escalation.svg'
)
}
end
end
end
ee/app/models/license.rb
View file @
91b24336
...
...
@@ -131,6 +131,7 @@ class License < ApplicationRecord
ci_project_subscriptions
incident_timeline_view
oncall_schedules
escalation_policies
export_user_permissions
]
EEP_FEATURES
.
freeze
...
...
ee/app/policies/ee/project_policy.rb
View file @
91b24336
...
...
@@ -133,6 +133,11 @@ module EE
::
Gitlab
::
IncidentManagement
.
oncall_schedules_available?
(
@subject
)
end
with_scope
:subject
condition
(
:escalation_policies_available
)
do
::
Gitlab
::
IncidentManagement
.
escalation_policies_available?
(
@subject
)
end
rule
{
visual_review_bot
}.
policy
do
prevent
:read_note
enable
:create_note
...
...
@@ -163,6 +168,7 @@ module EE
end
rule
{
oncall_schedules_available
&
can?
(
:reporter_access
)
}.
enable
:read_incident_management_oncall_schedule
rule
{
escalation_policies_available
&
can?
(
:reporter_access
)
}.
enable
:read_incident_management_escalation_policy
rule
{
can?
(
:developer_access
)
}.
policy
do
enable
:admin_issue_board
...
...
@@ -245,6 +251,7 @@ module EE
rule
{
license_scanning_enabled
&
can?
(
:maintainer_access
)
}.
enable
:admin_software_license_policy
rule
{
oncall_schedules_available
&
can?
(
:maintainer_access
)
}.
enable
:admin_incident_management_oncall_schedule
rule
{
escalation_policies_available
&
can?
(
:maintainer_access
)
}.
enable
:admin_incident_management_escalation_policy
rule
{
auditor
}.
policy
do
enable
:public_user_access
...
...
ee/app/views/projects/incident_management/escalation_policies/index.html.haml
0 → 100644
View file @
91b24336
-
page_title
_
(
'Escalation policies'
)
.js-escalation-policies
{
data:
escalation_policy_data
}
ee/app/views/projects/sidebar/_escalation_policies.html.haml
0 → 100644
View file @
91b24336
-
return
unless
project_nav_tab?
:escalation_policy
=
nav_link
(
controller: :escalation_policies
)
do
=
link_to
project_incident_management_escalation_policies_path
(
@project
),
title:
_
(
'Escalation policies'
)
do
%span
=
_
(
'Escalation Policies'
)
ee/config/routes/project.rb
View file @
91b24336
...
...
@@ -128,6 +128,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
namespace
:incident_management
,
path:
''
do
resources
:oncall_schedules
,
only:
[
:index
],
path:
'oncall_schedules'
resources
:escalation_policies
,
only:
[
:index
],
path:
'escalation_policies'
end
resources
:cluster_agents
,
only:
[
:show
],
param: :name
...
...
ee/lib/ee/sidebars/projects/menus/operations_menu.rb
View file @
91b24336
...
...
@@ -12,6 +12,7 @@ module EE
return
false
unless
super
insert_item_after
(
:incidents
,
on_call_schedules_menu_item
)
insert_item_after
(
:on_call_schedules
,
escalation_policies_menu_item
)
true
end
...
...
@@ -28,6 +29,17 @@ module EE
item_id: :on_call_schedules
)
end
def
escalation_policies_menu_item
return
unless
can?
(
context
.
current_user
,
:read_incident_management_escalation_policy
,
context
.
project
)
::
Sidebars
::
MenuItem
.
new
(
title:
_
(
'Escalation policies'
),
link:
project_incident_management_escalation_policies_path
(
context
.
project
),
active_routes:
{
controller: :escalation_policies
},
item_id: :escalation_policies
)
end
end
end
end
...
...
ee/lib/gitlab/incident_management.rb
View file @
91b24336
...
...
@@ -5,5 +5,11 @@ module Gitlab
def
self
.
oncall_schedules_available?
(
project
)
project
.
feature_available?
(
:oncall_schedules
)
end
def
self
.
escalation_policies_available?
(
project
)
oncall_schedules_available?
(
project
)
&&
project
.
feature_available?
(
:escalation_policies
)
&&
::
Feature
.
enabled?
(
:escalation_policies_mvc
,
project
,
default_enabled: :yaml
)
end
end
end
ee/spec/controllers/projects/incident_management/escalation_policies_controller_spec.rb
0 → 100644
View file @
91b24336
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Projects
::
IncidentManagement
::
EscalationPoliciesController
do
let_it_be
(
:user_with_read_permissions
)
{
create
(
:user
)
}
let_it_be
(
:user_with_admin_permissions
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let
(
:current_user
)
{
user_with_admin_permissions
}
describe
'GET #index'
do
let
(
:request
)
do
get
:index
,
params:
{
project_id:
project
.
to_param
,
namespace_id:
project
.
namespace
.
to_param
}
end
before
do
project
.
add_reporter
(
user_with_read_permissions
)
project
.
add_maintainer
(
user_with_admin_permissions
)
stub_licensed_features
(
oncall_schedules:
true
,
escalation_policies:
true
)
sign_in
(
current_user
)
end
context
'with read permissions'
do
let
(
:current_user
)
{
user_with_read_permissions
}
it
'renders index with 200 status code'
do
request
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:index
)
end
end
context
'with admin permissions'
do
let
(
:current_user
)
{
user_with_admin_permissions
}
it
'renders index with 200 status code'
do
request
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:index
)
end
end
context
'unauthorized'
do
let
(
:current_user
)
{
create
(
:user
)
}
it
'responds with 404'
do
request
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'with feature flag off'
do
before
do
stub_feature_flags
(
escalation_policies_mvc:
false
)
end
it
'responds with 404'
do
request
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'with unavailable feature'
do
before
do
stub_licensed_features
(
escalation_policies:
false
)
end
it
'responds with 404'
do
request
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'with unavailable on-call schedules feature'
do
before
do
stub_licensed_features
(
oncall_schedules:
false
)
end
it
'responds with 404'
do
request
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
end
end
ee/spec/frontend/escalation_policy/escalation_policy_wrapper_spec.js
0 → 100644
View file @
91b24336
import
{
GlEmptyState
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
OnCallScheduleWrapper
,
{
i18n
,
}
from
'
ee/escalation_policies/components/escalation_policies_wrapper.vue
'
;
describe
(
'
AlertManagementEmptyState
'
,
()
=>
{
let
wrapper
;
const
emptyEscalationPoliciesSvgPath
=
'
illustration/path.svg
'
;
function
mountComponent
()
{
wrapper
=
shallowMount
(
OnCallScheduleWrapper
,
{
provide
:
{
emptyEscalationPoliciesSvgPath
,
},
});
}
beforeEach
(()
=>
{
mountComponent
();
});
afterEach
(()
=>
{
wrapper
.
destroy
();
});
const
findEmptyState
=
()
=>
wrapper
.
findComponent
(
GlEmptyState
);
describe
(
'
Empty state
'
,
()
=>
{
it
(
'
shows empty state and passed correct attributes to it
'
,
()
=>
{
expect
(
findEmptyState
().
exists
()).
toBe
(
true
);
expect
(
findEmptyState
().
attributes
()).
toEqual
({
title
:
i18n
.
emptyState
.
title
,
description
:
i18n
.
emptyState
.
description
,
svgpath
:
emptyEscalationPoliciesSvgPath
,
});
});
});
});
ee/spec/helpers/incident_management/escalation_policy_helper_spec.rb
0 → 100644
View file @
91b24336
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
IncidentManagement
::
EscalationPolicyHelper
do
describe
'#escalation_policy_data'
do
subject
(
:data
)
{
helper
.
escalation_policy_data
}
it
'returns scalation policies data'
do
is_expected
.
to
eq
(
'empty_escalation_policies_svg_path'
=>
helper
.
image_path
(
'illustrations/empty-state/empty-escalation.svg'
)
)
end
end
end
ee/spec/lib/ee/sidebars/projects/menus/operations_menu_spec.rb
View file @
91b24336
...
...
@@ -22,4 +22,20 @@ RSpec.describe Sidebars::Projects::Menus::OperationsMenu do
specify
{
is_expected
.
to
be_nil
}
end
end
describe
'Escalation policies'
do
subject
{
described_class
.
new
(
context
).
items
.
index
{
|
e
|
e
.
item_id
==
:escalation_policies
}
}
before
do
stub_licensed_features
(
oncall_schedules:
true
,
escalation_policies:
true
)
end
specify
{
is_expected
.
not_to
be_nil
}
describe
'when the user does not have access'
do
let
(
:user
)
{
nil
}
specify
{
is_expected
.
to
be_nil
}
end
end
end
ee/spec/lib/gitlab/incident_management_spec.rb
View file @
91b24336
...
...
@@ -22,4 +22,39 @@ RSpec.describe Gitlab::IncidentManagement do
it
{
is_expected
.
to
be_falsey
}
end
end
describe
'.escalation_policies_available?'
do
subject
{
described_class
.
escalation_policies_available?
(
project
)
}
before
do
stub_licensed_features
(
oncall_schedules:
true
,
escalation_policies:
true
)
stub_feature_flags
(
escalation_policies_mvc:
project
)
end
it
{
is_expected
.
to
be_truthy
}
context
'when feature flag disabled'
do
before
do
stub_feature_flags
(
escalation_policies_mvc:
false
)
end
it
{
is_expected
.
to
be_falsey
}
end
context
'when escalation policies not avaialble'
do
before
do
stub_licensed_features
(
escalation_policies:
false
)
end
it
{
is_expected
.
to
be_falsey
}
end
context
'when on-call schedules not available'
do
before
do
stub_licensed_features
(
oncall_schedules:
false
)
end
it
{
is_expected
.
to
be_falsey
}
end
end
end
ee/spec/policies/project_policy_spec.rb
View file @
91b24336
...
...
@@ -1483,6 +1483,76 @@ RSpec.describe ProjectPolicy do
end
end
describe
'Escalation Policies'
do
using
RSpec
::
Parameterized
::
TableSyntax
context
':read_incident_management_escalation_policy'
do
let
(
:policy
)
{
:read_incident_management_escalation_policy
}
where
(
:role
,
:admin_mode
,
:allowed
)
do
:guest
|
nil
|
false
:reporter
|
nil
|
true
:developer
|
nil
|
true
:maintainer
|
nil
|
true
:owner
|
nil
|
true
:admin
|
false
|
false
:admin
|
true
|
true
end
before
do
enable_admin_mode!
(
current_user
)
if
admin_mode
allow
(
::
Gitlab
::
IncidentManagement
).
to
receive
(
:escalation_policies_available?
).
with
(
project
).
and_return
(
true
)
end
with_them
do
let
(
:current_user
)
{
public_send
(
role
)
}
it
{
is_expected
.
to
(
allowed
?
be_allowed
(
policy
)
:
be_disallowed
(
policy
))
}
context
'with unavailable escalation policies'
do
before
do
allow
(
::
Gitlab
::
IncidentManagement
).
to
receive
(
:escalation_policies_available?
).
with
(
project
).
and_return
(
false
)
end
it
{
is_expected
.
to
(
be_disallowed
(
policy
))
}
end
end
end
context
':admin_incident_management_escalation_policy'
do
let
(
:policy
)
{
:admin_incident_management_escalation_policy
}
where
(
:role
,
:admin_mode
,
:allowed
)
do
:guest
|
nil
|
false
:reporter
|
nil
|
false
:developer
|
nil
|
false
:maintainer
|
nil
|
true
:owner
|
nil
|
true
:admin
|
false
|
false
:admin
|
true
|
true
end
before
do
enable_admin_mode!
(
current_user
)
if
admin_mode
allow
(
::
Gitlab
::
IncidentManagement
).
to
receive
(
:escalation_policies_available?
).
with
(
project
).
and_return
(
true
)
end
with_them
do
let
(
:current_user
)
{
public_send
(
role
)
}
it
{
is_expected
.
to
(
allowed
?
be_allowed
(
policy
)
:
be_disallowed
(
policy
))
}
context
'with unavailable escalation policies'
do
before
do
allow
(
::
Gitlab
::
IncidentManagement
).
to
receive
(
:escalation_policies_available?
).
with
(
project
).
and_return
(
false
)
end
it
{
is_expected
.
to
(
be_disallowed
(
policy
))
}
end
end
end
end
context
'when project is readonly because the storage usage limit has been exceeded on the root namespace'
do
let
(
:current_user
)
{
owner
}
let
(
:abilities
)
do
...
...
ee/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
View file @
91b24336
...
...
@@ -284,6 +284,29 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
end
describe
'Escalation policies'
do
before
do
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
user
)
stub_licensed_features
(
oncall_schedules:
true
,
escalation_policies:
true
)
end
it
'has a link to the escalation policies page'
do
render
expect
(
rendered
).
to
have_link
(
'Escalation policies'
,
href:
project_incident_management_escalation_policies_path
(
project
))
end
describe
'when the user does not have access'
do
let
(
:user
)
{
nil
}
it
'does not have a link to the escalation policies page'
do
render
expect
(
rendered
).
not_to
have_link
(
'Escalation policies'
)
end
end
end
end
describe
'Settings > Operations'
do
...
...
locale/gitlab.pot
View file @
91b24336
...
...
@@ -12971,6 +12971,21 @@ msgstr ""
msgid "Errors:"
msgstr ""
msgid "Escalation Policies"
msgstr ""
msgid "Escalation policies"
msgstr ""
msgid "EscalationPolicies|Add an escalation policy"
msgstr ""
msgid "EscalationPolicies|Create an escalation policy in GitLab"
msgstr ""
msgid "EscalationPolicies|Set up escalation policies to define who is paged, and when, in the event the first users paged don't respond."
msgstr ""
msgid "Estimate"
msgstr ""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment