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
34cc2a8e
Commit
34cc2a8e
authored
Feb 07, 2017
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve DRYness of views
parent
571f3412
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
43 deletions
+51
-43
groups_controller.rb
app/controllers/groups_controller.rb
+4
-1
create_service.rb
app/services/groups/create_service.rb
+3
-1
update_service.rb
app/services/groups/update_service.rb
+5
-0
_create_chat_team.html.haml
app/views/groups/_create_chat_team.html.haml
+18
-0
edit.html.haml
app/views/groups/edit.html.haml
+1
-19
new.html.haml
app/views/groups/new.html.haml
+1
-16
create_team_worker.rb
app/workers/mattermost/create_team_worker.rb
+5
-4
20170120131253_create_chat_teams.rb
db/migrate/20170120131253_create_chat_teams.rb
+2
-2
schema.rb
db/schema.rb
+12
-0
No files found.
app/controllers/groups_controller.rb
View file @
34cc2a8e
...
@@ -27,6 +27,7 @@ class GroupsController < Groups::ApplicationController
...
@@ -27,6 +27,7 @@ class GroupsController < Groups::ApplicationController
end
end
def
create
def
create
byebug
@group
=
Groups
::
CreateService
.
new
(
current_user
,
group_params
).
execute
@group
=
Groups
::
CreateService
.
new
(
current_user
,
group_params
).
execute
if
@group
.
persisted?
if
@group
.
persisted?
...
@@ -81,6 +82,7 @@ class GroupsController < Groups::ApplicationController
...
@@ -81,6 +82,7 @@ class GroupsController < Groups::ApplicationController
end
end
def
update
def
update
byebug
if
Groups
::
UpdateService
.
new
(
@group
,
current_user
,
group_params
).
execute
if
Groups
::
UpdateService
.
new
(
@group
,
current_user
,
group_params
).
execute
redirect_to
edit_group_path
(
@group
),
notice:
"Group '
#{
@group
.
name
}
' was successfully updated."
redirect_to
edit_group_path
(
@group
),
notice:
"Group '
#{
@group
.
name
}
' was successfully updated."
else
else
...
@@ -139,7 +141,8 @@ class GroupsController < Groups::ApplicationController
...
@@ -139,7 +141,8 @@ class GroupsController < Groups::ApplicationController
:request_access_enabled
,
:request_access_enabled
,
:share_with_group_lock
,
:share_with_group_lock
,
:visibility_level
,
:visibility_level
,
:create_chat_team
:create_chat_team
,
:chat_team_name
]
]
end
end
...
...
app/services/groups/create_service.rb
View file @
34cc2a8e
...
@@ -6,6 +6,7 @@ module Groups
...
@@ -6,6 +6,7 @@ module Groups
def
execute
def
execute
create_chat_team
=
params
.
delete
(
:create_chat_team
)
create_chat_team
=
params
.
delete
(
:create_chat_team
)
team_name
=
params
.
delete
(
:chat_team_name
)
@group
=
Group
.
new
(
params
)
@group
=
Group
.
new
(
params
)
...
@@ -26,7 +27,8 @@ module Groups
...
@@ -26,7 +27,8 @@ module Groups
@group
.
add_owner
(
current_user
)
@group
.
add_owner
(
current_user
)
if
create_chat_team
&&
Gitlab
.
config
.
mattermost
.
enabled
if
create_chat_team
&&
Gitlab
.
config
.
mattermost
.
enabled
Mattermost
::
CreateTeamWorker
.
perform_async
(
@group
.
id
,
current_user
.
id
)
options
=
team_name
?
{
name:
team_name
}
:
{}
Mattermost
::
CreateTeamWorker
.
perform_async
(
@group
.
id
,
current_user
.
id
,
options
)
end
end
@group
@group
...
...
app/services/groups/update_service.rb
View file @
34cc2a8e
module
Groups
module
Groups
class
UpdateService
<
Groups
::
BaseService
class
UpdateService
<
Groups
::
BaseService
def
execute
def
execute
if
params
.
delete
(
:create_chat_team
)
==
'1'
chat_name
=
params
[
:chat_team_name
]
options
=
chat_name
?
{
name:
chat_name
}
:
{}
end
# check that user is allowed to set specified visibility_level
# check that user is allowed to set specified visibility_level
new_visibility
=
params
[
:visibility_level
]
new_visibility
=
params
[
:visibility_level
]
if
new_visibility
&&
new_visibility
.
to_i
!=
group
.
visibility_level
if
new_visibility
&&
new_visibility
.
to_i
!=
group
.
visibility_level
...
...
app/views/groups/_create_chat_team.html.haml
0 → 100644
View file @
34cc2a8e
.form-group
=
f
.
label
:name
,
class:
'control-label'
do
%span
.mattermost-icon
=
custom_icon
(
'icon_mattermost'
)
Mattermost
.col-sm-10
.checkbox
=
f
.
label
:name
do
=
f
.
check_box
:create_chat_team
,
checked:
true
Link the group to a new Mattermost team
.form-group
=
f
.
label
:chat_team
,
class:
'control-label'
do
Chat Team name
.col-sm-10
=
f
.
text_field
:chat_team
,
placeholder:
@group
.
name
,
class:
'form-control mattermost-team-name'
Leave blank to match your group name
app/views/groups/edit.html.haml
View file @
34cc2a8e
...
@@ -22,25 +22,7 @@
...
@@ -22,25 +22,7 @@
=
render
'shared/visibility_level'
,
f:
f
,
visibility_level:
@group
.
visibility_level
,
can_change_visibility_level:
can_change_group_visibility_level?
(
@group
),
form_model:
@group
=
render
'shared/visibility_level'
,
f:
f
,
visibility_level:
@group
.
visibility_level
,
can_change_visibility_level:
can_change_group_visibility_level?
(
@group
),
form_model:
@group
.form-group
=
render
'create_chat_team'
,
f:
f
if
Gitlab
.
config
.
mattermost
.
enabled
=
f
.
label
:name
,
class:
'control-label'
do
%span
.mattermost-icon
=
custom_icon
(
'icon_mattermost'
)
Mattermost
.col-sm-10
.checkbox
=
f
.
label
:name
do
=
f
.
check_box
:name
,
checked:
true
Link the group to a new or existing Mattermost team
-
enabled
=
Gitlab
.
config
.
mattermost
.
enabled
-
if
enabled
.form-group
.col-sm-offset-2.col-sm-10
=
f
.
text_field
:name
,
placeholder:
"FILL WITH TEAM NAME"
,
class:
'form-control mattermost-team-name'
%span
.mattermost-info
Team URL: INSERT TEAM URL
.form-group
.form-group
.col-sm-offset-2.col-sm-10
.col-sm-offset-2.col-sm-10
...
...
app/views/groups/new.html.haml
View file @
34cc2a8e
...
@@ -16,22 +16,7 @@
...
@@ -16,22 +16,7 @@
=
render
'shared/visibility_level'
,
f:
f
,
visibility_level:
default_group_visibility
,
can_change_visibility_level:
true
,
form_model:
@group
=
render
'shared/visibility_level'
,
f:
f
,
visibility_level:
default_group_visibility
,
can_change_visibility_level:
true
,
form_model:
@group
.form-group
=
render
'create_chat_team'
,
f:
f
if
Gitlab
.
config
.
mattermost
.
enabled
=
f
.
label
:create_chat_team
,
class:
'control-label'
do
%span
.mattermost-icon
=
custom_icon
(
'icon_mattermost'
)
Mattermost
.col-sm-10
.checkbox
=
f
.
label
:chat_team
do
=
f
.
check_box
:chat_team
Link the group to a new or existing Mattermost team
-
enabled
=
Gitlab
.
config
.
mattermost
.
enabled
-
if
enabled
.form-group
.col-sm-offset-2.col-sm-10
=
f
.
text_field
:name
,
placeholder:
'Mattermost team name'
,
class:
'form-control mattermost-team-name'
.form-group
.form-group
.col-sm-offset-2.col-sm-10
.col-sm-offset-2.col-sm-10
...
...
app/workers/mattermost/create_team_worker.rb
View file @
34cc2a8e
...
@@ -7,17 +7,18 @@ module Mattermost
...
@@ -7,17 +7,18 @@ module Mattermost
# Add 5 seconds so the first retry isn't 1 second later
# Add 5 seconds so the first retry isn't 1 second later
sidekiq_retry_in
do
|
count
|
sidekiq_retry_in
do
|
count
|
5
+
5
**
n
5
+
5
**
n
end
end
def
perform
(
group_id
,
current_user_id
,
options
=
{})
def
perform
(
group_id
,
current_user_id
,
options
=
{})
group
=
Group
.
find
(
group_id
)
group
=
Group
.
find_by
(
id:
group_id
)
current_user
=
User
.
find
(
current_user_id
)
current_user
=
User
.
find_by
(
id:
current_user_id
)
return
unless
group
&&
current_user
# The user that creates the team will be Team Admin
# The user that creates the team will be Team Admin
response
=
Mattermost
::
Team
.
new
(
current_user
).
create
(
group
,
options
)
response
=
Mattermost
::
Team
.
new
(
current_user
).
create
(
group
,
options
)
ChatTeam
.
create
(
namespace:
group
,
name:
response
[
'name'
],
team_id:
response
[
'id'
])
group
.
create_chat_team
(
name:
response
[
'name'
],
team_id:
response
[
'id'
])
end
end
end
end
end
end
db/migrate/20170120131253_create_chat_teams.rb
View file @
34cc2a8e
...
@@ -5,13 +5,13 @@ class CreateChatTeams < ActiveRecord::Migration
...
@@ -5,13 +5,13 @@ class CreateChatTeams < ActiveRecord::Migration
def
change
def
change
create_table
:chat_teams
do
|
t
|
create_table
:chat_teams
do
|
t
|
t
.
integer
:
namespace
_id
,
index:
true
t
.
integer
:
group
_id
,
index:
true
t
.
string
:team_id
t
.
string
:team_id
t
.
string
:name
t
.
string
:name
t
.
timestamps
null:
false
t
.
timestamps
null:
false
end
end
add_foreign_key
:chat_teams
,
:
namespace
s
,
on_delete: :cascade
add_foreign_key
:chat_teams
,
:
group
s
,
on_delete: :cascade
end
end
end
end
db/schema.rb
View file @
34cc2a8e
...
@@ -109,6 +109,7 @@ ActiveRecord::Schema.define(version: 20170204181513) do
...
@@ -109,6 +109,7 @@ ActiveRecord::Schema.define(version: 20170204181513) do
t
.
boolean
"html_emails_enabled"
,
default:
true
t
.
boolean
"html_emails_enabled"
,
default:
true
t
.
string
"plantuml_url"
t
.
string
"plantuml_url"
t
.
boolean
"plantuml_enabled"
t
.
boolean
"plantuml_enabled"
t
.
integer
"max_pages_size"
,
default:
100
,
null:
false
t
.
integer
"terminal_max_session_time"
,
default:
0
,
null:
false
t
.
integer
"terminal_max_session_time"
,
default:
0
,
null:
false
end
end
...
@@ -867,6 +868,17 @@ ActiveRecord::Schema.define(version: 20170204181513) do
...
@@ -867,6 +868,17 @@ ActiveRecord::Schema.define(version: 20170204181513) do
add_index
"oauth_applications"
,
[
"owner_id"
,
"owner_type"
],
name:
"index_oauth_applications_on_owner_id_and_owner_type"
,
using: :btree
add_index
"oauth_applications"
,
[
"owner_id"
,
"owner_type"
],
name:
"index_oauth_applications_on_owner_id_and_owner_type"
,
using: :btree
add_index
"oauth_applications"
,
[
"uid"
],
name:
"index_oauth_applications_on_uid"
,
unique:
true
,
using: :btree
add_index
"oauth_applications"
,
[
"uid"
],
name:
"index_oauth_applications_on_uid"
,
unique:
true
,
using: :btree
create_table
"pages_domains"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
t
.
text
"certificate"
t
.
text
"encrypted_key"
t
.
string
"encrypted_key_iv"
t
.
string
"encrypted_key_salt"
t
.
string
"domain"
end
add_index
"pages_domains"
,
[
"domain"
],
name:
"index_pages_domains_on_domain"
,
unique:
true
,
using: :btree
create_table
"personal_access_tokens"
,
force: :cascade
do
|
t
|
create_table
"personal_access_tokens"
,
force: :cascade
do
|
t
|
t
.
integer
"user_id"
,
null:
false
t
.
integer
"user_id"
,
null:
false
t
.
string
"token"
,
null:
false
t
.
string
"token"
,
null:
false
...
...
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