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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
bddbf9ae
Commit
bddbf9ae
authored
Jul 07, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Project alias for Slack application can be edited
parent
bc97513a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
100 additions
and
10 deletions
+100
-10
app/controllers/projects/settings/slacks_controller.rb
app/controllers/projects/settings/slacks_controller.rb
+30
-2
app/models/slack_integration.rb
app/models/slack_integration.rb
+2
-1
app/views/projects/services/gitlab_slack_application/_slack_integration_form.html.haml
...itlab_slack_application/_slack_integration_form.html.haml
+8
-6
app/views/projects/settings/slacks/edit.html.haml
app/views/projects/settings/slacks/edit.html.haml
+24
-0
config/routes/project.rb
config/routes/project.rb
+1
-1
spec/features/projects/settings/slack_application_spec.rb
spec/features/projects/settings/slack_application_spec.rb
+35
-0
No files found.
app/controllers/projects/settings/slacks_controller.rb
View file @
bddbf9ae
...
...
@@ -3,6 +3,10 @@ module Projects
class
SlacksController
<
Projects
::
ApplicationController
before_action
:handle_oauth_error
,
only: :slack_auth
before_action
:authorize_admin_project!
before_action
:slack_integration
,
only:
[
:edit
,
:update
]
before_action
:service
,
only:
[
:destroy
,
:edit
,
:update
]
layout
'project_settings'
def
slack_auth
result
=
Projects
::
SlackApplicationInstallService
.
new
(
project
,
current_user
,
params
).
execute
...
...
@@ -15,12 +19,24 @@ module Projects
end
def
destroy
service
=
project
.
gitlab_slack_application_service
service
.
slack_integration
.
destroy
slack_integration
.
destroy
redirect_to_service_page
end
def
edit
end
def
update
if
slack_integration
.
update
(
slack_integration_params
)
flash
[
:notice
]
=
'The project alias was updated successfully'
redirect_to_service_page
else
render
:edit
end
end
private
def
redirect_to_service_page
...
...
@@ -36,6 +52,18 @@ module Projects
redirect_to_service_page
end
end
def
slack_integration
@slack_integration
||=
project
.
gitlab_slack_application_service
.
slack_integration
end
def
service
@service
=
project
.
gitlab_slack_application_service
end
def
slack_integration_params
params
.
require
(
:slack_integration
).
permit
(
:alias
)
end
end
end
end
app/models/slack_integration.rb
View file @
bddbf9ae
...
...
@@ -4,7 +4,8 @@ class SlackIntegration < ActiveRecord::Base
validates
:team_id
,
presence:
true
validates
:team_name
,
presence:
true
validates
:alias
,
presence:
true
,
uniqueness:
{
scope: :team_id
,
message:
'This alias has already been taken'
}
uniqueness:
{
scope: :team_id
,
message:
'This alias has already been taken'
},
length:
2
..
80
validates
:user_id
,
presence:
true
validates
:service
,
presence:
true
...
...
app/views/projects/services/gitlab_slack_application/_slack_integration_form.html.haml
View file @
bddbf9ae
...
...
@@ -5,8 +5,8 @@
%colgroup
%col
%col
%col
.hidden-xs
%col
{
width:
"120"
}
%col
%col
%thead
%tr
%th
Team name
...
...
@@ -18,9 +18,11 @@
=
slack_integration
.
team_name
%td
=
slack_integration
.
alias
%td
.light
%td
=
time_ago_in_words
slack_integration
.
created_at
ago
%td
.light
-
project
=
@service
.
project
=
link_to
'Remove'
,
namespace_project_settings_slack_path
(
project
.
namespace
,
project
),
method: :delete
,
class:
'btn btn-danger'
,
data:
{
confirm:
'Are you sure?'
}
%td
.controls
-
project
=
@service
.
project
=
link_to
'Edit'
,
edit_project_settings_slack_path
(
project
),
class:
'btn btn-sm'
=
link_to
'Remove'
,
project_settings_slack_path
(
project
),
method: :delete
,
class:
'btn btn-danger btn-sm'
,
data:
{
confirm:
'Are you sure?'
}
app/views/projects/settings/slacks/edit.html.haml
0 → 100644
View file @
bddbf9ae
-
page_title
'Edit Slack integration'
=
render
"projects/settings/head"
.row.prepend-top-default.append-bottom-default
.col-lg-3
%h4
.prepend-top-0
Edit project alias
%p
You can use this alias in your Slack commands
.col-lg-9
=
form_errors
(
@slack_integration
)
=
form_for
(
@slack_integration
,
url:
project_settings_slack_path
(
@project
),
method: :put
,
html:
{
class:
'gl-show-field-errors form-horizontal js-integration-settings-form'
})
do
|
form
|
.form-group
=
form
.
label
:alias
,
'Enter your alias'
,
class:
'control-label'
.col-sm-10
=
form
.
text_field
:alias
,
class:
'form-control'
,
placeholder:
@slack_integration
.
alias
,
required:
true
.footer-block.row-content-block
%button
.btn.btn-save
{
type:
'submit'
}
=
icon
(
'spinner spin'
,
class:
'hidden js-btn-spinner'
)
%span
.js-btn-label
Save changes
=
link_to
'Cancel'
,
edit_project_service_path
(
@project
,
@service
),
class:
'btn btn-cancel'
config/routes/project.rb
View file @
bddbf9ae
...
...
@@ -438,7 +438,7 @@ constraints(ProjectUrlConstrainer.new) do
resource
:ci_cd
,
only:
[
:show
],
controller:
'ci_cd'
resource
:integrations
,
only:
[
:show
]
resource
:slack
,
only:
[
:destroy
]
do
resource
:slack
,
only:
[
:destroy
,
:edit
,
:update
]
do
get
:slack_auth
end
...
...
spec/features/projects/settings/slack_application_spec.rb
0 → 100644
View file @
bddbf9ae
require
'spec_helper'
feature
'Slack application'
,
feature:
true
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:role
)
{
:developer
}
let
(
:service
)
{
create
(
:gitlab_slack_application_service
,
project:
project
)
}
let
(
:slack_application_form_path
)
{
edit_project_service_path
(
project
,
service
)
}
background
do
gitlab_sign_in
(
user
)
project
.
team
<<
[
user
,
:master
]
create
(
:slack_integration
,
service:
service
)
allow
(
Service
).
to
receive
(
:show_gitlab_slack_application?
).
and_return
(
true
)
end
scenario
'I can edit slack integration'
do
visit
slack_application_form_path
within
'.js-integration-settings-form'
do
click_link
'Edit'
end
fill_in
'slack_integration_alias'
,
with:
'alias-edited'
click_button
'Save changes'
expect
(
page
).
to
have_content
(
'The project alias is updated successfully'
)
within
'.js-integration-settings-form'
do
expect
(
page
).
to
have_content
(
'alias-edited'
)
end
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