Class: Decidim::Admin::Menu

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/admin/menu.rb

Class Method Summary collapse

Class Method Details

.register_admin_areas_menu!Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/decidim/admin/menu.rb', line 126

def self.register_admin_areas_menu!
  Decidim.menu :admin_areas_menu do |menu|
    menu.add_item :areas,
                  I18n.t("menu.areas", scope: "decidim.admin"),
                  decidim_admin.areas_path,
                  icon_name: "layout-masonry-line",
                  position: 1.5,
                  if: allowed_to?(:read, :area)
    menu.add_item :area_types,
                  I18n.t("menu.area_types", scope: "decidim.admin"),
                  decidim_admin.area_types_path,
                  icon_name: "layout-masonry-line",
                  position: 1.6,
                  if: allowed_to?(:read, :area_type)
  end
end

.register_admin_global_moderation_menu!Object



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
# File 'lib/decidim/admin/menu.rb', line 6

def self.register_admin_global_moderation_menu!
  Decidim.menu :admin_global_moderation_menu do |menu|
    moderations_count = Decidim::Admin::ModerationStats.new(current_user).count_content_moderations

    caption = I18n.t("menu.content", scope: "decidim.admin")
    caption += (:span, moderations_count, class: "component-counter")

    menu.add_item :moderations,
                  caption.html_safe,
                  decidim_admin.moderations_path,
                  position: 1,
                  active: is_active_link?(decidim_admin.moderations_path),
                  if: allowed_to?(:read, :global_moderation)

    user_reports = Decidim::Admin::ModerationStats.new(current_user).count_user_pending_reports

    caption = I18n.t("menu.reported_users", scope: "decidim.admin")
    caption += (:span, user_reports, class: "component-counter")

    menu.add_item :moderated_users,
                  caption.html_safe,
                  decidim_admin.moderated_users_path,
                  active: is_active_link?(decidim_admin.moderated_users_path),
                  if: allowed_to?(:index, :moderate_users)
  end
end

.register_admin_menu!Object



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/decidim/admin/menu.rb', line 204

def self.register_admin_menu!
  Decidim.menu :admin_menu do |menu|
    menu.add_item :moderations,
                  I18n.t("menu.moderation", scope: "decidim.admin"),
                  decidim_admin.moderations_path,
                  icon_name: "flag-line",
                  position: 4,
                  active: [%w(
                    decidim/admin/global_moderations
                    decidim/admin/global_moderations/reports
                    decidim/admin/moderated_users
                  ), []],
                  if: allowed_to?(:read, :global_moderation) || allowed_to?(:index, :moderate_users)

    menu.add_item :static_pages,
                  I18n.t("menu.static_pages", scope: "decidim.admin"),
                  decidim_admin.static_pages_path,
                  icon_name: "pages-line",
                  position: 4.5,
                  active: is_active_link?(decidim_admin.static_pages_path, :inclusive) ||
                          is_active_link?(decidim_admin.static_page_topics_path, :inclusive),
                  if: allowed_to?(:read, :static_page)

    menu.add_item :impersonatable_users,
                  I18n.t("menu.users", scope: "decidim.admin"),
                  allowed_to?(:read, :admin_user) ? decidim_admin.users_path : decidim_admin.impersonatable_users_path,
                  icon_name: "team-line",
                  position: 5,
                  active: [%w(
                    decidim/admin/users
                    decidim/admin/user_groups
                    decidim/admin/user_groups_csv_verifications
                    decidim/admin/officializations
                    decidim/admin/impersonatable_users
                    decidim/admin/conflicts
                    decidim/admin/managed_users/impersonation_logs
                    decidim/admin/managed_users/promotions
                    decidim/admin/authorization_workflows
                    decidim/verifications/id_documents/admin/pending_authorizations
                    decidim/verifications/id_documents/admin/config
                    decidim/verifications/postal_letter/admin/pending_authorizations
                    decidim/verifications/csv_census/admin/census
                  ), []],
                  if: allowed_to?(:read, :admin_user) || allowed_to?(:read, :managed_user)

    menu.add_item :newsletters,
                  I18n.t("menu.newsletters", scope: "decidim.admin"),
                  decidim_admin.newsletters_path,
                  icon_name: "mail-add-line",
                  position: 6,
                  active: is_active_link?(decidim_admin.newsletters_path, :inclusive) ||
                          is_active_link?(decidim_admin.newsletter_templates_path, :inclusive),
                  if: allowed_to?(:index, :newsletter)

    menu.add_item :edit_organization,
                  I18n.t("menu.settings", scope: "decidim.admin"),
                  decidim_admin.edit_organization_path,
                  icon_name: "tools-line",
                  position: 7,
                  active: [
                    %w(
                      decidim/admin/organization
                      decidim/admin/organization_appearance
                      decidim/admin/organization_homepage
                      decidim/admin/organization_homepage_content_blocks
                      decidim/admin/scopes
                      decidim/admin/scope_types
                      decidim/admin/areas decidim/admin/area_types
                      decidim/admin/help_sections
                      decidim/admin/organization_external_domain_allowlist
                    ),
                    []
                  ],
                  if: allowed_to?(:update, :organization, organization: current_organization)

    menu.add_item :logs,
                  I18n.t("menu.admin_log", scope: "decidim.admin"),
                  decidim_admin.logs_path,
                  icon_name: "pages-line",
                  position: 10,
                  active: [%w(decidim/admin/logs), []],
                  if: allowed_to?(:read, :admin_log)
  end
