Commit 7ec474fe authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch...

Merge branch 'mwaw232076-full-text-search-and-time-picker-is-not-be-available-for-managed-apps' into 'master'

Resolve "Full text search and time picker is not be available for managed-apps"

See merge request gitlab-org/gitlab!37926
parents c6a57cc1 618ae1bd
......@@ -6,8 +6,16 @@ const mapTrace = ({ timestamp = null, pod = '', message = '' }) =>
export const trace = state => state.logs.lines.map(mapTrace).join('\n');
export const showAdvancedFilters = state => {
const environment = state.environments.options.find(
({ name }) => name === state.environments.current,
if (state.environments.current) {
const environment = state.environments.options.find(
({ name }) => name === state.environments.current,
);
return Boolean(environment?.enable_advanced_logs_querying);
}
const managedApp = state.managedApps.options.find(
({ name }) => name === state.managedApps.current,
);
return Boolean(environment?.enable_advanced_logs_querying);
return Boolean(managedApp?.enable_advanced_logs_querying);
};
......@@ -99,6 +99,7 @@ module Clusters
delegate :available?, to: :application_ingress, prefix: true, allow_nil: true
delegate :available?, to: :application_prometheus, prefix: true, allow_nil: true
delegate :available?, to: :application_knative, prefix: true, allow_nil: true
delegate :available?, to: :application_elastic_stack, prefix: true, allow_nil: true
delegate :external_ip, to: :application_ingress, prefix: true, allow_nil: true
delegate :external_hostname, to: :application_ingress, prefix: true, allow_nil: true
......
......@@ -371,7 +371,7 @@ class Environment < ApplicationRecord
end
def elastic_stack_available?
!!deployment_platform&.cluster&.application_elastic_stack&.available?
!!deployment_platform&.cluster&.application_elastic_stack_available?
end
private
......
......@@ -24,4 +24,8 @@ class ClusterEntity < Grape::Entity
expose :kubernetes_errors do |cluster|
ClusterErrorEntity.new(cluster)
end
expose :enable_advanced_logs_querying do |cluster|
cluster.application_elastic_stack_available?
end
end
......@@ -11,6 +11,7 @@ class ClusterSerializer < BaseSerializer
:enabled,
:environment_scope,
:gitlab_managed_apps_logs_path,
:enable_advanced_logs_querying,
:kubernetes_errors,
:name,
:nodes,
......
---
title: Fix advanced filters in log explorer view for gitlab managed applications.
merge_request: 37926
author:
type: fixed
......@@ -35,6 +35,7 @@ export const mockManagedApps = [
status: 'connected',
path: '/root/autodevops-deploy/-/clusters/15',
gitlab_managed_apps_logs_path: '/root/autodevops-deploy/-/logs?cluster_id=15',
enable_advanced_logs_querying: true,
},
{
cluster_type: 'project_type',
......@@ -45,6 +46,7 @@ export const mockManagedApps = [
status: 'connected',
path: '/root/autodevops-deploy/-/clusters/16',
gitlab_managed_apps_logs_path: null,
enable_advanced_logs_querying: false,
},
];
......
import { trace, showAdvancedFilters } from '~/logs/stores/getters';
import logsPageState from '~/logs/stores/state';
import { mockLogsResult, mockTrace, mockEnvName, mockEnvironments } from '../mock_data';
import {
mockLogsResult,
mockTrace,
mockEnvName,
mockEnvironments,
mockManagedApps,
mockManagedAppName,
} from '../mock_data';
describe('Logs Store getters', () => {
let state;
......@@ -72,4 +79,43 @@ describe('Logs Store getters', () => {
});
});
});
describe('when no managedApps are set', () => {
beforeEach(() => {
state.environments.current = null;
state.environments.options = [];
state.managedApps.current = mockManagedAppName;
state.managedApps.options = [];
});
it('returns false', () => {
expect(showAdvancedFilters(state)).toBe(false);
});
});
describe('when the managedApp supports filters', () => {
beforeEach(() => {
state.environments.current = null;
state.environments.options = mockEnvironments;
state.managedApps.current = mockManagedAppName;
state.managedApps.options = mockManagedApps;
});
it('returns true', () => {
expect(showAdvancedFilters(state)).toBe(true);
});
});
describe('when the managedApp does not support filters', () => {
beforeEach(() => {
state.environments.current = null;
state.environments.options = mockEnvironments;
state.managedApps.options = mockManagedApps;
state.managedApps.current = mockManagedApps[1].name;
});
it('returns false', () => {
expect(showAdvancedFilters(state)).toBe(false);
});
});
});
......@@ -42,6 +42,7 @@ RSpec.describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
it { is_expected.to delegate_method(:available?).to(:application_ingress).with_prefix }
it { is_expected.to delegate_method(:available?).to(:application_prometheus).with_prefix }
it { is_expected.to delegate_method(:available?).to(:application_knative).with_prefix }
it { is_expected.to delegate_method(:available?).to(:application_elastic_stack).with_prefix }
it { is_expected.to delegate_method(:external_ip).to(:application_ingress).with_prefix }
it { is_expected.to delegate_method(:external_hostname).to(:application_ingress).with_prefix }
......
......@@ -78,5 +78,26 @@ RSpec.describe ClusterEntity do
expect(subject[:gitlab_managed_apps_logs_path]).to eq(log_explorer_path)
end
end
context 'enable_advanced_logs_querying' do
let(:cluster) { create(:cluster, :project) }
let(:user) { create(:user) }
subject { described_class.new(cluster, request: request).as_json }
context 'elastic stack is not installed on cluster' do
it 'returns false' do
expect(subject[:enable_advanced_logs_querying]).to be false
end
end
context 'elastic stack is installed on cluster' do
it 'returns true' do
create(:clusters_applications_elastic_stack, :installed, cluster: cluster)
expect(subject[:enable_advanced_logs_querying]).to be true
end
end
end
end
end
......@@ -14,6 +14,7 @@ RSpec.describe ClusterSerializer do
:enabled,
:environment_scope,
:gitlab_managed_apps_logs_path,
:enable_advanced_logs_querying,
:kubernetes_errors,
:name,
:nodes,
......
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