2021-06-08 01:23:25 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Sidebars
|
|
|
|
module Projects
|
|
|
|
module Menus
|
|
|
|
class MonitorMenu < ::Sidebars::Menu
|
|
|
|
override :configure_menu_items
|
|
|
|
def configure_menu_items
|
2022-10-11 01:57:18 +05:30
|
|
|
return false unless feature_enabled?
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
add_item(metrics_dashboard_menu_item)
|
|
|
|
add_item(error_tracking_menu_item)
|
|
|
|
add_item(alert_management_menu_item)
|
|
|
|
add_item(incidents_menu_item)
|
2023-04-23 21:23:45 +05:30
|
|
|
add_item(airflow_dashboard_menu_item)
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
override :extra_container_html_options
|
|
|
|
def extra_container_html_options
|
|
|
|
{
|
2021-09-30 23:02:18 +05:30
|
|
|
class: 'shortcuts-monitor'
|
2021-06-08 01:23:25 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
override :title
|
|
|
|
def title
|
2021-09-30 23:02:18 +05:30
|
|
|
_('Monitor')
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
override :sprite_icon
|
|
|
|
def sprite_icon
|
2021-09-30 23:02:18 +05:30
|
|
|
'monitor'
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
override :active_routes
|
|
|
|
def active_routes
|
|
|
|
{ controller: [:user, :gcp] }
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
def feature_enabled?
|
2023-03-04 22:38:38 +05:30
|
|
|
context.project.feature_available?(:monitor, context.current_user)
|
2022-10-11 01:57:18 +05:30
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
def metrics_dashboard_menu_item
|
|
|
|
unless can?(context.current_user, :metrics_dashboard, context.project)
|
|
|
|
return ::Sidebars::NilMenuItem.new(item_id: :metrics)
|
|
|
|
end
|
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Metrics'),
|
|
|
|
link: project_metrics_dashboard_path(context.project),
|
|
|
|
active_routes: { path: 'metrics_dashboard#show' },
|
|
|
|
container_html_options: { class: 'shortcuts-metrics' },
|
|
|
|
item_id: :metrics
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def error_tracking_menu_item
|
|
|
|
unless can?(context.current_user, :read_sentry_issue, context.project)
|
|
|
|
return ::Sidebars::NilMenuItem.new(item_id: :error_tracking)
|
|
|
|
end
|
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Error Tracking'),
|
|
|
|
link: project_error_tracking_index_path(context.project),
|
|
|
|
active_routes: { controller: :error_tracking },
|
|
|
|
item_id: :error_tracking
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def alert_management_menu_item
|
|
|
|
unless can?(context.current_user, :read_alert_management_alert, context.project)
|
|
|
|
return ::Sidebars::NilMenuItem.new(item_id: :alert_management)
|
|
|
|
end
|
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Alerts'),
|
|
|
|
link: project_alert_management_index_path(context.project),
|
|
|
|
active_routes: { controller: :alert_management },
|
|
|
|
item_id: :alert_management
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def incidents_menu_item
|
|
|
|
unless can?(context.current_user, :read_issue, context.project)
|
|
|
|
return ::Sidebars::NilMenuItem.new(item_id: :incidents)
|
|
|
|
end
|
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Incidents'),
|
|
|
|
link: project_incidents_path(context.project),
|
|
|
|
active_routes: { controller: [:incidents, :incident_management] },
|
|
|
|
item_id: :incidents
|
|
|
|
)
|
|
|
|
end
|
2023-04-23 21:23:45 +05:30
|
|
|
|
|
|
|
def airflow_dashboard_menu_item
|
|
|
|
unless can?(context.current_user, :read_airflow_dags, context.project) &&
|
|
|
|
Feature.enabled?(:airflow_dags, context.project)
|
|
|
|
return ::Sidebars::NilMenuItem.new(item_id: :airflow)
|
|
|
|
end
|
|
|
|
|
|
|
|
::Sidebars::MenuItem.new(
|
|
|
|
title: _('Airflow'),
|
|
|
|
link: project_airflow_dags_path(context.project),
|
|
|
|
active_routes: { path: 'airflow/dags#show' },
|
|
|
|
item_id: :airflow_dags
|
|
|
|
)
|
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Sidebars::Projects::Menus::MonitorMenu.prepend_mod_with('Sidebars::Projects::Menus::MonitorMenu')
|