2023-03-22 16:42:54 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class NavigationsController < ApplicationController
|
|
|
|
include ApplicationHelper
|
|
|
|
|
|
|
|
def top_menu
|
|
|
|
render json: {
|
|
|
|
root_url: root_path,
|
2023-06-13 17:51:00 +08:00
|
|
|
team_switch_url: switch_users_settings_teams_path,
|
2023-03-22 16:42:54 +08:00
|
|
|
current_team: current_team&.id,
|
|
|
|
search_url: search_path,
|
|
|
|
teams: teams,
|
|
|
|
settings: [],
|
2023-04-06 19:02:34 +08:00
|
|
|
help_menu: help_menu_links,
|
|
|
|
settings_menu: settings_menu_links,
|
|
|
|
user_menu: user_menu_links,
|
2023-03-22 16:42:54 +08:00
|
|
|
user: user
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-04-14 17:38:28 +08:00
|
|
|
def navigator_state
|
|
|
|
session[:navigator_collapsed] = params[:state] == 'collapsed'
|
2023-10-12 20:40:13 +08:00
|
|
|
|
|
|
|
width = params[:width].to_i
|
|
|
|
session[:navigator_width] = width if width.positive?
|
2023-04-14 17:38:28 +08:00
|
|
|
end
|
|
|
|
|
2023-03-22 16:42:54 +08:00
|
|
|
private
|
|
|
|
|
|
|
|
def teams
|
|
|
|
current_user.teams.order(:name).map do |t|
|
2023-06-13 17:51:00 +08:00
|
|
|
[
|
|
|
|
t.id,
|
|
|
|
t.name
|
|
|
|
]
|
2023-03-22 16:42:54 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def user
|
|
|
|
{
|
2023-04-17 17:36:08 +08:00
|
|
|
name: current_user.full_name,
|
2023-03-22 16:42:54 +08:00
|
|
|
avatar_url: avatar_path(current_user, :icon_small),
|
2024-03-14 20:27:27 +08:00
|
|
|
sign_out_url: destroy_user_session_path,
|
|
|
|
preferences_url: preferences_url
|
2023-03-22 16:42:54 +08:00
|
|
|
}
|
|
|
|
end
|
2023-04-06 19:02:34 +08:00
|
|
|
|
|
|
|
def help_menu_links
|
|
|
|
links = [
|
|
|
|
{ name: I18n.t('left_menu_bar.support_links.support'), url: Constants::SUPPORT_URL },
|
|
|
|
{ name: I18n.t('left_menu_bar.support_links.tutorials'), url: Constants::TUTORIALS_URL },
|
|
|
|
{ name: I18n.t('left_menu_bar.academy'), url: Constants::ACADEMY_BL_LINK }
|
|
|
|
]
|
|
|
|
|
|
|
|
private_methods.select { |i| i.to_s[/^help_menu_links_[a-z]*_extension$/] }.each do |method|
|
|
|
|
links = __send__(method, links)
|
|
|
|
end
|
|
|
|
|
|
|
|
links
|
|
|
|
end
|
|
|
|
|
|
|
|
def settings_menu_links
|
|
|
|
links = [
|
|
|
|
{
|
|
|
|
name: I18n.t('users.settings.sidebar.teams'), url: teams_path
|
|
|
|
}, {
|
|
|
|
name: I18n.t('users.settings.sidebar.account_nav.addons'), url: addons_path
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2023-04-14 20:59:14 +08:00
|
|
|
if can_create_acitivity_filters?
|
|
|
|
links.push({ name: I18n.t('users.settings.sidebar.webhooks'), url: users_settings_webhooks_path })
|
|
|
|
end
|
|
|
|
|
2023-04-06 19:02:34 +08:00
|
|
|
private_methods.select { |i| i.to_s[/^settings_menu_links_[a-z]*_extension$/] }.each do |method|
|
|
|
|
links = __send__(method, links)
|
|
|
|
end
|
|
|
|
|
|
|
|
links
|
|
|
|
end
|
|
|
|
|
|
|
|
def user_menu_links
|
|
|
|
links = [
|
|
|
|
{
|
|
|
|
name: I18n.t('users.settings.sidebar.account_nav.profile'), url: edit_user_registration_path
|
|
|
|
}, {
|
|
|
|
name: I18n.t('users.settings.sidebar.account_nav.preferences'), url: preferences_path
|
|
|
|
}, {
|
|
|
|
name: I18n.t('users.settings.sidebar.account_nav.connected_accounts'), url: connected_accounts_path
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
private_methods.select { |i| i.to_s[/^user_menu_links_[a-z]*_extension$/] }.each do |method|
|
|
|
|
links = __send__(method, links)
|
|
|
|
end
|
|
|
|
|
|
|
|
links
|
|
|
|
end
|
2023-03-22 16:42:54 +08:00
|
|
|
end
|