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
99d8d6f0
Commit
99d8d6f0
authored
Dec 13, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add MattermostController
parent
87d16063
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
159 additions
and
98 deletions
+159
-98
mattermost_controller.rb
app/controllers/projects/mattermost_controller.rb
+47
-0
new.html.haml
app/views/projects/mattermost/new.html.haml
+6
-0
_help.html.haml
...ojects/services/mattermost_slash_commands/_help.html.haml
+100
-98
project.rb
config/routes/project.rb
+6
-0
No files found.
app/controllers/projects/mattermost_controller.rb
0 → 100644
View file @
99d8d6f0
class
Projects
::
MattermostController
<
Projects
::
ApplicationController
layout
'project_settings'
before_action
:authorize_admin_project!
before_action
:service
before_action
:teams
,
only:
[
:new
]
def
new
end
def
configure
@service
.
configure
(
host
,
current_user
,
params
)
redirect_to
(
new_namespace_project_service_path
(
@project
.
namespace
,
@project
,
@service
.
to_param
),
notice:
'This service is now configured.'
)
rescue
Mattermost
::
NoSessionError
redirect_to
(
edit_namespace_project_service_path
(
@project
.
namespace
,
@project
,
@service
.
to_param
),
alert:
'No session could be set up, is Mattermost configured with Single Sign on?'
)
end
private
def
configure_params
params
.
require
(
:configure_params
).
permit
(
:trigger
,
:team_id
)
end
def
service
@service
||=
@project
.
services
.
find_by
(
type:
'MattermostSlashCommandsService'
)
end
def
teams
# Mocking for frontend development
@teams
=
[{
"id"
=>
"qz8gdr1fopncueb8n9on8ohk3h"
,
"create_at"
=>
1479992105904
,
"update_at"
=>
1479992105904
,
"delete_at"
=>
0
,
"display_name"
=>
"chatops"
,
"name"
=>
"chatops"
,
"email"
=>
"admin@example.com"
,
"type"
=>
"O"
,
"company_name"
=>
""
,
"allowed_domains"
=>
""
,
"invite_id"
=>
"gthxi47gj7rxtcx6zama63zd1w"
,
"allow_open_invite"
=>
false
}]
# @teams =
# begin
# Mattermost::Mattermost.new(Gitlab.config.mattermost.host, current_user).with_session do
# Mattermost::Team.all
# end
# rescue Mattermost::NoSessionError
# @teams = []
# end
end
end
app/views/projects/mattermost/new.html.haml
0 → 100644
View file @
99d8d6f0
=
"hello world"
=
form_for
(
:create
,
method: :post
,
url:
configure_namespace_project_mattermost_path
(
@project
.
namespace
,
@project
,
@service
.
to_param
))
do
|
f
|
=
"Team ID"
=
f
.
text_field
(
:team_id
)
=
f
.
submit
'Configure'
,
class:
'btn btn-save'
app/views/projects/services/mattermost_slash_commands/_help.html.haml
View file @
99d8d6f0
-
pretty_path_with_namespace
=
"
#{
@project
?
@project
.
namespace
.
name
:
'namespace'
}
/
#{
@project
?
@project
.
name
:
'name'
}
"
-
run_actions_text
=
"Perform common operations on this project:
#{
pretty_path_with_namespace
}
"
-
unless
GitLab
.
config
.
mattermost
.
enabled
.well
This service allows GitLab users to perform common operations on this
project by entering slash commands in Mattermost.
%br
See list of available commands in Mattermost after setting up this service,
by entering
%code
/
<
command_trigger_word
>
help
%br
%br
To setup this service:
%ul
.list-unstyled
%li
1.
=
link_to
'Enable custom slash commands'
,
'https://docs.mattermost.com/developer/slash-commands.html#enabling-custom-commands'
on your Mattermost installation
%li
2.
=
link_to
'Add a slash command'
,
'https://docs.mattermost.com/developer/slash-commands.html#set-up-a-custom-command'
in Mattermost with these options:
%hr
.help-form
.form-group
=
label_tag
:display_name
,
'Display name'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:display_name
,
"GitLab /
#{
pretty_path_with_namespace
}
"
,
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#display_name'
)
.form-group
=
label_tag
:description
,
'Description'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:description
,
run_actions_text
,
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#description'
)
.form-group
=
label_tag
nil
,
'Command trigger word'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.text-block
%p
Fill in the word that works best for your team.
%p
Suggestions:
%code
=
'gitlab'
%code
=
@project
.
path
# Path contains no spaces, but dashes
%code
=
@project
.
path_with_namespace
.form-group
=
label_tag
:request_url
,
'Request URL'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:request_url
,
service_trigger_url
(
subject
),
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#request_url'
)
.form-group
=
label_tag
nil
,
'Request method'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.text-block
POST
.form-group
=
label_tag
:response_username
,
'Response username'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:response_username
,
'GitLab'
,
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#response_username'
)
.form-group
=
label_tag
:response_icon
,
'Response icon'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:response_icon
,
asset_url
(
'gitlab_logo.png'
),
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#response_icon'
)
.form-group
=
label_tag
nil
,
'Autocomplete'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.text-block
Yes
.form-group
=
label_tag
:autocomplete_hint
,
'Autocomplete hint'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:autocomplete_hint
,
'[help]'
,
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#autocomplete_hint'
)
.form-group
=
label_tag
:autocomplete_description
,
'Autocomplete description'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:autocomplete_description
,
run_actions_text
,
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#autocomplete_description'
)
%hr
%ul
.list-unstyled
%li
3. After adding the slash command, paste the
%strong
token
into the field below
.well
This service allows GitLab users to perform common operations on this
project by entering slash commands in Mattermost.
%br
See list of available commands in Mattermost after setting up this service,
by entering
%code
/
<
command_trigger_word
>
help
%br
%br
To setup this service:
%ul
.list-unstyled
%li
1.
=
link_to
'Enable custom slash commands'
,
'https://docs.mattermost.com/developer/slash-commands.html#enabling-custom-commands'
on your Mattermost installation
%li
2.
=
link_to
'Add a slash command'
,
'https://docs.mattermost.com/developer/slash-commands.html#set-up-a-custom-command'
in Mattermost with these options:
%hr
.help-form
.form-group
=
label_tag
:display_name
,
'Display name'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:display_name
,
"GitLab /
#{
pretty_path_with_namespace
}
"
,
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#display_name'
)
.form-group
=
label_tag
:description
,
'Description'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:description
,
run_actions_text
,
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#description'
)
.form-group
=
label_tag
nil
,
'Command trigger word'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.text-block
%p
Fill in the word that works best for your team.
%p
Suggestions:
%code
=
'gitlab'
%code
=
@project
.
path
# Path contains no spaces, but dashes
%code
=
@project
.
path_with_namespace
.form-group
=
label_tag
:request_url
,
'Request URL'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:request_url
,
service_trigger_url
(
subject
),
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#request_url'
)
.form-group
=
label_tag
nil
,
'Request method'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.text-block
POST
.form-group
=
label_tag
:response_username
,
'Response username'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:response_username
,
'GitLab'
,
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#response_username'
)
.form-group
=
label_tag
:response_icon
,
'Response icon'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:response_icon
,
asset_url
(
'gitlab_logo.png'
),
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#response_icon'
)
.form-group
=
label_tag
nil
,
'Autocomplete'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.text-block
Yes
.form-group
=
label_tag
:autocomplete_hint
,
'Autocomplete hint'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:autocomplete_hint
,
'[help]'
,
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#autocomplete_hint'
)
.form-group
=
label_tag
:autocomplete_description
,
'Autocomplete description'
,
class:
'col-sm-2 col-xs-12 control-label'
.col-sm-10.col-xs-12.input-group
=
text_field_tag
:autocomplete_description
,
run_actions_text
,
class:
'form-control input-sm'
,
readonly:
'readonly'
.input-group-btn
=
clipboard_button
(
clipboard_target:
'#autocomplete_description'
)
%hr
%ul
.list-unstyled
%li
3. After adding the slash command, paste the
%strong
token
into the field below
-
if
Gitlab
.
config
.
mattermost
.
enabled
=
link_to
"Auto config"
,
new_namespace_project_mattermost_path
(
@project
.
namespace
,
@project
)
config/routes/project.rb
View file @
99d8d6f0
...
...
@@ -65,6 +65,12 @@ constraints(ProjectUrlConstrainer.new) do
end
end
resources
:mattermost
,
only:
[
:new
]
do
member
do
post
:configure
end
end
resources
:deploy_keys
,
constraints:
{
id:
/\d+/
},
only:
[
:index
,
:new
,
:create
]
do
member
do
put
:enable
...
...
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