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
34ae179b
Commit
34ae179b
authored
Oct 30, 2021
by
Tristan Read
Committed by
Peter Leitzen
Nov 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide Create Incident button on incident list page
parent
38365cfa
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
47 deletions
+82
-47
app/assets/javascripts/incidents/components/incidents_list.vue
...ssets/javascripts/incidents/components/incidents_list.vue
+5
-1
app/assets/javascripts/incidents/list.js
app/assets/javascripts/incidents/list.js
+2
-0
app/helpers/projects/incidents_helper.rb
app/helpers/projects/incidents_helper.rb
+2
-1
ee/spec/helpers/ee/projects/incidents_helper_spec.rb
ee/spec/helpers/ee/projects/incidents_helper_spec.rb
+11
-3
spec/features/incidents/user_creates_new_incident_spec.rb
spec/features/incidents/user_creates_new_incident_spec.rb
+26
-29
spec/helpers/projects/incidents_helper_spec.rb
spec/helpers/projects/incidents_helper_spec.rb
+36
-13
No files found.
app/assets/javascripts/incidents/components/incidents_list.vue
View file @
34ae179b
...
...
@@ -125,6 +125,7 @@ export default {
'
authorUsernameQuery
'
,
'
assigneeUsernameQuery
'
,
'
slaFeatureAvailable
'
,
'
canCreateIncident
'
,
],
apollo
:
{
incidents
:
{
...
...
@@ -244,6 +245,9 @@ export default {
btnText
:
createIncidentBtnLabel
,
};
},
isHeaderButtonVisible
()
{
return
this
.
canCreateIncident
&&
(
!
this
.
isEmpty
||
this
.
activeClosedTabHasNoIncidents
);
},
},
methods
:
{
hasAssignees
(
assignees
)
{
...
...
@@ -311,7 +315,7 @@ export default {
>
<template
#header-actions
>
<gl-button
v-if=
"
!isEmpty || activeClosedTabHasNoIncidents
"
v-if=
"
isHeaderButtonVisible
"
class=
"gl-my-3 gl-mr-5 create-incident-button"
data-testid=
"createIncidentBtn"
data-qa-selector=
"create_incident_button"
...
...
app/assets/javascripts/incidents/list.js
View file @
34ae179b
...
...
@@ -21,6 +21,7 @@ export default () => {
authorUsernameQuery
,
assigneeUsernameQuery
,
slaFeatureAvailable
,
canCreateIncident
,
}
=
domEl
.
dataset
;
const
apolloProvider
=
new
VueApollo
({
...
...
@@ -44,6 +45,7 @@ export default () => {
authorUsernameQuery
,
assigneeUsernameQuery
,
slaFeatureAvailable
:
parseBoolean
(
slaFeatureAvailable
),
canCreateIncident
:
parseBoolean
(
canCreateIncident
),
},
apolloProvider
,
render
(
createElement
)
{
...
...
app/helpers/projects/incidents_helper.rb
View file @
34ae179b
...
...
@@ -11,7 +11,8 @@ module Projects::IncidentsHelper
'empty-list-svg-path'
=>
image_path
(
'illustrations/incident-empty-state.svg'
),
'text-query'
:
params
[
:search
],
'author-username-query'
:
params
[
:author_username
],
'assignee-username-query'
:
params
[
:assignee_username
]
'assignee-username-query'
:
params
[
:assignee_username
],
'can-create-incident'
:
create_issue_type_allowed?
(
project
,
:incident
).
to_s
}
end
end
...
...
ee/spec/helpers/ee/projects/incidents_helper_spec.rb
View file @
34ae179b
...
...
@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec
.
describe
Projects
::
IncidentsHelper
do
include
Gitlab
::
Routing
.
url_helpers
let
_it_be_with_refind
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
build_stubbed
(
:project
)
}
let
(
:user
)
{
build_stubbed
(
:user
)
}
let
(
:project_path
)
{
project
.
full_path
}
let
(
:new_issue_path
)
{
new_project_issue_path
(
project
)
}
let
(
:issue_path
)
{
project_issues_path
(
project
)
}
...
...
@@ -18,6 +18,13 @@ RSpec.describe Projects::IncidentsHelper do
}
end
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
helper
).
to
receive
(
:can?
)
.
with
(
user
,
:create_incident
,
project
)
.
and_return
(
true
)
end
describe
'#incidents_data'
do
let
(
:expected_incidents_data
)
do
{
...
...
@@ -31,7 +38,8 @@ RSpec.describe Projects::IncidentsHelper do
'sla-feature-available'
=>
'false'
,
'text-query'
:
'search text'
,
'author-username-query'
:
'root'
,
'assignee-username-query'
:
'max.power'
'assignee-username-query'
:
'max.power'
,
'can-create-incident'
:
'true'
}
end
...
...
spec/features/incidents/user_creates_new_incident_spec.rb
View file @
34ae179b
...
...
@@ -4,52 +4,49 @@ require 'spec_helper'
RSpec
.
describe
'Incident Management index'
,
:js
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:
develop
er
)
{
create
(
:user
)
}
let_it_be
(
:
report
er
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let_it_be
(
:incident
)
{
create
(
:incident
,
project:
project
)
}
before_all
do
project
.
add_
developer
(
develop
er
)
project
.
add_
reporter
(
report
er
)
project
.
add_guest
(
guest
)
end
shared_examples
'create incident form'
do
it
'shows the create new issue button'
do
expect
(
page
).
to
have_selector
(
'.create-incident-button'
)
end
before
do
sign_in
(
user
)
it
'when clicked shows the create issue page with the Incident type pre-selected'
do
find
(
'.create-incident-button'
).
click
wait_for_all_requests
visit
project_incidents_path
(
project
)
wait_for_all_requests
end
expect
(
page
).
to
have_selector
(
'.dropdown-menu-toggle'
)
expect
(
page
).
to
have_selector
(
'.js-issuable-type-filter-dropdown-wrap'
)
describe
'incident list is visited'
do
context
'by reporter'
do
let
(
:user
)
{
reporter
}
page
.
within
(
'.js-issuable-type-filter-dropdown-wrap'
)
do
expect
(
page
).
to
have_
content
(
'Incident
'
)
it
'shows the create new incident button'
do
expect
(
page
).
to
have_
selector
(
'.create-incident-button
'
)
end
end
end
context
'when a developer displays the incident list
'
do
before
do
sign_in
(
developer
)
it
'when clicked shows the create issue page with the Incident type pre-selected
'
do
find
(
'.create-incident-button'
).
click
wait_for_all_requests
visit
project_incidents_path
(
project
)
wait_for_all_requests
end
expect
(
page
).
to
have_selector
(
'.dropdown-menu-toggle'
)
expect
(
page
).
to
have_selector
(
'.js-issuable-type-filter-dropdown-wrap'
)
it_behaves_like
'create incident form'
page
.
within
(
'.js-issuable-type-filter-dropdown-wrap'
)
do
expect
(
page
).
to
have_content
(
'Incident'
)
end
end
end
end
context
'when a guest displays the incident list'
do
before
do
sign_in
(
guest
)
context
'by guest'
do
let
(
:user
)
{
guest
}
visit
project_incidents_path
(
project
)
wait_for_all_requests
it
'does not show new incident button'
do
expect
(
page
).
not_to
have_selector
(
'.create-incident-button'
)
end
it_behaves_like
'create incident form'
end
end
spec/helpers/projects/incidents_helper_spec.rb
View file @
34ae179b
...
...
@@ -5,7 +5,8 @@ require 'spec_helper'
RSpec
.
describe
Projects
::
IncidentsHelper
do
include
Gitlab
::
Routing
.
url_helpers
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
build_stubbed
(
:user
)
}
let
(
:project
)
{
build_stubbed
(
:project
)
}
let
(
:project_path
)
{
project
.
full_path
}
let
(
:new_issue_path
)
{
new_project_issue_path
(
project
)
}
let
(
:issue_path
)
{
project_issues_path
(
project
)
}
...
...
@@ -17,21 +18,43 @@ RSpec.describe Projects::IncidentsHelper do
}
end
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
helper
).
to
receive
(
:can?
)
.
with
(
user
,
:create_incident
,
project
)
.
and_return
(
can_create_incident
)
end
describe
'#incidents_data'
do
subject
(
:data
)
{
helper
.
incidents_data
(
project
,
params
)
}
it
'returns frontend configuration'
do
expect
(
data
).
to
include
(
'project-path'
=>
project_path
,
'new-issue-path'
=>
new_issue_path
,
'incident-template-name'
=>
'incident'
,
'incident-type'
=>
'incident'
,
'issue-path'
=>
issue_path
,
'empty-list-svg-path'
=>
match_asset_path
(
'/assets/illustrations/incident-empty-state.svg'
),
'text-query'
:
'search text'
,
'author-username-query'
:
'root'
,
'assignee-username-query'
:
'max.power'
)
shared_examples
'frontend configuration'
do
it
'returns frontend configuration'
do
expect
(
data
).
to
include
(
'project-path'
=>
project_path
,
'new-issue-path'
=>
new_issue_path
,
'incident-template-name'
=>
'incident'
,
'incident-type'
=>
'incident'
,
'issue-path'
=>
issue_path
,
'empty-list-svg-path'
=>
match_asset_path
(
'/assets/illustrations/incident-empty-state.svg'
),
'text-query'
:
'search text'
,
'author-username-query'
:
'root'
,
'assignee-username-query'
:
'max.power'
,
'can-create-incident'
:
can_create_incident
.
to_s
)
end
end
context
'when user can create incidents'
do
let
(
:can_create_incident
)
{
true
}
include_examples
'frontend configuration'
end
context
'when user cannot create incidents'
do
let
(
:can_create_incident
)
{
false
}
include_examples
'frontend configuration'
end
end
end
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