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
Tatuya Kamada
gitlab-ce
Commits
2cc64855
Commit
2cc64855
authored
Feb 15, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved team selection
Review changes
parent
b1864604
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
27 deletions
+53
-27
app/assets/stylesheets/framework/layout.scss
app/assets/stylesheets/framework/layout.scss
+13
-0
app/helpers/mattermost_helper.rb
app/helpers/mattermost_helper.rb
+2
-4
app/views/layouts/application.html.haml
app/views/layouts/application.html.haml
+1
-1
app/views/projects/mattermosts/_team_selection.html.haml
app/views/projects/mattermosts/_team_selection.html.haml
+6
-7
app/views/projects/mattermosts/new.html.haml
app/views/projects/mattermosts/new.html.haml
+2
-0
lib/mattermost/team.rb
lib/mattermost/team.rb
+1
-1
spec/features/projects/services/mattermost_slash_command_spec.rb
...atures/projects/services/mattermost_slash_command_spec.rb
+28
-14
No files found.
app/assets/stylesheets/framework/layout.scss
View file @
2cc64855
...
@@ -8,6 +8,19 @@ body {
...
@@ -8,6 +8,19 @@ body {
&
.navless
{
&
.navless
{
background-color
:
$white-light
!
important
;
background-color
:
$white-light
!
important
;
}
}
&
.card-content
{
background-color
:
$gray-darker
;
.content-wrapper
{
padding
:
0
;
.container-fluid
,
.container-limited
{
background-color
:
$gray-darker
;
}
}
}
}
}
.container
{
.container
{
...
...
app/helpers/mattermost_helper.rb
View file @
2cc64855
module
MattermostHelper
module
MattermostHelper
def
mattermost_teams_options
(
teams
)
def
mattermost_teams_options
(
teams
)
teams
_options
=
teams
.
map
do
|
id
,
options
|
teams
.
map
do
|
team
|
[
options
[
'display_name'
]
||
options
[
'name'
],
id
]
[
team
[
'display_name'
]
||
team
[
'name'
],
team
[
'id'
]
]
end
end
teams_options
.
compact
.
unshift
([
'Select team...'
,
'0'
])
end
end
end
end
app/views/layouts/application.html.haml
View file @
2cc64855
!!! 5
!!! 5
%html
{
lang:
"en"
,
class:
"#{page_class}"
}
%html
{
lang:
"en"
,
class:
"#{page_class}"
}
=
render
"layouts/head"
=
render
"layouts/head"
%body
{
data:
{
page:
body_data_page
,
project:
"#{@project.path if @project}"
,
group:
"#{@group.path if @group}"
}
}
%body
{
class:
@body_class
,
data:
{
page:
body_data_page
,
project:
"#{@project.path if @project}"
,
group:
"#{@group.path if @group}"
}
}
=
Gon
::
Base
.
render_data
=
Gon
::
Base
.
render_data
=
render
"layouts/header/default"
,
title:
header_title
=
render
"layouts/header/default"
,
title:
header_title
...
...
app/views/projects/mattermosts/_team_selection.html.haml
View file @
2cc64855
...
@@ -2,16 +2,15 @@
...
@@ -2,16 +2,15 @@
This service will be installed on the Mattermost instance at
This service will be installed on the Mattermost instance at
%strong
=
link_to
Gitlab
.
config
.
mattermost
.
host
,
Gitlab
.
config
.
mattermost
.
host
%strong
=
link_to
Gitlab
.
config
.
mattermost
.
host
,
Gitlab
.
config
.
mattermost
.
host
%hr
%hr
=
form_for
(
:mattermost
,
method: :post
,
url:
namespace_project_mattermost_path
(
@project
.
namespace
,
@project
))
do
|
f
|
=
form_for
(
:mattermost
,
method: :post
,
url:
namespace_project_mattermost_path
(
@project
.
namespace
,
@project
)
,
html:
{
class:
'js-requires-input'
}
)
do
|
f
|
%h4
Team
%h4
Team
%p
%p
=
@teams
.
one?
?
'The team'
:
'Select the team'
=
@teams
.
one?
?
'The team'
:
'Select the team'
where the slash commands will be used in
where the slash commands will be used in
-
selected_id
=
@teams
.
one?
?
@teams
.
keys
.
first
:
0
-
selected_id
=
@teams
.
one?
?
@teams
.
first
[
'id'
]
:
nil
-
options
=
mattermost_teams_options
(
@teams
)
-
options
=
options_for_select
(
mattermost_teams_options
(
@teams
),
selected_id
)
-
options
=
options_for_select
(
options
,
selected_id
)
=
f
.
select
(
:team_id
,
options
,
{
include_blank:
'Select team...'
},
{
class:
'form-control'
,
disabled:
@teams
.
one?
,
selected:
selected_id
,
required:
true
})
=
f
.
select
(
:team_id
,
options
,
{},
{
class:
'form-control'
,
disabled:
@teams
.
one?
,
selected:
selected_id
})
=
f
.
hidden_field
(
:team_id
,
value:
selected_id
,
required:
true
)
if
@teams
.
one?
=
f
.
hidden_field
(
:team_id
,
value:
selected_id
)
if
@teams
.
one?
.help-block
.help-block
-
if
@teams
.
one?
-
if
@teams
.
one?
This is the only available team.
This is the only available team.
...
@@ -25,7 +24,7 @@
...
@@ -25,7 +24,7 @@
%hr
%hr
%h4
Command trigger word
%h4
Command trigger word
%p
Choose the word that will trigger commands
%p
Choose the word that will trigger commands
=
f
.
text_field
(
:trigger
,
value:
@project
.
path
,
class:
'form-control'
)
=
f
.
text_field
(
:trigger
,
value:
@project
.
path
,
class:
'form-control'
,
required:
true
)
.help-block
.help-block
%p
%p
Trigger word must be unique, and can't begin with a slash or contain any spaces.
Trigger word must be unique, and can't begin with a slash or contain any spaces.
...
...
app/views/projects/mattermosts/new.html.haml
View file @
2cc64855
-
@body_class
=
'card-content'
.service-installation
.service-installation
.inline.pull-right
.inline.pull-right
=
custom_icon
(
'mattermost_logo'
,
size:
48
)
=
custom_icon
(
'mattermost_logo'
,
size:
48
)
...
...
lib/mattermost/team.rb
View file @
2cc64855
module
Mattermost
module
Mattermost
class
Team
<
Client
class
Team
<
Client
def
all
def
all
session_get
(
'/api/v3/teams/all'
)
session_get
(
'/api/v3/teams/all'
)
.
values
end
end
end
end
end
end
spec/features/projects/services/mattermost_slash_command_spec.rb
View file @
2cc64855
require
'spec_helper'
require
'spec_helper'
feature
'Setup Mattermost slash commands'
,
feature:
true
do
feature
'Setup Mattermost slash commands'
,
:feature
,
:js
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:service
)
{
project
.
create_mattermost_slash_commands_service
}
let
(
:service
)
{
project
.
create_mattermost_slash_commands_service
}
...
@@ -62,11 +62,11 @@ feature 'Setup Mattermost slash commands', feature: true do
...
@@ -62,11 +62,11 @@ feature 'Setup Mattermost slash commands', feature: true do
click_link
'Add to Mattermost'
click_link
'Add to Mattermost'
team_name
=
teams
.
first
[
1
][
'display_name'
]
team_name
=
teams
.
first
[
'display_name'
]
select_element
=
find
(
'
select
#mattermost_team_id'
)
select_element
=
find
(
'#mattermost_team_id'
)
selected_option
=
select_element
.
find
(
'option[selected]'
)
selected_option
=
select_element
.
find
(
'option[selected]'
)
expect
(
select_element
[
'disabled'
]).
to
eq
(
'disabled'
)
expect
(
select_element
[
'disabled'
]).
to
be
(
true
)
expect
(
selected_option
).
to
have_content
(
team_name
.
to_s
)
expect
(
selected_option
).
to
have_content
(
team_name
.
to_s
)
end
end
...
@@ -75,7 +75,7 @@ feature 'Setup Mattermost slash commands', feature: true do
...
@@ -75,7 +75,7 @@ feature 'Setup Mattermost slash commands', feature: true do
click_link
'Add to Mattermost'
click_link
'Add to Mattermost'
expect
(
find
(
'input#mattermost_team_id'
,
visible:
false
).
value
).
to
eq
(
teams
.
first
[
0
].
to_s
)
expect
(
find
(
'input#mattermost_team_id'
,
visible:
false
).
value
).
to
eq
(
teams
.
first
[
'id'
]
)
end
end
it
'shows an explanation user is a member of multiple teams'
do
it
'shows an explanation user is a member of multiple teams'
do
...
@@ -92,12 +92,9 @@ feature 'Setup Mattermost slash commands', feature: true do
...
@@ -92,12 +92,9 @@ feature 'Setup Mattermost slash commands', feature: true do
click_link
'Add to Mattermost'
click_link
'Add to Mattermost'
select_element
=
find
(
'select#mattermost_team_id'
)
select_element
=
find
(
'#mattermost_team_id'
)
selected_option
=
select_element
.
find
(
'option[selected]'
)
expect
(
select_element
[
'disabled'
]).
to
be
(
nil
)
expect
(
select_element
[
'disabled'
]).
to
be
(
false
)
expect
(
selected_option
).
to
have_content
(
'Select team...'
)
# The 'Select team...' placeholder is item `0`.
expect
(
select_element
.
all
(
'option'
).
count
).
to
eq
(
3
)
expect
(
select_element
.
all
(
'option'
).
count
).
to
eq
(
3
)
end
end
...
@@ -110,20 +107,37 @@ feature 'Setup Mattermost slash commands', feature: true do
...
@@ -110,20 +107,37 @@ feature 'Setup Mattermost slash commands', feature: true do
expect
(
page
).
to
have_content
(
'test mattermost error message'
)
expect
(
page
).
to
have_content
(
'test mattermost error message'
)
end
end
it
'enables the submit button if the required fields are provided'
,
:js
do
stub_teams
(
count:
1
)
click_link
'Add to Mattermost'
expect
(
find
(
'input[type="submit"]'
)[
'disabled'
]).
not_to
be
(
true
)
end
it
'disables the submit button if the required fields are not provided'
,
:js
do
stub_teams
(
count:
1
)
click_link
'Add to Mattermost'
fill_in
(
'mattermost_trigger'
,
with:
''
)
expect
(
find
(
'input[type="submit"]'
)[
'disabled'
]).
to
be
(
true
)
end
def
stub_teams
(
count:
0
)
def
stub_teams
(
count:
0
)
teams
=
create_teams
(
count
)
teams
=
create_teams
(
count
)
allow_any_instance_of
(
MattermostSlashCommandsService
).
to
receive
(
:list_teams
)
{
teams
}
allow_any_instance_of
(
MattermostSlashCommandsService
).
to
receive
(
:list_teams
)
{
[
teams
,
nil
]
}
teams
teams
end
end
def
create_teams
(
count
=
0
)
def
create_teams
(
count
=
0
)
teams
=
{}
teams
=
[]
count
.
times
do
|
i
|
count
.
times
do
|
i
|
i
+=
1
teams
.
push
({
"id"
=>
"x
#{
i
}
"
,
"display_name"
=>
"x
#{
i
}
-name"
})
teams
[
i
]
=
{
id:
i
,
display_name:
i
}
end
end
teams
teams
...
...
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