Commit 5193dfae authored by Clement Ho's avatar Clement Ho

Merge branch '53041-groups-named-shared' into 'master'

Fix for #24832, naming a project  "shared" will not open the "Shared Projects" tab

Closes #24832

See merge request gitlab-org/gitlab!16847
parents 3ab72627 64b0ed0c
...@@ -15,6 +15,8 @@ export const getPagePath = (index = 0) => { ...@@ -15,6 +15,8 @@ export const getPagePath = (index = 0) => {
return page.split(':')[index]; return page.split(':')[index];
}; };
export const getDashPath = (path = window.location.pathname) => path.split('/-/')[1] || null;
export const isInGroupsPage = () => getPagePath() === 'groups'; export const isInGroupsPage = () => getPagePath() === 'groups';
export const isInProjectPage = () => getPagePath() === 'projects'; export const isInProjectPage = () => getPagePath() === 'projects';
......
/* eslint-disable no-new */ /* eslint-disable no-new */
import { getPagePath } from '~/lib/utils/common_utils'; import { getPagePath, getDashPath } from '~/lib/utils/common_utils';
import { ACTIVE_TAB_SHARED, ACTIVE_TAB_ARCHIVED } from '~/groups/constants'; import { ACTIVE_TAB_SHARED, ACTIVE_TAB_ARCHIVED } from '~/groups/constants';
import NewGroupChild from '~/groups/new_group_child'; import NewGroupChild from '~/groups/new_group_child';
import notificationsDropdown from '~/notifications_dropdown'; import notificationsDropdown from '~/notifications_dropdown';
...@@ -12,9 +12,8 @@ import GroupTabs from './group_tabs'; ...@@ -12,9 +12,8 @@ import GroupTabs from './group_tabs';
export default function initGroupDetails(actionName = 'show') { export default function initGroupDetails(actionName = 'show') {
const newGroupChildWrapper = document.querySelector('.js-new-project-subgroup'); const newGroupChildWrapper = document.querySelector('.js-new-project-subgroup');
const loadableActions = [ACTIVE_TAB_SHARED, ACTIVE_TAB_ARCHIVED]; const loadableActions = [ACTIVE_TAB_SHARED, ACTIVE_TAB_ARCHIVED];
const paths = window.location.pathname.split('/'); const dashPath = getDashPath();
const subpath = paths[paths.length - 1]; let action = loadableActions.includes(dashPath) ? dashPath : getPagePath(1);
let action = loadableActions.includes(subpath) ? subpath : getPagePath(1);
if (actionName && action === actionName) { if (actionName && action === actionName) {
action = 'show'; // 'show' resets GroupTabs to default action through base class action = 'show'; // 'show' resets GroupTabs to default action through base class
} }
......
---
title: Naming a project "shared" will no longer automatically open the "Shared Projects" tab.
merge_request: 16847
author: Jesse Hall @jessehall3
type: fixed
...@@ -943,4 +943,14 @@ describe('common_utils', () => { ...@@ -943,4 +943,14 @@ describe('common_utils', () => {
expect(commonUtils.isScopedLabel({ title: 'foobar' })).toBe(false); expect(commonUtils.isScopedLabel({ title: 'foobar' })).toBe(false);
}); });
}); });
describe('getDashPath', () => {
it('returns the path following /-/', () => {
expect(commonUtils.getDashPath('/some/-/url-with-dashes-/')).toEqual('url-with-dashes-/');
});
it('returns null when no path follows /-/', () => {
expect(commonUtils.getDashPath('/some/url')).toEqual(null);
});
});
}); });
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