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
Jérome Perrin
gitlab-ce
Commits
f0889bdf
Commit
f0889bdf
authored
Dec 16, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorporate review
parent
7363a7d3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
21 deletions
+21
-21
app/controllers/projects/services_controller.rb
app/controllers/projects/services_controller.rb
+1
-1
app/models/project_services/mattermost_slash_commands_service.rb
...els/project_services/mattermost_slash_commands_service.rb
+20
-6
app/views/projects/mattermost/new.html.haml
app/views/projects/mattermost/new.html.haml
+0
-2
lib/mattermost/command.rb
lib/mattermost/command.rb
+0
-12
No files found.
app/controllers/projects/services_controller.rb
View file @
f0889bdf
...
...
@@ -3,7 +3,7 @@ class Projects::ServicesController < Projects::ApplicationController
# Authorize
before_action
:authorize_admin_project!
before_action
:service
,
only:
[
:edit
,
:update
,
:test
,
:configure
]
before_action
:service
,
only:
[
:edit
,
:update
,
:test
]
respond_to
:html
...
...
app/models/project_services/mattermost_slash_commands_service.rb
View file @
f0889bdf
...
...
@@ -25,15 +25,12 @@ class MattermostSlashCommandsService < ChatService
]
end
def
configure
(
host
,
current_user
,
team_id
:,
trigger
:,
url
:,
icon_url
:
)
def
configure
(
host
,
current_user
,
params
)
new_token
=
Mattermost
::
Session
.
new
(
host
,
current_user
).
with_session
do
Mattermost
::
Command
.
create
(
team_id
,
trigger:
trigger
||
@service
.
project
.
path
,
url:
url
,
icon_url:
icon_url
)
Mattermost
::
Command
.
create
(
params
[
:team_id
],
command
)
end
update!
(
token:
new_token
)
update!
(
token:
new_token
,
active:
true
)
end
def
trigger
(
params
)
...
...
@@ -50,6 +47,23 @@ class MattermostSlashCommandsService < ChatService
private
def
command
(
trigger
:,
url
:,
icon_url
:)
pretty_project_name
=
project
.
name_with_namespace
{
auto_complete:
true
,
auto_complete_desc:
"Perform common operations on:
#{
pretty_project_name
}
"
,
auto_complete_hint:
'[help]'
,
description:
"Perform common operations on:
#{
pretty_project_name
}
"
,
display_name:
"GitLab /
#{
pretty_project_name
}
"
,
method:
'P'
,
user_name:
'GitLab'
,
trigger:
trigger
,
url:
url
,
icon_url:
icon_url
}
end
def
find_chat_user
(
params
)
ChatNames
::
FindUserService
.
new
(
self
,
params
).
execute
end
...
...
app/views/projects/mattermost/new.html.haml
View file @
f0889bdf
=
"hello world"
=
@teams
=
form_for
(
:create
,
method: :post
,
url:
configure_namespace_project_mattermost_path
(
@project
.
namespace
,
@project
,
))
do
|
f
|
=
"Team ID"
=
f
.
text_field
(
:team_id
)
...
...
lib/mattermost/command.rb
View file @
f0889bdf
module
Mattermost
class
Command
<
Session
def
self
.
create
(
team_id
,
trigger:
'gitlab'
,
url
:,
icon_url
:)
command
=
{
auto_complete:
true
,
auto_complete_desc:
'List all available commands'
,
auto_complete_hint:
'[help]'
,
description:
'Perform common operations on GitLab'
,
display_name:
'GitLab Slash Commands'
,
method:
'P'
,
user_name:
'GitLab'
,
trigger:
trigger
,
url:
url
,
icon_url:
icon_url
}
post_command
(
command
)[
'token'
]
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