end

.register_admin_scopes_menu!Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/decidim/admin/menu.rb', line 109

def self.register_admin_scopes_menu!
  Decidim.menu :admin_scopes_menu do |menu|
    menu.add_item :scopes,
                  I18n.t("menu.scopes", scope: "decidim.admin"),
                  decidim_admin.scopes_path,
                  icon_name: "price-tag-3-line",
                  position: 1.3,
                  if: allowed_to?(:read, :scope)
    menu.add_item :scope_types,
                  I18n.t("menu.scope_types", scope: "decidim.admin"),
                  decidim_admin.scope_types_path,
                  icon_name: "price-tag-3-line",
                  position: 1.4,
                  if: allowed_to?(:read, :scope_type)
  end
end

.register_admin_settings_menu!Object



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/decidim/admin/menu.rb', line 143

def self.register_admin_settings_menu!
  Decidim.menu :admin_settings_menu do |menu|
    menu.add_item :edit_organization,
                  I18n.t("menu.configuration", scope: "decidim.admin"),
                  decidim_admin.edit_organization_path,
                  position: 1.0,
                  icon_name: "pencil-line",
                  if: allowed_to?(:update, :organization, organization: current_organization)

    menu.add_item :edit_organization_appearance,
                  I18n.t("menu.appearance", scope: "decidim.admin"),
                  decidim_admin.edit_organization_appearance_path,
                  position: 1.1,
                  icon_name: "tools-line",
                  if: allowed_to?(:update, :organization, organization: current_organization)

    menu.add_item :edit_organization_homepage,
                  I18n.t("menu.homepage", scope: "decidim.admin"),
                  decidim_admin.edit_organization_homepage_path,
                  position: 1.2,
                  icon_name: "home-gear-line",
                  if: allowed_to?(:update, :organization, organization: current_organization)

    menu.add_item :scopes,
                  I18n.t("menu.scopes", scope: "decidim.admin"),
                  decidim_admin.scopes_path,
                  icon_name: "price-tag-3-line",
                  position: 1.3,
                  if: allowed_to?(:read, :scope),
                  active: [%w(
                    decidim/admin/scopes
                    decidim/admin/scope_types
                  ), []]

    menu.add_item :areas,
                  I18n.t("menu.areas", scope: "decidim.admin"),
                  decidim_admin.areas_path,
                  icon_name: "layout-masonry-line",
                  position: 1.5,
                  if: allowed_to?(:read, :area),
                  active: [%w(
                    decidim/admin/areas
                    decidim/admin/area_types
                  ), []]

    menu.add_item :help_sections,
                  I18n.t("menu.help_sections", scope: "decidim.admin"),
                  decidim_admin.help_sections_path,
                  icon_name: "question-line",
                  position: 1.6,
                  if: allowed_to?(:update, :help_sections)

    menu.add_item :external_domain_allowlist,
                  I18n.t("menu.external_domain_allowlist", scope: "decidim.admin"),
                  decidim_admin.edit_organization_external_domain_allowlist_path,
                  icon_name: "computer-line",
                  position: 1.7,
                  if: allowed_to?(:update, :organization, organization: current_organization)
  end
