Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2023-04-10 09:09:02 +00:00
parent 7ee8ee85bd
commit 7d30ce5e22
9 changed files with 196 additions and 17 deletions

View File

@ -5,6 +5,8 @@ import { helpPagePath } from '~/helpers/help_page_helper';
import { PROMO_URL } from 'jh_else_ce/lib/utils/url_utility';
import { __ } from '~/locale';
import { STORAGE_KEY } from '~/whats_new/utils/notification';
import Tracking from '~/tracking';
import { HELP_MENU_TRACKING_DEFAULTS } from '../constants';
export default {
components: {
@ -14,6 +16,7 @@ export default {
GlDisclosureDropdownGroup,
GitlabVersionCheckBadge,
},
mixins: [Tracking.mixin({ property: 'nav_help_menu' })],
i18n: {
help: __('Help'),
support: __('Support'),
@ -46,21 +49,63 @@ export default {
text: this.$options.i18n.version,
href: helpPagePath('update/index'),
version: `${this.sidebarData.gitlab_version.major}.${this.sidebarData.gitlab_version.minor}`,
extraAttrs: {
...this.trackingAttrs('version_help_dropdown'),
},
},
],
},
helpLinks: {
items: [
{ text: this.$options.i18n.help, href: helpPagePath() },
{ text: this.$options.i18n.support, href: this.sidebarData.support_path },
{ text: this.$options.i18n.docs, href: 'https://docs.gitlab.com' },
{ text: this.$options.i18n.plans, href: `${PROMO_URL}/pricing` },
{ text: this.$options.i18n.forum, href: 'https://forum.gitlab.com/' },
{
text: this.$options.i18n.help,
href: helpPagePath(),
extraAttrs: {
...this.trackingAttrs('help'),
},
},
{
text: this.$options.i18n.support,
href: this.sidebarData.support_path,
extraAttrs: {
...this.trackingAttrs('support'),
},
},
{
text: this.$options.i18n.docs,
href: 'https://docs.gitlab.com',
extraAttrs: {
...this.trackingAttrs('gitlab_documentation'),
},
},
{
text: this.$options.i18n.plans,
href: `${PROMO_URL}/pricing`,
extraAttrs: {
...this.trackingAttrs('compare_gitlab_plans'),
},
},
{
text: this.$options.i18n.forum,
href: 'https://forum.gitlab.com/',
extraAttrs: {
...this.trackingAttrs('community_forum'),
},
},
{
text: this.$options.i18n.contribute,
href: helpPagePath('', { anchor: 'contributing-to-gitlab' }),
extraAttrs: {
...this.trackingAttrs('contribute_to_gitlab'),
},
},
{
text: this.$options.i18n.feedback,
href: 'https://about.gitlab.com/submit-feedback',
extraAttrs: {
...this.trackingAttrs('submit_feedback'),
},
},
{ text: this.$options.i18n.feedback, href: 'https://about.gitlab.com/submit-feedback' },
],
},
helpActions: {
@ -70,6 +115,9 @@ export default {
action: this.showKeyboardShortcuts,
extraAttrs: {
class: 'js-shortcuts-modal-trigger',
'data-track-action': 'click_button',
'data-track-label': 'keyboard_shortcuts_help',
'data-track-property': HELP_MENU_TRACKING_DEFAULTS['data-track-property'],
},
shortcut: '?',
},
@ -79,6 +127,11 @@ export default {
count:
this.showWhatsNewNotification &&
this.sidebarData.whats_new_most_recent_release_items_count,
extraAttrs: {
'data-track-action': 'click_button',
'data-track-label': 'whats_new',
'data-track-property': HELP_MENU_TRACKING_DEFAULTS['data-track-property'],
},
},
].filter(Boolean),
},
@ -118,12 +171,29 @@ export default {
this.toggleWhatsNewDrawer();
}
},
trackingAttrs(label) {
return {
...HELP_MENU_TRACKING_DEFAULTS,
'data-track-label': label,
};
},
trackDropdownToggle(show) {
this.track('click_toggle', {
label: show ? 'show_help_dropdown' : 'hide_help_dropdown',
});
},
},
};
</script>
<template>
<gl-disclosure-dropdown ref="dropdown">
<gl-disclosure-dropdown
ref="dropdown"
@shown="trackDropdownToggle(true)"
@hidden="trackDropdownToggle(false)"
>
<template #toggle>
<gl-button category="tertiary" icon="question-o" class="btn-with-notification">
<span v-if="showWhatsNewNotification" class="notification-dot-info"></span>

View File

