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
11815435
Commit
11815435
authored
Nov 20, 2020
by
Jan Provaznik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show service desk address field only of enabled
Shows the settings field only if service_Desk_email is configured.
parent
a23ede4b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
100 additions
and
13 deletions
+100
-13
app/assets/javascripts/projects/settings_service_desk/components/service_desk_root.vue
...ts/settings_service_desk/components/service_desk_root.vue
+5
-0
app/assets/javascripts/projects/settings_service_desk/components/service_desk_setting.vue
...settings_service_desk/components/service_desk_setting.vue
+5
-1
app/assets/javascripts/projects/settings_service_desk/index.js
...ssets/javascripts/projects/settings_service_desk/index.js
+2
-0
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+0
-1
app/models/project.rb
app/models/project.rb
+5
-2
app/views/projects/_service_desk_settings.html.haml
app/views/projects/_service_desk_settings.html.haml
+1
-0
spec/features/projects/settings/service_desk_setting_spec.rb
spec/features/projects/settings/service_desk_setting_spec.rb
+46
-9
spec/models/project_spec.rb
spec/models/project_spec.rb
+36
-0
No files found.
app/assets/javascripts/projects/settings_service_desk/components/service_desk_root.vue
View file @
11815435
...
...
@@ -30,6 +30,10 @@ export default {
required
:
false
,
default
:
''
,
},
customEmailEnabled
:
{
type
:
Boolean
,
required
:
false
,
},
selectedTemplate
:
{
type
:
String
,
required
:
false
,
...
...
@@ -140,6 +144,7 @@ export default {
:is-enabled=
"isEnabled"
:incoming-email=
"incomingEmail"
:custom-email=
"updatedCustomEmail"
:custom-email-enabled=
"customEmailEnabled"
:initial-selected-template=
"selectedTemplate"
:initial-outgoing-name=
"outgoingName"
:initial-project-key=
"projectKey"
...
...
app/assets/javascripts/projects/settings_service_desk/components/service_desk_setting.vue
View file @
11815435
...
...
@@ -31,6 +31,10 @@ export default {
required
:
false
,
default
:
''
,
},
customEmailEnabled
:
{
type
:
Boolean
,
required
:
false
,
},
initialSelectedTemplate
:
{
type
:
String
,
required
:
false
,
...
...
@@ -69,7 +73,7 @@ export default {
return
[
''
].
concat
(
this
.
templates
);
},
hasProjectKeySupport
()
{
return
Boolean
(
this
.
glFeatures
.
serviceDeskCustomAddress
);
return
Boolean
(
this
.
customEmailEnabled
);
},
email
()
{
return
this
.
customEmail
||
this
.
incomingEmail
;
...
...
app/assets/javascripts/projects/settings_service_desk/index.js
View file @
11815435
...
...
@@ -18,6 +18,7 @@ export default () => {
endpoint
:
dataset
.
endpoint
,
incomingEmail
:
dataset
.
incomingEmail
,
customEmail
:
dataset
.
customEmail
,
customEmailEnabled
:
parseBoolean
(
dataset
.
customEmailEnabled
),
selectedTemplate
:
dataset
.
selectedTemplate
,
outgoingName
:
dataset
.
outgoingName
,
projectKey
:
dataset
.
projectKey
,
...
...
@@ -31,6 +32,7 @@ export default () => {
endpoint
:
this
.
endpoint
,
incomingEmail
:
this
.
incomingEmail
,
customEmail
:
this
.
customEmail
,
customEmailEnabled
:
this
.
customEmailEnabled
,
selectedTemplate
:
this
.
selectedTemplate
,
outgoingName
:
this
.
outgoingName
,
projectKey
:
this
.
projectKey
,
...
...
app/controllers/projects_controller.rb
View file @
11815435
...
...
@@ -41,7 +41,6 @@ class ProjectsController < Projects::ApplicationController
end
before_action
only:
[
:edit
]
do
push_frontend_feature_flag
(
:service_desk_custom_address
,
@project
)
push_frontend_feature_flag
(
:approval_suggestions
,
@project
,
default_enabled:
true
)
end
...
...
app/models/project.rb
View file @
11815435
...
...
@@ -2499,8 +2499,7 @@ class Project < ApplicationRecord
end
def
service_desk_custom_address
return
unless
::
Gitlab
::
ServiceDeskEmail
.
enabled?
return
unless
::
Feature
.
enabled?
(
:service_desk_custom_address
,
self
)
return
unless
service_desk_custom_address_enabled?
key
=
service_desk_setting
&
.
project_key
return
unless
key
.
present?
...
...
@@ -2508,6 +2507,10 @@ class Project < ApplicationRecord
::
Gitlab
::
ServiceDeskEmail
.
address_for_key
(
"
#{
full_path_slug
}
-
#{
key
}
"
)
end
def
service_desk_custom_address_enabled?
::
Gitlab
::
ServiceDeskEmail
.
enabled?
&&
::
Feature
.
enabled?
(
:service_desk_custom_address
,
self
)
end
def
root_namespace
if
namespace
.
has_parent?
namespace
.
root_ancestor
...
...
app/views/projects/_service_desk_settings.html.haml
View file @
11815435
...
...
@@ -12,6 +12,7 @@
enabled:
"#{@project.service_desk_enabled}"
,
incoming_email:
(
@project
.
service_desk_incoming_address
if
@project
.
service_desk_enabled
),
custom_email:
(
@project
.
service_desk_custom_address
if
@project
.
service_desk_enabled
),
custom_email_enabled:
"#{@project.service_desk_custom_address_enabled?}"
,
selected_template:
"#{@project.service_desk_setting&.issue_template_key}"
,
outgoing_name:
"#{@project.service_desk_setting&.outgoing_name}"
,
project_key:
"#{@project.service_desk_setting&.project_key}"
,
...
...
spec/features/projects/settings/service_desk_setting_spec.rb
View file @
11815435
...
...
@@ -14,20 +14,57 @@ RSpec.describe 'Service Desk Setting', :js do
allow_any_instance_of
(
Project
).
to
receive
(
:present
).
with
(
current_user:
user
).
and_return
(
presenter
)
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
)
{
true
}
visit
edit_project_path
(
project
)
end
it
'shows activation checkbox'
do
visit
edit_project_path
(
project
)
expect
(
page
).
to
have_selector
(
"#service-desk-checkbox"
)
end
it
'shows incoming email after activating'
do
find
(
"#service-desk-checkbox"
).
click
wait_for_requests
project
.
reload
expect
(
project
.
service_desk_enabled
).
to
be_truthy
expect
(
project
.
service_desk_address
).
to
be_present
expect
(
find
(
'[data-testid="incoming-email"]'
).
value
).
to
eq
(
project
.
service_desk_address
)
context
'when service_desk_email is disabled'
do
before
do
allow
(
::
Gitlab
::
ServiceDeskEmail
).
to
receive
(
:enabled?
).
and_return
(
false
)
visit
edit_project_path
(
project
)
end
it
'shows incoming email but not project name suffix after activating'
do
find
(
"#service-desk-checkbox"
).
click
wait_for_requests
project
.
reload
expect
(
project
.
service_desk_enabled
).
to
be_truthy
expect
(
project
.
service_desk_address
).
to
be_present
expect
(
find
(
'[data-testid="incoming-email"]'
).
value
).
to
eq
(
project
.
service_desk_incoming_address
)
expect
(
page
).
not_to
have_selector
(
'#service-desk-project-suffix'
)
end
end
context
'when service_desk_email is enabled'
do
before
do
allow
(
::
Gitlab
::
ServiceDeskEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
::
Gitlab
::
ServiceDeskEmail
).
to
receive
(
:address_for_key
)
{
'address-suffix@example.com'
}
visit
edit_project_path
(
project
)
end
it
'allows setting of custom address suffix'
do
find
(
"#service-desk-checkbox"
).
click
wait_for_requests
project
.
reload
expect
(
find
(
'[data-testid="incoming-email"]'
).
value
).
to
eq
(
project
.
service_desk_incoming_address
)
page
.
within
'#js-service-desk'
do
fill_in
(
'service-desk-project-suffix'
,
with:
'foo'
)
click_button
'Save changes'
end
wait_for_requests
expect
(
find
(
'[data-testid="incoming-email"]'
).
value
).
to
eq
(
'address-suffix@example.com'
)
end
end
end
spec/models/project_spec.rb
View file @
11815435
...
...
@@ -1535,6 +1535,42 @@ RSpec.describe Project, factory_default: :keep do
end
end
describe
'.service_desk_custom_address_enabled?'
do
let_it_be
(
:project
)
{
create
(
:project
,
service_desk_enabled:
true
)
}
subject
(
:address_enabled
)
{
project
.
service_desk_custom_address_enabled?
}
context
'when service_desk_email is enabled'
do
before
do
allow
(
::
Gitlab
::
ServiceDeskEmail
).
to
receive
(
:enabled?
).
and_return
(
true
)
end
it
'returns true'
do
expect
(
address_enabled
).
to
be_truthy
end
context
'when service_desk_custom_address flag is disabled'
do
before
do
stub_feature_flags
(
service_desk_custom_address:
false
)
end
it
'returns false'
do
expect
(
address_enabled
).
to
be_falsey
end
end
end
context
'when service_desk_email is disabled'
do
before
do
allow
(
::
Gitlab
::
ServiceDeskEmail
).
to
receive
(
:enabled?
).
and_return
(
false
)
end
it
'returns false when service_desk_email is disabled'
do
expect
(
address_enabled
).
to
be_falsey
end
end
end
describe
'.find_by_service_desk_project_key'
do
it
'returns the correct project'
do
project1
=
create
(
:project
)
...
...
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