diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /app/assets/javascripts/logs | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'app/assets/javascripts/logs')
-rw-r--r-- | app/assets/javascripts/logs/components/environment_logs.vue | 41 | ||||
-rw-r--r-- | app/assets/javascripts/logs/components/log_control_buttons.vue | 37 | ||||
-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 |
7 files changed, 131 insertions, 28 deletions
diff --git a/app/assets/javascripts/logs/components/environment_logs.vue b/app/assets/javascripts/logs/components/environment_logs.vue index 01a4cbd41f6..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> @@ -202,7 +231,7 @@ export default { <log-control-buttons ref="scrollButtons" - class="flex-grow-0 pr-2 mb-2 controllers" + class="flex-grow-0 pr-2 mb-2 controllers gl-display-inline-flex" :scroll-down-button-disabled="scrollDownButtonDisabled" @refresh="refreshPodLogs()" @scrollDown="scrollDown" diff --git a/app/assets/javascripts/logs/components/log_control_buttons.vue b/app/assets/javascripts/logs/components/log_control_buttons.vue index 3f5de4c22e0..e44b5394fa1 100644 --- a/app/assets/javascripts/logs/components/log_control_buttons.vue +++ b/app/assets/javascripts/logs/components/log_control_buttons.vue @@ -1,11 +1,9 @@ <script> -import { GlDeprecatedButton, GlTooltipDirective } from '@gitlab/ui'; -import Icon from '~/vue_shared/components/icon.vue'; +import { GlButton, GlTooltipDirective } from '@gitlab/ui'; export default { components: { - Icon, - GlDeprecatedButton, + GlButton, }, directives: { GlTooltip: GlTooltipDirective, @@ -51,14 +49,16 @@ export default { :title="__('Scroll to top')" aria-labelledby="scroll-to-top" > - <gl-deprecated-button + <gl-button id="scroll-to-top" - class="btn-blank js-scroll-to-top" + class="js-scroll-to-top gl-mr-2 btn-blank" :aria-label="__('Scroll to top')" :disabled="scrollUpButtonDisabled" + icon="scroll_up" + category="primary" + variant="default" @click="handleScrollUp()" - ><icon name="scroll_up" - /></gl-deprecated-button> + /> </div> <div v-if="scrollDownAvailable" @@ -68,25 +68,28 @@ export default { :title="__('Scroll to bottom')" aria-labelledby="scroll-to-bottom" > - <gl-deprecated-button + <gl-button id="scroll-to-bottom" - class="btn-blank js-scroll-to-bottom" + class="js-scroll-to-bottom gl-mr-2 btn-blank" :aria-label="__('Scroll to bottom')" :v-if="scrollDownAvailable" :disabled="scrollDownButtonDisabled" + icon="scroll_down" + category="primary" + variant="default" @click="handleScrollDown()" - ><icon name="scroll_down" - /></gl-deprecated-button> + /> </div> - <gl-deprecated-button + <gl-button id="refresh-log" v-gl-tooltip - class="ml-1 px-2 js-refresh-log" + class="js-refresh-log" :title="__('Refresh')" :aria-label="__('Refresh')" + icon="retry" + category="primary" + variant="default" @click="handleRefreshClick" - > - <icon name="retry" /> - </gl-deprecated-button> + /> </div> </template> 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: { |