BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
21 deletions
+21
-21
services_controller.rb
app/controllers/projects/services_controller.rb
+1
-1
mattermost_slash_commands_service.rb
...els/project_services/mattermost_slash_commands_service.rb
+20
-6
new.html.haml
app/views/projects/mattermost/new.html.haml
+0
-2
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
...
@@ -3,7 +3,7 @@ class Projects::ServicesController < Projects::ApplicationController
# Authorize
# Authorize
before_action
:authorize_admin_project!
before_action
:authorize_admin_project!
before_action
:service
,
only:
[
:edit
,
:update
,
:test
,
:configure
]
before_action
:service
,
only:
[
:edit
,
:update
,
:test
]
respond_to
:html
respond_to
:html
...
...
app/models/project_services/mattermost_slash_commands_service.rb
View file @
f0889bdf
...
@@ -25,15 +25,12 @@ class MattermostSlashCommandsService < ChatService
...
@@ -25,15 +25,12 @@ class MattermostSlashCommandsService < ChatService
]
]
end
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
new_token
=
Mattermost
::
Session
.
new
(
host
,
current_user
).
with_session
do
Mattermost
::
Command
.
create
(
team_id
,
Mattermost
::
Command
.
create
(
params
[
:team_id
],
command
)
trigger:
trigger
||
@service
.
project
.
path
,
url:
url
,
icon_url:
icon_url
)
end
end
update!
(
token:
new_token
)
update!
(
token:
new_token
,
active:
true
)
end
end
def
trigger
(
params
)
def
trigger
(
params
)
...
@@ -50,6 +47,23 @@ class MattermostSlashCommandsService < ChatService
...
@@ -50,6 +47,23 @@ class MattermostSlashCommandsService < ChatService
private
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
)
def
find_chat_user
(
params
)
ChatNames
::
FindUserService
.
new
(
self
,
params
).
execute
ChatNames
::
FindUserService
.
new
(
self
,
params
).
execute
end
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
|
=
form_for
(
:create
,
method: :post
,
url:
configure_namespace_project_mattermost_path
(
@project
.
namespace
,
@project
,
))
do
|
f
|
=
"Team ID"
=
"Team ID"
=
f
.
text_field
(
:team_id
)
=
f
.
text_field
(
:team_id
)
...
...
lib/mattermost/command.rb
View file @
f0889bdf
module
Mattermost
module
Mattermost
class
Command
<
Session
class
Command
<
Session
def
self
.
create
(
team_id
,
trigger:
'gitlab'
,
url
:,
icon_url
:)
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'
]
post_command
(
command
)[
'token'
]
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