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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
dbca77e3
Commit
dbca77e3
authored
Sep 05, 2019
by
Maneschi Romain
Committed by
Clement Ho
Sep 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If user can't activate error tracking display a learn more button pointing
to doc
parent
aadd1c8c
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
86 additions
and
14 deletions
+86
-14
app/assets/javascripts/error_tracking/components/error_tracking_list.vue
...scripts/error_tracking/components/error_tracking_list.vue
+17
-1
app/assets/javascripts/error_tracking/index.js
app/assets/javascripts/error_tracking/index.js
+3
-1
app/controllers/projects/settings/operations_controller.rb
app/controllers/projects/settings/operations_controller.rb
+1
-1
app/graphql/types/permission_types/project.rb
app/graphql/types/permission_types/project.rb
+1
-1
app/helpers/projects/error_tracking_helper.rb
app/helpers/projects/error_tracking_helper.rb
+2
-1
app/policies/project_policy.rb
app/policies/project_policy.rb
+1
-0
app/views/projects/error_tracking/index.html.haml
app/views/projects/error_tracking/index.html.haml
+1
-1
changelogs/unreleased/66467-enable-error-tracking-only-user-can-read-sentry-logs.yml
...-enable-error-tracking-only-user-can-read-sentry-logs.yml
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/frontend/error_tracking/components/error_tracking_list_spec.js
...end/error_tracking/components/error_tracking_list_spec.js
+28
-4
spec/helpers/projects/error_tracking_helper_spec.rb
spec/helpers/projects/error_tracking_helper_spec.rb
+24
-4
No files found.
app/assets/javascripts/error_tracking/components/error_tracking_list.vue
View file @
dbca77e3
...
...
@@ -38,6 +38,10 @@ export default {
type
:
String
,
required
:
true
,
},
userCanEnableErrorTracking
:
{
type
:
Boolean
,
required
:
true
,
},
},
computed
:
{
...
mapState
([
'
errors
'
,
'
externalUrl
'
,
'
loading
'
]),
...
...
@@ -111,7 +115,7 @@ export default {
</gl-table>
</div>
</div>
<div
v-else
>
<div
v-else
-if=
"userCanEnableErrorTracking"
>
<gl-empty-state
:title=
"__('Get started with error tracking')"
:description=
"__('Monitor your errors by integrating with Sentry')"
...
...
@@ -120,5 +124,17 @@ export default {
:svg-path=
"illustrationPath"
/>
</div>
<div
v-else
>
<gl-empty-state
:title=
"__('Get started with error tracking')"
:svg-path=
"illustrationPath"
>
<
template
#description
>
<div>
<span>
{{
__
(
'
Monitor your errors by integrating with Sentry.
'
)
}}
</span>
<a
href=
"/help/user/project/operations/error_tracking.html"
>
{{
__
(
'
More information
'
)
}}
</a>
</div>
</
template
>
</gl-empty-state>
</div>
</div>
</template>
app/assets/javascripts/error_tracking/index.js
View file @
dbca77e3
...
...
@@ -14,9 +14,10 @@ export default () => {
render
(
createElement
)
{
const
domEl
=
document
.
querySelector
(
this
.
$options
.
el
);
const
{
indexPath
,
enableErrorTrackingLink
,
illustrationPath
}
=
domEl
.
dataset
;
let
{
errorTrackingEnabled
}
=
domEl
.
dataset
;
let
{
errorTrackingEnabled
,
userCanEnableErrorTracking
}
=
domEl
.
dataset
;
errorTrackingEnabled
=
parseBoolean
(
errorTrackingEnabled
);
userCanEnableErrorTracking
=
parseBoolean
(
userCanEnableErrorTracking
);
return
createElement
(
'
error-tracking-list
'
,
{
props
:
{
...
...
@@ -24,6 +25,7 @@ export default () => {
enableErrorTrackingLink
,
errorTrackingEnabled
,
illustrationPath
,
userCanEnableErrorTracking
,
},
});
},
...
...
app/controllers/projects/settings/operations_controller.rb
View file @
dbca77e3
...
...
@@ -3,7 +3,7 @@
module
Projects
module
Settings
class
OperationsController
<
Projects
::
ApplicationController
before_action
:authorize_
update_environment
!
before_action
:authorize_
admin_operations
!
helper_method
:error_tracking_setting
...
...
app/graphql/types/permission_types/project.rb
View file @
dbca77e3
...
...
@@ -16,7 +16,7 @@ module Types
:create_deployment
,
:push_to_delete_protected_branch
,
:admin_wiki
,
:admin_project
,
:update_pages
,
:admin_remote_mirror
,
:create_label
,
:update_wiki
,
:destroy_wiki
,
:create_pages
,
:destroy_pages
,
:read_pages_content
:create_pages
,
:destroy_pages
,
:read_pages_content
,
:admin_operations
end
end
end
app/helpers/projects/error_tracking_helper.rb
View file @
dbca77e3
# frozen_string_literal: true
module
Projects::ErrorTrackingHelper
def
error_tracking_data
(
project
)
def
error_tracking_data
(
current_user
,
project
)
error_tracking_enabled
=
!!
project
.
error_tracking_setting
&
.
enabled?
{
'index-path'
=>
project_error_tracking_index_path
(
project
,
format: :json
),
'user-can-enable-error-tracking'
=>
can?
(
current_user
,
:admin_operations
,
project
).
to_s
,
'enable-error-tracking-link'
=>
project_settings_operations_path
(
project
),
'error-tracking-enabled'
=>
error_tracking_enabled
.
to_s
,
'illustration-path'
=>
image_path
(
'illustrations/cluster_popover.svg'
)
...
...
app/policies/project_policy.rb
View file @
dbca77e3
...
...
@@ -294,6 +294,7 @@ class ProjectPolicy < BasePolicy
enable
:destroy_release
enable
:destroy_artifacts
enable
:daily_statistics
enable
:admin_operations
end
rule
{
(
mirror_available
&
can?
(
:admin_project
))
|
admin
}.
enable
:admin_remote_mirror
...
...
app/views/projects/error_tracking/index.html.haml
View file @
dbca77e3
-
page_title
_
(
'Errors'
)
#js-error_tracking
{
data:
error_tracking_data
(
@project
)
}
#js-error_tracking
{
data:
error_tracking_data
(
@
current_user
,
@
project
)
}
changelogs/unreleased/66467-enable-error-tracking-only-user-can-read-sentry-logs.yml
0 → 100644
View file @
dbca77e3
---
title
:
Display `more information` docs link on error tracking page when users do not have permissions to enable that feature
merge_request
:
32365
author
:
Romain Maneschi
type
:
fixed
locale/gitlab.pot
View file @
dbca77e3
...
...
@@ -7212,6 +7212,9 @@ msgstr ""
msgid "Monitor your errors by integrating with Sentry"
msgstr ""
msgid "Monitor your errors by integrating with Sentry."
msgstr ""
msgid "Monitoring"
msgstr ""
...
...
spec/frontend/error_tracking/components/error_tracking_list_spec.js
View file @
dbca77e3
...
...
@@ -11,19 +11,24 @@ describe('ErrorTrackingList', () => {
let
wrapper
;
let
actions
;
function
mountComponent
({
errorTrackingEnabled
=
true
}
=
{})
{
function
mountComponent
({
errorTrackingEnabled
=
true
,
userCanEnableErrorTracking
=
true
,
stubs
=
{
'
gl-link
'
:
GlLink
,
},
}
=
{})
{
wrapper
=
shallowMount
(
ErrorTrackingList
,
{
localVue
,
store
,
propsData
:
{
indexPath
:
'
/path
'
,
enableErrorTrackingLink
:
'
/link
'
,
userCanEnableErrorTracking
,
errorTrackingEnabled
,
illustrationPath
:
'
illustration/path
'
,
},
stubs
:
{
'
gl-link
'
:
GlLink
,
},
stubs
,
});
}
...
...
@@ -115,4 +120,23 @@ describe('ErrorTrackingList', () => {
expect
(
wrapper
.
find
(
GlButton
).
exists
()).
toBeFalsy
();
});
});
describe
(
'
When error tracking is disabled and user is not allowed to enable it
'
,
()
=>
{
beforeEach
(()
=>
{
mountComponent
({
errorTrackingEnabled
:
false
,
userCanEnableErrorTracking
:
false
,
stubs
:
{
'
gl-link
'
:
GlLink
,
'
gl-empty-state
'
:
GlEmptyState
,
},
});
});
it
(
'
shows empty state
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
a
'
).
attributes
(
'
href
'
)).
toBe
(
'
/help/user/project/operations/error_tracking.html
'
,
);
});
});
});
spec/helpers/projects/error_tracking_helper_spec.rb
View file @
dbca77e3
...
...
@@ -6,21 +6,31 @@ describe Projects::ErrorTrackingHelper do
include
Gitlab
::
Routing
.
url_helpers
set
(
:project
)
{
create
(
:project
)
}
set
(
:current_user
)
{
create
(
:user
)
}
describe
'#error_tracking_data'
do
let
(
:can_enable_error_tracking
)
{
true
}
let
(
:setting_path
)
{
project_settings_operations_path
(
project
)
}
let
(
:index_path
)
do
project_error_tracking_index_path
(
project
,
format: :json
)
end
before
do
allow
(
helper
)
.
to
receive
(
:can?
)
.
with
(
current_user
,
:admin_operations
,
project
)
.
and_return
(
can_enable_error_tracking
)
end
context
'without error_tracking_setting'
do
it
'returns frontend configuration'
do
expect
(
error_tracking_data
(
project
)).
to
eq
(
expect
(
helper
.
error_tracking_data
(
current_user
,
project
)).
to
match
(
'index-path'
=>
index_path
,
'user-can-enable-error-tracking'
=>
'true'
,
'enable-error-tracking-link'
=>
setting_path
,
'error-tracking-enabled'
=>
'false'
,
"illustration-path"
=>
"/images/illustrations/cluster_popover.svg"
'illustration-path'
=>
match_asset_path
(
'/assets/illustrations/cluster_popover.svg'
)
)
end
end
...
...
@@ -36,7 +46,7 @@ describe Projects::ErrorTrackingHelper do
end
it
'show error tracking enabled'
do
expect
(
error_tracking_data
(
project
)).
to
include
(
expect
(
helper
.
error_tracking_data
(
current_user
,
project
)).
to
include
(
'error-tracking-enabled'
=>
'true'
)
end
...
...
@@ -48,11 +58,21 @@ describe Projects::ErrorTrackingHelper do
end
it
'show error tracking not enabled'
do
expect
(
error_tracking_data
(
project
)).
to
include
(
expect
(
helper
.
error_tracking_data
(
current_user
,
project
)).
to
include
(
'error-tracking-enabled'
=>
'false'
)
end
end
end
context
'when user is not maintainer'
do
let
(
:can_enable_error_tracking
)
{
false
}
it
'shows error tracking enablement as disabled'
do
expect
(
helper
.
error_tracking_data
(
current_user
,
project
)).
to
include
(
'user-can-enable-error-tracking'
=>
'false'
)
end
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