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

navbar_structure_helper.rb « helpers « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5519a6910a21549f2dbd4624bebdc8e5813125b6 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# frozen_string_literal: true

module NavbarStructureHelper
  def insert_after_nav_item(before_nav_item_name, new_nav_item:)
    expect(structure).to include(a_hash_including(nav_item: before_nav_item_name))

    index = structure.find_index { |h| h[:nav_item] == before_nav_item_name if h }
    structure.insert(index + 1, new_nav_item)
  end

  def insert_before_nav_item(after_nav_item_name, new_nav_item:)
    expect(structure).to include(a_hash_including(nav_item: after_nav_item_name))

    index = structure.find_index { |h| h[:nav_item] == after_nav_item_name if h }
    structure.insert(index, new_nav_item)
  end

  def insert_after_sub_nav_item(before_sub_nav_item_name, within:, new_sub_nav_item_name:)
    expect(structure).to include(a_hash_including(nav_item: within))
    hash = structure.find { |h| h[:nav_item] == within if h }

    expect(hash).to have_key(:nav_sub_items)
    expect(hash[:nav_sub_items]).to include(before_sub_nav_item_name)

    index = hash[:nav_sub_items].find_index(before_sub_nav_item_name)
    hash[:nav_sub_items].insert(index + 1, new_sub_nav_item_name)
  end

  def insert_before_sub_nav_item(after_sub_nav_item_name, within:, new_sub_nav_item_name:)
    expect(structure).to include(a_hash_including(nav_item: within))
    hash = structure.find { |h| h[:nav_item] == within if h }

    expect(hash).to have_key(:nav_sub_items)
    expect(hash[:nav_sub_items]).to include(after_sub_nav_item_name)

    index = hash[:nav_sub_items].find_index(after_sub_nav_item_name)
    hash[:nav_sub_items].insert(index, new_sub_nav_item_name)
  end

  def insert_package_nav
    insert_after_sub_nav_item(
      _("Feature flags"),
      within: _('Deploy'),
      new_sub_nav_item_name: _("Package Registry")
    )
  end

  def create_package_nav(before)
    insert_before_nav_item(
      before,
      new_nav_item: {
        nav_item: _("Deploy"),
        nav_sub_items: [_("Package Registry")]
      }
    )
  end

  def insert_customer_relations_nav(after)
    insert_after_sub_nav_item(
      after,
      within: _('Plan'),
      new_sub_nav_item_name: _("Customer contacts")
    )
    insert_after_sub_nav_item(
      _("Customer contacts"),
      within: _('Plan'),
      new_sub_nav_item_name: _("Customer organizations")
    )
  end

  def insert_container_nav
    insert_after_sub_nav_item(
      _('Package Registry'),
      within: _('Deploy'),
      new_sub_nav_item_name: _('Container Registry')
    )
  end

  def insert_dependency_proxy_nav
    insert_before_sub_nav_item(
      _('Kubernetes'),
      within: _('Operate'),
      new_sub_nav_item_name: _('Dependency Proxy')
    )
  end

  def insert_infrastructure_registry_nav
    insert_after_sub_nav_item(
      s_('Terraform|Terraform states'),
      within: _('Operate'),
      new_sub_nav_item_name: _('Terraform modules')
    )
  end

  def insert_harbor_registry_nav(within)
    insert_after_sub_nav_item(
      within,
      within: _('Operate'),
      new_sub_nav_item_name: _('Harbor Registry')
    )
  end

  def insert_infrastructure_google_cloud_nav
    insert_after_sub_nav_item(
      s_('Terraform|Terraform modules'),
      within: _('Operate'),
      new_sub_nav_item_name: _('Google Cloud')
    )
  end

  def insert_infrastructure_aws_nav
    insert_after_sub_nav_item(
      _('Google Cloud'),
      within: _('Operate'),
      new_sub_nav_item_name: _('AWS')
    )
  end

  def insert_model_experiments_nav(within)
    insert_after_sub_nav_item(
      within,
      within: _('Analyze'),
      new_sub_nav_item_name: _('Model experiments')
    )
  end

  def project_analytics_sub_nav_item
    [
      _('Value stream analytics'),
      _('Contributor analytics'),
      _('CI/CD analytics'),
      _('Repository analytics'),
      (_('Code review analytics') if Gitlab.ee?),
      (_('Merge request analytics') if Gitlab.ee?)
    ]
  end

  def group_analytics_sub_nav_item
    [_("Contribution analytics")]
  end
end

NavbarStructureHelper.prepend_mod