Commit 50f6187d authored by Miguel Rincon's avatar Miguel Rincon Committed by Robert Speicher

Add link to logs in sidebar

- Add pod logs redirect route
- Redirect to default env when not set
- Create new ee specific link file
- Add link locale string
parent e458c36f
......@@ -133,7 +133,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
if environment
redirect_to environment_metrics_path(environment)
else
render :empty
render :empty_metrics
end
end
......
......@@ -247,6 +247,8 @@
%span
= _('Serverless')
= render_if_exists 'layouts/nav/sidebar/pod_logs_link' # EE-specific
- if project_nav_tab? :clusters
- show_cluster_hint = show_gke_cluster_integration_callout?(@project)
= nav_link(controller: [:clusters, :user, :gcp]) do
......
- page_title _('Pod logs')
.row.empty-state
.col-sm-12
.svg-content
= image_tag 'illustrations/operations_log_pods_empty.svg'
.col-12
.text-content
%h4.text-center
= s_('Environments|No deployed environments')
%p.state-description.text-center
= s_('Logs|To see the pod logs, deploy your code to an environment.')
.text-center
= link_to s_('Environments|Learn about environments'), help_page_path('ci/environments'), class: 'btn btn-success'
......@@ -7,8 +7,8 @@
.col-12
.text-content
%h4.text-center
= s_('Metrics|No deployed environments')
= s_('Environments|No deployed environments')
%p.state-description
= s_('Metrics|Check out the CI/CD documentation on deploying to an environment')
.text-center
= link_to s_("Metrics|Learn about environments"), help_page_path('ci/environments'), class: 'btn btn-success'
= link_to s_("Environments|Learn about environments"), help_page_path('ci/environments'), class: 'btn btn-success'
......@@ -441,6 +441,10 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :metrics, action: :metrics_redirect
get :folder, path: 'folders/*id', constraints: { format: /(html|json)/ }
get :search
Gitlab.ee do
get :logs, action: :logs_redirect
end
end
resources :deployments, only: [:index] do
......
......@@ -14,6 +14,19 @@ module EE
end
end
def logs_redirect
environment = project.default_environment
if environment
redirect_to logs_project_environment_path(project, environment)
else
render :empty_logs
end
end
def logs
end
def k8s_pod_logs
respond_to do |format|
format.json do
......@@ -33,9 +46,6 @@ module EE
end
end
def logs
end
private
def environment_ee
......
- return unless project_nav_tab?(:environments)
= nav_link(controller: :environments, action: [:logs, :logs_redirect]) do
= link_to logs_project_environments_path(@project), title: _('Pod logs') do
%span
= _('Pod logs')
---
title: Add logs menu item to the sidebar
merge_request: 19471
author:
type: added
......@@ -76,6 +76,25 @@ describe Projects::EnvironmentsController do
end
end
describe 'GET #logs_redirect' do
let(:project) { create(:project) }
it 'redirects to environment if it exists' do
environment = create(:environment, name: 'production', project: project)
get :logs_redirect, params: { namespace_id: project.namespace, project_id: project }
expect(response).to redirect_to(logs_project_environment_path(project, environment))
end
it 'renders empty logs page if no environment exists' do
get :logs_redirect, params: { namespace_id: project.namespace, project_id: project }
expect(response).to be_ok
expect(response).to render_template 'empty_logs'
end
end
describe 'GET logs' do
let(:pod_name) { "foo" }
......
......@@ -6409,12 +6409,18 @@ msgstr ""
msgid "Environments|Job"
msgstr ""
msgid "Environments|Learn about environments"
msgstr ""
msgid "Environments|Learn more about stopping environments"
msgstr ""
msgid "Environments|New environment"
msgstr ""
msgid "Environments|No deployed environments"
msgstr ""
msgid "Environments|No deployments yet"
msgstr ""
......@@ -10183,6 +10189,9 @@ msgstr ""
msgid "Logs"
msgstr ""
msgid "Logs|To see the pod logs, deploy your code to an environment."
msgstr ""
msgid "MD5"
msgstr ""
......@@ -10684,9 +10693,6 @@ msgstr ""
msgid "Metrics|Label of the y-axis (usually the unit). The x-axis always represents time."
msgstr ""
msgid "Metrics|Learn about environments"
msgstr ""
msgid "Metrics|Legend label (optional)"
msgstr ""
......@@ -10702,9 +10708,6 @@ msgstr ""
msgid "Metrics|New metric"
msgstr ""
msgid "Metrics|No deployed environments"
msgstr ""
msgid "Metrics|PromQL query is valid"
msgstr ""
......@@ -12361,6 +12364,9 @@ msgstr ""
msgid "Please wait while we import the repository for you. Refresh at will."
msgstr ""
msgid "Pod logs"
msgstr ""
msgid "Pod not found"
msgstr ""
......
......@@ -330,11 +330,11 @@ describe Projects::EnvironmentsController do
expect(response).to redirect_to(environment_metrics_path(environment))
end
it 'redirects to empty page if no environment exists' do
it 'redirects to empty metrics page if no environment exists' do
get :metrics_redirect, params: { namespace_id: project.namespace, project_id: project }
expect(response).to be_ok
expect(response).to render_template 'empty'
expect(response).to render_template 'empty_metrics'
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment