Skip to content

Commit

Permalink
Update routers
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Jun 17, 2021
1 parent c49e004 commit aebdca9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { SourceAdded } from './views/content_sources/components/source_added';
import { SourceSubNav } from './views/content_sources/components/source_sub_nav';
import { ErrorState } from './views/error_state';
import { GroupsRouter } from './views/groups';
import { GroupSubNav } from './views/groups/components/group_sub_nav';
import { Overview } from './views/overview';
import { RoleMappings } from './views/role_mappings';
import { Security } from './views/security';
Expand All @@ -64,7 +63,6 @@ export const WorkplaceSearchConfigured: React.FC<InitialAppData> = (props) => {

// We don't want so show the subnavs on the container root pages.
const showSourcesSubnav = pathname !== SOURCES_PATH && pathname !== PERSONAL_SOURCES_PATH;
const showGroupsSubnav = pathname !== GROUPS_PATH;

/**
* Personal dashboard urls begin with /p/
Expand Down Expand Up @@ -132,13 +130,7 @@ export const WorkplaceSearchConfigured: React.FC<InitialAppData> = (props) => {
</Layout>
</Route>
<Route path={GROUPS_PATH}>
<Layout
navigation={<WorkplaceSearchNav groupsSubNav={showGroupsSubnav && <GroupSubNav />} />}
restrictWidth
readOnlyMode={readOnlyMode}
>
<GroupsRouter />
</Layout>
<GroupsRouter />
</Route>
<Route path={ROLE_MAPPINGS_PATH}>
<RoleMappings />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ import { Route, Switch } from 'react-router-dom';

import { shallow } from 'enzyme';

import { FlashMessages } from '../../../shared/flash_messages';
import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';

import { GroupOverview } from './components/group_overview';
import { GroupSourcePrioritization } from './components/group_source_prioritization';
import { ManageUsersModal } from './components/manage_users_modal';
Expand All @@ -40,10 +37,10 @@ describe('GroupRouter', () => {
resetGroup,
});
});

it('renders', () => {
const wrapper = shallow(<GroupRouter />);

expect(wrapper.find(FlashMessages)).toHaveLength(1);
expect(wrapper.find(Switch)).toHaveLength(1);
expect(wrapper.find(Route)).toHaveLength(2);
expect(wrapper.find(GroupOverview)).toHaveLength(1);
Expand All @@ -62,22 +59,4 @@ describe('GroupRouter', () => {
expect(wrapper.find(ManageUsersModal)).toHaveLength(1);
expect(wrapper.find(SharedSourcesModal)).toHaveLength(1);
});

it('handles breadcrumbs while loading', () => {
setMockValues({
sharedSourcesModalVisible: false,
manageUsersModalVisible: false,
group: {},
});

const loadingBreadcrumbs = ['Groups', '...'];

const wrapper = shallow(<GroupRouter />);

const firstBreadCrumb = wrapper.find(SetPageChrome).first();
const lastBreadCrumb = wrapper.find(SetPageChrome).last();

expect(firstBreadCrumb.prop('trail')).toEqual([...loadingBreadcrumbs, 'Source Prioritization']);
expect(lastBreadCrumb.prop('trail')).toEqual(loadingBreadcrumbs);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import { Route, Switch, useParams } from 'react-router-dom';

import { useActions, useValues } from 'kea';

import { FlashMessages } from '../../../shared/flash_messages';
import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { SendWorkplaceSearchTelemetry as SendTelemetry } from '../../../shared/telemetry';
import { NAV } from '../../constants';
import { GROUP_SOURCE_PRIORITIZATION_PATH, GROUP_PATH } from '../../routes';

import { GroupOverview } from './components/group_overview';
Expand All @@ -26,11 +22,7 @@ export const GroupRouter: React.FC = () => {
const { groupId } = useParams() as { groupId: string };

const { initializeGroup, resetGroup } = useActions(GroupLogic);
const {
sharedSourcesModalVisible,
manageUsersModalVisible,
group: { name },
} = useValues(GroupLogic);
const { sharedSourcesModalVisible, manageUsersModalVisible } = useValues(GroupLogic);

useEffect(() => {
initializeGroup(groupId);
Expand All @@ -39,15 +31,11 @@ export const GroupRouter: React.FC = () => {

return (
<>
<FlashMessages />
<Switch>
<Route path={GROUP_SOURCE_PRIORITIZATION_PATH}>
<SetPageChrome trail={[NAV.GROUPS, name || '...', NAV.SOURCE_PRIORITIZATION]} />
<GroupSourcePrioritization />
</Route>
<Route path={GROUP_PATH}>
<SetPageChrome trail={[NAV.GROUPS, name || '...']} />
<SendTelemetry action="viewed" metric="group_overview" />
<GroupOverview />
</Route>
</Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import { Route, Switch } from 'react-router-dom';

import { useActions } from 'kea';

import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { SendWorkplaceSearchTelemetry as SendTelemetry } from '../../../shared/telemetry';
import { NAV } from '../../constants';
import { GROUP_PATH, GROUPS_PATH } from '../../routes';

import { GroupRouter } from './group_router';
Expand All @@ -31,8 +28,6 @@ export const GroupsRouter: React.FC = () => {
return (
<Switch>
<Route exact path={GROUPS_PATH}>
<SetPageChrome trail={[NAV.GROUPS]} />
<SendTelemetry action="viewed" metric="groups" />
<Groups />
</Route>
<Route path={GROUP_PATH}>
Expand Down

0 comments on commit aebdca9

Please sign in to comment.