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 ...@@ -133,7 +133,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
if environment if environment
redirect_to environment_metrics_path(environment) redirect_to environment_metrics_path(environment)
else else
render :empty render :empty_metrics
end end
end end
......
...@@ -247,6 +247,8 @@ ...@@ -247,6 +247,8 @@
%span %span
= _('Serverless') = _('Serverless')
= render_if_exists 'layouts/nav/sidebar/pod_logs_link' # EE-specific
- if project_nav_tab? :clusters - if project_nav_tab? :clusters
- show_cluster_hint = show_gke_cluster_integration_callout?(@project) - show_cluster_hint = show_gke_cluster_integration_callout?(@project)
= nav_link(controller: [:clusters, :user, :gcp]) do = 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 @@ ...@@ -7,8 +7,8 @@
.col-12 .col-12
.text-content .text-content
%h4.text-center %h4.text-center
= s_('Metrics|No deployed environments') = s_('Environments|No deployed environments')
%p.state-description %p.state-description
= s_('Metrics|Check out the CI/CD documentation on deploying to an environment') = s_('Metrics|Check out the CI/CD documentation on deploying to an environment')
.text-center .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 ...@@ -441,6 +441,10 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :metrics, action: :metrics_redirect get :metrics, action: :metrics_redirect
get :folder, path: 'folders/*id', constraints: { format: /(html|json)/ } get :folder, path: 'folders/*id', constraints: { format: /(html|json)/ }
get :search get :search
Gitlab.ee do
get :logs, action: :logs_redirect
end
end end
resources :deployments, only: [:index] do resources :deployments, only: [:index] do
......
...@@ -14,6 +14,19 @@ module EE ...@@ -14,6 +14,19 @@ module EE
end end
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 def k8s_pod_logs
respond_to do |format| respond_to do |format|
format.json do format.json do
...@@ -33,9 +46,6 @@ module EE ...@@ -33,9 +46,6 @@ module EE
end end
end end
def logs
end
private private
def environment_ee 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 ...@@ -76,6 +76,25 @@ describe Projects::EnvironmentsController do
end end
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 describe 'GET logs' do
let(:pod_name) { "foo" } let(:pod_name) { "foo" }
......
...@@ -6409,12 +6409,18 @@ msgstr "" ...@@ -6409,12 +6409,18 @@ msgstr ""
msgid "Environments|Job" msgid "Environments|Job"
msgstr "" msgstr ""
msgid "Environments|Learn about environments"
msgstr ""
msgid "Environments|Learn more about stopping environments" msgid "Environments|Learn more about stopping environments"
msgstr "" msgstr ""
msgid "Environments|New environment" msgid "Environments|New environment"
msgstr "" msgstr ""
msgid "Environments|No deployed environments"
msgstr ""
msgid "Environments|No deployments yet" msgid "Environments|No deployments yet"
msgstr "" msgstr ""
...@@ -10183,6 +10189,9 @@ msgstr "" ...@@ -10183,6 +10189,9 @@ msgstr ""
msgid "Logs" msgid "Logs"
msgstr "" msgstr ""
msgid "Logs|To see the pod logs, deploy your code to an environment."
msgstr ""
msgid "MD5" msgid "MD5"
msgstr "" msgstr ""
...@@ -10684,9 +10693,6 @@ msgstr "" ...@@ -10684,9 +10693,6 @@ msgstr ""
msgid "Metrics|Label of the y-axis (usually the unit). The x-axis always represents time." msgid "Metrics|Label of the y-axis (usually the unit). The x-axis always represents time."
msgstr "" msgstr ""
msgid "Metrics|Learn about environments"
msgstr ""
msgid "Metrics|Legend label (optional)" msgid "Metrics|Legend label (optional)"
msgstr "" msgstr ""
...@@ -10702,9 +10708,6 @@ msgstr "" ...@@ -10702,9 +10708,6 @@ msgstr ""
msgid "Metrics|New metric" msgid "Metrics|New metric"
msgstr "" msgstr ""
msgid "Metrics|No deployed environments"
msgstr ""
msgid "Metrics|PromQL query is valid" msgid "Metrics|PromQL query is valid"
msgstr "" msgstr ""
...@@ -12361,6 +12364,9 @@ msgstr "" ...@@ -12361,6 +12364,9 @@ msgstr ""
msgid "Please wait while we import the repository for you. Refresh at will." msgid "Please wait while we import the repository for you. Refresh at will."
msgstr "" msgstr ""
msgid "Pod logs"
msgstr ""
msgid "Pod not found" msgid "Pod not found"
msgstr "" msgstr ""
......
...@@ -330,11 +330,11 @@ describe Projects::EnvironmentsController do ...@@ -330,11 +330,11 @@ describe Projects::EnvironmentsController do
expect(response).to redirect_to(environment_metrics_path(environment)) expect(response).to redirect_to(environment_metrics_path(environment))
end 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 } get :metrics_redirect, params: { namespace_id: project.namespace, project_id: project }
expect(response).to be_ok expect(response).to be_ok
expect(response).to render_template 'empty' expect(response).to render_template 'empty_metrics'
end end
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