@ -25,3 +25,8 @@ export const USER_MENU_TRACKING_DEFAULTS = {
'data-track-property': 'nav_user_menu',
'data-track-action': 'click_link',
};
export const HELP_MENU_TRACKING_DEFAULTS = {
'data-track-property': 'nav_help_menu',
'data-track-action': 'click_link',
};

View File

@ -13,6 +13,7 @@ class NamespaceSetting < ApplicationRecord
enum enabled_git_access_protocol: { all: 0, ssh: 1, http: 2 }, _suffix: true
validates :enabled_git_access_protocol, inclusion: { in: enabled_git_access_protocols.keys }
validates :code_suggestions, allow_nil: false, inclusion: { in: [true, false] }
validate :allow_mfa_for_group
validate :allow_resource_access_token_creation_for_group

View File

@ -16,7 +16,7 @@
.settings-content
= render 'groups/settings/general'
%section.settings.gs-permissions.no-animate#js-permissions-settings{ class: ('expanded' if expanded), data: { qa_selector: 'permission_lfs_2fa_content' } }
%section.settings.gs-permissions.no-animate#js-permissions-settings{ class: ('expanded' if expanded), data: { qa_selector: 'permission_lfs_2fa_content', testid: 'permissions-settings' } }
.settings-header
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only{ role: 'button' }
= _('Permissions and group features')

View File

@ -38,6 +38,7 @@
- if @group.licensed_feature_available?(:group_wikis)
= render_if_exists 'groups/settings/wiki', f: f, group: @group
= render 'groups/settings/lfs', f: f
= render_if_exists 'groups/settings/code_suggestions', f: f, group: @group
= render 'groups/settings/git_access_protocols', f: f, group: @group
= render 'groups/settings/project_creation_level', f: f, group: @group
= render 'groups/settings/subgroup_creation_level', f: f, group: @group

View File

@ -10407,6 +10407,18 @@ msgstr ""
msgid "CodeQuality|New code quality degradations on this line"
msgstr ""
msgid "CodeSuggestions|%{link_start}What are code suggestions?%{link_end}"
msgstr ""
msgid "CodeSuggestions|By enabling this feature, you accept the %{link_start}Testing Terms of Use%{link_end}."
msgstr ""
msgid "CodeSuggestions|Code Suggestions"
msgstr ""
msgid "CodeSuggestions|Projects in this group can use Code Suggestions in VS Code"
msgstr ""
msgid "Cohorts|Inactive users"
msgstr ""
@ -51233,6 +51245,9 @@ msgstr ""
msgid "banned user already exists"
msgstr ""
msgid "beta"
msgstr ""
msgid "blocks"
msgstr ""

View File

