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

branch_switcher.vue « file_nav « components « pipeline_editor « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b3eba0fcc1974ecc792b1f9620666c39ec15bbfa (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
<script>
import { GlDropdown, GlDropdownItem, GlDropdownSectionHeader, GlIcon } from '@gitlab/ui';
import { s__ } from '~/locale';
import { DEFAULT_FAILURE } from '~/pipeline_editor/constants';
import getAvailableBranches from '~/pipeline_editor/graphql/queries/available_branches.graphql';
import getCurrentBranch from '~/pipeline_editor/graphql/queries/client/current_branch.graphql';

export default {
  i18n: {
    title: s__('Branches'),
    fetchError: s__('Unable to fetch branch list for this project.'),
  },
  components: {
    GlDropdown,
    GlDropdownItem,
    GlDropdownSectionHeader,
    GlIcon,
  },
  inject: ['projectFullPath'],
  apollo: {
    branches: {
      query: getAvailableBranches,
      variables() {
        return {
          projectFullPath: this.projectFullPath,
        };
      },
      update(data) {
        return data.project?.repository?.branches || [];
      },
      error() {
        this.$emit('showError', {
          type: DEFAULT_FAILURE,
          reasons: [this.$options.i18n.fetchError],
        });
      },
    },
    currentBranch: {
      query: getCurrentBranch,
    },
  },
  computed: {
    hasBranchList() {
      return this.branches?.length > 0;
    },
  },
};
</script>

<template>
  <gl-dropdown v-if="hasBranchList" class="gl-ml-2" :text="currentBranch" icon="branch">
    <gl-dropdown-section-header>
      {{ this.$options.i18n.title }}
    </gl-dropdown-section-header>
    <gl-dropdown-item
      v-for="branch in branches"
      :key="branch.name"
      :is-checked="currentBranch === branch.name"
      :is-check-item="true"
    >
      <gl-icon name="check" class="gl-visibility-hidden" />
      {{ branch.name }}
    </gl-dropdown-item>
  </gl-dropdown>
</template>