diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/pages/groups/details/index.js | 5 | ||||
-rw-r--r-- | app/assets/javascripts/pages/groups/shared/group_details.js | 31 | ||||
-rw-r--r-- | app/assets/javascripts/pages/groups/shared/group_tabs.js (renamed from app/assets/javascripts/pages/groups/show/group_tabs.js) | 0 | ||||
-rw-r--r-- | app/assets/javascripts/pages/groups/show/index.js | 27 | ||||
-rw-r--r-- | app/assets/javascripts/pages/users/user_tabs.js | 1 | ||||
-rw-r--r-- | app/controllers/groups_controller.rb | 36 | ||||
-rw-r--r-- | app/helpers/groups_helper.rb | 1 | ||||
-rw-r--r-- | app/views/layouts/nav/sidebar/_group.html.haml | 11 |
8 files changed, 77 insertions, 35 deletions
diff --git a/app/assets/javascripts/pages/groups/details/index.js b/app/assets/javascripts/pages/groups/details/index.js new file mode 100644 index 00000000000..3bcaa0f0232 --- /dev/null +++ b/app/assets/javascripts/pages/groups/details/index.js @@ -0,0 +1,5 @@ +import initGroupDetails from '../shared/group_details'; + +document.addEventListener('DOMContentLoaded', () => { + initGroupDetails('details'); +}); diff --git a/app/assets/javascripts/pages/groups/shared/group_details.js b/app/assets/javascripts/pages/groups/shared/group_details.js new file mode 100644 index 00000000000..01ef3f1db2b --- /dev/null +++ b/app/assets/javascripts/pages/groups/shared/group_details.js @@ -0,0 +1,31 @@ +/* eslint-disable no-new */ + +import { getPagePath } from '~/lib/utils/common_utils'; +import { ACTIVE_TAB_SHARED, ACTIVE_TAB_ARCHIVED } from '~/groups/constants'; +import NewGroupChild from '~/groups/new_group_child'; +import notificationsDropdown from '~/notifications_dropdown'; +import NotificationsForm from '~/notifications_form'; +import ProjectsList from '~/projects_list'; +import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation'; +import GroupTabs from './group_tabs'; + +export default function initGroupDetails(actionName = 'show') { + const newGroupChildWrapper = document.querySelector('.js-new-project-subgroup'); + const loadableActions = [ACTIVE_TAB_SHARED, ACTIVE_TAB_ARCHIVED]; + const paths = window.location.pathname.split('/'); + const subpath = paths[paths.length - 1]; + let action = loadableActions.includes(subpath) ? subpath : getPagePath(1); + if (actionName && action === actionName) { + action = 'show'; // 'show' resets GroupTabs to default action through base class + } + + new GroupTabs({ parentEl: '.groups-listing', action }); + new ShortcutsNavigation(); + new NotificationsForm(); + notificationsDropdown(); + new ProjectsList(); + + if (newGroupChildWrapper) { + new NewGroupChild(newGroupChildWrapper); + } +} diff --git a/app/assets/javascripts/pages/groups/show/group_tabs.js b/app/assets/javascripts/pages/groups/shared/group_tabs.js index c6fe61d2bd9..c6fe61d2bd9 100644 --- a/app/assets/javascripts/pages/groups/show/group_tabs.js +++ b/app/assets/javascripts/pages/groups/shared/group_tabs.js diff --git a/app/assets/javascripts/pages/groups/show/index.js b/app/assets/javascripts/pages/groups/show/index.js index 3a45fd70d02..af924e74f1f 100644 --- a/app/assets/javascripts/pages/groups/show/index.js +++ b/app/assets/javascripts/pages/groups/show/index.js @@ -1,28 +1,5 @@ -/* eslint-disable no-new */ - -import { getPagePath } from '~/lib/utils/common_utils'; -import { ACTIVE_TAB_SHARED, ACTIVE_TAB_ARCHIVED } from '~/groups/constants'; -import NewGroupChild from '~/groups/new_group_child'; -import notificationsDropdown from '~/notifications_dropdown'; -import NotificationsForm from '~/notifications_form'; -import ProjectsList from '~/projects_list'; -import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation'; -import GroupTabs from './group_tabs'; +import initGroupDetails from '../shared/group_details'; document.addEventListener('DOMContentLoaded', () => { - const newGroupChildWrapper = document.querySelector('.js-new-project-subgroup'); - const loadableActions = [ACTIVE_TAB_SHARED, ACTIVE_TAB_ARCHIVED]; - const paths = window.location.pathname.split('/'); - const subpath = paths[paths.length - 1]; - const action = loadableActions.includes(subpath) ? subpath : getPagePath(1); - - new GroupTabs({ parentEl: '.groups-listing', action }); - new ShortcutsNavigation(); - new NotificationsForm(); - notificationsDropdown(); - new ProjectsList(); - - if (newGroupChildWrapper) { - new NewGroupChild(newGroupChildWrapper); - } + initGroupDetails(); }); diff --git a/app/assets/javascripts/pages/users/user_tabs.js b/app/assets/javascripts/pages/users/user_tabs.js index 636308c5401..7f800d20835 100644 --- a/app/assets/javascripts/pages/users/user_tabs.js +++ b/app/assets/javascripts/pages/users/user_tabs.js @@ -91,6 +91,7 @@ export default class UserTabs { this.actions = Object.keys(this.loaded); this.bindEvents(); + // TODO: refactor to make this configurable via constructor params with a default value of 'show' if (this.action === 'show') { this.action = this.defaultAction; } diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 4e50106398a..0192b1c253e 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -58,11 +58,24 @@ class GroupsController < Groups::ApplicationController def show respond_to do |format| - format.html + format.html do + render_show_html + end format.atom do - load_events - render layout: 'xml.atom' + render_details_view_atom + end + end + end + + def details + respond_to do |format| + format.html do + render_details_html + end + + format.atom do + render_details_view_atom end end end @@ -119,6 +132,19 @@ class GroupsController < Groups::ApplicationController protected + def render_show_html + render 'groups/show' + end + + def render_details_html + render 'groups/show' + end + + def render_details_view_atom + load_events + render layout: 'xml.atom', template: 'groups/show' + end + # rubocop: disable CodeReuse/ActiveRecord def authorize_create_group! allowed = if params[:parent_id].present? @@ -178,8 +204,8 @@ class GroupsController < Groups::ApplicationController .includes(:namespace) @events = EventCollection - .new(@projects, offset: params[:offset].to_i, filter: event_filter) - .to_a + .new(@projects, offset: params[:offset].to_i, filter: event_filter) + .to_a Events::RenderService .new(current_user) diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 4a9ed123161..9d028dccad7 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -4,6 +4,7 @@ module GroupsHelper def group_overview_nav_link_paths %w[ groups#show + groups#details groups#activity groups#subgroups analytics#show diff --git a/app/views/layouts/nav/sidebar/_group.html.haml b/app/views/layouts/nav/sidebar/_group.html.haml index 21ea9f3b2f3..eefe86eb6b4 100644 --- a/app/views/layouts/nav/sidebar/_group.html.haml +++ b/app/views/layouts/nav/sidebar/_group.html.haml @@ -20,13 +20,14 @@ = _('Overview') %ul.sidebar-sub-level-items - = nav_link(path: ['groups#show', 'groups#activity', 'groups#subgroups'], html_options: { class: "fly-out-top-item" } ) do + = nav_link(path: ['groups#show', 'groups#details', 'groups#activity', 'groups#subgroups'], html_options: { class: "fly-out-top-item" } ) do = link_to group_path(@group) do %strong.fly-out-top-item-name = _('Overview') %li.divider.fly-out-top-item - = nav_link(path: ['groups#show', 'groups#subgroups'], html_options: { class: 'home' }) do - = link_to group_path(@group), title: _('Group details') do + + = nav_link(path: ['groups#show', 'groups#details', 'groups#subgroups'], html_options: { class: 'home' }) do + = link_to details_group_path(@group), title: _('Group details') do %span = _('Details') @@ -40,9 +41,9 @@ - if group_sidebar_link?(:contribution_analytics) = nav_link(path: 'analytics#show') do - = link_to group_analytics_path(@group), title: 'Contribution Analytics', data: {placement: 'right'} do + = link_to group_analytics_path(@group), title: _('Contribution Analytics'), data: { placement: 'right' } do %span - Contribution Analytics + = _('Contribution Analytics') = render_if_exists "layouts/nav/ee/epic_link", group: @group |