end

.register_admin_static_pages_menu!Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/decidim/admin/menu.rb', line 58

def self.register_admin_static_pages_menu!
  Decidim.menu :admin_static_pages_menu do |menu|
    menu.add_item :static_pages,
                  I18n.t("menu.static_pages", scope: "decidim.admin"),
                  decidim_admin.static_pages_path,
                  icon_name: "pages-line",
                  position: 1,
                  active: is_active_link?(decidim_admin.static_pages_path, :inclusive),
                  if: allowed_to?(:read, :static_page)
    menu.add_item :static_page_topics,
                  I18n.t("menu.static_page_topics", scope: "decidim.admin"),
                  decidim_admin.static_page_topics_path,
                  icon_name: "pages-line",
                  position: 2,
                  active: is_active_link?(decidim_admin.static_page_topics_path, :inclusive),
                  if: allowed_to?(:create, :static_page_topic)
  end
end

.register_admin_user_menu!Object



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
# File 'lib/decidim/admin/menu.rb', line 77

def self.register_admin_user_menu!
  Decidim.menu :admin_user_menu do |menu|
    menu.add_item :users,
                  I18n.t("menu.admins", scope: "decidim.admin"), decidim_admin.users_path,
                  icon_name: "user-line",
                  active: is_active_link?(decidim_admin.users_path),
                  if: allowed_to?(:read, :admin_user)
    menu.add_item :user_groups,
                  I18n.t("menu.user_groups", scope: "decidim.admin"), decidim_admin.user_groups_path,
                  icon_name: "group-line",
                  active: is_active_link?(decidim_admin.user_groups_path),
                  if: current_organization.user_groups_enabled? && allowed_to?(:index, :user_group)
    menu.add_item :officializations,
                  I18n.t("menu.participants", scope: "decidim.admin"), decidim_admin.officializations_path,
                  icon_name: "service-line",
                  active: is_active_link?(decidim_admin.officializations_path),
                  if: allowed_to?(:index, :officialization)
    menu.add_item :impersonatable_users,
                  I18n.t("menu.impersonations", scope: "decidim.admin"), decidim_admin.impersonatable_users_path,
                  icon_name: "user-add-line",
                  active: is_active_link?(decidim_admin.impersonatable_users_path),
                  if: allowed_to?(:index, :impersonatable_user),
                  submenu: { target_menu: :impersonate_menu }
    menu.add_item :authorization_workflows,
                  I18n.t("menu.authorization_workflows", scope: "decidim.admin"), decidim_admin.authorization_workflows_path,
                  icon_name: "key-2-line",
                  active: is_active_link?(decidim_admin.authorization_workflows_path),
                  if: allowed_to?(:index, :authorization),
                  submenu: { target_menu: :workflows_menu }
  end
end

.register_impersonate_menu!Object



48
49
50
51
52
53
54
55
56
# File 'lib/decidim/admin/menu.rb', line 48

def self.register_impersonate_menu!
  Decidim.menu :impersonate_menu do |menu|
    menu.add_item :conflicts,
                  I18n.t("title", scope: "decidim.admin.conflicts"),
                  decidim_admin.conflicts_path,
                  active: is_active_link?(decidim_admin.conflicts_path),
                  if: allowed_to?(:index, :impersonatable_user)
  end
end

.register_workflows_menu!Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/decidim/admin/menu.rb', line 33

def self.register_workflows_menu!
  Decidim.menu :workflows_menu do |menu|
    Decidim::Verifications.admin_workflows.each do |manifest|
      next unless current_organization.available_authorizations.include?(manifest.name.to_s)

      workflow = Decidim::Verifications::Adapter.new(manifest)

      menu.add_item manifest.name.to_s,
                    workflow.fullname,
                    workflow.admin_root_path,
                    active: is_active_link?(workflow.admin_root_path)
    end
  end
end