Skip to content

Commit

Permalink
Don't export SubNav, remove SubNavWithTabsContext
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-alan committed Nov 30, 2023
1 parent 4cab56f commit 5233f63
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
3 changes: 0 additions & 3 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ import { FindByIdsModal } from './internal/components/search/FindByIdsModal';
import { QueryFilterPanel } from './internal/components/search/QueryFilterPanel';
import { ProductNavigationMenu } from './internal/components/productnavigation/ProductNavigationMenu';
import { useSubNavTabsContext } from './internal/components/navigation/hooks';
import { SubNav, SubNavWithTabsContext } from './internal/components/navigation/SubNav';
import { Breadcrumb } from './internal/components/navigation/Breadcrumb';
import { BreadcrumbCreate } from './internal/components/navigation/BreadcrumbCreate';
import { MenuItemModel, MenuSectionModel, ProductMenuModel } from './internal/components/navigation/model';
Expand Down Expand Up @@ -1362,7 +1361,6 @@ export {
ProductNavigationMenu,
FindByIdsModal,
QueryFilterPanel,
SubNav,
Breadcrumb,
BreadcrumbCreate,
// notification related items
Expand Down Expand Up @@ -1655,7 +1653,6 @@ export {
useNotFound,
// SubNavTabsWithContext
useSubNavTabsContext,
SubNavWithTabsContext,
// BarTender
BarTenderConfiguration,
PrintLabelsModal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { User } from '../base/models/User';
import { useServerContext } from '../base/ServerContext';

import { isAdminRoute, ProductMenuButton } from './ProductMenu';
import { SubNavWithTabsContext } from './SubNav';
import { SubNav } from './SubNav';
import { UserMenuGroup, UserMenuProps } from './UserMenuGroup';
import { MenuSectionConfig } from './model';
import { SEARCH_PLACEHOLDER } from './constants';
Expand Down Expand Up @@ -171,7 +171,7 @@ export const NavigationBar: FC<Props> = memo(props => {
</nav>

<div className="sub-nav-wrapper">
<SubNavWithTabsContext />
<SubNav />
</div>
</div>
);
Expand Down
16 changes: 4 additions & 12 deletions packages/components/src/internal/components/navigation/SubNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/
import React, { FC, useRef, useState, useCallback, useEffect, memo, useMemo } from 'react';
import { List } from 'immutable';
import { Button } from 'react-bootstrap';

import { getServerContext } from '@labkey/api';
Expand All @@ -31,12 +30,10 @@ import { useSubNavTabsContext } from './hooks';

interface Props {
noun?: ITab;
tabs: List<ITab>; // TODO: convert to ITab[]
tabs: ITab[];
}

export const SubNav: FC<Props> = ({ noun, tabs }) => {
// FIXME: after all usages of SuNav are gone update this component to use the context to get noun/tabs and stop
// exporting in index
const SubNavImpl: FC<Props> = ({ noun, tabs }) => {
const location = useLocation();
const isAdminPage = useMemo(() => isAdminRoute(location.pathname), [location.pathname]);
const scrollable = useRef<HTMLDivElement>();
Expand Down Expand Up @@ -145,17 +142,12 @@ export const SubNav: FC<Props> = ({ noun, tabs }) => {
);
};

/**
* SubNavWithContext renders a SubNav component using data stored in the SubNavContext, this component is useful when
* you need to update the SubNav based on data you load asynchronously after the page loads.
*/
export const SubNavWithTabsContext: FC = memo(() => {
export const SubNav: FC = memo(() => {
const { noun, tabs } = useSubNavTabsContext();

if (tabs.length === 0 && noun === undefined) {
return null;
}

// FIXME: don't convert to List
return <SubNav noun={noun} tabs={List(tabs)} />;
return <SubNavImpl noun={noun} tabs={tabs} />;
});

0 comments on commit 5233f63

Please sign in to comment.