@ -1,4 +1,4 @@
import { GlDisclosureDropdownGroup } from '@gitlab/ui';
import { GlDisclosureDropdown, GlDisclosureDropdownGroup } from '@gitlab/ui';
import { within } from '@testing-library/dom';
import toggleWhatsNewDrawer from '~/whats_new';
import { mountExtended } from 'helpers/vue_test_utils_helper';
@ -7,15 +7,18 @@ import { helpPagePath } from '~/helpers/help_page_helper';
import { PROMO_URL } from 'jh_else_ce/lib/utils/url_utility';
import { useLocalStorageSpy } from 'helpers/local_storage_helper';
import { STORAGE_KEY } from '~/whats_new/utils/notification';
import { mockTracking } from 'helpers/tracking_helper';
import { sidebarData } from '../mock_data';
jest.mock('~/whats_new');
describe('HelpCenter component', () => {
let wrapper;
let trackingSpy;
const GlEmoji = { template: '<img/>' };
const findDropdown = () => wrapper.findComponent(GlDisclosureDropdown);
const findDropdownGroup = (i = 0) => {
return wrapper.findAllComponents(GlDisclosureDropdownGroup).at(i);
};
@ -28,6 +31,15 @@ describe('HelpCenter component', () => {
propsData: { sidebarData },
stubs: { GlEmoji },
});
trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn);
};
const trackingAttrs = (label) => {
return {
'data-track-action': 'click_link',
'data-track-property': 'nav_help_menu',
'data-track-label': label,
};
};
describe('default', () => {
@ -37,16 +49,37 @@ describe('HelpCenter component', () => {
it('renders menu items', () => {
expect(findDropdownGroup(0).props('group').items).toEqual([
{ text: HelpCenter.i18n.help, href: helpPagePath() },
{ text: HelpCenter.i18n.support, href: sidebarData.support_path },
{ text: HelpCenter.i18n.docs, href: 'https://docs.gitlab.com' },
{ text: HelpCenter.i18n.plans, href: `${PROMO_URL}/pricing` },
{ text: HelpCenter.i18n.forum, href: 'https://forum.gitlab.com/' },
{ text: HelpCenter.i18n.help, href: helpPagePath(), extraAttrs: trackingAttrs('help') },
{
text: HelpCenter.i18n.support,
href: sidebarData.support_path,
extraAttrs: trackingAttrs('support'),
},
{
text: HelpCenter.i18n.docs,
href: 'https://docs.gitlab.com',
extraAttrs: trackingAttrs('gitlab_documentation'),
},
{
text: HelpCenter.i18n.plans,
href: `${PROMO_URL}/pricing`,
extraAttrs: trackingAttrs('compare_gitlab_plans'),
},
{
text: HelpCenter.i18n.forum,
href: 'https://forum.gitlab.com/',
extraAttrs: trackingAttrs('community_forum'),
},
{
text: HelpCenter.i18n.contribute,
href: helpPagePath('', { anchor: 'contributing-to-gitlab' }),
extraAttrs: trackingAttrs('contribute_to_gitlab'),
},
{
text: HelpCenter.i18n.feedback,
href: 'https://about.gitlab.com/submit-feedback',
extraAttrs: trackingAttrs('submit_feedback'),
},
{ text: HelpCenter.i18n.feedback, href: 'https://about.gitlab.com/submit-feedback' },
]);
expect(findDropdownGroup(1).props('group').items).toEqual([
@ -62,7 +95,12 @@ describe('HelpCenter component', () => {
it('shows version information as first item', () => {
expect(findDropdownGroup(0).props('group').items).toEqual([
{ text: HelpCenter.i18n.version, href: helpPagePath('update/index'), version: '16.0' },
{
text: HelpCenter.i18n.version,
href: helpPagePath('update/index'),
version: '16.0',
extraAttrs: trackingAttrs('version_help_dropdown'),
},
]);
});
});
@ -86,11 +124,24 @@ describe('HelpCenter component', () => {
// ~/behaviors/shortcuts/shortcuts.js.
expect(button.classList.contains('js-shortcuts-modal-trigger')).toBe(true);
});
it('should have Snowplow tracking attributes', () => {
expect(findButton('Keyboard shortcuts ?').dataset).toEqual(
expect.objectContaining({
trackAction: 'click_button',
trackLabel: 'keyboard_shortcuts_help',
trackProperty: 'nav_help_menu',
}),
);
});
});
describe('showWhatsNew', () => {
beforeEach(() => {
jest.spyOn(wrapper.vm.$refs.dropdown, 'close');
beforeEach(() => {
createWrapper({ ...sidebarData, show_version_check: true });
});
findButton("What's new 5").click();
});
@ -107,6 +158,18 @@ describe('HelpCenter component', () => {
expect(toggleWhatsNewDrawer).toHaveBeenCalledTimes(2);
expect(toggleWhatsNewDrawer).toHaveBeenLastCalledWith();
});
it('should have Snowplow tracking attributes', () => {
createWrapper({ ...sidebarData, display_whats_new: true });
expect(findButton("What's new 5").dataset).toEqual(
expect.objectContaining({
trackAction: 'click_button',
trackLabel: 'whats_new',
trackProperty: 'nav_help_menu',
}),
);
});
});
describe('shouldShowWhatsNewNotification', () => {
@ -153,5 +216,23 @@ describe('HelpCenter component', () => {
});
});
});
describe('toggle dropdown', () => {
it('should track Snowplow event when dropdown is shown', () => {
findDropdown().vm.$emit('shown');
expect(trackingSpy).toHaveBeenCalledWith(undefined, 'click_toggle', {
label: 'show_help_dropdown',
property: 'nav_help_menu',
});
});
it('should track Snowplow event when dropdown is hidden', () => {
findDropdown().vm.$emit('hidden');
expect(trackingSpy).toHaveBeenCalledWith(undefined, 'click_toggle', {
label: 'hide_help_dropdown',
property: 'nav_help_menu',
});
});
});
});
});

View File

@ -15,6 +15,8 @@ RSpec.describe NamespaceSetting, feature_category: :subgroups, type: :model do
it { is_expected.to define_enum_for(:enabled_git_access_protocol).with_values([:all, :ssh, :http]).with_suffix }
describe "validations" do
it { is_expected.to validate_inclusion_of(:code_suggestions).in_array([true, false]) }
describe "#default_branch_name_content" do
let_it_be(:group) { create(:group) }

View File

@ -2,9 +2,13 @@
require 'spec_helper'
RSpec.describe 'groups/edit.html.haml' do
RSpec.describe 'groups/edit.html.haml', feature_category: :subgroups do
include Devise::Test::ControllerHelpers
before do
stub_template 'groups/settings/_code_suggestions' => ''
end
describe '"Share with group lock" setting' do
let(:root_owner) { create(:user) }
let(:root_group) { create(:group) }