diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-27 21:09:41 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-27 21:09:41 +0300 |
commit | f569792df8a25caa1bed9c448c8c4c3f837f5164 (patch) | |
tree | 8c2ed7dae5ba132a97c0321a7649174e5832d637 /app | |
parent | c2908ec6a0d7b62996cdb8da0350705bdad691bf (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/alert_management/components/alert_management_list.vue | 59 | ||||
-rw-r--r-- | app/assets/javascripts/alert_management/list.js | 7 | ||||
-rw-r--r-- | app/assets/javascripts/boards/models/issue.js | 26 | ||||
-rw-r--r-- | app/assets/javascripts/boards/stores/boards_store.js | 28 | ||||
-rw-r--r-- | app/assets/javascripts/users_select.js (renamed from app/assets/javascripts/users_select/index.js) | 29 | ||||
-rw-r--r-- | app/assets/javascripts/users_select/constants.js | 18 | ||||
-rw-r--r-- | app/assets/javascripts/users_select/utils.js | 27 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 2 | ||||
-rw-r--r-- | app/graphql/types/jira_import_type.rb | 5 | ||||
-rw-r--r-- | app/helpers/explore_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/projects/alert_management_helper.rb | 6 | ||||
-rw-r--r-- | app/models/jira_import_state.rb | 2 | ||||
-rw-r--r-- | app/views/dashboard/snippets/index.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/alert_management/index.html.haml | 2 |
14 files changed, 94 insertions, 121 deletions
diff --git a/app/assets/javascripts/alert_management/components/alert_management_list.vue b/app/assets/javascripts/alert_management/components/alert_management_list.vue index 626d3017319..bd60dd45261 100644 --- a/app/assets/javascripts/alert_management/components/alert_management_list.vue +++ b/app/assets/javascripts/alert_management/components/alert_management_list.vue @@ -1,5 +1,5 @@ <script> -import { GlEmptyState, GlButton, GlLoadingIcon, GlTable, GlAlert } from '@gitlab/ui'; +import { GlEmptyState, GlDeprecatedButton, GlLoadingIcon, GlTable, GlAlert } from '@gitlab/ui'; import { s__ } from '~/locale'; import getAlerts from '../graphql/queries/getAlerts.query.graphql'; @@ -49,26 +49,28 @@ export default { ], components: { GlEmptyState, - GlButton, GlLoadingIcon, GlTable, GlAlert, + GlDeprecatedButton, }, props: { indexPath: { type: String, required: true, }, - // TODO: Handle alertManagementEnabled depending on resolution - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/30024. alertManagementEnabled: { type: Boolean, - required: false, - default: true, + required: true, }, enableAlertManagementPath: { type: String, required: true, }, + userCanEnableAlertManagement: { + type: Boolean, + required: true, + }, emptyAlertSvgPath: { type: String, required: true, @@ -137,29 +139,28 @@ export default { </template> </gl-table> </div> - <template v-else> - <gl-empty-state - :title="s__('AlertManagement|Surface alerts in GitLab')" - :svg-path="emptyAlertSvgPath" - > - <template #description> - <div class="d-block"> - <span>{{ - s__( - 'AlertManagement|Display alerts from all your monitoring tools directly within GitLab. Streamline the investigation of your alerts and the escalation of alerts to incidents.', - ) - }}</span> - <a href="/help/user/project/operations/alert_management.html"> - {{ s__('AlertManagement|More information') }} - </a> - </div> - <div class="d-block center pt-4"> - <gl-button category="primary" variant="success" :href="enableAlertManagementPath"> - {{ s__('AlertManagement|Authorize external service') }} - </gl-button> - </div> - </template> - </gl-empty-state> - </template> + <gl-empty-state v-else :title="__('Surface alerts in GitLab')" :svg-path="emptyAlertSvgPath"> + <template #description> + <div class="d-block"> + <span>{{ + s__( + 'AlertManagement|Display alerts from all your monitoring tools directly within GitLab. Streamline the investigation of your alerts and the escalation of alerts to incidents.', + ) + }}</span> + <a href="/help/user/project/operations/alert_management.html" target="_blank"> + {{ s__('AlertManagement|More information') }} + </a> + </div> + <div v-if="userCanEnableAlertManagement" class="d-block center pt-4"> + <gl-deprecated-button + category="primary" + variant="success" + :href="enableAlertManagementPath" + > + {{ s__('AlertManagement|Authorize external service') }} + </gl-deprecated-button> + </div> + </template> + </gl-empty-state> </div> </template> diff --git a/app/assets/javascripts/alert_management/list.js b/app/assets/javascripts/alert_management/list.js index ce408a8bdaa..3de4ebd96f8 100644 --- a/app/assets/javascripts/alert_management/list.js +++ b/app/assets/javascripts/alert_management/list.js @@ -1,6 +1,7 @@ import Vue from 'vue'; import VueApollo from 'vue-apollo'; import createDefaultClient from '~/lib/graphql'; +import { parseBoolean } from '~/lib/utils/common_utils'; import AlertManagementList from './components/alert_management_list.vue'; Vue.use(VueApollo); @@ -10,6 +11,10 @@ export default () => { const domEl = document.querySelector(selector); const { indexPath, enableAlertManagementPath, emptyAlertSvgPath } = domEl.dataset; + let { alertManagementEnabled, userCanEnableAlertManagement } = domEl.dataset; + + alertManagementEnabled = parseBoolean(alertManagementEnabled); + userCanEnableAlertManagement = parseBoolean(userCanEnableAlertManagement); const apolloProvider = new VueApollo({ defaultClient: createDefaultClient(), @@ -27,6 +32,8 @@ export default () => { indexPath, enableAlertManagementPath, emptyAlertSvgPath, + alertManagementEnabled, + userCanEnableAlertManagement, }, }); }, diff --git a/app/assets/javascripts/boards/models/issue.js b/app/assets/javascripts/boards/models/issue.js index d099c4b930c..af1a910149e 100644 --- a/app/assets/javascripts/boards/models/issue.js +++ b/app/assets/javascripts/boards/models/issue.js @@ -99,31 +99,7 @@ class ListIssue { } update() { - const data = { - issue: { - milestone_id: this.milestone ? this.milestone.id : null, - due_date: this.dueDate, - assignee_ids: this.assignees.length > 0 ? this.assignees.map(u => u.id) : [0], - label_ids: this.labels.map(label => label.id), - }, - }; - - if (!data.issue.label_ids.length) { - data.issue.label_ids = ['']; - } - - const projectPath = this.project ? this.project.path : ''; - return axios.patch(`${this.path}.json`, data).then(({ data: body = {} } = {}) => { - /** - * Since post implementation of Scoped labels, server can reject - * same key-ed labels. To keep the UI and server Model consistent, - * we're just assigning labels that server echo's back to us when we - * PATCH the said object. - */ - if (body) { - this.labels = convertObjectPropsToCamelCase(body.labels, { deep: true }); - } - }); + return boardsStore.updateIssue(this); } } diff --git a/app/assets/javascripts/boards/stores/boards_store.js b/app/assets/javascripts/boards/stores/boards_store.js index e5447080e37..4b4c7550553 100644 --- a/app/assets/javascripts/boards/stores/boards_store.js +++ b/app/assets/javascripts/boards/stores/boards_store.js @@ -6,7 +6,11 @@ import { sortBy } from 'lodash'; import Vue from 'vue'; import Cookies from 'js-cookie'; import BoardsStoreEE from 'ee_else_ce/boards/stores/boards_store_ee'; -import { getUrlParamsArray, parseBoolean } from '~/lib/utils/common_utils'; +import { + getUrlParamsArray, + parseBoolean, + convertObjectPropsToCamelCase, +} from '~/lib/utils/common_utils'; import { __ } from '~/locale'; import axios from '~/lib/utils/axios_utils'; import { mergeUrlParams } from '~/lib/utils/url_utility'; @@ -632,6 +636,28 @@ const boardsStore = { issue.assignees = obj.assignees.map(a => new ListAssignee(a)); } }, + updateIssue(issue) { + const data = { + issue: { + milestone_id: issue.milestone ? issue.milestone.id : null, + due_date: issue.dueDate, + assignee_ids: issue.assignees.length > 0 ? issue.assignees.map(({ id }) => id) : [0], + label_ids: issue.labels.length > 0 ? issue.labels.map(({ id }) => id) : [''], + }, + }; + + return axios.patch(`${issue.path}.json`, data).then(({ data: body = {} } = {}) => { + /** + * Since post implementation of Scoped labels, server can reject + * same key-ed labels. To keep the UI and server Model consistent, + * we're just assigning labels that server echo's back to us when we + * PATCH the said object. + */ + if (body) { + issue.labels = convertObjectPropsToCamelCase(body.labels, { deep: true }); + } + }); + }, }; BoardsStoreEE.initEESpecific(boardsStore); diff --git a/app/assets/javascripts/users_select/index.js b/app/assets/javascripts/users_select.js index 577c21fed5d..ebbe8549656 100644 --- a/app/assets/javascripts/users_select/index.js +++ b/app/assets/javascripts/users_select.js @@ -4,15 +4,10 @@ import $ from 'jquery'; import { escape, template, uniqBy } from 'lodash'; -import axios from '../lib/utils/axios_utils'; -import { s__, __, sprintf } from '../locale'; -import ModalStore from '../boards/stores/modal_store'; -import { parseBoolean } from '../lib/utils/common_utils'; -import { - AJAX_USERS_SELECT_OPTIONS_MAP, - AJAX_USERS_SELECT_PARAMS_MAP, -} from 'ee_else_ce/users_select/constants'; -import { getAjaxUsersSelectOptions, getAjaxUsersSelectParams } from './utils'; +import axios from './lib/utils/axios_utils'; +import { s__, __, sprintf } from './locale'; +import ModalStore from './boards/stores/modal_store'; +import { parseBoolean } from './lib/utils/common_utils'; // TODO: remove eventHub hack after code splitting refactor window.emitSidebarEvent = window.emitSidebarEvent || $.noop; @@ -563,8 +558,13 @@ function UsersSelect(currentUser, els, options = {}) { import(/* webpackChunkName: 'select2' */ 'select2/select2') .then(() => { $('.ajax-users-select').each((i, select) => { - const options = getAjaxUsersSelectOptions($(select), AJAX_USERS_SELECT_OPTIONS_MAP); + const options = {}; options.skipLdap = $(select).hasClass('skip_ldap'); + options.projectId = $(select).data('projectId'); + options.groupId = $(select).data('groupId'); + options.showCurrentUser = $(select).data('currentUser'); + options.authorId = $(select).data('authorId'); + options.skipUsers = $(select).data('skipUsers'); const showNullUser = $(select).data('nullUser'); const showAnyUser = $(select).data('anyUser'); const showEmailUser = $(select).data('emailUser'); @@ -705,7 +705,14 @@ UsersSelect.prototype.users = function(query, options, callback) { const params = { search: query, active: true, - ...getAjaxUsersSelectParams(options, AJAX_USERS_SELECT_PARAMS_MAP), + project_id: options.projectId || null, + group_id: options.groupId || null, + skip_ldap: options.skipLdap || null, + todo_filter: options.todoFilter || null, + todo_state_filter: options.todoStateFilter || null, + current_user: options.showCurrentUser || null, + author_id: options.authorId || null, + skip_users: options.skipUsers || null, }; if (options.issuableType === 'merge_request') { diff --git a/app/assets/javascripts/users_select/constants.js b/app/assets/javascripts/users_select/constants.js deleted file mode 100644 index 64df1e1748c..00000000000 --- a/app/assets/javascripts/users_select/constants.js +++ /dev/null @@ -1,18 +0,0 @@ -export const AJAX_USERS_SELECT_OPTIONS_MAP = { - projectId: 'projectId', - groupId: 'groupId', - showCurrentUser: 'currentUser', - authorId: 'authorId', - skipUsers: 'skipUsers', -}; - -export const AJAX_USERS_SELECT_PARAMS_MAP = { - project_id: 'projectId', - group_id: 'groupId', - skip_ldap: 'skipLdap', - todo_filter: 'todoFilter', - todo_state_filter: 'todoStateFilter', - current_user: 'showCurrentUser', - author_id: 'authorId', - skip_users: 'skipUsers', -}; diff --git a/app/assets/javascripts/users_select/utils.js b/app/assets/javascripts/users_select/utils.js deleted file mode 100644 index b46fd15fb77..00000000000 --- a/app/assets/javascripts/users_select/utils.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Get options from data attributes on passed `$select`. - * @param {jQuery} $select - * @param {Object} optionsMap e.g. { optionKeyName: 'dataAttributeName' } - */ -export const getAjaxUsersSelectOptions = ($select, optionsMap) => { - return Object.keys(optionsMap).reduce((accumulator, optionKey) => { - const dataKey = optionsMap[optionKey]; - accumulator[optionKey] = $select.data(dataKey); - - return accumulator; - }, {}); -}; - -/** - * Get query parameters used for users request from passed `options` parameter - * @param {Object} options e.g. { currentUserId: 1, fooBar: 'baz' } - * @param {Object} paramsMap e.g. { user_id: 'currentUserId', foo_bar: 'fooBar' } - */ -export const getAjaxUsersSelectParams = (options, paramsMap) => { - return Object.keys(paramsMap).reduce((accumulator, paramKey) => { - const optionKey = paramsMap[paramKey]; - accumulator[paramKey] = options[optionKey] || null; - - return accumulator; - }, {}); -}; diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 26ef6117e1c..b5695322eb6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -497,7 +497,7 @@ class ApplicationController < ActionController::Base end def public_visibility_restricted? - Gitlab::CurrentSettings.restricted_visibility_levels.include? Gitlab::VisibilityLevel::PUBLIC + Gitlab::VisibilityLevel.public_visibility_restricted? end def set_usage_stats_consent_flag diff --git a/app/graphql/types/jira_import_type.rb b/app/graphql/types/jira_import_type.rb index ccd463370b6..4a124566ffb 100644 --- a/app/graphql/types/jira_import_type.rb +++ b/app/graphql/types/jira_import_type.rb @@ -7,9 +7,10 @@ module Types class JiraImportType < BaseObject graphql_name 'JiraImport' - field :scheduled_at, Types::TimeType, null: true, - method: :created_at, + field :created_at, Types::TimeType, null: true, description: 'Timestamp of when the Jira import was created' + field :scheduled_at, Types::TimeType, null: true, + description: 'Timestamp of when the Jira import was scheduled' field :scheduled_by, Types::UserType, null: true, description: 'User that started the Jira import' field :jira_project_key, GraphQL::STRING_TYPE, null: false, diff --git a/app/helpers/explore_helper.rb b/app/helpers/explore_helper.rb index b66c7a69b71..026dbd60ac6 100644 --- a/app/helpers/explore_helper.rb +++ b/app/helpers/explore_helper.rb @@ -52,7 +52,7 @@ module ExploreHelper end def public_visibility_restricted? - Gitlab::CurrentSettings.restricted_visibility_levels&.include? Gitlab::VisibilityLevel::PUBLIC + Gitlab::VisibilityLevel.public_visibility_restricted? end private diff --git a/app/helpers/projects/alert_management_helper.rb b/app/helpers/projects/alert_management_helper.rb index 1b0400fbaa5..6aadc18ac3a 100644 --- a/app/helpers/projects/alert_management_helper.rb +++ b/app/helpers/projects/alert_management_helper.rb @@ -1,12 +1,14 @@ # frozen_string_literal: true module Projects::AlertManagementHelper - def alert_management_data(project) + def alert_management_data(current_user, project) { 'index-path' => project_alert_management_index_path(project, format: :json), 'enable-alert-management-path' => project_settings_operations_path(project), - 'empty-alert-svg-path' => image_path('illustrations/alert-management-empty-state.svg') + 'empty-alert-svg-path' => image_path('illustrations/alert-management-empty-state.svg'), + 'user-can-enable-alert-management' => 'false', + 'alert-management-enabled' => Feature.enabled?(:alert_management_minimal, project).to_s } end end diff --git a/app/models/jira_import_state.rb b/app/models/jira_import_state.rb index bde2795e7b8..71bb25470f5 100644 --- a/app/models/jira_import_state.rb +++ b/app/models/jira_import_state.rb @@ -46,7 +46,7 @@ class JiraImportState < ApplicationRecord after_transition initial: :scheduled do |state, _| state.run_after_commit do job_id = Gitlab::JiraImport::Stage::StartImportWorker.perform_async(project.id) - state.update(jid: job_id) if job_id + state.update(jid: job_id, scheduled_at: Time.now) if job_id end end diff --git a/app/views/dashboard/snippets/index.html.haml b/app/views/dashboard/snippets/index.html.haml index 05214346496..2f0cc76f2e0 100644 --- a/app/views/dashboard/snippets/index.html.haml +++ b/app/views/dashboard/snippets/index.html.haml @@ -6,8 +6,6 @@ = render 'dashboard/snippets_head' - if current_user.snippets.exists? = render partial: 'snippets/snippets_scope_menu', locals: { include_private: true, counts: @snippet_counts } - -- if current_user.snippets.exists? = render partial: 'shared/snippets/list', locals: { link_project: true } - else = render 'shared/empty_states/snippets', button_path: button_path diff --git a/app/views/projects/alert_management/index.html.haml b/app/views/projects/alert_management/index.html.haml index dab6aec0446..415820ac3ad 100644 --- a/app/views/projects/alert_management/index.html.haml +++ b/app/views/projects/alert_management/index.html.haml @@ -1,3 +1,3 @@ - page_title _('Alerts') -#js-alert_management{ data: alert_management_data(@project) } +#js-alert_management{ data: alert_management_data(@current_user, @project) } |