Commit 5053c020 authored by Jose Vargas's avatar Jose Vargas

Add dropdown constants

This also rewrites some conditions
and tests for better clarity
parent 93b58f5e
......@@ -180,7 +180,7 @@ export default {
:disabled="environments.isLoading"
class="mb-2 gl-h-32 pr-2 d-flex d-md-block js-environments-dropdown"
>
<gl-dropdown-header class="text-center">
<gl-dropdown-header class="gl-text-center">
{{ s__('Environments|Environments') }}
</gl-dropdown-header>
<gl-dropdown-item
......@@ -193,11 +193,11 @@ export default {
:class="{ invisible: !isCurrentEnvironment(env.name) }"
name="status_success_borderless"
/>
<div class="flex-grow-1">{{ env.name }}</div>
<div class="gl-flex-grow-1">{{ env.name }}</div>
</div>
</gl-dropdown-item>
<gl-dropdown-divider />
<gl-dropdown-header class="text-center">
<gl-dropdown-header class="gl-text-center">
{{ s__('Environments|Managed apps') }}
</gl-dropdown-header>
<gl-dropdown-item
......@@ -210,7 +210,7 @@ export default {
:class="{ invisible: !isCurrentManagedApp(app.name) }"
name="status_success_borderless"
/>
<div class="flex-grow-1">{{ app.name }}</div>
<div class="gl-flex-grow-1">{{ app.name }}</div>
</div>
</gl-dropdown-item>
</gl-dropdown>
......
......@@ -10,3 +10,8 @@ export const tracking = {
REFRESH_POD_LOGS: 'refresh_pod_logs',
MANAGED_APP_SELECTED: 'managed_app_selected',
};
export const logExplorerOptions = {
environments: 'environments',
managedApps: 'managedApps',
};
......@@ -2,7 +2,7 @@ import { backOff } from '~/lib/utils/common_utils';
import httpStatusCodes from '~/lib/utils/http_status';
import axios from '~/lib/utils/axios_utils';
import { convertToFixedRange } from '~/lib/utils/datetime_range';
import { TOKEN_TYPE_POD_NAME, tracking } from '../constants';
import { TOKEN_TYPE_POD_NAME, tracking, logExplorerOptions } from '../constants';
import trackLogs from '../logs_tracking_helper';
import * as types from './mutation_types';
......@@ -25,11 +25,15 @@ const requestUntilData = (url, params) =>
const requestLogsUntilData = ({ commit, state }) => {
const params = {};
const type = state.environments.current != null ? 'environments' : 'managedApps';
const type = state.environments.current
? logExplorerOptions.environments
: logExplorerOptions.managedApps;
const selectedObj = state[type].options.find(({ name }) => name === state[type].current);
const path =
type === 'environments' ? selectedObj.logs_api_path : selectedObj.gitlab_managed_apps_logs_path;
type === logExplorerOptions.environments
? selectedObj.logs_api_path
: selectedObj.gitlab_managed_apps_logs_path;
if (state.pods.current) {
params.pod_name = state.pods.current;
......
......@@ -9169,9 +9169,6 @@ msgstr ""
msgid "Environments|Rollback environment %{name}?"
msgstr ""
msgid "Environments|Select environment"
msgstr ""
msgid "Environments|Select pod"
msgstr ""
......
......@@ -39,7 +39,7 @@ describe('Logs Store Mutations', () => {
describe('SET_MANAGED_APP', () => {
it('sets the managed app', () => {
mutations[types.SET_MANAGED_APP](state, mockManagedAppName);
expect(state.managedApps.current).toEqual(mockManagedAppName);
expect(state.managedApps.current).toBe(mockManagedAppName);
expect(state.environments.current).toBe(null);
});
});
......@@ -273,7 +273,7 @@ describe('Logs Store Mutations', () => {
mutations[types.RECEIVE_MANAGED_APPS_DATA_SUCCESS](state, mockManagedApps);
expect(state.managedApps.options).toEqual(mockManagedApps);
expect(state.managedApps.isLoading).toEqual(false);
expect(state.managedApps.isLoading).toBe(false);
});
});
......
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