diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 12:08:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 12:08:49 +0300 |
commit | 46b10c0fc884400941c17e2777b242ac54d111e5 (patch) | |
tree | 184bc49764f03791610c8ae716c03e0100ed45f5 /app | |
parent | 3358e1fdb8fe1e8f739024ee4f3d1071b296a010 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/monitoring/components/dashboard.vue | 28 | ||||
-rw-r--r-- | app/assets/javascripts/monitoring/stores/actions.js | 13 | ||||
-rw-r--r-- | app/assets/javascripts/monitoring/stores/mutation_types.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/monitoring/stores/mutations.js | 7 | ||||
-rw-r--r-- | app/assets/javascripts/monitoring/stores/state.js | 1 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/prometheus.scss | 14 | ||||
-rw-r--r-- | app/controllers/groups/application_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/groups/milestones_controller.rb | 13 | ||||
-rw-r--r-- | app/models/project.rb | 3 |
9 files changed, 74 insertions, 15 deletions
diff --git a/app/assets/javascripts/monitoring/components/dashboard.vue b/app/assets/javascripts/monitoring/components/dashboard.vue index c34623cf858..6178d1fab67 100644 --- a/app/assets/javascripts/monitoring/components/dashboard.vue +++ b/app/assets/javascripts/monitoring/components/dashboard.vue @@ -6,8 +6,11 @@ import { GlButton, GlDropdown, GlDropdownItem, + GlDropdownHeader, + GlDropdownDivider, GlFormGroup, GlModal, + GlLoadingIcon, GlSearchBoxByType, GlModalDirective, GlTooltipDirective, @@ -41,7 +44,10 @@ export default { Icon, GlButton, GlDropdown, + GlLoadingIcon, GlDropdownItem, + GlDropdownHeader, + GlDropdownDivider, GlSearchBoxByType, GlFormGroup, GlModal, @@ -210,6 +216,7 @@ export default { 'useDashboardEndpoint', 'allDashboards', 'additionalPanelTypesEnabled', + 'environmentsLoading', ]), ...mapGetters('monitoringDashboard', ['getMetricStates', 'filteredEnvironments']), firstDashboard() { @@ -235,6 +242,9 @@ export default { shouldRenderSearchableEnvironmentsDropdown() { return this.glFeatures.searchableEnvironmentsDropdown; }, + shouldShowEnvironmentsDropdownNoMatchedMsg() { + return !this.environmentsLoading && this.filteredEnvironments.length === 0; + }, }, created() { this.setEndpoints({ @@ -262,7 +272,7 @@ export default { 'setGettingStartedEmptyState', 'setEndpoints', 'setPanelGroupMetrics', - 'setEnvironmentsSearchTerm', + 'filterEnvironments', ]), updatePanels(key, panels) { this.setPanelGroupMetrics({ @@ -305,7 +315,7 @@ export default { this.formIsValid = isValid; }, debouncedEnvironmentsSearch: debounce(function environmentsSearchOnInput(searchTerm) { - this.setEnvironmentsSearchTerm(searchTerm); + this.filterEnvironments(searchTerm); }, 500), submitCustomMetricsForm() { this.$refs.customMetricsForm.submit(); @@ -390,16 +400,22 @@ export default { toggle-class="dropdown-menu-toggle" menu-class="monitor-environment-dropdown-menu" :text="currentEnvironmentName" - :disabled="filteredEnvironments.length === 0" > <div class="d-flex flex-column overflow-hidden"> + <gl-dropdown-header class="text-center">{{ __('Environment') }}</gl-dropdown-header> + <gl-dropdown-divider /> <gl-search-box-by-type v-if="shouldRenderSearchableEnvironmentsDropdown" ref="monitorEnvironmentsDropdownSearch" class="m-2" @input="debouncedEnvironmentsSearch" /> - <div class="flex-fill overflow-auto"> + <gl-loading-icon + v-if="environmentsLoading" + ref="monitorEnvironmentsDropdownLoading" + :inline="true" + /> + <div v-else class="flex-fill overflow-auto"> <gl-dropdown-item v-for="environment in filteredEnvironments" :key="environment.id" @@ -411,11 +427,11 @@ export default { </div> <div v-if="shouldRenderSearchableEnvironmentsDropdown" - v-show="filteredEnvironments.length === 0" + v-show="shouldShowEnvironmentsDropdownNoMatchedMsg" ref="monitorEnvironmentsDropdownMsg" class="text-secondary no-matches-message" > - {{ s__('No matching results') }} + {{ __('No matching results') }} </div> </div> </gl-dropdown> diff --git a/app/assets/javascripts/monitoring/stores/actions.js b/app/assets/javascripts/monitoring/stores/actions.js index e26e1457f55..29000475bd4 100644 --- a/app/assets/javascripts/monitoring/stores/actions.js +++ b/app/assets/javascripts/monitoring/stores/actions.js @@ -32,8 +32,9 @@ export const setEndpoints = ({ commit }, endpoints) => { commit(types.SET_ENDPOINTS, endpoints); }; -export const setEnvironmentsSearchTerm = ({ commit }, searchTerm) => { - commit(types.SET_ENVIRONMENTS_SEARCH_TERM, searchTerm); +export const filterEnvironments = ({ commit, dispatch }, searchTerm) => { + commit(types.SET_ENVIRONMENTS_FILTER, searchTerm); + dispatch('fetchEnvironmentsData'); }; export const setShowErrorBanner = ({ commit }, enabled) => { @@ -56,6 +57,7 @@ export const receiveDeploymentsDataSuccess = ({ commit }, data) => commit(types.RECEIVE_DEPLOYMENTS_DATA_SUCCESS, data); export const receiveDeploymentsDataFailure = ({ commit }) => commit(types.RECEIVE_DEPLOYMENTS_DATA_FAILURE); +export const requestEnvironmentsData = ({ commit }) => commit(types.REQUEST_ENVIRONMENTS_DATA); export const receiveEnvironmentsDataSuccess = ({ commit }, data) => commit(types.RECEIVE_ENVIRONMENTS_DATA_SUCCESS, data); export const receiveEnvironmentsDataFailure = ({ commit }) => @@ -189,8 +191,9 @@ export const fetchDeploymentsData = ({ state, dispatch }) => { }); }; -export const fetchEnvironmentsData = ({ state, dispatch }) => - gqClient +export const fetchEnvironmentsData = ({ state, dispatch }) => { + dispatch('requestEnvironmentsData'); + return gqClient .mutate({ mutation: getEnvironments, variables: { @@ -207,12 +210,14 @@ export const fetchEnvironmentsData = ({ state, dispatch }) => s__('Metrics|There was an error fetching the environments data, please try again'), ); } + dispatch('receiveEnvironmentsDataSuccess', environments); }) .catch(() => { dispatch('receiveEnvironmentsDataFailure'); createFlash(s__('Metrics|There was an error getting environments information.')); }); +}; /** * Set a new array of metrics to a panel group diff --git a/app/assets/javascripts/monitoring/stores/mutation_types.js b/app/assets/javascripts/monitoring/stores/mutation_types.js index 73d402ac6df..bdfaf42b35c 100644 --- a/app/assets/javascripts/monitoring/stores/mutation_types.js +++ b/app/assets/javascripts/monitoring/stores/mutation_types.js @@ -22,4 +22,4 @@ export const SET_NO_DATA_EMPTY_STATE = 'SET_NO_DATA_EMPTY_STATE'; export const SET_SHOW_ERROR_BANNER = 'SET_SHOW_ERROR_BANNER'; export const SET_PANEL_GROUP_METRICS = 'SET_PANEL_GROUP_METRICS'; -export const SET_ENVIRONMENTS_SEARCH_TERM = 'SET_ENVIRONMENTS_SEARCH_TERM'; +export const SET_ENVIRONMENTS_FILTER = 'SET_ENVIRONMENTS_FILTER'; diff --git a/app/assets/javascripts/monitoring/stores/mutations.js b/app/assets/javascripts/monitoring/stores/mutations.js index f0390bfc636..2a86a6a26d8 100644 --- a/app/assets/javascripts/monitoring/stores/mutations.js +++ b/app/assets/javascripts/monitoring/stores/mutations.js @@ -123,10 +123,15 @@ export default { [types.RECEIVE_DEPLOYMENTS_DATA_FAILURE](state) { state.deploymentData = []; }, + [types.REQUEST_ENVIRONMENTS_DATA](state) { + state.environmentsLoading = true; + }, [types.RECEIVE_ENVIRONMENTS_DATA_SUCCESS](state, environments) { + state.environmentsLoading = false; state.environments = environments; }, [types.RECEIVE_ENVIRONMENTS_DATA_FAILURE](state) { + state.environmentsLoading = false; state.environments = []; }, @@ -195,7 +200,7 @@ export default { const panelGroup = state.dashboard.panel_groups.find(pg => payload.key === pg.key); panelGroup.panels = payload.panels; }, - [types.SET_ENVIRONMENTS_SEARCH_TERM](state, searchTerm) { + [types.SET_ENVIRONMENTS_FILTER](state, searchTerm) { state.environmentsSearchTerm = searchTerm; }, }; diff --git a/app/assets/javascripts/monitoring/stores/state.js b/app/assets/javascripts/monitoring/stores/state.js index 2a2a7c9c88d..9d3227e8aae 100644 --- a/app/assets/javascripts/monitoring/stores/state.js +++ b/app/assets/javascripts/monitoring/stores/state.js @@ -15,6 +15,7 @@ export default () => ({ deploymentData: [], environments: [], environmentsSearchTerm: '', + environmentsLoading: false, allDashboards: [], currentDashboard: null, projectPath: null, diff --git a/app/assets/stylesheets/pages/prometheus.scss b/app/assets/stylesheets/pages/prometheus.scss index 3e6313173b8..7269effd38d 100644 --- a/app/assets/stylesheets/pages/prometheus.scss +++ b/app/assets/stylesheets/pages/prometheus.scss @@ -46,6 +46,20 @@ } } +.prometheus-graphs-header { + .monitor-environment-dropdown-menu { + &.show { + display: flex; + flex-direction: column; + overflow: hidden; + } + + .no-matches-message { + padding: $gl-padding-8 $gl-padding-12; + } + } +} + .prometheus-panel { margin-top: 20px; } diff --git a/app/controllers/groups/application_controller.rb b/app/controllers/groups/application_controller.rb index d03a50f6f77..0760bdf1e01 100644 --- a/app/controllers/groups/application_controller.rb +++ b/app/controllers/groups/application_controller.rb @@ -20,6 +20,14 @@ class Groups::ApplicationController < ApplicationController @projects ||= GroupProjectsFinder.new(group: group, current_user: current_user).execute end + def group_projects_with_subgroups + @group_projects_with_subgroups ||= GroupProjectsFinder.new( + group: group, + current_user: current_user, + options: { include_subgroups: true } + ).execute + end + def authorize_admin_group! unless can?(current_user, :admin_group, group) return render_404 diff --git a/app/controllers/groups/milestones_controller.rb b/app/controllers/groups/milestones_controller.rb index 7eba73daa3c..a478e9fffb8 100644 --- a/app/controllers/groups/milestones_controller.rb +++ b/app/controllers/groups/milestones_controller.rb @@ -103,8 +103,15 @@ class Groups::MilestonesController < Groups::ApplicationController end def group_projects_with_access - group_projects.with_issues_available_for_user(current_user) - .or(group_projects.with_merge_requests_available_for_user(current_user)) + group_projects_with_subgroups.with_issues_or_mrs_available_for_user(current_user) + end + + def group_ids(include_ancestors: false) + if include_ancestors + group.self_and_hierarchy.public_or_visible_to_user(current_user).select(:id) + else + group.self_and_descendants.public_or_visible_to_user(current_user).select(:id) + end end def milestone @@ -119,7 +126,7 @@ class Groups::MilestonesController < Groups::ApplicationController end def search_params - groups = request.format.json? ? group.self_and_ancestors.select(:id) : group.id + groups = request.format.json? ? group_ids(include_ancestors: true) : group_ids params.permit(:state, :search_title).merge(group_ids: groups) end diff --git a/app/models/project.rb b/app/models/project.rb index b2de2b32ae0..f8c201d73e5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -453,6 +453,9 @@ class Project < ApplicationRecord scope :with_issues_enabled, -> { with_feature_enabled(:issues) } scope :with_issues_available_for_user, ->(current_user) { with_feature_available_for_user(:issues, current_user) } scope :with_merge_requests_available_for_user, ->(current_user) { with_feature_available_for_user(:merge_requests, current_user) } + scope :with_issues_or_mrs_available_for_user, -> (user) do + with_issues_available_for_user(user).or(with_merge_requests_available_for_user(user)) + end scope :with_merge_requests_enabled, -> { with_feature_enabled(:merge_requests) } scope :with_remote_mirrors, -> { joins(:remote_mirrors).where(remote_mirrors: { enabled: true }).distinct } scope :with_limit, -> (maximum) { limit(maximum) } |