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
Léo-Paul Géneau
gitlab-ce
Commits
3970640b
Commit
3970640b
authored
Sep 15, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix note form hint showing slash commands supported for commits
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
4276172b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
11 deletions
+36
-11
CHANGELOG
CHANGELOG
+1
-0
app/helpers/notes_helper.rb
app/helpers/notes_helper.rb
+4
-0
app/services/notes/slash_commands_service.rb
app/services/notes/slash_commands_service.rb
+11
-9
app/views/projects/notes/_form.html.haml
app/views/projects/notes/_form.html.haml
+4
-2
spec/features/projects/commits/note_spec.rb
spec/features/projects/commits/note_spec.rb
+16
-0
No files found.
CHANGELOG
View file @
3970640b
...
...
@@ -14,6 +14,7 @@ v 8.12.0 (unreleased)
- Filter tags by name !6121
- Update gitlab shell secret file also when it is empty. !3774 (glensc)
- Give project selection dropdowns responsive width, make non-wrapping.
- Fix note form hint showing slash commands supported for commits.
- Make push events have equal vertical spacing.
- API: Ensure invitees are not returned in Members API.
- Add two-factor recovery endpoint to internal API !5510
...
...
app/helpers/notes_helper.rb
View file @
3970640b
...
...
@@ -10,6 +10,10 @@ module NotesHelper
Ability
.
can_edit_note?
(
current_user
,
note
)
end
def
note_supports_slash_commands?
(
note
)
Notes
::
SlashCommandsService
.
supported?
(
note
,
current_user
)
end
def
noteable_json
(
noteable
)
{
id:
noteable
.
id
,
...
...
app/services/notes/slash_commands_service.rb
View file @
3970640b
...
...
@@ -5,9 +5,17 @@ module Notes
'MergeRequest'
=>
MergeRequests
::
UpdateService
}
def
supported?
(
note
)
def
self
.
noteable_update_service
(
note
)
UPDATE_SERVICES
[
note
.
noteable_type
]
end
def
self
.
supported?
(
note
,
current_user
)
noteable_update_service
(
note
)
&&
can?
(
current_user
,
:"update_
#{
note
.
noteable_type
.
underscore
}
"
,
note
.
noteable
)
current_user
.
can?
(
:"update_
#{
note
.
noteable_type
.
underscore
}
"
,
note
.
noteable
)
end
def
supported?
(
note
)
self
.
class
.
supported?
(
note
,
current_user
)
end
def
extract_commands
(
note
)
...
...
@@ -21,13 +29,7 @@ module Notes
return
if
command_params
.
empty?
return
unless
supported?
(
note
)
noteable_update_service
(
note
).
new
(
project
,
current_user
,
command_params
).
execute
(
note
.
noteable
)
end
private
def
noteable_update_service
(
note
)
UPDATE_SERVICES
[
note
.
noteable_type
]
self
.
class
.
noteable_update_service
(
note
).
new
(
project
,
current_user
,
command_params
).
execute
(
note
.
noteable
)
end
end
end
app/views/projects/notes/_form.html.haml
View file @
3970640b
-
supports_slash_commands
=
note_supports_slash_commands?
(
@note
)
=
form_for
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
@note
],
remote:
true
,
html:
{
:'data-type'
=>
'json'
,
multipart:
true
,
id:
nil
,
class:
"new-note js-new-note-form js-quick-submit common-note-form"
,
"data-noteable-iid"
=>
@note
.
noteable
.
try
(
:iid
),
},
authenticity_token:
true
do
|
f
|
=
hidden_field_tag
:view
,
diff_view
=
hidden_field_tag
:line_type
...
...
@@ -14,8 +16,8 @@
attr: :note
,
classes:
'note-textarea js-note-text'
,
placeholder:
"Write a comment or drag your files here..."
,
supports_slash_commands:
true
=
render
'projects/notes/hints'
,
supports_slash_commands:
true
supports_slash_commands:
supports_slash_commands
=
render
'projects/notes/hints'
,
supports_slash_commands:
supports_slash_commands
.error-alert
.note-form-actions.clearfix
...
...
spec/features/projects/commits/note_spec.rb
0 → 100644
View file @
3970640b
require
'spec_helper'
describe
'Projects > Commits > Note'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:commit
)
{
project
.
commit
(
'7d3b0f7cff5f37573aea97cebfd5692ea1689924'
)
}
before
do
login_as
:user
project
.
team
<<
[
@user
,
:master
]
visit
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
.
id
)
end
it
'says that only markdown is supported, not slash commands'
do
expect
(
page
).
to
have_content
(
'Styling with Markdown is supported'
)
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