diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 21:08:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 21:08:57 +0300 |
commit | d8121cb00b8bbd281d7362902590b110639bdeba (patch) | |
tree | 0a0f71b247b232773a46732d9f74aa3cfed0ef1a /app | |
parent | 536aa3a1f4b96abc4ca34489bf2cbe503afcded7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/monitoring/components/dashboard.vue | 4 | ||||
-rw-r--r-- | app/assets/javascripts/monitoring/components/dashboards_dropdown.vue | 114 | ||||
-rw-r--r-- | app/assets/javascripts/mr_popover/constants.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/registry/settings/components/settings_form.vue | 13 | ||||
-rw-r--r-- | app/assets/javascripts/registry/settings/store/getters.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/vue_alerts.js | 22 | ||||
-rw-r--r-- | app/assets/javascripts/vue_shared/components/dismissible_alert.vue | 32 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/prometheus.scss | 7 | ||||
-rw-r--r-- | app/helpers/analytics_navbar_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/groups_helper.rb | 1 | ||||
-rw-r--r-- | app/views/layouts/nav/sidebar/_analytics_links.html.haml (renamed from app/views/layouts/nav/sidebar/_project_analytics_link.html.haml) | 10 | ||||
-rw-r--r-- | app/views/layouts/nav/sidebar/_group.html.haml | 25 | ||||
-rw-r--r-- | app/views/layouts/nav/sidebar/_project.html.haml | 2 |
13 files changed, 181 insertions, 56 deletions
diff --git a/app/assets/javascripts/monitoring/components/dashboard.vue b/app/assets/javascripts/monitoring/components/dashboard.vue index 5c643a864d6..c76c039fb3b 100644 --- a/app/assets/javascripts/monitoring/components/dashboard.vue +++ b/app/assets/javascripts/monitoring/components/dashboard.vue @@ -402,7 +402,9 @@ export default { :text="currentEnvironmentName" > <div class="d-flex flex-column overflow-hidden"> - <gl-dropdown-header class="text-center">{{ __('Environment') }}</gl-dropdown-header> + <gl-dropdown-header class="monitor-environment-dropdown-header text-center">{{ + __('Environment') + }}</gl-dropdown-header> <gl-dropdown-divider /> <gl-search-box-by-type v-if="shouldRenderSearchableEnvironmentsDropdown" diff --git a/app/assets/javascripts/monitoring/components/dashboards_dropdown.vue b/app/assets/javascripts/monitoring/components/dashboards_dropdown.vue index 6d93eee0b4f..8f3e0a6ec75 100644 --- a/app/assets/javascripts/monitoring/components/dashboards_dropdown.vue +++ b/app/assets/javascripts/monitoring/components/dashboards_dropdown.vue @@ -4,11 +4,14 @@ import { GlAlert, GlDropdown, GlDropdownItem, + GlDropdownHeader, GlDropdownDivider, + GlSearchBoxByType, GlModal, GlLoadingIcon, GlModalDirective, } from '@gitlab/ui'; +import { s__ } from '~/locale'; import DuplicateDashboardForm from './duplicate_dashboard_form.vue'; const events = { @@ -20,7 +23,9 @@ export default { GlAlert, GlDropdown, GlDropdownItem, + GlDropdownHeader, GlDropdownDivider, + GlSearchBoxByType, GlModal, GlLoadingIcon, DuplicateDashboardForm, @@ -44,6 +49,7 @@ export default { alert: null, loading: false, form: {}, + searchTerm: '', }; }, computed: { @@ -54,6 +60,17 @@ export default { selectedDashboardText() { return this.selectedDashboard.display_name; }, + filteredDashboards() { + return this.allDashboards.filter(({ display_name }) => + display_name.toLowerCase().includes(this.searchTerm.toLowerCase()), + ); + }, + shouldShowNoMsgContainer() { + return this.filteredDashboards.length === 0; + }, + okButtonText() { + return this.loading ? s__('Metrics|Duplicating...') : s__('Metrics|Duplicate'); + }, }, methods: { ...mapActions('monitoringDashboard', ['duplicateSystemDashboard']), @@ -95,45 +112,70 @@ export default { }; </script> <template> - <gl-dropdown toggle-class="dropdown-menu-toggle" :text="selectedDashboardText"> - <gl-dropdown-item - v-for="dashboard in allDashboards" - :key="dashboard.path" - :active="dashboard.path === selectedDashboard.path" - active-class="is-active" - @click="selectDashboard(dashboard)" - > - {{ dashboard.display_name || dashboard.path }} - </gl-dropdown-item> - - <template v-if="isSystemDashboard"> + <gl-dropdown + toggle-class="dropdown-menu-toggle" + menu-class="monitor-dashboard-dropdown-menu" + :text="selectedDashboardText" + > + <div class="d-flex flex-column overflow-hidden"> + <gl-dropdown-header class="monitor-dashboard-dropdown-header text-center">{{ + __('Dashboard') + }}</gl-dropdown-header> <gl-dropdown-divider /> + <gl-search-box-by-type + ref="monitorDashboardsDropdownSearch" + v-model="searchTerm" + class="m-2" + /> + <div class="flex-fill overflow-auto"> + <gl-dropdown-item + v-for="dashboard in filteredDashboards" + :key="dashboard.path" + :active="dashboard.path === selectedDashboard.path" + active-class="is-active" + @click="selectDashboard(dashboard)" + > + {{ dashboard.display_name || dashboard.path }} + </gl-dropdown-item> + </div> - <gl-modal - ref="duplicateDashboardModal" - modal-id="duplicateDashboardModal" - :title="s__('Metrics|Duplicate dashboard')" - ok-variant="success" - @ok="ok" - @hide="hide" + <div + v-show="shouldShowNoMsgContainer" + ref="monitorDashboardsDropdownMsg" + class="text-secondary no-matches-message" > - <gl-alert v-if="alert" class="mb-3" variant="danger" @dismiss="alert = null"> - {{ alert }} - </gl-alert> - <duplicate-dashboard-form - :dashboard="selectedDashboard" - :default-branch="defaultBranch" - @change="formChange" - /> - <template #modal-ok> - <gl-loading-icon v-if="loading" inline color="light" /> - {{ loading ? s__('Metrics|Duplicating...') : s__('Metrics|Duplicate') }} - </template> - </gl-modal> + {{ __('No matching results') }} + </div> + + <template v-if="isSystemDashboard"> + <gl-dropdown-divider /> + + <gl-modal + ref="duplicateDashboardModal" + modal-id="duplicateDashboardModal" + :title="s__('Metrics|Duplicate dashboard')" + ok-variant="success" + @ok="ok" + @hide="hide" + > + <gl-alert v-if="alert" class="mb-3" variant="danger" @dismiss="alert = null"> + {{ alert }} + </gl-alert> + <duplicate-dashboard-form + :dashboard="selectedDashboard" + :default-branch="defaultBranch" + @change="formChange" + /> + <template #modal-ok> + <gl-loading-icon v-if="loading" inline color="light" /> + {{ okButtonText }} + </template> + </gl-modal> - <gl-dropdown-item ref="duplicateDashboardItem" v-gl-modal="'duplicateDashboardModal'"> - {{ s__('Metrics|Duplicate dashboard') }} - </gl-dropdown-item> - </template> + <gl-dropdown-item ref="duplicateDashboardItem" v-gl-modal="'duplicateDashboardModal'"> + {{ s__('Metrics|Duplicate dashboard') }} + </gl-dropdown-item> + </template> + </div> </gl-dropdown> </template> diff --git a/app/assets/javascripts/mr_popover/constants.js b/app/assets/javascripts/mr_popover/constants.js index c13c417cc18..352bc635293 100644 --- a/app/assets/javascripts/mr_popover/constants.js +++ b/app/assets/javascripts/mr_popover/constants.js @@ -3,6 +3,7 @@ import { __ } from '~/locale'; export const mrStates = { merged: 'merged', closed: 'closed', + open: 'open', }; export const humanMRStates = { diff --git a/app/assets/javascripts/registry/settings/components/settings_form.vue b/app/assets/javascripts/registry/settings/components/settings_form.vue index 5456a36aefc..6a617f97271 100644 --- a/app/assets/javascripts/registry/settings/components/settings_form.vue +++ b/app/assets/javascripts/registry/settings/components/settings_form.vue @@ -1,5 +1,5 @@ <script> -import { mapActions, mapState } from 'vuex'; +import { mapActions, mapState, mapGetters } from 'vuex'; import { GlFormGroup, GlToggle, @@ -42,6 +42,7 @@ export default { }, computed: { ...mapState(['formOptions', 'isLoading']), + ...mapGetters({ isEdited: 'getIsEdited' }), ...mapComputed( [ 'enabled', @@ -92,6 +93,9 @@ export default { isSubmitButtonDisabled() { return this.formIsInvalid || this.isLoading; }, + isCancelButtonDisabled() { + return !this.isEdited || this.isLoading; + }, }, methods: { ...mapActions(['resetSettings', 'saveSettings']), @@ -211,7 +215,12 @@ export default { </template> <template #footer> <div class="d-flex justify-content-end"> - <gl-button ref="cancel-button" type="reset" class="mr-2 d-block" :disabled="isLoading"> + <gl-button + ref="cancel-button" + type="reset" + :disabled="isCancelButtonDisabled" + class="mr-2 d-block" + > {{ __('Cancel') }} </gl-button> <gl-button diff --git a/app/assets/javascripts/registry/settings/store/getters.js b/app/assets/javascripts/registry/settings/store/getters.js index fc32a9f08e4..cd6392bd0cc 100644 --- a/app/assets/javascripts/registry/settings/store/getters.js +++ b/app/assets/javascripts/registry/settings/store/getters.js @@ -1,3 +1,4 @@ +import { isEqual } from 'lodash'; import { findDefaultOption } from '../utils'; export const getCadence = state => @@ -6,3 +7,4 @@ export const getKeepN = state => state.settings.keep_n || findDefaultOption(state.formOptions.keepN); export const getOlderThan = state => state.settings.older_than || findDefaultOption(state.formOptions.olderThan); +export const getIsEdited = state => !isEqual(state.original, state.settings); diff --git a/app/assets/javascripts/vue_alerts.js b/app/assets/javascripts/vue_alerts.js new file mode 100644 index 00000000000..6550eb31491 --- /dev/null +++ b/app/assets/javascripts/vue_alerts.js @@ -0,0 +1,22 @@ +import Vue from 'vue'; +import { parseBoolean } from '~/lib/utils/common_utils'; +import DismissibleAlert from '~/vue_shared/components/dismissible_alert.vue'; + +const mountVueAlert = el => { + const props = { + html: el.innerHTML, + }; + const attrs = { + ...el.dataset, + dismissible: parseBoolean(el.dataset.dismissible), + }; + + return new Vue({ + el, + render(h) { + return h(DismissibleAlert, { props, attrs }); + }, + }); +}; + +export default () => [...document.querySelectorAll('.js-vue-alert')].map(mountVueAlert); diff --git a/app/assets/javascripts/vue_shared/components/dismissible_alert.vue b/app/assets/javascripts/vue_shared/components/dismissible_alert.vue new file mode 100644 index 00000000000..986fa14349e --- /dev/null +++ b/app/assets/javascripts/vue_shared/components/dismissible_alert.vue @@ -0,0 +1,32 @@ +<script> +import { GlAlert } from '@gitlab/ui'; + +export default { + components: { + GlAlert, + }, + props: { + html: { + type: String, + required: false, + default: '', + }, + }, + data() { + return { + isDismissed: false, + }; + }, + methods: { + dismiss() { + this.isDismissed = true; + }, + }, +}; +</script> + +<template> + <gl-alert v-if="!isDismissed" v-bind="$attrs" @dismiss="dismiss" v-on="$listeners"> + <div v-html="html"></div> + </gl-alert> +</template> diff --git a/app/assets/stylesheets/pages/prometheus.scss b/app/assets/stylesheets/pages/prometheus.scss index 7269effd38d..2138231aaed 100644 --- a/app/assets/stylesheets/pages/prometheus.scss +++ b/app/assets/stylesheets/pages/prometheus.scss @@ -47,7 +47,12 @@ } .prometheus-graphs-header { - .monitor-environment-dropdown-menu { + .monitor-dashboard-dropdown-header header { + font-size: $gl-font-size; + } + + .monitor-environment-dropdown-menu, + .monitor-dashboard-dropdown-menu { &.show { display: flex; flex-direction: column; diff --git a/app/helpers/analytics_navbar_helper.rb b/app/helpers/analytics_navbar_helper.rb index d9aadfaeb15..c3416aeeac0 100644 --- a/app/helpers/analytics_navbar_helper.rb +++ b/app/helpers/analytics_navbar_helper.rb @@ -20,6 +20,10 @@ module AnalyticsNavbarHelper ].compact end + def group_analytics_navbar_links(group, current_user) + [] + end + private def navbar_sub_item(args) diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 6ddcbf61090..661197e84ae 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -7,7 +7,6 @@ module GroupsHelper groups#details groups#activity groups#subgroups - analytics#show ] end diff --git a/app/views/layouts/nav/sidebar/_project_analytics_link.html.haml b/app/views/layouts/nav/sidebar/_analytics_links.html.haml index 3eb8c024588..b859a1ade66 100644 --- a/app/views/layouts/nav/sidebar/_project_analytics_link.html.haml +++ b/app/views/layouts/nav/sidebar/_analytics_links.html.haml @@ -1,16 +1,16 @@ -- navbar_sub_item = project_analytics_navbar_links(@project, current_user).sort_by(&:title) -- all_paths = navbar_sub_item.map(&:path) +- navbar_links = links.sort_by(&:title) +- all_paths = navbar_links.map(&:path) -- if navbar_sub_item.any? +- if navbar_links.any? = nav_link(path: all_paths) do - = link_to navbar_sub_item.first.link, data: { qa_selector: 'project_analytics_link' } do + = link_to navbar_links.first.link do .nav-icon-container = sprite_icon('chart') %span.nav-item-name = _('Analytics') %ul.sidebar-sub-level-items - - navbar_sub_item.each do |menu_item| + - navbar_links.each do |menu_item| = nav_link(path: menu_item.path) do = link_to(menu_item.link, menu_item.link_to_options) do %span= menu_item.title diff --git a/app/views/layouts/nav/sidebar/_group.html.haml b/app/views/layouts/nav/sidebar/_group.html.haml index 88bb0a97487..60c5ef3877f 100644 --- a/app/views/layouts/nav/sidebar/_group.html.haml +++ b/app/views/layouts/nav/sidebar/_group.html.haml @@ -1,3 +1,4 @@ +- should_display_analytics_pages_in_sidebar = Feature.enabled?(:analytics_pages_under_group_analytics_sidebar, @group) - issues_count = group_issues_count(state: 'opened') - merge_requests_count = group_merge_requests_count(state: 'opened') @@ -11,7 +12,9 @@ = @group.name %ul.sidebar-top-level-items.qa-group-sidebar - if group_sidebar_link?(:overview) - = nav_link(path: group_overview_nav_link_paths, html_options: { class: 'home' }) do + - paths = group_overview_nav_link_paths + - paths << 'contribution_analytics#show' unless should_display_analytics_pages_in_sidebar + = nav_link(path: paths, unless: -> { should_display_analytics_pages_in_sidebar && current_path?('groups/contribution_analytics#show') }, html_options: { class: 'home' }) do = link_to group_path(@group) do .nav-icon-container = sprite_icon('home') @@ -42,18 +45,19 @@ %span = _('Activity') - - if group_sidebar_link?(:contribution_analytics) - = nav_link(path: 'analytics#show') do - = link_to group_contribution_analytics_path(@group), title: _('Contribution Analytics'), data: { placement: 'right', qa_selector: 'contribution_analytics_link' } do - %span - = _('Contribution Analytics') + - unless should_display_analytics_pages_in_sidebar + - if group_sidebar_link?(:contribution_analytics) + = nav_link(path: 'contribution_analytics#show') do + = link_to group_contribution_analytics_path(@group), title: _('Contribution Analytics'), data: { placement: 'right', qa_selector: 'contribution_analytics_link' } do + %span + = _('Contribution Analytics') - = render_if_exists 'layouts/nav/group_insights_link' + = render_if_exists 'layouts/nav/group_insights_link' = render_if_exists "layouts/nav/ee/epic_link", group: @group - if group_sidebar_link?(:issues) - = nav_link(path: group_issues_sub_menu_items) do + = nav_link(path: group_issues_sub_menu_items, unless: -> { should_display_analytics_pages_in_sidebar && current_path?('issues_analytics#show') }) do = link_to issues_group_path(@group), data: { qa_selector: 'group_issues_item' } do .nav-icon-container = sprite_icon('issues') @@ -80,7 +84,8 @@ %span = boards_link_text - = render_if_exists 'layouts/nav/issues_analytics_link' + - unless should_display_analytics_pages_in_sidebar + = render_if_exists 'layouts/nav/issues_analytics_link' - if group_sidebar_link?(:labels) = nav_link(path: 'labels#index') do @@ -126,6 +131,8 @@ = render_if_exists 'groups/sidebar/packages' + = render 'layouts/nav/sidebar/analytics_links', links: group_analytics_navbar_links(@group, current_user) + - if group_sidebar_link?(:group_members) = nav_link(path: 'group_members#index') do = link_to group_group_members_path(@group) do diff --git a/app/views/layouts/nav/sidebar/_project.html.haml b/app/views/layouts/nav/sidebar/_project.html.haml index c2ac00e012a..f17981e501c 100644 --- a/app/views/layouts/nav/sidebar/_project.html.haml +++ b/app/views/layouts/nav/sidebar/_project.html.haml @@ -298,7 +298,7 @@ = render_if_exists 'layouts/nav/sidebar/project_packages_link' - = render 'layouts/nav/sidebar/project_analytics_link' + = render 'layouts/nav/sidebar/analytics_links', links: project_analytics_navbar_links(@project, current_user) - if project_nav_tab? :wiki - wiki_url = project_wiki_path(@project, :home) |