Welcome to mirror list, hosted at ThFree Co, Russian Federation.

push_events.vue « components « webhooks « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 677f06314e056a536e6ecd7ef6a7b38d5788fa40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<script>
import { GlFormCheckbox, GlFormRadio, GlFormRadioGroup, GlFormInput, GlSprintf } from '@gitlab/ui';
import {
  BRANCH_FILTER_ALL_BRANCHES,
  WILDCARD_CODE_STABLE,
  WILDCARD_CODE_PRODUCTION,
  REGEX_CODE,
  descriptionText,
} from '~/webhooks/constants';

export default {
  components: {
    GlFormCheckbox,
    GlFormRadio,
    GlFormRadioGroup,
    GlFormInput,
    GlSprintf,
  },
  inject: ['pushEvents', 'strategy', 'isNewHook', 'pushEventsBranchFilter'],
  data() {
    return {
      pushEventsData: !this.isNewHook && this.pushEvents,
      branchFilterStrategyData: this.isNewHook ? BRANCH_FILTER_ALL_BRANCHES : this.strategy,
      pushEventsBranchFilterData: this.pushEventsBranchFilter,
    };
  },
  WILDCARD_CODE_STABLE,
  WILDCARD_CODE_PRODUCTION,
  REGEX_CODE,
  descriptionText,
};
</script>

<template>
  <div>
    <gl-form-checkbox v-model="pushEventsData">{{ s__('Webhooks|Push events') }}</gl-form-checkbox>
    <input type="hidden" :value="pushEventsData" name="hook[push_events]" />

    <div v-if="pushEventsData" class="gl-pl-6">
      <gl-form-radio-group v-model="branchFilterStrategyData" name="hook[branch_filter_strategy]">
        <gl-form-radio
          class="gl-mt-2 branch-filter-strategy-radio"
          value="all_branches"
          data-testid="rule_all_branches"
        >
          <div data-qa-selector="strategy_radio_all">{{ __('All branches') }}</div>
        </gl-form-radio>

        <!-- wildcard -->
        <gl-form-radio
          class="gl-mt-2 branch-filter-strategy-radio"
          value="wildcard"
          data-testid="rule_wildcard"
        >
          <div data-qa-selector="strategy_radio_wildcard">
            {{ s__('Webhooks|Wildcard pattern') }}
          </div>
        </gl-form-radio>
        <div class="gl-ml-6">
          <gl-form-input
            v-if="branchFilterStrategyData === 'wildcard'"
            v-model="pushEventsBranchFilterData"
            name="hook[push_events_branch_filter]"
            data-qa-selector="webhook_branch_filter_field"
            data-testid="webhook_branch_filter_field"
          />
        </div>
        <p
          v-if="branchFilterStrategyData === 'wildcard'"
          class="form-text text-muted custom-control"
        >
          <gl-sprintf :message="$options.descriptionText.wildcard">
            <template #WILDCARD_CODE_STABLE>
              <code>{{ $options.WILDCARD_CODE_STABLE }}</code>
            </template>
            <template #WILDCARD_CODE_PRODUCTION>
              <code>{{ $options.WILDCARD_CODE_PRODUCTION }}</code>
            </template>
          </gl-sprintf>
        </p>

        <!-- regex -->
        <gl-form-radio
          class="gl-mt-2 branch-filter-strategy-radio"
          value="regex"
          data-testid="rule_regex"
        >
          <div data-qa-selector="strategy_radio_regex">
            {{ s__('Webhooks|Regular expression') }}
          </div>
        </gl-form-radio>
        <div class="gl-ml-6">
          <gl-form-input
            v-if="branchFilterStrategyData === 'regex'"
            v-model="pushEventsBranchFilterData"
            name="hook[push_events_branch_filter]"
            data-qa-selector="webhook_branch_filter_field"
            data-testid="webhook_branch_filter_field"
          />
        </div>

        <p v-if="branchFilterStrategyData === 'regex'" class="form-text text-muted custom-control">
          <gl-sprintf :message="$options.descriptionText.regex">
            <template #REGEX_CODE>
              <code>{{ $options.REGEX_CODE }}</code>
            </template>
          </gl-sprintf>
        </p>
      </gl-form-radio-group>
    </div>
  </div>
</template>