Commit 73c83398 authored by Justin Ho's avatar Justin Ho

Use sentence case for trigger events

Pass externalized strings from the backend instead of
doing string transforms on the frontend.

Changelog: changed
parent 0175304d
<script> <script>
import { GlFormGroup, GlFormCheckbox, GlFormInput } from '@gitlab/ui'; import { GlFormGroup, GlFormCheckbox, GlFormInput } from '@gitlab/ui';
import { startCase } from 'lodash';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -45,7 +44,6 @@ export default { ...@@ -45,7 +44,6 @@ export default {
fieldName(name) { fieldName(name) {
return `service[${name}]`; return `service[${name}]`;
}, },
startCase,
}, },
}; };
</script> </script>
...@@ -58,10 +56,10 @@ export default { ...@@ -58,10 +56,10 @@ export default {
data-testid="trigger-fields-group" data-testid="trigger-fields-group"
> >
<div id="trigger-fields" class="gl-pt-3"> <div id="trigger-fields" class="gl-pt-3">
<gl-form-group v-for="event in events" :key="event.title" :description="event.description"> <gl-form-group v-for="event in events" :key="event.name" :description="event.description">
<input :name="checkboxName(event.name)" type="hidden" :value="event.value || false" /> <input :name="checkboxName(event.name)" type="hidden" :value="event.value || false" />
<gl-form-checkbox v-model="event.value" :disabled="isInheriting"> <gl-form-checkbox v-model="event.value" :disabled="isInheriting">
{{ startCase(event.title) }} {{ event.title }}
</gl-form-checkbox> </gl-form-checkbox>
<gl-form-input <gl-form-input
v-if="event.field" v-if="event.field"
......
# frozen_string_literal: true # frozen_string_literal: true
module IntegrationsHelper module IntegrationsHelper
def integration_event_title(event)
case event
when "push", "push_events"
_("Push")
when "tag_push", "tag_push_events"
_("Tag push")
when "note", "note_events"
_("Note")
when "confidential_note", "confidential_note_events"
_("Confidential note")
when "issue", "issue_events"
_("Issue")
when "confidential_issue", "confidential_issue_events"
_("Confidential issue")
when "merge_request", "merge_request_events"
_("Merge request")
when "pipeline", "pipeline_events"
_("Pipeline")
when "wiki_page", "wiki_page_events"
_("Wiki page")
when "commit", "commit_events"
_("Commit")
when "deployment"
_("Deployment")
when "alert"
_("Alert")
end
end
def integration_event_description(integration, event) def integration_event_description(integration, event)
case integration case integration
when Integrations::Jira when Integrations::Jira
......
...@@ -4,7 +4,7 @@ class ServiceEventEntity < Grape::Entity ...@@ -4,7 +4,7 @@ class ServiceEventEntity < Grape::Entity
include RequestAwareEntity include RequestAwareEntity
expose :title do |event| expose :title do |event|
event IntegrationsHelper.integration_event_title(event)
end end
expose :event_field_name, as: :name expose :event_field_name, as: :name
......
...@@ -3147,6 +3147,9 @@ msgstr "" ...@@ -3147,6 +3147,9 @@ msgstr ""
msgid "Akismet helps prevent the creation of spam issues in public projects." msgid "Akismet helps prevent the creation of spam issues in public projects."
msgstr "" msgstr ""
msgid "Alert"
msgstr ""
msgid "AlertManagement|Acknowledged" msgid "AlertManagement|Acknowledged"
msgstr "" msgstr ""
...@@ -9110,6 +9113,12 @@ msgstr "" ...@@ -9110,6 +9113,12 @@ msgstr ""
msgid "Confidential" msgid "Confidential"
msgstr "" msgstr ""
msgid "Confidential issue"
msgstr ""
msgid "Confidential note"
msgstr ""
msgid "Confidentiality" msgid "Confidentiality"
msgstr "" msgstr ""
...@@ -12197,6 +12206,9 @@ msgstr "" ...@@ -12197,6 +12206,9 @@ msgstr ""
msgid "Deploying to AWS is easy with GitLab" msgid "Deploying to AWS is easy with GitLab"
msgstr "" msgstr ""
msgid "Deployment"
msgstr ""
msgid "Deployment Frequency" msgid "Deployment Frequency"
msgstr "" msgstr ""
...@@ -35756,6 +35768,9 @@ msgstr "" ...@@ -35756,6 +35768,9 @@ msgstr ""
msgid "Tag name is required" msgid "Tag name is required"
msgstr "" msgstr ""
msgid "Tag push"
msgstr ""
msgid "Tag push events" msgid "Tag push events"
msgstr "" msgstr ""
...@@ -41297,6 +41312,9 @@ msgstr "" ...@@ -41297,6 +41312,9 @@ msgstr ""
msgid "Wiki" msgid "Wiki"
msgstr "" msgstr ""
msgid "Wiki page"
msgstr ""
msgid "Wiki page was successfully created." msgid "Wiki page was successfully created."
msgstr "" msgstr ""
......
...@@ -40,13 +40,13 @@ describe('TriggerFields', () => { ...@@ -40,13 +40,13 @@ describe('TriggerFields', () => {
describe('events without field property', () => { describe('events without field property', () => {
const events = [ const events = [
{ {
title: 'push', title: 'Push',
name: 'push_event', name: 'push_event',
description: 'Event on push', description: 'Event on push',
value: true, value: true,
}, },
{ {
title: 'merge_request', title: 'Merge request',
name: 'merge_requests_event', name: 'merge_requests_event',
description: 'Event on merge_request', description: 'Event on merge_request',
value: false, value: false,
...@@ -81,7 +81,7 @@ describe('TriggerFields', () => { ...@@ -81,7 +81,7 @@ describe('TriggerFields', () => {
const checkboxes = findAllGlFormGroups(); const checkboxes = findAllGlFormGroups();
const expectedResults = [ const expectedResults = [
{ labelText: 'Push', inputName: 'service[push_event]' }, { labelText: 'Push', inputName: 'service[push_event]' },
{ labelText: 'Merge Request', inputName: 'service[merge_requests_event]' }, { labelText: 'Merge request', inputName: 'service[merge_requests_event]' },
]; ];
expect(checkboxes).toHaveLength(2); expect(checkboxes).toHaveLength(2);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment