From 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 18 Feb 2021 10:34:06 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-9-stable-ee --- .../account/components/delete_account_modal.vue | 2 +- .../profile/account/components/update_username.vue | 4 +- app/assets/javascripts/profile/account/index.js | 5 +- .../preferences/components/profile_preferences.vue | 105 ++++++++++++++++++--- .../javascripts/profile/preferences/constants.js | 22 +++++ .../preferences/profile_preferences_bundle.js | 20 ++-- app/assets/javascripts/profile/profile.js | 5 +- 7 files changed, 133 insertions(+), 30 deletions(-) create mode 100644 app/assets/javascripts/profile/preferences/constants.js (limited to 'app/assets/javascripts/profile') diff --git a/app/assets/javascripts/profile/account/components/delete_account_modal.vue b/app/assets/javascripts/profile/account/components/delete_account_modal.vue index f06dc72d365..2336cb18cb5 100644 --- a/app/assets/javascripts/profile/account/components/delete_account_modal.vue +++ b/app/assets/javascripts/profile/account/components/delete_account_modal.vue @@ -1,8 +1,8 @@ @@ -36,10 +97,10 @@ export default {

- {{ s__('ProfilePreferences|Integrations') }} + {{ $options.i18n.integrations }}

- {{ s__('ProfilePreferences|Customize integrations with third party services.') }} + {{ $options.i18n.integrationsDescription }}

@@ -52,5 +113,19 @@ export default { :config="$options.integrationViewConfigs[view.name]" />
+
+
+
+ + {{ $options.i18n.saveChanges }} + +
+
diff --git a/app/assets/javascripts/profile/preferences/constants.js b/app/assets/javascripts/profile/preferences/constants.js new file mode 100644 index 00000000000..ea8464ba065 --- /dev/null +++ b/app/assets/javascripts/profile/preferences/constants.js @@ -0,0 +1,22 @@ +import { s__, __ } from '~/locale'; + +export const INTEGRATION_VIEW_CONFIGS = { + sourcegraph: { + title: s__('Preferences|Sourcegraph'), + label: s__('Preferences|Enable integrated code intelligence on code views'), + formName: 'sourcegraph_enabled', + }, + gitpod: { + title: s__('Preferences|Gitpod'), + label: s__('Preferences|Enable Gitpod integration'), + formName: 'gitpod_enabled', + }, +}; + +export const i18n = { + saveChanges: __('Save changes'), + defaultSuccess: __('Preferences saved.'), + defaultError: s__('Preferences|Failed to save preferences.'), + integrations: s__('Preferences|Integrations'), + integrationsDescription: s__('Preferences|Customize integrations with third party services.'), +}; diff --git a/app/assets/javascripts/profile/preferences/profile_preferences_bundle.js b/app/assets/javascripts/profile/preferences/profile_preferences_bundle.js index 744e0174a4e..6520e68d41c 100644 --- a/app/assets/javascripts/profile/preferences/profile_preferences_bundle.js +++ b/app/assets/javascripts/profile/preferences/profile_preferences_bundle.js @@ -3,16 +3,20 @@ import ProfilePreferences from './components/profile_preferences.vue'; export default () => { const el = document.querySelector('#js-profile-preferences-app'); - const shouldParse = ['integrationViews', 'userFields']; + const formEl = document.querySelector('#profile-preferences-form'); + const shouldParse = ['integrationViews', 'themes', 'userFields']; - const provide = Object.keys(el.dataset).reduce((memo, key) => { - let value = el.dataset[key]; - if (shouldParse.includes(key)) { - value = JSON.parse(value); - } + const provide = Object.keys(el.dataset).reduce( + (memo, key) => { + let value = el.dataset[key]; + if (shouldParse.includes(key)) { + value = JSON.parse(value); + } - return { ...memo, [key]: value }; - }, {}); + return { ...memo, [key]: value }; + }, + { formEl }, + ); return new Vue({ el, diff --git a/app/assets/javascripts/profile/profile.js b/app/assets/javascripts/profile/profile.js index bfeeff47163..a7332b81b9f 100644 --- a/app/assets/javascripts/profile/profile.js +++ b/app/assets/javascripts/profile/profile.js @@ -1,11 +1,11 @@ import $ from 'jquery'; import axios from '~/lib/utils/axios_utils'; -import { Rails } from '~/lib/utils/rails_ujs'; -import { deprecatedCreateFlash as flash } from '../flash'; import { parseBoolean } from '~/lib/utils/common_utils'; +import { Rails } from '~/lib/utils/rails_ujs'; import TimezoneDropdown, { formatTimezone, } from '~/pages/projects/pipeline_schedules/shared/components/timezone_dropdown'; +import { deprecatedCreateFlash as flash } from '../flash'; export default class Profile { constructor({ form } = {}) { @@ -42,6 +42,7 @@ export default class Profile { $('#user_notification_email').on('select2-selecting', (event) => { setTimeout(this.submitForm.bind(event.currentTarget)); }); + $('#user_email_opted_in').on('change', this.submitForm); $('#user_notified_of_own_activity').on('change', this.submitForm); this.form.on('submit', this.onSubmitForm); } -- cgit v1.2.3