Commit 71df6576 authored by David O'Regan's avatar David O'Regan Committed by Olena Horal-Koretska

Depreciate GMA from Logs view in Operations

Changelog: deprecated
parent 6a3f50e4
......@@ -5,7 +5,6 @@ import {
GlDropdown,
GlDropdownSectionHeader,
GlDropdownItem,
GlDropdownDivider,
GlInfiniteScroll,
} from '@gitlab/ui';
import { throttle } from 'lodash';
......@@ -25,7 +24,6 @@ export default {
GlDropdown,
GlDropdownSectionHeader,
GlDropdownItem,
GlDropdownDivider,
GlInfiniteScroll,
LogSimpleFilters,
LogAdvancedFilters,
......@@ -66,7 +64,7 @@ export default {
};
},
computed: {
...mapState('environmentLogs', ['environments', 'timeRange', 'logs', 'pods', 'managedApps']),
...mapState('environmentLogs', ['environments', 'timeRange', 'logs', 'pods']),
...mapGetters('environmentLogs', ['trace', 'showAdvancedFilters']),
showLoader() {
......@@ -88,15 +86,12 @@ export default {
});
this.fetchEnvironments(this.environmentsPath);
this.fetchManagedApps(this.clustersPath);
},
methods: {
...mapActions('environmentLogs', [
'setInitData',
'showEnvironment',
'showManagedApp',
'fetchEnvironments',
'fetchManagedApps',
'refreshPodLogs',
'fetchMoreLogsPrepend',
'dismissRequestEnvironmentsError',
......@@ -107,9 +102,6 @@ export default {
isCurrentEnvironment(envName) {
return envName === this.environments.current;
},
isCurrentManagedApp(appName) {
return appName === this.managedApps.current;
},
topReached() {
if (!this.logs.isLoading) {
this.fetchMoreLogsPrepend();
......@@ -173,7 +165,7 @@ export default {
<div class="flex-grow-0">
<gl-dropdown
id="environments-dropdown"
:text="environments.current || managedApps.current"
:text="environments.current"
:disabled="environments.isLoading"
class="gl-mr-3 gl-mb-3 gl-display-flex gl-md-display-block js-environments-dropdown"
>
......@@ -189,19 +181,6 @@ export default {
>
{{ env.name }}
</gl-dropdown-item>
<gl-dropdown-divider />
<gl-dropdown-section-header>
{{ s__('Environments|Managed apps') }}
</gl-dropdown-section-header>
<gl-dropdown-item
v-for="app in managedApps.options"
:key="app.id"
:is-check-item="true"
:is-checked="isCurrentManagedApp(app.name)"
@click="showManagedApp(app.name)"
>
{{ app.name }}
</gl-dropdown-item>
</gl-dropdown>
</div>
......
......@@ -13,5 +13,4 @@ export const tracking = {
export const logExplorerOptions = {
environments: 'environments',
managedApps: 'managedApps',
};
......@@ -25,15 +25,9 @@ const requestUntilData = (url, params) =>
const requestLogsUntilData = ({ commit, state }) => {
const params = {};
const type = state.environments.current
? logExplorerOptions.environments
: logExplorerOptions.managedApps;
const type = logExplorerOptions.environments;
const selectedObj = state[type].options.find(({ name }) => name === state[type].current);
const path =
type === logExplorerOptions.environments
? selectedObj.logs_api_path
: selectedObj.gitlab_managed_apps_logs_path;
const path = selectedObj.logs_api_path;
if (state.pods.current) {
params.pod_name = state.pods.current;
......@@ -106,11 +100,6 @@ export const showEnvironment = ({ dispatch, commit }, environmentName) => {
dispatch('fetchLogs', tracking.ENVIRONMENT_SELECTED);
};
export const showManagedApp = ({ dispatch, commit }, managedApp) => {
commit(types.SET_MANAGED_APP, managedApp);
dispatch('fetchLogs', tracking.MANAGED_APP_SELECTED);
};
export const refreshPodLogs = ({ dispatch, commit }) => {
commit(types.REFRESH_POD_LOGS);
dispatch('fetchLogs', tracking.REFRESH_POD_LOGS);
......@@ -135,23 +124,6 @@ export const fetchEnvironments = ({ commit, dispatch }, environmentsPath) => {
});
};
/**
* Fetch managed apps data
* @param {Object} store
* @param {String} clustersPath
*/
export const fetchManagedApps = ({ commit }, clustersPath) => {
return axios
.get(clustersPath)
.then(({ data }) => {
commit(types.RECEIVE_MANAGED_APPS_DATA_SUCCESS, data.clusters);
})
.catch(() => {
commit(types.RECEIVE_MANAGED_APPS_DATA_ERROR);
});
};
export const fetchLogs = ({ commit, state }, trackingLabel) => {
commit(types.REQUEST_LOGS_DATA);
......
......@@ -6,16 +6,9 @@ const mapTrace = ({ timestamp = null, pod = '', message = '' }) =>
export const trace = (state) => state.logs.lines.map(mapTrace).join('\n');
export const showAdvancedFilters = (state) => {
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,
const environment = state.environments.options.find(
({ name }) => name === state.environments.current,
);
return Boolean(managedApp?.enable_advanced_logs_querying);
return Boolean(environment?.enable_advanced_logs_querying);
};
......@@ -13,9 +13,6 @@ export const RECEIVE_ENVIRONMENTS_DATA_SUCCESS = 'RECEIVE_ENVIRONMENTS_DATA_SUCC
export const RECEIVE_ENVIRONMENTS_DATA_ERROR = 'RECEIVE_ENVIRONMENTS_DATA_ERROR';
export const HIDE_REQUEST_ENVIRONMENTS_ERROR = 'HIDE_REQUEST_ENVIRONMENTS_ERROR';
export const RECEIVE_MANAGED_APPS_DATA_SUCCESS = 'RECEIVE_MANAGED_APPS_DATA_SUCCESS';
export const RECEIVE_MANAGED_APPS_DATA_ERROR = 'RECEIVE_MANAGED_APPS_DATA_ERROR';
export const REQUEST_LOGS_DATA = 'REQUEST_LOGS_DATA';
export const RECEIVE_LOGS_DATA_SUCCESS = 'RECEIVE_LOGS_DATA_SUCCESS';
export const RECEIVE_LOGS_DATA_ERROR = 'RECEIVE_LOGS_DATA_ERROR';
......
......@@ -32,9 +32,6 @@ export default {
// Clear current pod options
state.pods.current = null;
state.pods.options = [];
// Clear current managedApps options
state.managedApps.current = null;
},
[types.REQUEST_ENVIRONMENTS_DATA](state) {
state.environments.options = [];
......@@ -110,26 +107,4 @@ export default {
[types.RECEIVE_PODS_DATA_ERROR](state) {
state.pods.options = [];
},
// Managed apps data
[types.RECEIVE_MANAGED_APPS_DATA_SUCCESS](state, apps) {
state.managedApps.options = apps.filter(
({ gitlab_managed_apps_logs_path }) => gitlab_managed_apps_logs_path, // eslint-disable-line babel/camelcase
);
state.managedApps.isLoading = false;
},
[types.RECEIVE_MANAGED_APPS_DATA_ERROR](state) {
state.managedApps.options = [];
state.managedApps.isLoading = false;
state.managedApps.fetchError = true;
},
[types.SET_MANAGED_APP](state, managedApp) {
state.managedApps.current = managedApp;
// Clear current pod options
state.pods.current = null;
state.pods.options = [];
// Clear current environment options
state.environments.current = null;
},
};
......@@ -30,16 +30,6 @@ export default () => ({
fetchError: false,
},
/**
* Managed apps list information
*/
managedApps: {
options: [],
isLoading: false,
current: null,
fetchError: false,
},
/**
* Logs including trace
*/
......
......@@ -12562,9 +12562,6 @@ msgstr ""
msgid "Environments|Logs from %{start} to %{end}."
msgstr ""
msgid "Environments|Managed apps"
msgstr ""
msgid "Environments|More information"
msgstr ""
......
......@@ -40,7 +40,7 @@ RSpec.describe 'Environment > Pod Logs', :js, :kubeclient do
dropdown_items = find(".dropdown-menu").all(".dropdown-item")
expect(dropdown_items.first).to have_content(environment.name)
expect(dropdown_items.size).to eq(3)
expect(dropdown_items.size).to eq(2)
end
end
......
......@@ -12,7 +12,6 @@ import {
mockTrace,
mockEnvironmentsEndpoint,
mockDocumentationPath,
mockManagedAppsEndpoint,
} from '../mock_data';
jest.mock('~/lib/utils/scroll_utils');
......@@ -35,7 +34,7 @@ describe('EnvironmentLogs', () => {
environmentName: mockEnvName,
environmentsPath: mockEnvironmentsEndpoint,
clusterApplicationsDocumentationPath: mockDocumentationPath,
clustersPath: mockManagedAppsEndpoint,
clustersPath: '/gitlab-org',
};
const updateControlBtnsMock = jest.fn();
......
......@@ -7,8 +7,6 @@ export const mockDocumentationPath = '/documentation.md';
export const mockLogsEndpoint = '/dummy_logs_path.json';
export const mockCursor = 'MOCK_CURSOR';
export const mockNextCursor = 'MOCK_NEXT_CURSOR';
export const mockManagedAppName = 'kubernetes-cluster-1';
export const mockManagedAppsEndpoint = `${mockProjectPath}/clusters.json`;
const makeMockEnvironment = (id, name, advancedQuerying) => ({
id,
......@@ -25,31 +23,6 @@ export const mockEnvironments = [
makeMockEnvironment(102, 'review/a-feature', false),
];
export const mockManagedApps = [
{
cluster_type: 'project_type',
enabled: true,
environment_scope: '*',
name: 'kubernetes-cluster-1',
provider_type: 'user',
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',
enabled: true,
environment_scope: '*',
name: 'kubernetes-cluster-2',
provider_type: 'user',
status: 'connected',
path: '/root/autodevops-deploy/-/clusters/16',
gitlab_managed_apps_logs_path: null,
enable_advanced_logs_querying: false,
},
];
export const mockPodName = 'production-764c58d697-aaaaa';
export const mockPods = [
mockPodName,
......
......@@ -11,7 +11,6 @@ import {
fetchEnvironments,
fetchLogs,
fetchMoreLogsPrepend,
fetchManagedApps,
} from '~/logs/stores/actions';
import * as types from '~/logs/stores/mutation_types';
import logsPageState from '~/logs/stores/state';
......@@ -31,8 +30,6 @@ import {
mockResponse,
mockCursor,
mockNextCursor,
mockManagedApps,
mockManagedAppsEndpoint,
} from '../mock_data';
jest.mock('~/flash');
......@@ -219,30 +216,6 @@ describe('Logs Store actions', () => {
});
});
describe('fetchManagedApps', () => {
beforeEach(() => {
mock = new MockAdapter(axios);
});
it('should commit RECEIVE_MANAGED_APPS_DATA_SUCCESS mutation on succesful fetch', () => {
mock.onGet(mockManagedAppsEndpoint).replyOnce(200, { clusters: mockManagedApps });
return testAction(fetchManagedApps, mockManagedAppsEndpoint, state, [
{ type: types.RECEIVE_MANAGED_APPS_DATA_SUCCESS, payload: mockManagedApps },
]);
});
it('should commit RECEIVE_MANAGED_APPS_DATA_ERROR on wrong data', () => {
mock.onGet(mockManagedAppsEndpoint).replyOnce(500);
return testAction(
fetchManagedApps,
mockManagedAppsEndpoint,
state,
[{ type: types.RECEIVE_MANAGED_APPS_DATA_ERROR }],
[],
);
});
});
describe('when the backend responds succesfully', () => {
let expectedMutations;
let expectedActions;
......
import { trace, showAdvancedFilters } from '~/logs/stores/getters';
import logsPageState from '~/logs/stores/state';
import {
mockLogsResult,
mockTrace,
mockEnvName,
mockEnvironments,
mockManagedApps,
mockManagedAppName,
} from '../mock_data';
import { mockLogsResult, mockTrace, mockEnvName, mockEnvironments } from '../mock_data';
describe('Logs Store getters', () => {
let state;
......@@ -79,43 +72,4 @@ 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);
});
});
});
......@@ -11,8 +11,6 @@ import {
mockSearch,
mockCursor,
mockNextCursor,
mockManagedApps,
mockManagedAppName,
} from '../mock_data';
describe('Logs Store Mutations', () => {
......@@ -32,15 +30,6 @@ describe('Logs Store Mutations', () => {
it('sets the environment', () => {
mutations[types.SET_PROJECT_ENVIRONMENT](state, mockEnvName);
expect(state.environments.current).toEqual(mockEnvName);
expect(state.managedApps.current).toBe(null);
});
});
describe('SET_MANAGED_APP', () => {
it('sets the managed app', () => {
mutations[types.SET_MANAGED_APP](state, mockManagedAppName);
expect(state.managedApps.current).toBe(mockManagedAppName);
expect(state.environments.current).toBe(null);
});
});
......@@ -265,29 +254,4 @@ describe('Logs Store Mutations', () => {
);
});
});
describe('RECEIVE_MANAGED_APPS_DATA_SUCCESS', () => {
it('receives managed apps data success', () => {
expect(state.managedApps.options).toEqual([]);
mutations[types.RECEIVE_MANAGED_APPS_DATA_SUCCESS](state, mockManagedApps);
expect(state.managedApps.options.length).toEqual(1);
expect(state.managedApps.options).toEqual([mockManagedApps[0]]);
expect(state.managedApps.isLoading).toBe(false);
});
});
describe('RECEIVE_MANAGED_APPS_DATA_ERROR', () => {
it('received managed apps data error', () => {
mutations[types.RECEIVE_MANAGED_APPS_DATA_ERROR](state);
expect(state.managedApps).toEqual({
options: [],
isLoading: false,
current: null,
fetchError: true,
});
});
});
});
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