Commit abdf1d42 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch '330878-depreciate-logs-path' into 'master'

Depreciate GMA from Logs view in Operations

See merge request gitlab-org/gitlab!63517
parents 1a4ed9bd 71df6576
...@@ -5,7 +5,6 @@ import { ...@@ -5,7 +5,6 @@ import {
GlDropdown, GlDropdown,
GlDropdownSectionHeader, GlDropdownSectionHeader,
GlDropdownItem, GlDropdownItem,
GlDropdownDivider,
GlInfiniteScroll, GlInfiniteScroll,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { throttle } from 'lodash'; import { throttle } from 'lodash';
...@@ -25,7 +24,6 @@ export default { ...@@ -25,7 +24,6 @@ export default {
GlDropdown, GlDropdown,
GlDropdownSectionHeader, GlDropdownSectionHeader,
GlDropdownItem, GlDropdownItem,
GlDropdownDivider,
GlInfiniteScroll, GlInfiniteScroll,
LogSimpleFilters, LogSimpleFilters,
LogAdvancedFilters, LogAdvancedFilters,
...@@ -66,7 +64,7 @@ export default { ...@@ -66,7 +64,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState('environmentLogs', ['environments', 'timeRange', 'logs', 'pods', 'managedApps']), ...mapState('environmentLogs', ['environments', 'timeRange', 'logs', 'pods']),
...mapGetters('environmentLogs', ['trace', 'showAdvancedFilters']), ...mapGetters('environmentLogs', ['trace', 'showAdvancedFilters']),
showLoader() { showLoader() {
...@@ -88,15 +86,12 @@ export default { ...@@ -88,15 +86,12 @@ export default {
}); });
this.fetchEnvironments(this.environmentsPath); this.fetchEnvironments(this.environmentsPath);
this.fetchManagedApps(this.clustersPath);
}, },
methods: { methods: {
...mapActions('environmentLogs', [ ...mapActions('environmentLogs', [
'setInitData', 'setInitData',
'showEnvironment', 'showEnvironment',
'showManagedApp',
'fetchEnvironments', 'fetchEnvironments',
'fetchManagedApps',
'refreshPodLogs', 'refreshPodLogs',
'fetchMoreLogsPrepend', 'fetchMoreLogsPrepend',
'dismissRequestEnvironmentsError', 'dismissRequestEnvironmentsError',
...@@ -107,9 +102,6 @@ export default { ...@@ -107,9 +102,6 @@ export default {
isCurrentEnvironment(envName) { isCurrentEnvironment(envName) {
return envName === this.environments.current; return envName === this.environments.current;
}, },
isCurrentManagedApp(appName) {
return appName === this.managedApps.current;
},
topReached() { topReached() {
if (!this.logs.isLoading) { if (!this.logs.isLoading) {
this.fetchMoreLogsPrepend(); this.fetchMoreLogsPrepend();
...@@ -173,7 +165,7 @@ export default { ...@@ -173,7 +165,7 @@ export default {
<div class="flex-grow-0"> <div class="flex-grow-0">
<gl-dropdown <gl-dropdown
id="environments-dropdown" id="environments-dropdown"
:text="environments.current || managedApps.current" :text="environments.current"
:disabled="environments.isLoading" :disabled="environments.isLoading"
class="gl-mr-3 gl-mb-3 gl-display-flex gl-md-display-block js-environments-dropdown" class="gl-mr-3 gl-mb-3 gl-display-flex gl-md-display-block js-environments-dropdown"
> >
...@@ -189,19 +181,6 @@ export default { ...@@ -189,19 +181,6 @@ export default {
> >
{{ env.name }} {{ env.name }}
</gl-dropdown-item> </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> </gl-dropdown>
</div> </div>
......
...@@ -13,5 +13,4 @@ export const tracking = { ...@@ -13,5 +13,4 @@ export const tracking = {
export const logExplorerOptions = { export const logExplorerOptions = {
environments: 'environments', environments: 'environments',
managedApps: 'managedApps',
}; };
...@@ -25,15 +25,9 @@ const requestUntilData = (url, params) => ...@@ -25,15 +25,9 @@ const requestUntilData = (url, params) =>
const requestLogsUntilData = ({ commit, state }) => { const requestLogsUntilData = ({ commit, state }) => {
const params = {}; const params = {};
const type = state.environments.current const type = logExplorerOptions.environments;
? logExplorerOptions.environments
: logExplorerOptions.managedApps;
const selectedObj = state[type].options.find(({ name }) => name === state[type].current); const selectedObj = state[type].options.find(({ name }) => name === state[type].current);
const path = selectedObj.logs_api_path;
const path =
type === logExplorerOptions.environments
? selectedObj.logs_api_path
: selectedObj.gitlab_managed_apps_logs_path;
if (state.pods.current) { if (state.pods.current) {
params.pod_name = state.pods.current; params.pod_name = state.pods.current;
...@@ -106,11 +100,6 @@ export const showEnvironment = ({ dispatch, commit }, environmentName) => { ...@@ -106,11 +100,6 @@ export const showEnvironment = ({ dispatch, commit }, environmentName) => {
dispatch('fetchLogs', tracking.ENVIRONMENT_SELECTED); 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 }) => { export const refreshPodLogs = ({ dispatch, commit }) => {
commit(types.REFRESH_POD_LOGS); commit(types.REFRESH_POD_LOGS);
dispatch('fetchLogs', tracking.REFRESH_POD_LOGS); dispatch('fetchLogs', tracking.REFRESH_POD_LOGS);
...@@ -135,23 +124,6 @@ export const fetchEnvironments = ({ commit, dispatch }, environmentsPath) => { ...@@ -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) => { export const fetchLogs = ({ commit, state }, trackingLabel) => {
commit(types.REQUEST_LOGS_DATA); commit(types.REQUEST_LOGS_DATA);
......
...@@ -6,16 +6,9 @@ const mapTrace = ({ timestamp = null, pod = '', message = '' }) => ...@@ -6,16 +6,9 @@ const mapTrace = ({ timestamp = null, pod = '', message = '' }) =>
export const trace = (state) => state.logs.lines.map(mapTrace).join('\n'); export const trace = (state) => state.logs.lines.map(mapTrace).join('\n');
export const showAdvancedFilters = (state) => { export const showAdvancedFilters = (state) => {
if (state.environments.current) { const environment = state.environments.options.find(
const environment = state.environments.options.find( ({ name }) => name === state.environments.current,
({ 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(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 ...@@ -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 RECEIVE_ENVIRONMENTS_DATA_ERROR = 'RECEIVE_ENVIRONMENTS_DATA_ERROR';
export const HIDE_REQUEST_ENVIRONMENTS_ERROR = 'HIDE_REQUEST_ENVIRONMENTS_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 REQUEST_LOGS_DATA = 'REQUEST_LOGS_DATA';
export const RECEIVE_LOGS_DATA_SUCCESS = 'RECEIVE_LOGS_DATA_SUCCESS'; export const RECEIVE_LOGS_DATA_SUCCESS = 'RECEIVE_LOGS_DATA_SUCCESS';
export const RECEIVE_LOGS_DATA_ERROR = 'RECEIVE_LOGS_DATA_ERROR'; export const RECEIVE_LOGS_DATA_ERROR = 'RECEIVE_LOGS_DATA_ERROR';
......
...@@ -32,9 +32,6 @@ export default { ...@@ -32,9 +32,6 @@ export default {
// Clear current pod options // Clear current pod options
state.pods.current = null; state.pods.current = null;
state.pods.options = []; state.pods.options = [];
// Clear current managedApps options
state.managedApps.current = null;
}, },
[types.REQUEST_ENVIRONMENTS_DATA](state) { [types.REQUEST_ENVIRONMENTS_DATA](state) {
state.environments.options = []; state.environments.options = [];
...@@ -110,26 +107,4 @@ export default { ...@@ -110,26 +107,4 @@ export default {
[types.RECEIVE_PODS_DATA_ERROR](state) { [types.RECEIVE_PODS_DATA_ERROR](state) {
state.pods.options = []; 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 () => ({ ...@@ -30,16 +30,6 @@ export default () => ({
fetchError: false, fetchError: false,
}, },
/**
* Managed apps list information
*/
managedApps: {
options: [],
isLoading: false,
current: null,
fetchError: false,
},
/** /**
* Logs including trace * Logs including trace
*/ */
......
...@@ -12559,9 +12559,6 @@ msgstr "" ...@@ -12559,9 +12559,6 @@ msgstr ""
msgid "Environments|Logs from %{start} to %{end}." msgid "Environments|Logs from %{start} to %{end}."
msgstr "" msgstr ""
msgid "Environments|Managed apps"
msgstr ""
msgid "Environments|More information" msgid "Environments|More information"
msgstr "" msgstr ""
......
...@@ -40,7 +40,7 @@ RSpec.describe 'Environment > Pod Logs', :js, :kubeclient do ...@@ -40,7 +40,7 @@ RSpec.describe 'Environment > Pod Logs', :js, :kubeclient do
dropdown_items = find(".dropdown-menu").all(".dropdown-item") dropdown_items = find(".dropdown-menu").all(".dropdown-item")
expect(dropdown_items.first).to have_content(environment.name) 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
end end
......
...@@ -12,7 +12,6 @@ import { ...@@ -12,7 +12,6 @@ import {
mockTrace, mockTrace,
mockEnvironmentsEndpoint, mockEnvironmentsEndpoint,
mockDocumentationPath, mockDocumentationPath,
mockManagedAppsEndpoint,
} from '../mock_data'; } from '../mock_data';
jest.mock('~/lib/utils/scroll_utils'); jest.mock('~/lib/utils/scroll_utils');
...@@ -35,7 +34,7 @@ describe('EnvironmentLogs', () => { ...@@ -35,7 +34,7 @@ describe('EnvironmentLogs', () => {
environmentName: mockEnvName, environmentName: mockEnvName,
environmentsPath: mockEnvironmentsEndpoint, environmentsPath: mockEnvironmentsEndpoint,
clusterApplicationsDocumentationPath: mockDocumentationPath, clusterApplicationsDocumentationPath: mockDocumentationPath,
clustersPath: mockManagedAppsEndpoint, clustersPath: '/gitlab-org',
}; };
const updateControlBtnsMock = jest.fn(); const updateControlBtnsMock = jest.fn();
......
...@@ -7,8 +7,6 @@ export const mockDocumentationPath = '/documentation.md'; ...@@ -7,8 +7,6 @@ export const mockDocumentationPath = '/documentation.md';
export const mockLogsEndpoint = '/dummy_logs_path.json'; export const mockLogsEndpoint = '/dummy_logs_path.json';
export const mockCursor = 'MOCK_CURSOR'; export const mockCursor = 'MOCK_CURSOR';
export const mockNextCursor = 'MOCK_NEXT_CURSOR'; export const mockNextCursor = 'MOCK_NEXT_CURSOR';
export const mockManagedAppName = 'kubernetes-cluster-1';
export const mockManagedAppsEndpoint = `${mockProjectPath}/clusters.json`;
const makeMockEnvironment = (id, name, advancedQuerying) => ({ const makeMockEnvironment = (id, name, advancedQuerying) => ({
id, id,
...@@ -25,31 +23,6 @@ export const mockEnvironments = [ ...@@ -25,31 +23,6 @@ export const mockEnvironments = [
makeMockEnvironment(102, 'review/a-feature', false), 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 mockPodName = 'production-764c58d697-aaaaa';
export const mockPods = [ export const mockPods = [
mockPodName, mockPodName,
......
...@@ -11,7 +11,6 @@ import { ...@@ -11,7 +11,6 @@ import {
fetchEnvironments, fetchEnvironments,
fetchLogs, fetchLogs,
fetchMoreLogsPrepend, fetchMoreLogsPrepend,
fetchManagedApps,
} from '~/logs/stores/actions'; } from '~/logs/stores/actions';
import * as types from '~/logs/stores/mutation_types'; import * as types from '~/logs/stores/mutation_types';
import logsPageState from '~/logs/stores/state'; import logsPageState from '~/logs/stores/state';
...@@ -31,8 +30,6 @@ import { ...@@ -31,8 +30,6 @@ import {
mockResponse, mockResponse,
mockCursor, mockCursor,
mockNextCursor, mockNextCursor,
mockManagedApps,
mockManagedAppsEndpoint,
} from '../mock_data'; } from '../mock_data';
jest.mock('~/flash'); jest.mock('~/flash');
...@@ -219,30 +216,6 @@ describe('Logs Store actions', () => { ...@@ -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', () => { describe('when the backend responds succesfully', () => {
let expectedMutations; let expectedMutations;
let expectedActions; let expectedActions;
......
import { trace, showAdvancedFilters } from '~/logs/stores/getters'; import { trace, showAdvancedFilters } from '~/logs/stores/getters';
import logsPageState from '~/logs/stores/state'; import logsPageState from '~/logs/stores/state';
import { import { mockLogsResult, mockTrace, mockEnvName, mockEnvironments } from '../mock_data';
mockLogsResult,
mockTrace,
mockEnvName,
mockEnvironments,
mockManagedApps,
mockManagedAppName,
} from '../mock_data';
describe('Logs Store getters', () => { describe('Logs Store getters', () => {
let state; let state;
...@@ -79,43 +72,4 @@ describe('Logs Store getters', () => { ...@@ -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 { ...@@ -11,8 +11,6 @@ import {
mockSearch, mockSearch,
mockCursor, mockCursor,
mockNextCursor, mockNextCursor,
mockManagedApps,
mockManagedAppName,
} from '../mock_data'; } from '../mock_data';
describe('Logs Store Mutations', () => { describe('Logs Store Mutations', () => {
...@@ -32,15 +30,6 @@ describe('Logs Store Mutations', () => { ...@@ -32,15 +30,6 @@ describe('Logs Store Mutations', () => {
it('sets the environment', () => { it('sets the environment', () => {
mutations[types.SET_PROJECT_ENVIRONMENT](state, mockEnvName); mutations[types.SET_PROJECT_ENVIRONMENT](state, mockEnvName);
expect(state.environments.current).toEqual(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', () => { ...@@ -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