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
009829e5
Commit
009829e5
authored
May 05, 2020
by
Justin Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract TriggerFields to Vue component
Pass data on form schema and values from backend
parent
b7d15b5f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
2 deletions
+92
-2
app/assets/javascripts/integrations/edit/components/integration_form.vue
...scripts/integrations/edit/components/integration_form.vue
+8
-0
app/assets/javascripts/integrations/edit/components/trigger_fields.vue
...vascripts/integrations/edit/components/trigger_fields.vue
+65
-0
app/assets/javascripts/integrations/edit/index.js
app/assets/javascripts/integrations/edit/index.js
+2
-1
app/models/service.rb
app/models/service.rb
+13
-0
app/views/shared/_service_settings.html.haml
app/views/shared/_service_settings.html.haml
+1
-1
locale/gitlab.pot
locale/gitlab.pot
+3
-0
No files found.
app/assets/javascripts/integrations/edit/components/integration_form.vue
View file @
009829e5
<
script
>
<
script
>
import
ActiveToggle
from
'
./active_toggle.vue
'
;
import
ActiveToggle
from
'
./active_toggle.vue
'
;
import
JiraTriggerFields
from
'
./jira_trigger_fields.vue
'
;
import
JiraTriggerFields
from
'
./jira_trigger_fields.vue
'
;
import
TriggerFields
from
'
./trigger_fields.vue
'
;
export
default
{
export
default
{
name
:
'
IntegrationForm
'
,
name
:
'
IntegrationForm
'
,
components
:
{
components
:
{
ActiveToggle
,
ActiveToggle
,
JiraTriggerFields
,
JiraTriggerFields
,
TriggerFields
,
},
},
props
:
{
props
:
{
activeToggleProps
:
{
activeToggleProps
:
{
...
@@ -21,6 +23,11 @@ export default {
...
@@ -21,6 +23,11 @@ export default {
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
triggerEvents
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
type
:
{
type
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
...
@@ -38,5 +45,6 @@ export default {
...
@@ -38,5 +45,6 @@ export default {
<div>
<div>
<active-toggle
v-if=
"showActive"
v-bind=
"activeToggleProps"
/>
<active-toggle
v-if=
"showActive"
v-bind=
"activeToggleProps"
/>
<jira-trigger-fields
v-if=
"isJira"
v-bind=
"triggerFieldsProps"
/>
<jira-trigger-fields
v-if=
"isJira"
v-bind=
"triggerFieldsProps"
/>
<trigger-fields
v-else
:events=
"triggerEvents"
:type=
"type"
/>
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/integrations/edit/components/trigger_fields.vue
0 → 100644
View file @
009829e5
<
script
>
import
{
startCase
}
from
'
lodash
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
GlFormGroup
,
GlFormCheckbox
,
GlFormInput
}
from
'
@gitlab/ui
'
;
export
default
{
name
:
'
TriggerFields
'
,
components
:
{
GlFormGroup
,
GlFormCheckbox
,
GlFormInput
,
},
props
:
{
events
:
{
type
:
Array
,
required
:
false
,
default
:
null
,
},
type
:
{
type
:
String
,
required
:
true
,
},
},
computed
:
{
placeholder
()
{
if
(
this
.
type
===
'
slack
'
)
{
return
__
(
'
Slack channels (e.g. general, development)
'
);
}
else
if
(
this
.
type
===
'
mattermost
'
)
{
return
__
(
'
Channel handle (e.g. town-square)
'
);
}
return
null
;
},
},
methods
:
{
checkboxName
(
name
)
{
return
`service[
${
name
}
]`
;
},
checkboxTitle
(
title
)
{
return
startCase
(
title
);
},
fieldName
(
name
)
{
return
`service[
${
name
}
]`
;
},
},
};
</
script
>
<
template
>
<gl-form-group
label=
"Trigger"
label-for=
"trigger-fields"
>
<div
id=
"trigger-fields"
>
<gl-form-group
v-for=
"event in events"
:key=
"event.title"
:description=
"event.description"
>
<input
:name=
"checkboxName(event.name)"
type=
"hidden"
value=
"false"
/>
<gl-form-checkbox
v-model=
"event.value"
:name=
"checkboxName(event.name)"
>
{{
checkboxTitle
(
event
.
title
)
}}
</gl-form-checkbox>
<gl-form-input
v-if=
"event.field.name"
v-model=
"event.field.value"
:name=
"fieldName(event.field.name)"
:placeholder=
"placeholder"
/>
</gl-form-group>
</div>
</gl-form-group>
</
template
>
app/assets/javascripts/integrations/edit/index.js
View file @
009829e5
...
@@ -15,7 +15,7 @@ export default el => {
...
@@ -15,7 +15,7 @@ export default el => {
return
result
;
return
result
;
}
}
const
{
type
,
commentDetail
,
...
booleanAttributes
}
=
el
.
dataset
;
const
{
type
,
commentDetail
,
triggerEvents
,
...
booleanAttributes
}
=
el
.
dataset
;
const
{
const
{
showActive
,
showActive
,
activated
,
activated
,
...
@@ -40,6 +40,7 @@ export default el => {
...
@@ -40,6 +40,7 @@ export default el => {
initialEnableComments
:
enableComments
,
initialEnableComments
:
enableComments
,
initialCommentDetail
:
commentDetail
,
initialCommentDetail
:
commentDetail
,
},
},
triggerEvents
:
JSON
.
parse
(
triggerEvents
),
},
},
});
});
},
},
...
...
app/models/service.rb
View file @
009829e5
...
@@ -170,6 +170,19 @@ class Service < ApplicationRecord
...
@@ -170,6 +170,19 @@ class Service < ApplicationRecord
end
end
end
end
def
configurable_events_json
configurable_events
.
map
do
|
event
|
event_method
=
ServicesHelper
.
service_event_field_name
(
event
)
result
=
{
title:
event
,
name:
event_method
,
value:
send
(
event_method
),
description:
self
.
class
.
event_description
(
event
)
}
# rubocop:disable GitlabSecurity/PublicSend
field
=
event_field
(
event
)
if
field
result
.
merge
({
field:
{
name:
field
[
:name
],
value:
send
(
field
[
:name
])
}
})
# rubocop:disable GitlabSecurity/PublicSend
else
result
end
end
.
to_json
end
def
configurable_event_actions
def
configurable_event_actions
self
.
class
.
supported_event_actions
self
.
class
.
supported_event_actions
end
end
...
...
app/views/shared/_service_settings.html.haml
View file @
009829e5
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
.service-settings
.service-settings
.js-vue-integration-settings
{
data:
{
show_active:
@service
.
show_active_box?
.
to_s
,
activated:
(
@service
.
active
||
@service
.
new_record?
).
to_s
,
type:
@service
.
to_param
,
merge_request_events:
@service
.
merge_requests_events
.
to_s
,
.js-vue-integration-settings
{
data:
{
show_active:
@service
.
show_active_box?
.
to_s
,
activated:
(
@service
.
active
||
@service
.
new_record?
).
to_s
,
type:
@service
.
to_param
,
merge_request_events:
@service
.
merge_requests_events
.
to_s
,
commit_events:
@service
.
commit_events
.
to_s
,
enable_comments:
@service
.
comment_on_event_enabled
.
to_s
,
comment_detail:
@service
.
comment_detail
}
}
commit_events:
@service
.
commit_events
.
to_s
,
enable_comments:
@service
.
comment_on_event_enabled
.
to_s
,
comment_detail:
@service
.
comment_detail
,
trigger_events:
@service
.
configurable_events_json
}
}
-
if
@service
.
configurable_events
.
present?
&&
!
@service
.
is_a?
(
JiraService
)
-
if
@service
.
configurable_events
.
present?
&&
!
@service
.
is_a?
(
JiraService
)
.form-group.row
.form-group.row
...
...
locale/gitlab.pot
View file @
009829e5
...
@@ -3760,6 +3760,9 @@ msgstr ""
...
@@ -3760,6 +3760,9 @@ msgstr ""
msgid "Changing group path can have unintended side effects."
msgid "Changing group path can have unintended side effects."
msgstr ""
msgstr ""
msgid "Channel handle (e.g. town-square)"
msgstr ""
msgid "Charts"
msgid "Charts"
msgstr ""
msgstr ""
...
...
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