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