diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-16 21:09:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-16 21:09:35 +0300 |
commit | 3a9076e0a4c28af9a1a40ed5e181b70fb1b659de (patch) | |
tree | 3d531c50bec43c1845c7d74f76442b7a6f49849f /app/assets/javascripts/logs | |
parent | 2d8454515e7b631a8f39a6415c86154d6c62841c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/logs')
-rw-r--r-- | app/assets/javascripts/logs/components/environment_logs.vue | 39 | ||||
-rw-r--r-- | app/assets/javascripts/logs/constants.js | 6 | ||||
-rw-r--r-- | app/assets/javascripts/logs/stores/actions.js | 38 | ||||
-rw-r--r-- | app/assets/javascripts/logs/stores/mutation_types.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/logs/stores/mutations.js | 23 | ||||
-rw-r--r-- | app/assets/javascripts/logs/stores/state.js | 10 |
6 files changed, 110 insertions, 10 deletions
diff --git a/app/assets/javascripts/logs/components/environment_logs.vue b/app/assets/javascripts/logs/components/environment_logs.vue index 86fd6b583d3..f37f48aa431 100644 --- a/app/assets/javascripts/logs/components/environment_logs.vue +++ b/app/assets/javascripts/logs/components/environment_logs.vue @@ -8,6 +8,7 @@ import { GlDropdown, GlDropdownHeader, GlDropdownItem, + GlDropdownDivider, GlInfiniteScroll, } from '@gitlab/ui'; @@ -27,6 +28,7 @@ export default { GlDropdown, GlDropdownHeader, GlDropdownItem, + GlDropdownDivider, GlInfiniteScroll, LogSimpleFilters, LogAdvancedFilters, @@ -55,6 +57,10 @@ export default { type: String, required: true, }, + clustersPath: { + type: String, + required: true, + }, }, data() { return { @@ -63,7 +69,7 @@ export default { }; }, computed: { - ...mapState('environmentLogs', ['environments', 'timeRange', 'logs', 'pods']), + ...mapState('environmentLogs', ['environments', 'timeRange', 'logs', 'pods', 'managedApps']), ...mapGetters('environmentLogs', ['trace', 'showAdvancedFilters']), showLoader() { @@ -85,12 +91,15 @@ export default { }); this.fetchEnvironments(this.environmentsPath); + this.fetchManagedApps(this.clustersPath); }, methods: { ...mapActions('environmentLogs', [ 'setInitData', 'showEnvironment', + 'showManagedApp', 'fetchEnvironments', + 'fetchManagedApps', 'refreshPodLogs', 'fetchMoreLogsPrepend', 'dismissRequestEnvironmentsError', @@ -101,6 +110,9 @@ export default { isCurrentEnvironment(envName) { return envName === this.environments.current; }, + isCurrentManagedApp(appName) { + return appName === this.managedApps.current; + }, topReached() { if (!this.logs.isLoading) { this.fetchMoreLogsPrepend(); @@ -164,12 +176,12 @@ export default { <div class="flex-grow-0"> <gl-dropdown id="environments-dropdown" - :text="environments.current" + :text="environments.current || managedApps.current" :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"> - {{ s__('Environments|Select environment') }} + <gl-dropdown-header class="gl-text-center"> + {{ s__('Environments|Environments') }} </gl-dropdown-header> <gl-dropdown-item v-for="env in environments.options" @@ -181,7 +193,24 @@ 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="gl-text-center"> + {{ s__('Environments|Managed apps') }} + </gl-dropdown-header> + <gl-dropdown-item + v-for="app in managedApps.options" + :key="app.id" + @click="showManagedApp(app.name)" + > + <div class="gl-display-flex"> + <gl-icon + :class="{ invisible: !isCurrentManagedApp(app.name) }" + name="status_success_borderless" + /> + <div class="gl-flex-grow-1">{{ app.name }}</div> </div> </gl-dropdown-item> </gl-dropdown> diff --git a/app/assets/javascripts/logs/constants.js b/app/assets/javascripts/logs/constants.js index f83d369c6b8..0cdef53df34 100644 --- a/app/assets/javascripts/logs/constants.js +++ b/app/assets/javascripts/logs/constants.js @@ -8,4 +8,10 @@ export const tracking = { TIME_RANGE_SET: 'time_range_set', ENVIRONMENT_SELECTED: 'environment_selected', REFRESH_POD_LOGS: 'refresh_pod_logs', + MANAGED_APP_SELECTED: 'managed_app_selected', +}; + +export const logExplorerOptions = { + environments: 'environments', + managedApps: 'managedApps', }; diff --git a/app/assets/javascripts/logs/stores/actions.js b/app/assets/javascripts/logs/stores/actions.js index d828e8f8a3e..0edd825b6e9 100644 --- a/app/assets/javascripts/logs/stores/actions.js +++ b/app/assets/javascripts/logs/stores/actions.js @@ -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,9 +25,15 @@ const requestUntilData = (url, params) => const requestLogsUntilData = ({ commit, state }) => { const params = {}; - const { logs_api_path } = state.environments.options.find( - ({ name }) => name === state.environments.current, - ); + const type = state.environments.current + ? logExplorerOptions.environments + : logExplorerOptions.managedApps; + 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; if (state.pods.current) { params.pod_name = state.pods.current; @@ -48,7 +54,7 @@ const requestLogsUntilData = ({ commit, state }) => { params.cursor = state.logs.cursor; } - return requestUntilData(logs_api_path, params); + return requestUntilData(path, params); }; /** @@ -100,6 +106,11 @@ 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); @@ -124,6 +135,23 @@ 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); diff --git a/app/assets/javascripts/logs/stores/mutation_types.js b/app/assets/javascripts/logs/stores/mutation_types.js index 9010ec51817..eaa4b13f8bd 100644 --- a/app/assets/javascripts/logs/stores/mutation_types.js +++ b/app/assets/javascripts/logs/stores/mutation_types.js @@ -1,5 +1,6 @@ export const SET_PROJECT_ENVIRONMENT = 'SET_PROJECT_ENVIRONMENT'; export const SET_SEARCH = 'SET_SEARCH'; +export const SET_MANAGED_APP = 'SET_MANAGED_APP'; export const SET_TIME_RANGE = 'SET_TIME_RANGE'; export const SHOW_TIME_RANGE_INVALID_WARNING = 'SHOW_TIME_RANGE_INVALID_WARNING'; @@ -12,6 +13,9 @@ 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'; diff --git a/app/assets/javascripts/logs/stores/mutations.js b/app/assets/javascripts/logs/stores/mutations.js index 5e1c794c3a9..be22204d88d 100644 --- a/app/assets/javascripts/logs/stores/mutations.js +++ b/app/assets/javascripts/logs/stores/mutations.js @@ -32,6 +32,9 @@ 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 = []; @@ -107,4 +110,24 @@ 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; + 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; + }, }; diff --git a/app/assets/javascripts/logs/stores/state.js b/app/assets/javascripts/logs/stores/state.js index 11185c9ccf1..fbe6589dd84 100644 --- a/app/assets/javascripts/logs/stores/state.js +++ b/app/assets/javascripts/logs/stores/state.js @@ -31,6 +31,16 @@ export default () => ({ }, /** + * Managed apps list information + */ + managedApps: { + options: [], + isLoading: false, + current: null, + fetchError: false, + }, + + /** * Logs including trace */ logs: { |