Commit 337207b3 authored by Stan Hu's avatar Stan Hu

Merge branch '2256-add-customer-relations-root-appss' into 'master'

Add customer relations menu item and root apps

See merge request gitlab-org/gitlab!72787
parents 2645e1ff 5bcce579
<script>
export default {};
</script>
<template>
<div></div>
</template>
<script>
export default {};
</script>
<template>
<div></div>
</template>
import Vue from 'vue';
import CrmContactsRoot from './components/contacts_root.vue';
export default () => {
const el = document.getElementById('js-crm-contacts-app');
if (!el) {
return false;
}
return new Vue({
el,
render(createElement) {
return createElement(CrmContactsRoot);
},
});
};
import Vue from 'vue';
import CrmOrganizationsRoot from './components/organizations_root.vue';
export default () => {
const el = document.getElementById('js-crm-organizations-app');
if (!el) {
return false;
}
return new Vue({
el,
render(createElement) {
return createElement(CrmOrganizationsRoot);
},
});
};
import initCrmContactsApp from '~/crm/contacts_bundle';
initCrmContactsApp();
import initCrmOrganizationsApp from '~/crm/organizations_bundle';
initCrmOrganizationsApp();
# frozen_string_literal: true
class Groups::CrmController < Groups::ApplicationController
feature_category :team_planning
before_action :authorize_read_crm_contact!, only: [:contacts]
before_action :authorize_read_crm_organization!, only: [:organizations]
def contacts
respond_to do |format|
format.html
end
end
def organizations
respond_to do |format|
format.html
end
end
private
def authorize_read_crm_contact!
render_404 unless can?(current_user, :read_crm_contact, group)
end
def authorize_read_crm_organization!
render_404 unless can?(current_user, :read_crm_organization, group)
end
end
- breadcrumb_title _('Customer Relations Contacts')
- page_title _('Customer Relations Contacts')
#js-crm-contacts-app
- breadcrumb_title _('Customer Relations Organizations')
- page_title _('Customer Relations Organizations')
#js-crm-organizations-app
...@@ -125,6 +125,13 @@ constraints(::Constraints::GroupUrlConstrainer.new) do ...@@ -125,6 +125,13 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
get 'milestones' get 'milestones'
end end
end end
resources :crm, only: [] do
collection do
get 'contacts'
get 'organizations'
end
end
end end
scope(path: '*id', scope(path: '*id',
......
...@@ -15,6 +15,7 @@ RSpec.describe 'Group navbar' do ...@@ -15,6 +15,7 @@ RSpec.describe 'Group navbar' do
before do before do
group.add_maintainer(user) group.add_maintainer(user)
stub_feature_flags(group_iterations: false) stub_feature_flags(group_iterations: false)
stub_feature_flags(customer_relations: false)
stub_group_wikis(false) stub_group_wikis(false)
sign_in(user) sign_in(user)
...@@ -190,6 +191,18 @@ RSpec.describe 'Group navbar' do ...@@ -190,6 +191,18 @@ RSpec.describe 'Group navbar' do
it_behaves_like 'verified navigation bar' it_behaves_like 'verified navigation bar'
end end
context 'when customer_relations feature flag is enabled' do
before do
stub_feature_flags(customer_relations: true)
insert_customer_relations_nav(_('Analytics'))
visit group_path(group)
end
it_behaves_like 'verified navigation bar'
end
end end
context 'when iterations are available' do context 'when iterations are available' do
......
# frozen_string_literal: true
module Sidebars
module Groups
module Menus
class CustomerRelationsMenu < ::Sidebars::Menu
override :configure_menu_items
def configure_menu_items
add_item(contacts_menu_item) if can_read_contact?
add_item(organizations_menu_item) if can_read_organization?
true
end
override :title
def title
_('Customer relations')
end
override :sprite_icon
def sprite_icon
'users'
end
override :render?
def render?
can_read_contact? || can_read_organization?
end
private
def contacts_menu_item
::Sidebars::MenuItem.new(
title: _('Contacts'),
link: contacts_group_crm_index_path(context.group),
active_routes: { path: 'groups/crm#contacts' },
item_id: :crm_contacts
)
end
def organizations_menu_item
::Sidebars::MenuItem.new(
title: _('Organizations'),
link: organizations_group_crm_index_path(context.group),
active_routes: { path: 'groups/crm#organizations' },
item_id: :crm_organizations
)
end
def can_read_contact?
can?(context.current_user, :read_crm_contact, context.group)
end
def can_read_organization?
can?(context.current_user, :read_crm_organization, context.group)
end
end
end
end
end
...@@ -13,6 +13,7 @@ module Sidebars ...@@ -13,6 +13,7 @@ module Sidebars
add_menu(Sidebars::Groups::Menus::CiCdMenu.new(context)) add_menu(Sidebars::Groups::Menus::CiCdMenu.new(context))
add_menu(Sidebars::Groups::Menus::KubernetesMenu.new(context)) add_menu(Sidebars::Groups::Menus::KubernetesMenu.new(context))
add_menu(Sidebars::Groups::Menus::PackagesRegistriesMenu.new(context)) add_menu(Sidebars::Groups::Menus::PackagesRegistriesMenu.new(context))
add_menu(Sidebars::Groups::Menus::CustomerRelationsMenu.new(context))
add_menu(Sidebars::Groups::Menus::SettingsMenu.new(context)) add_menu(Sidebars::Groups::Menus::SettingsMenu.new(context))
end end
......
...@@ -8830,6 +8830,9 @@ msgstr "" ...@@ -8830,6 +8830,9 @@ msgstr ""
msgid "Contact support" msgid "Contact support"
msgstr "" msgstr ""
msgid "Contacts"
msgstr ""
msgid "Container Registry" msgid "Container Registry"
msgstr "" msgstr ""
...@@ -10102,6 +10105,15 @@ msgstr "" ...@@ -10102,6 +10105,15 @@ msgstr ""
msgid "Custom range (UTC)" msgid "Custom range (UTC)"
msgstr "" msgstr ""
msgid "Customer Relations Contacts"
msgstr ""
msgid "Customer Relations Organizations"
msgstr ""
msgid "Customer relations"
msgstr ""
msgid "Customizable by an administrator." msgid "Customizable by an administrator."
msgstr "" msgstr ""
...@@ -24185,6 +24197,9 @@ msgstr "" ...@@ -24185,6 +24197,9 @@ msgstr ""
msgid "Or you can choose one of the suggested colors below" msgid "Or you can choose one of the suggested colors below"
msgstr "" msgstr ""
msgid "Organizations"
msgstr ""
msgid "Orphaned member" msgid "Orphaned member"
msgstr "" msgstr ""
......
...@@ -15,6 +15,7 @@ RSpec.describe 'Group navbar' do ...@@ -15,6 +15,7 @@ RSpec.describe 'Group navbar' do
insert_package_nav(_('Kubernetes')) insert_package_nav(_('Kubernetes'))
stub_feature_flags(group_iterations: false) stub_feature_flags(group_iterations: false)
stub_feature_flags(customer_relations: false)
stub_config(dependency_proxy: { enabled: false }) stub_config(dependency_proxy: { enabled: false })
stub_config(registry: { enabled: false }) stub_config(registry: { enabled: false })
stub_group_wikis(false) stub_group_wikis(false)
...@@ -40,6 +41,22 @@ RSpec.describe 'Group navbar' do ...@@ -40,6 +41,22 @@ RSpec.describe 'Group navbar' do
it_behaves_like 'verified navigation bar' it_behaves_like 'verified navigation bar'
end end
context 'when customer_relations feature flag is enabled' do
before do
stub_feature_flags(customer_relations: true)
if Gitlab.ee?
insert_customer_relations_nav(_('Analytics'))
else
insert_customer_relations_nav(_('Packages & Registries'))
end
visit group_path(group)
end
it_behaves_like 'verified navigation bar'
end
context 'when dependency proxy is available' do context 'when dependency proxy is available' do
before do before do
stub_config(dependency_proxy: { enabled: true }) stub_config(dependency_proxy: { enabled: true })
......
...@@ -29,6 +29,19 @@ module NavbarStructureHelper ...@@ -29,6 +29,19 @@ module NavbarStructureHelper
) )
end end
def insert_customer_relations_nav(within)
insert_after_nav_item(
within,
new_nav_item: {
nav_item: _('Customer relations'),
nav_sub_items: [
_('Contacts'),
_('Organizations')
]
}
)
end
def insert_container_nav def insert_container_nav
insert_after_sub_nav_item( insert_after_sub_nav_item(
_('Package Registry'), _('Package Registry'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment