Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix nav violations (#74738)

Fraserb3e5ae05d12e
diff --git a/enterprise/frontend/src/metabase-enterprise/group_managers/actions.ts b/enterprise/frontend/src/metabase-enterprise/group_managers/actions.ts
index 6c245c46ac7..cb50e6fb238 100644
--- a/enterprise/frontend/src/metabase-enterprise/group_managers/actions.ts
+++ b/enterprise/frontend/src/metabase-enterprise/group_managers/actions.ts
@@ -1,8 +1,8 @@
import { push } from "react-router-redux";
-import { getAdminPaths } from "metabase/admin/app/selectors";
import { permissionApi } from "metabase/api";
import { createThunkAction } from "metabase/redux";
+import { getAdminPaths } from "metabase/selectors/admin";
import {
getRevokeManagerGroupsRedirect,
diff --git a/frontend/lint/module-boundaries.mjs b/frontend/lint/module-boundaries.mjs
index 290c6740ef2..e4efd834d62 100644
--- a/frontend/lint/module-boundaries.mjs
+++ b/frontend/lint/module-boundaries.mjs
@@ -163,6 +163,12 @@ const elements = [
mode: "full",
}),
),
+ createElement({
+ type: "app",
+ name: "nav",
+ pattern: "frontend/src/metabase/app/nav/**",
+ enforceOutgoing: true,
+ }),
// catch-all for unmoduled files - must be last
createElement({
type: "shared",
diff --git a/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.tsx b/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.tsx
index c6a5df88bfb..57a9dc3bdc2 100644
--- a/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.tsx
+++ b/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.tsx
@@ -17,7 +17,7 @@ import { COLLECTION_PAGE_SIZE } from "metabase/collections/components/Collection
import { CollectionItemsTable } from "metabase/collections/components/CollectionContent/CollectionItemsTable";
import { EmptyState } from "metabase/common/components/EmptyState";
import { useLocale } from "metabase/common/hooks/use-locale";
-import CollectionBreadcrumbs from "metabase/nav/containers/CollectionBreadcrumbs";
+import { CollectionBreadcrumbs } from "metabase/nav/containers/CollectionBreadcrumbs";
import { Icon, Stack } from "metabase/ui";
import { isNotNull } from "metabase/utils/types";
import type { CollectionId, CollectionItemModel } from "metabase-types/api";
diff --git a/frontend/src/metabase/App.tsx b/frontend/src/metabase/App.tsx
index fade233748a..8d00b7ab5e8 100644
--- a/frontend/src/metabase/App.tsx
+++ b/frontend/src/metabase/App.tsx
@@ -2,6 +2,8 @@ import type { Location } from "history";
import type { ReactNode } from "react";
import { useEffect, useState } from "react";
+import { AppBarContainer } from "metabase/app/nav/AppBar";
+import { Navbar } from "metabase/app/nav/Navbar";
import { AppBanner } from "metabase/common/components/AppBanner";
import {
Archived,
@@ -15,8 +17,6 @@ import { ContentViewportContext } from "metabase/common/context/ContentViewportC
import CS from "metabase/css/core/index.css";
import ScrollToTop from "metabase/hoc/ScrollToTop";
import { usePageTitle } from "metabase/hooks/use-page-title";
-import AppBar from "metabase/nav/containers/AppBar";
-import Navbar from "metabase/nav/containers/Navbar";
import { connect, useSelector } from "metabase/redux";
import { setErrorPage } from "metabase/redux/app";
import type { AppErrorDescriptor, State } from "metabase/redux/store";
@@ -116,7 +116,7 @@ function App({
<KeyboardTriggeredErrorModal />
<AppContainer className={CS.spread}>
<AppBanner />
- {isAppBarVisible && <AppBar />}
+ {isAppBarVisible && <AppBarContainer />}
<AppContentContainer isAdminApp={isAdminApp}>
{isNavBarEnabled && <Navbar />}
<AppContent ref={setViewportElement}>
diff --git a/frontend/src/metabase/AppKBarProvider.tsx b/frontend/src/metabase/AppKBarProvider.tsx
index 99caaa11dce..81a7f8b4788 100644
--- a/frontend/src/metabase/AppKBarProvider.tsx
+++ b/frontend/src/metabase/AppKBarProvider.tsx
@@ -1,11 +1,11 @@
import { KBarProvider, useKBar, useRegisterActions } from "kbar";
import { type PropsWithChildren, useMemo } from "react";
-import { getAdminPaths } from "metabase/admin/app/selectors";
import { getPerformanceAdminPaths } from "metabase/admin/performance/constants/complex";
import type { PaletteAction } from "metabase/palette/types";
import { PLUGIN_CACHING } from "metabase/plugins";
import { useSelector } from "metabase/redux";
+import { getAdminPaths } from "metabase/selectors/admin";
import { getUserIsAdmin } from "metabase/selectors/user";
export const AppKBarProvider = ({ children }: PropsWithChildren) => (
diff --git a/frontend/src/metabase/admin/app/selectors.ts b/frontend/src/metabase/admin/app/selectors.ts
index d3f9f8f0dce..354203207fa 100644
--- a/frontend/src/metabase/admin/app/selectors.ts
+++ b/frontend/src/metabase/admin/app/selectors.ts
@@ -16,10 +16,6 @@ export const hasDeprecatedDatabase = (state: State, props: Props): boolean => {
);
};
-export const getAdminPaths = (state: State) => {
- return state.admin?.app?.paths ?? [];
-};
-
export const isDeprecationNoticeEnabled = (state: State): boolean => {
// check if the deprecation notice has been dismissed on this version
return (
diff --git a/frontend/src/metabase/admin/performance/components/StrategyForm.tsx b/frontend/src/metabase/admin/performance/components/StrategyForm.tsx
index b4efb1eedb9..89e0c8e4402 100644
--- a/frontend/src/metabase/admin/performance/components/StrategyForm.tsx
+++ b/frontend/src/metabase/admin/performance/components/StrategyForm.tsx
@@ -41,11 +41,14 @@ import type {
} from "metabase-types/api";
import { CacheDurationUnit } from "metabase-types/api";
-import { strategyValidationSchema } from "../constants/complex";
import { defaultCronSchedule, rootId } from "../constants/simple";
import { useIsFormPending } from "../hooks/useIsFormPending";
import { isModelWithClearableCache } from "../types";
-import { getDefaultValueForField, getLabelString } from "../utils";
+import {
+ getDefaultValueForField,
+ getLabelString,
+ strategyValidationSchema,
+} from "../utils";
import PerformanceAppStyles from "./PerformanceApp.module.css";
import S from "./StrategyForm.module.css";
diff --git a/frontend/src/metabase/admin/performance/constants/complex.ts b/frontend/src/metabase/admin/performance/constants/complex.ts
index 461fd7e09a0..da2fb1a94f4 100644
--- a/frontend/src/metabase/admin/performance/constants/complex.ts
+++ b/frontend/src/metabase/admin/performance/constants/complex.ts
@@ -5,7 +5,6 @@ import type { AdminPath } from "metabase/redux/store";
import type { CacheableModel } from "metabase-types/api";
import { PerformanceTabId, type StrategyData } from "../types";
-import { getStrategyValidationSchema, isValidStrategyName } from "../utils";
import { defaultMinDurationMs } from "./simple";
@@ -36,40 +35,6 @@ export const getAdaptiveStrategyValidationSchema = () => {
});
};
-export const strategyValidationSchema = Yup.object().test(
- "strategy-validation",
- "The object must match one of the strategy validation schemas",
- function (value) {
- if (!value) {
- return this.createError({
- message: "Strategy is falsy",
- });
- }
- const { type } = value as unknown as { type: string };
- if (!isValidStrategyName(type)) {
- return this.createError({
- message: `"${type}" is not a valid strategy name`,
- path: "type",
- });
- }
- const schema = getStrategyValidationSchema(strategies[type]);
- try {
- schema.validateSync(value);
- return true;
- } catch (error: unknown) {
- if (error instanceof Yup.ValidationError) {
- return this.createError({
- message: error.message,
- path: error.path,
- });
- } else {
- console.error("Unhandled error:", error);
- return false;
- }
- }
- },
-) as Yup.AnySchema;
-
export const strategies = {
inherit: {
// NOTE: We use functions for labels because otherwise t doesn't work properly
diff --git a/frontend/src/metabase/admin/performance/utils.tsx b/frontend/src/metabase/admin/performance/utils.tsx
index f9abefde3d1..d85b4a21df3 100644
--- a/frontend/src/metabase/admin/performance/utils.tsx
+++ b/frontend/src/metabase/admin/performance/utils.tsx
@@ -1,5 +1,6 @@
import { match } from "ts-pattern";
import { c } from "ttag";
+import * as Yup from "yup";
import type { SchemaObjectDescription } from "yup/lib/schema";
import { cronToScheduleSettings } from "metabase/common/components/Schedule/cron";
@@ -14,6 +15,7 @@ import type {
CacheableModel,
} from "metabase-types/api";
+import { strategies } from "./constants/complex";
import { defaultMinDurationMs, rootId } from "./constants/simple";
import type { PerformanceTabId, StrategyData, StrategyLabel } from "./types";
@@ -98,6 +100,40 @@ export const getStrategyValidationSchema = (strategyData: StrategyData) => {
}
};
+export const strategyValidationSchema = Yup.object().test(
+ "strategy-validation",
+ "The object must match one of the strategy validation schemas",
+ function (value) {
+ if (!value) {
+ return this.createError({
+ message: "Strategy is falsy",
+ });
+ }
+ const { type } = value as unknown as { type: string };
+ if (!isValidStrategyName(type)) {
+ return this.createError({
+ message: `"${type}" is not a valid strategy name`,
+ path: "type",
+ });
+ }
+ const schema = getStrategyValidationSchema(strategies[type]);
+ try {
+ schema.validateSync(value);
+ return true;
+ } catch (error: unknown) {
+ if (error instanceof Yup.ValidationError) {
+ return this.createError({
+ message: error.message,
+ path: error.path,
+ });
+ } else {
+ console.error("Unhandled error:", error);
+ return false;
+ }
+ }
+ },
+) as Yup.AnySchema;
+
export const getFieldsForStrategyType = (strategyType: CacheStrategyType) => {
const { strategies } = PLUGIN_CACHING;
const strategyData = strategies[strategyType];
diff --git a/frontend/src/metabase/admin/utils.ts b/frontend/src/metabase/admin/utils.ts
index b38691524d4..9af8fdcb071 100644
--- a/frontend/src/metabase/admin/utils.ts
+++ b/frontend/src/metabase/admin/utils.ts
@@ -2,11 +2,11 @@ import { useLayoutEffect } from "react";
import { push, replace, routerActions } from "react-router-redux";
import { connectedReduxRedirect } from "redux-auth-wrapper/history3/redirect";
-import { getAdminPaths } from "metabase/admin/app/selectors";
import { shouldShowTenantsUpsell } from "metabase/admin/people/selectors";
import { connect, metabaseReduxContext } from "metabase/redux";
import type { State } from "metabase/redux/store";
import type { AdminPath } from "metabase/redux/store/admin";
+import { getAdminPaths } from "metabase/selectors/admin";
import { getSetting } from "metabase/selectors/settings";
export const createAdminRouteGuard = (routeKey: string) => {
diff --git a/frontend/src/metabase/app/nav/AppBar.tsx b/frontend/src/metabase/app/nav/AppBar.tsx
new file mode 100644
index 00000000000..f97a39790f8
--- /dev/null
+++ b/frontend/src/metabase/app/nav/AppBar.tsx
@@ -0,0 +1,122 @@
+import { withRouter } from "react-router";
+import { push } from "react-router-redux";
+
+import { useInitialCollectionId } from "metabase/collections/hooks";
+import {
+ getCommentSidebarOpen,
+ getSidebarOpen,
+} from "metabase/documents/selectors";
+import { getMetabotVisible } from "metabase/metabot/state";
+import { AppBar as AppBarView } from "metabase/nav/components/AppBar";
+import type { AppBarProps } from "metabase/nav/components/AppBar/AppBar";
+import QuestionLineage from "metabase/nav/components/QuestionLineage";
+import { CollectionBreadcrumbs } from "metabase/nav/containers/CollectionBreadcrumbs";
+import { isQuestionPath } from "metabase/nav/containers/MainNavbar/getSelectedItems";
+import { zoomInRow } from "metabase/query_builder/actions";
+import {
+ getOriginalQuestion,
+ getQuestion,
+} from "metabase/query_builder/selectors";
+import { connect, useDispatch, useSelector } from "metabase/redux";
+import { closeNavbar, toggleNavbar } from "metabase/redux/app";
+import type { State } from "metabase/redux/store";
+import type { RouterProps } from "metabase/selectors/app";
+import {
+ getDetailViewState,
+ getIsAppSwitcherVisible,
+ getIsCollectionPathVisible,
+ getIsLogoVisible,
+ getIsMetricsViewer,
+ getIsNavBarEnabled,
+ getIsNavbarOpen,
+ getIsNewButtonVisible,
+ getIsQuestionLineageVisible,
+ getIsSearchVisible,
+} from "metabase/selectors/app";
+import { getIsEmbeddingIframe } from "metabase/selectors/embed";
+import { getUser } from "metabase/selectors/user";
+import { modelToUrl } from "metabase/urls";
+import type { SearchResult } from "metabase-types/api";
+
+type SearchResultSelection =
+ | { type: "zoom"; objectId: SearchResult["id"] }
+ | { type: "navigate"; url: string };
+
+/**
+ * Decides what should happen when a search result is selected from the app bar.
+ * When the result is an indexed-entity row that belongs to the model we're
+ * already viewing, we zoom into that row in place instead of navigating away.
+ */
+export function getSearchResultSelection(
+ result: SearchResult,
+ currentCardId: number | undefined,
+): SearchResultSelection {
+ if (result.model === "indexed-entity" && result.model_id === currentCardId) {
+ return { type: "zoom", objectId: result.id };
+ }
+ return { type: "navigate", url: modelToUrl(result) };
+}
+
+const mapStateToProps = (state: State, props: RouterProps) => ({
+ currentUser: getUser(state),
+ isNavBarOpen: getIsNavbarOpen(state),
+ isNavBarEnabled: getIsNavBarEnabled(state, props),
+ isMetabotVisible: getMetabotVisible(state, "omnibot"),
+ isDocumentSidebarOpen: getSidebarOpen(state),
+ isCommentSidebarOpen: getCommentSidebarOpen(state),
+ isLogoVisible: getIsLogoVisible(state),
+ isSearchVisible: getIsSearchVisible(state),
+ isEmbeddingIframe: getIsEmbeddingIframe(state),
+ isNewButtonVisible: getIsNewButtonVisible(state),
+ isAppSwitcherVisible: getIsAppSwitcherVisible(state),
+ isCollectionPathVisible: getIsCollectionPathVisible(state, props),
+ isQuestionLineageVisible: getIsQuestionLineageVisible(state, props),
+ detailView: getDetailViewState(state),
+ isMetricsViewer: getIsMetricsViewer(state, props),
+});
+
+const mapDispatchToProps = {
+ onToggleNavbar: toggleNavbar,
+ onCloseNavbar: closeNavbar,
+};
+
+function AppBarContainerInner(props: AppBarProps & RouterProps) {
+ const collectionId = useInitialCollectionId(props) ?? undefined;
+ const dispatch = useDispatch();
+ const question = useSelector(getQuestion);
+ const originalQuestion = useSelector(getOriginalQuestion);
+
+ const { pathname } = props.location;
+ const dashboard =
+ pathname && isQuestionPath(pathname) ? question?.dashboard() : undefined;
+
+ const locationState = props.location.state as { cardId?: number } | undefined;
+
+ const onSearchItemSelect = (result: SearchResult) => {
+ const selection = getSearchResultSelection(result, locationState?.cardId);
+ if (selection.type === "zoom") {
+ dispatch(zoomInRow({ objectId: selection.objectId }));
+ } else {
+ dispatch(push(selection.url));
+ }
+ };
+
+ return (
+ <AppBarView
+ {...props}
+ collectionId={collectionId}
+ collectionBreadcrumbs={<CollectionBreadcrumbs dashboard={dashboard} />}
+ questionLineage={
+ <QuestionLineage
+ question={question}
+ originalQuestion={originalQuestion}
+ />
+ }
+ onSearchItemSelect={onSearchItemSelect}
+ />
+ );
+}
+
+export const AppBarContainer = withRouter(
+ connect(mapStateToProps, mapDispatchToProps)(AppBarContainerInner),
+);
diff --git a/frontend/src/metabase/nav/containers/AppBar/AppBar.unit.spec.tsx b/frontend/src/metabase/app/nav/AppBar.unit.spec.tsx
similarity index 88%
rename from frontend/src/metabase/nav/containers/AppBar/AppBar.unit.spec.tsx
rename to frontend/src/metabase/app/nav/AppBar.unit.spec.tsx
index 060a7f7e2da..21de43bef90 100644
--- a/frontend/src/metabase/nav/containers/AppBar/AppBar.unit.spec.tsx
+++ b/frontend/src/metabase/app/nav/AppBar.unit.spec.tsx
@@ -23,14 +23,16 @@ import {
createMockQueryBuilderState,
createMockStoreDashboard,
} from "metabase/redux/store/mocks";
+import { modelToUrl } from "metabase/urls";
import type { Card } from "metabase-types/api";
import {
createMockCard,
createMockCollection,
createMockDashboard,
+ createMockSearchResult,
} from "metabase-types/api/mocks";
-import AppBar from "./AppBar";
+import { AppBarContainer, getSearchResultSelection } from "./AppBar";
const FOO_COLLECTION = createMockCollection({
id: 3,
@@ -275,6 +277,45 @@ describe("AppBar", () => {
});
});
+describe("getSearchResultSelection", () => {
+ const indexedEntity = createMockSearchResult({
+ id: 42,
+ model: "indexed-entity",
+ model_id: 7,
+ model_name: "People",
+ });
+
+ it("zooms into the row for an indexed-entity result on the current model", () => {
+ expect(getSearchResultSelection(indexedEntity, 7)).toEqual({
+ type: "zoom",
+ objectId: 42,
+ });
+ });
+
+ it("navigates for an indexed-entity result on a different model", () => {
+ expect(getSearchResultSelection(indexedEntity, 9)).toEqual({
+ type: "navigate",
+ url: modelToUrl(indexedEntity),
+ });
+ });
+
+ it("navigates when there is no current card", () => {
+ expect(getSearchResultSelection(indexedEntity, undefined)).toEqual({
+ type: "navigate",
+ url: modelToUrl(indexedEntity),
+ });
+ });
+
+ it("navigates for a non indexed-entity result even when ids match", () => {
+ const card = createMockSearchResult({ id: 7, model: "card", model_id: 7 });
+
+ expect(getSearchResultSelection(card, 7)).toEqual({
+ type: "navigate",
+ url: modelToUrl(card),
+ });
+ });
+});
+
function setup({
embedOptions,
card = createMockCard(),
@@ -297,7 +338,7 @@ function setup({
setupCardEndpoints(card);
setupDashboardEndpoints(BAR_DASHBOARD);
- return renderWithProviders(<Route path="*" component={AppBar} />, {
+ return renderWithProviders(<Route path="*" component={AppBarContainer} />, {
withRouter: true,
initialRoute,
storeInitialState: {
diff --git a/frontend/src/metabase/nav/containers/Navbar.tsx b/frontend/src/metabase/app/nav/Navbar.tsx
similarity index 50%
rename from frontend/src/metabase/nav/containers/Navbar.tsx
rename to frontend/src/metabase/app/nav/Navbar.tsx
index 02670226a53..8686e370f57 100644
--- a/frontend/src/metabase/nav/containers/Navbar.tsx
+++ b/frontend/src/metabase/app/nav/Navbar.tsx
@@ -1,31 +1,42 @@
import { useMemo } from "react";
import { type WithRouterProps, withRouter } from "react-router";
-import { getAdminPaths } from "metabase/admin/app/selectors";
import { useListDatabasesQuery } from "metabase/api";
+import { getDashboard } from "metabase/dashboard/selectors";
+import { AdminNavbar } from "metabase/nav/components/AdminNavbar";
+import { MainNavbar } from "metabase/nav/containers/MainNavbar";
import { connect } from "metabase/redux";
-import type { AdminPath, State } from "metabase/redux/store";
+import type { AdminPath, State, StoreDashboard } from "metabase/redux/store";
+import { getAdminPaths } from "metabase/selectors/admin";
import { getIsNavbarOpen } from "metabase/selectors/app";
import { getUser } from "metabase/selectors/user";
import type { User } from "metabase-types/api";
-import { AdminNavbar } from "../components/AdminNavbar";
-
-import MainNavbar from "./MainNavbar";
-
type NavbarProps = WithRouterProps & {
isOpen: boolean;
user: User | null;
adminPaths: AdminPath[];
+ dashboard?: StoreDashboard;
};
const mapStateToProps = (state: State) => ({
isOpen: getIsNavbarOpen(state),
user: getUser(state),
adminPaths: getAdminPaths(state),
+ // Can't use the dashboard entity loader instead.
+ // The dashboard page uses DashboardsApi.get directly,
+ // so we can't re-use data between these components.
+ dashboard: getDashboard(state),
});
-function Navbar({ isOpen, user, location, params, adminPaths }: NavbarProps) {
+function NavbarInner({
+ isOpen,
+ user,
+ location,
+ params,
+ adminPaths,
+ dashboard,
+}: NavbarProps) {
useListDatabasesQuery();
const isAdminApp = useMemo(
() => location.pathname.startsWith("/admin/"),
@@ -39,9 +50,13 @@ function Navbar({ isOpen, user, location, params, adminPaths }: NavbarProps) {
return isAdminApp ? (
<AdminNavbar path={location.pathname} adminPaths={adminPaths} />
) : (
- <MainNavbar isOpen={isOpen} location={location} params={params} />
+ <MainNavbar
+ isOpen={isOpen}
+ location={location}
+ params={params}
+ dashboard={dashboard}
+ />
);
}
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export default withRouter(connect(mapStateToProps)(Navbar));
+export const Navbar = withRouter(connect(mapStateToProps)(NavbarInner));
diff --git a/frontend/src/metabase/nav/containers/Navbar.unit.spec.tsx b/frontend/src/metabase/app/nav/Navbar.unit.spec.tsx
similarity index 99%
rename from frontend/src/metabase/nav/containers/Navbar.unit.spec.tsx
rename to frontend/src/metabase/app/nav/Navbar.unit.spec.tsx
index f42031df96d..42668803809 100644
--- a/frontend/src/metabase/nav/containers/Navbar.unit.spec.tsx
+++ b/frontend/src/metabase/app/nav/Navbar.unit.spec.tsx
@@ -37,7 +37,7 @@ import {
createMockUser,
} from "metabase-types/api/mocks";
-import Navbar from "./Navbar";
+import { Navbar } from "./Navbar";
type SetupOpts = {
isOpen?: boolean;
diff --git a/frontend/src/metabase/nav/components/AppBar/AppBar.tsx b/frontend/src/metabase/nav/components/AppBar/AppBar.tsx
index 3cd1bf340d0..ddaeacb4b34 100644
--- a/frontend/src/metabase/nav/components/AppBar/AppBar.tsx
+++ b/frontend/src/metabase/nav/components/AppBar/AppBar.tsx
@@ -1,16 +1,17 @@
+import type { ReactNode } from "react";
import { t } from "ttag";
import ErrorBoundary from "metabase/ErrorBoundary";
import { useIsSmallScreen } from "metabase/common/hooks/use-is-small-screen";
import type { DetailViewState } from "metabase/redux/store";
-import type { CollectionId, User } from "metabase-types/api";
+import type { CollectionId, SearchResult, User } from "metabase-types/api";
import S from "./AppBar.module.css";
-import AppBarLarge from "./AppBarLarge";
-import AppBarSmall from "./AppBarSmall";
+import { AppBarLarge } from "./AppBarLarge";
+import { AppBarSmall } from "./AppBarSmall";
export interface AppBarProps {
- currentUser: User;
+ currentUser: User | null;
collectionId?: CollectionId;
detailView: DetailViewState | null;
isNavBarOpen?: boolean;
@@ -26,11 +27,14 @@ export interface AppBarProps {
isCollectionPathVisible?: boolean;
isQuestionLineageVisible?: boolean;
isMetricsViewer?: boolean;
+ collectionBreadcrumbs?: ReactNode;
+ questionLineage?: ReactNode;
+ onSearchItemSelect?: (result: SearchResult) => void;
onToggleNavbar: () => void;
onCloseNavbar: () => void;
}
-const AppBar = (props: AppBarProps): JSX.Element => {
+export const AppBar = (props: AppBarProps): JSX.Element => {
const isSmallScreen = useIsSmallScreen();
return (
@@ -51,6 +55,3 @@ const AppBar = (props: AppBarProps): JSX.Element => {
</header>
);
};
-
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export default AppBar;
diff --git a/frontend/src/metabase/nav/components/AppBar/AppBar.unit.spec.tsx b/frontend/src/metabase/nav/components/AppBar/AppBar.unit.spec.tsx
index 761476fedd3..bf91f1c1f07 100644
--- a/frontend/src/metabase/nav/components/AppBar/AppBar.unit.spec.tsx
+++ b/frontend/src/metabase/nav/components/AppBar/AppBar.unit.spec.tsx
@@ -6,8 +6,7 @@ import {
} from "__support__/ui";
import { createMockUser } from "metabase-types/api/mocks";
-import type { AppBarProps } from "./AppBar";
-import AppBar from "./AppBar";
+import { AppBar, type AppBarProps } from "./AppBar";
function NewItemButtonMock() {
return <div data-testid="new-button" />;
@@ -32,8 +31,6 @@ function QuestionLineageMock() {
jest.mock("../NewItemButton", () => NewItemButtonMock);
jest.mock("../search/SearchBar/SearchBar", () => SearchBarMock);
jest.mock("../search/SearchButton/SearchButton", () => ({ SearchButton }));
-jest.mock("../../containers/CollectionBreadcrumbs", () => BreadcrumbsMock);
-jest.mock("../../containers/QuestionLineage", () => QuestionLineageMock);
describe("AppBar", () => {
let matchMediaSpy: jest.SpyInstance;
@@ -179,6 +176,8 @@ describe("AppBar", () => {
const getProps = (opts?: Partial<AppBarProps>): AppBarProps => ({
detailView: null,
currentUser: createMockUser(),
+ collectionBreadcrumbs: <BreadcrumbsMock />,
+ questionLineage: <QuestionLineageMock />,
onToggleNavbar: jest.fn(),
onCloseNavbar: jest.fn(),
...opts,
diff --git a/frontend/src/metabase/nav/components/AppBar/AppBarLarge.tsx b/frontend/src/metabase/nav/components/AppBar/AppBarLarge.tsx
index ddcdaa7aafd..0d3b012c6af 100644
--- a/frontend/src/metabase/nav/components/AppBar/AppBarLarge.tsx
+++ b/frontend/src/metabase/nav/components/AppBar/AppBarLarge.tsx
@@ -1,3 +1,4 @@
+import type { ReactNode } from "react";
import { t } from "ttag";
import { Nav as DetailViewNav } from "metabase/detail-view/components";
@@ -7,10 +8,8 @@ import { useUserMetabotPermissions } from "metabase/metabot/hooks";
import { PLUGIN_REMOTE_SYNC } from "metabase/plugins";
import type { DetailViewState } from "metabase/redux/store";
import { Box, Flex } from "metabase/ui";
-import type { CollectionId } from "metabase-types/api";
+import type { CollectionId, SearchResult } from "metabase-types/api";
-import CollectionBreadcrumbs from "../../containers/CollectionBreadcrumbs";
-import QuestionLineage from "../../containers/QuestionLineage";
import { AppSwitcher } from "../AppSwitcher";
import NewItemButton from "../NewItemButton";
import { SearchBar } from "../search/SearchBar";
@@ -36,10 +35,13 @@ export interface AppBarLargeProps {
isCollectionPathVisible?: boolean;
isQuestionLineageVisible?: boolean;
isMetricsViewer?: boolean;
+ collectionBreadcrumbs?: ReactNode;
+ questionLineage?: ReactNode;
+ onSearchItemSelect?: (result: SearchResult) => void;
onToggleNavbar: () => void;
}
-const AppBarLarge = ({
+export const AppBarLarge = ({
detailView,
collectionId,
isNavBarOpen,
@@ -55,6 +57,9 @@ const AppBarLarge = ({
isCollectionPathVisible,
isQuestionLineageVisible,
isMetricsViewer,
+ collectionBreadcrumbs,
+ questionLineage,
+ onSearchItemSelect,
onToggleNavbar,
}: AppBarLargeProps): JSX.Element => {
const isNavBarVisible = isNavBarOpen && isNavBarEnabled;
@@ -96,9 +101,9 @@ const AppBarLarge = ({
table={detailView.table}
/>
) : isQuestionLineageVisible ? (
- <QuestionLineage />
+ questionLineage
) : isCollectionPathVisible ? (
- <CollectionBreadcrumbs />
+ collectionBreadcrumbs
) : null}
</AppBarInfoContainer>
</Flex>
@@ -114,7 +119,11 @@ const AppBarLarge = ({
flex="1 1 auto"
>
{isSearchVisible &&
- (isEmbeddingIframe ? <SearchBar /> : <SearchButton mr="md" />)}
+ (isEmbeddingIframe ? (
+ <SearchBar onSearchItemSelect={onSearchItemSelect} />
+ ) : (
+ <SearchButton mr="md" />
+ ))}
{isNewButtonVisible && <NewItemButton collectionId={collectionId} />}
{<MetabotAppBarButton />}
{isAppSwitcherVisible && (
@@ -127,6 +136,3 @@ const AppBarLarge = ({
</AppBarRoot>
);
};
-
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export default AppBarLarge;
diff --git a/frontend/src/metabase/nav/components/AppBar/AppBarSmall.tsx b/frontend/src/metabase/nav/components/AppBar/AppBarSmall.tsx
index 6f112f2f504..c6299aa4344 100644
--- a/frontend/src/metabase/nav/components/AppBar/AppBarSmall.tsx
+++ b/frontend/src/metabase/nav/components/AppBar/AppBarSmall.tsx
@@ -1,13 +1,12 @@
-import { useCallback, useState } from "react";
+import { type ReactNode, useCallback, useState } from "react";
import { Nav as DetailViewNav } from "metabase/detail-view/components";
import { MetabotAppBarButton } from "metabase/metabot/components/MetabotAppBarButton";
import { SearchBar } from "metabase/nav/components/search/SearchBar";
import type { DetailViewState } from "metabase/redux/store";
import { Box, Flex } from "metabase/ui";
+import type { SearchResult } from "metabase-types/api";
-import CollectionBreadcrumbs from "../../containers/CollectionBreadcrumbs";
-import QuestionLineage from "../../containers/QuestionLineage";
import { AppSwitcher } from "../AppSwitcher";
import { SearchButton } from "../search/SearchButton/SearchButton";
@@ -31,11 +30,14 @@ export interface AppBarSmallProps {
isAppSwitcherVisible?: boolean;
isCollectionPathVisible?: boolean;
isQuestionLineageVisible?: boolean;
+ collectionBreadcrumbs?: ReactNode;
+ questionLineage?: ReactNode;
+ onSearchItemSelect?: (result: SearchResult) => void;
onToggleNavbar: () => void;
onCloseNavbar: () => void;
}
-const AppBarSmall = ({
+export const AppBarSmall = ({
detailView,
isNavBarOpen,
isNavBarEnabled,
@@ -45,6 +47,9 @@ const AppBarSmall = ({
isAppSwitcherVisible,
isCollectionPathVisible,
isQuestionLineageVisible,
+ collectionBreadcrumbs,
+ questionLineage,
+ onSearchItemSelect,
onToggleNavbar,
onCloseNavbar,
}: AppBarSmallProps): JSX.Element => {
@@ -84,6 +89,7 @@ const AppBarSmall = ({
<SearchBar
onSearchActive={handleSearchActive}
onSearchInactive={handleSearchInactive}
+ onSearchItemSelect={onSearchItemSelect}
/>
) : (
<Flex justify="end">
@@ -112,15 +118,12 @@ const AppBarSmall = ({
table={detailView.table}
/>
) : isQuestionLineageVisible ? (
- <QuestionLineage />
+ questionLineage
) : isCollectionPathVisible ? (
- <CollectionBreadcrumbs />
+ collectionBreadcrumbs
) : null}
</AppBarSubheader>
)}
</Box>
);
};
-
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export default AppBarSmall;
diff --git a/frontend/src/metabase/nav/components/AppBar/index.ts b/frontend/src/metabase/nav/components/AppBar/index.ts
index c0c098ce3b8..c3bbf372676 100644
--- a/frontend/src/metabase/nav/components/AppBar/index.ts
+++ b/frontend/src/metabase/nav/components/AppBar/index.ts
@@ -1,2 +1 @@
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export { default } from "./AppBar";
+export { AppBar } from "./AppBar";
diff --git a/frontend/src/metabase/nav/components/AppSwitcher/AppSwitcher.tsx b/frontend/src/metabase/nav/components/AppSwitcher/AppSwitcher.tsx
index a8181e7aed0..6e0533efa76 100644
--- a/frontend/src/metabase/nav/components/AppSwitcher/AppSwitcher.tsx
+++ b/frontend/src/metabase/nav/components/AppSwitcher/AppSwitcher.tsx
@@ -1,7 +1,6 @@
import { useMemo, useState } from "react";
import { t } from "ttag";
-import { getAdminPaths } from "metabase/admin/app/selectors";
import { logout } from "metabase/auth/actions";
import { ErrorDiagnosticModalWrapper } from "metabase/common/components/ErrorPages/ErrorDiagnosticModal";
import { trackErrorDiagnosticModalOpened } from "metabase/common/components/ErrorPages/analytics";
@@ -17,6 +16,7 @@ import {
import { useDispatch, useSelector } from "metabase/redux";
import { openDiagnostics } from "metabase/redux/app";
import { setOpenModal } from "metabase/redux/ui";
+import { getAdminPaths } from "metabase/selectors/admin";
import { getUser } from "metabase/selectors/user";
import { getApplicationName } from "metabase/selectors/whitelabel";
import {
diff --git a/frontend/src/metabase/nav/components/search/SearchBar/SearchBar.tsx b/frontend/src/metabase/nav/components/search/SearchBar/SearchBar.tsx
index f5cdb069997..759be5a26df 100644
--- a/frontend/src/metabase/nav/components/search/SearchBar/SearchBar.tsx
+++ b/frontend/src/metabase/nav/components/search/SearchBar/SearchBar.tsx
@@ -16,7 +16,6 @@ import { useOnClickOutside } from "metabase/common/hooks/use-on-click-outside";
import { useToggle } from "metabase/common/hooks/use-toggle";
import { RecentsList } from "metabase/nav/components/search/RecentsList";
import { SearchResultsDropdown } from "metabase/nav/components/search/SearchResultsDropdown";
-import { zoomInRow } from "metabase/query_builder/actions";
import { useDispatch, useSelector } from "metabase/redux";
import type { SearchAwareLocation } from "metabase/search/types";
import {
@@ -50,11 +49,22 @@ type RouterProps = {
type OwnProps = {
onSearchActive?: () => void;
onSearchInactive?: () => void;
+ /**
+ * Override how a search result is handled. When omitted, results navigate
+ * via `modelToUrl`. The main-app caller injects a callback that zooms in on
+ * indexed-entity results that match the current QB page.
+ */
+ onSearchItemSelect?: (result: SearchResult) => void;
};
type Props = RouterProps & OwnProps;
-function SearchBarView({ location, onSearchActive, onSearchInactive }: Props) {
+function SearchBarView({
+ location,
+ onSearchActive,
+ onSearchInactive,
+ onSearchItemSelect: onSearchItemSelectProp,
+}: Props) {
const isTypeaheadEnabled = useSelector((state) =>
getSetting(state, "search-typeahead-enabled"),
);
@@ -96,15 +106,13 @@ function SearchBarView({ location, onSearchActive, onSearchInactive }: Props) {
const onSearchItemSelect = useCallback(
(result: SearchResult) => {
- // if we're already looking at the right model, don't navigate, just update the zoomed in row
- const isSameModel = result?.model_id === location?.state?.cardId;
- if (isSameModel && result.model === "indexed-entity") {
- dispatch(zoomInRow({ objectId: result.id }));
+ if (onSearchItemSelectProp) {
+ onSearchItemSelectProp(result);
} else {
onChangeLocation(modelToUrl(result));
}
},
- [dispatch, onChangeLocation, location?.state?.cardId],
+ [onSearchItemSelectProp, onChangeLocation],
);
useOnClickOutside(container, setInactive);
diff --git a/frontend/src/metabase/nav/containers/AppBar/AppBar.tsx b/frontend/src/metabase/nav/containers/AppBar/AppBar.tsx
deleted file mode 100644
index 4f2e2189fa6..00000000000
--- a/frontend/src/metabase/nav/containers/AppBar/AppBar.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import { withRouter } from "react-router";
-import _ from "underscore";
-
-import { useInitialCollectionId } from "metabase/collections/hooks";
-import {
- getCommentSidebarOpen,
- getSidebarOpen,
-} from "metabase/documents/selectors";
-import { getMetabotVisible } from "metabase/metabot/state";
-import { connect } from "metabase/redux";
-import { closeNavbar, toggleNavbar } from "metabase/redux/app";
-import type { State } from "metabase/redux/store";
-import type { RouterProps } from "metabase/selectors/app";
-import {
- getDetailViewState,
- getIsAppSwitcherVisible,
- getIsCollectionPathVisible,
- getIsLogoVisible,
- getIsMetricsViewer,
- getIsNavBarEnabled,
- getIsNavbarOpen,
- getIsNewButtonVisible,
- getIsQuestionLineageVisible,
- getIsSearchVisible,
-} from "metabase/selectors/app";
-import { getIsEmbeddingIframe } from "metabase/selectors/embed";
-import { getUser } from "metabase/selectors/user";
-
-import AppBar from "../../components/AppBar";
-import type { AppBarProps } from "../../components/AppBar/AppBar";
-
-const mapStateToProps = (state: State, props: RouterProps) => ({
- currentUser: getUser(state),
- isNavBarOpen: getIsNavbarOpen(state),
- isNavBarEnabled: getIsNavBarEnabled(state, props),
- isMetabotVisible: getMetabotVisible(state, "omnibot"),
- isDocumentSidebarOpen: getSidebarOpen(state),
- isCommentSidebarOpen: getCommentSidebarOpen(state),
- isLogoVisible: getIsLogoVisible(state),
- isSearchVisible: getIsSearchVisible(state),
- isEmbeddingIframe: getIsEmbeddingIframe(state),
- isNewButtonVisible: getIsNewButtonVisible(state),
- isAppSwitcherVisible: getIsAppSwitcherVisible(state),
- isCollectionPathVisible: getIsCollectionPathVisible(state, props),
- isQuestionLineageVisible: getIsQuestionLineageVisible(state, props),
- detailView: getDetailViewState(state),
- isMetricsViewer: getIsMetricsViewer(state, props),
-});
-
-const mapDispatchToProps = {
- onToggleNavbar: toggleNavbar,
- onCloseNavbar: closeNavbar,
-};
-
-function AppBarContainer(props: AppBarProps & RouterProps) {
- const collectionId = useInitialCollectionId(props) ?? undefined;
- return <AppBar {...props} collectionId={collectionId} />;
-}
-
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export default _.compose(
- withRouter,
- connect(mapStateToProps, mapDispatchToProps),
-)(AppBarContainer);
diff --git a/frontend/src/metabase/nav/containers/AppBar/index.ts b/frontend/src/metabase/nav/containers/AppBar/index.ts
deleted file mode 100644
index c0c098ce3b8..00000000000
--- a/frontend/src/metabase/nav/containers/AppBar/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export { default } from "./AppBar";
diff --git a/frontend/src/metabase/nav/containers/CollectionBreadcrumbs/CollectionBreadcrumbs.tsx b/frontend/src/metabase/nav/containers/CollectionBreadcrumbs/CollectionBreadcrumbs.tsx
index 7d934afe27e..4f537fe4a97 100644
--- a/frontend/src/metabase/nav/containers/CollectionBreadcrumbs/CollectionBreadcrumbs.tsx
+++ b/frontend/src/metabase/nav/containers/CollectionBreadcrumbs/CollectionBreadcrumbs.tsx
@@ -1,7 +1,4 @@
-import { useLocation } from "react-use";
-
import { useGetCollectionQuery } from "metabase/api";
-import { getQuestion } from "metabase/query_builder/selectors";
import { useSelector } from "metabase/redux";
import { getCollectionId } from "metabase/selectors/app";
import type { CollectionId } from "metabase-types/api";
@@ -13,7 +10,7 @@ import {
type CollectionBreadcrumbsProps = Omit<
BreadcrumbsProps,
- "collection" | "dashboard" | "baseCollectionId"
+ "collection" | "baseCollectionId"
> & {
collectionId?: CollectionId;
baseCollectionId?: CollectionId | null;
@@ -25,20 +22,11 @@ export const CollectionBreadcrumbs = (props: CollectionBreadcrumbsProps) => {
const { data: collection } = useGetCollectionQuery({ id: collectionId });
- const question = useSelector(getQuestion);
- const { pathname } = useLocation();
- const isOnQuestionPage = pathname && /\/question\//.test(pathname);
- const dashboard = isOnQuestionPage ? question?.dashboard() : undefined;
-
return (
<Breadcrumbs
{...props}
collection={collection}
- dashboard={dashboard}
baseCollectionId={props.baseCollectionId ?? null}
/>
);
};
-
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export default CollectionBreadcrumbs;
diff --git a/frontend/src/metabase/nav/containers/CollectionBreadcrumbs/index.ts b/frontend/src/metabase/nav/containers/CollectionBreadcrumbs/index.ts
index 5c918136831..e700e90f71e 100644
--- a/frontend/src/metabase/nav/containers/CollectionBreadcrumbs/index.ts
+++ b/frontend/src/metabase/nav/containers/CollectionBreadcrumbs/index.ts
@@ -1,2 +1 @@
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export { default } from "./CollectionBreadcrumbs";
+export { CollectionBreadcrumbs } from "./CollectionBreadcrumbs";
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbar.tsx b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbar.tsx
index 07188ab5f3a..2c7df1af8bc 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbar.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbar.tsx
@@ -1,25 +1,24 @@
import type { LocationDescriptor } from "history";
import { useEffect, useMemo } from "react";
import { push } from "react-router-redux";
-import _ from "underscore";
import {
skipToken,
useGetCardQuery,
useGetCollectionQuery,
} from "metabase/api";
-import { getDashboard } from "metabase/dashboard/selectors";
import { NavbarPromoSlot } from "metabase/nav/components/NavbarPromoSlot";
import { connect } from "metabase/redux";
import { closeNavbar, openNavbar } from "metabase/redux/app";
import type { State } from "metabase/redux/store";
import * as Urls from "metabase/urls";
import Question from "metabase-lib/v1/Question";
-import type { CollectionId, Dashboard } from "metabase-types/api";
+import type { CollectionId } from "metabase-types/api";
import { NavRoot, Sidebar } from "./MainNavbar.styled";
import MainNavbarContainer from "./MainNavbarContainer";
-import getSelectedItems, {
+import {
+ getSelectedItems,
isCollectionPath,
isMetricPath,
isModelPath,
@@ -36,9 +35,8 @@ interface EntityLoaderProps {
}
interface StateProps {
- dashboard?: Dashboard;
- questionId?: number;
- collectionId?: CollectionId;
+ questionId?: number | null;
+ collectionId?: CollectionId | null;
}
interface DispatchProps extends MainNavbarDispatchProps {
@@ -52,11 +50,6 @@ type Props = MainNavbarOwnProps &
function mapStateToProps(state: State, props: MainNavbarOwnProps) {
return {
- // Can't use dashboard entity loader instead.
- // The dashboard page uses DashboardsApi.get directly,
- // so we can't re-use data between these components.
- dashboard: getDashboard(state),
-
questionId: maybeGetQuestionId(state, props),
collectionId: maybeGetCollectionId(state, props),
};
@@ -68,7 +61,7 @@ const mapDispatchToProps = {
onChangeLocation: push,
};
-function MainNavbar({
+function MainNavbarInner({
isOpen,
location,
params,
@@ -165,15 +158,7 @@ function maybeGetCollectionId(
return canFetchQuestion ? Urls.extractEntityId(params.slug) : null;
}
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export default _.compose(connect(mapStateToProps, mapDispatchToProps))(
- /**
- * Previously the `_.compose` type was broken, so it wasn't checking for type compatibility, and would
- * return the composed function type as `any`. Now that it works better, legit errors are surfacing.
- * But I don't have time, or enough context to fix this one.
- *
- * It seems the error came from the mismatch of the `dashboard` type, where the component expects
- * a dashboard response, but the injected prop is from the redux store which has a different type.
- */
- MainNavbar as any,
-);
+export const MainNavbar = connect(
+ mapStateToProps,
+ mapDispatchToProps,
+)(MainNavbarInner);
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/getSelectedItems.ts b/frontend/src/metabase/nav/containers/MainNavbar/getSelectedItems.ts
index 0d9fe787f17..a4566c1309c 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/getSelectedItems.ts
+++ b/frontend/src/metabase/nav/containers/MainNavbar/getSelectedItems.ts
@@ -1,7 +1,8 @@
import { coerceCollectionId } from "metabase/collections/utils";
+import type { StoreDashboard } from "metabase/redux/store";
import * as Urls from "metabase/urls";
import type Question from "metabase-lib/v1/Question";
-import type { Collection, Dashboard } from "metabase-types/api";
+import type { Collection } from "metabase-types/api";
import type { SelectedItem } from "./types";
@@ -12,7 +13,7 @@ type Opts = {
pageId?: string;
};
question?: Question;
- dashboard?: Dashboard;
+ dashboard?: StoreDashboard;
collection?: Collection;
};
@@ -71,7 +72,7 @@ function isDashboardPath(pathname: string): boolean {
);
}
-function getSelectedItems({
+export function getSelectedItems({
pathname,
params,
question,
@@ -124,6 +125,3 @@ function getSelectedItems({
}
return [{ url: pathname, type: "non-entity" }];
}
-
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export default getSelectedItems;
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/index.ts b/frontend/src/metabase/nav/containers/MainNavbar/index.ts
index 84ccb576410..0b0ee6e721b 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/index.ts
+++ b/frontend/src/metabase/nav/containers/MainNavbar/index.ts
@@ -1,2 +1 @@
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export { default } from "./MainNavbar";
+export { MainNavbar } from "./MainNavbar";
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/tests/setup.tsx b/frontend/src/metabase/nav/containers/MainNavbar/tests/setup.tsx
index 922e25294e9..a1e309bdf42 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/tests/setup.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/tests/setup.tsx
@@ -21,7 +21,7 @@ import {
} from "__support__/ui";
import type { ModelResult } from "metabase/browse/models";
import { ROOT_COLLECTION } from "metabase/collections/constants";
-import type { DashboardState } from "metabase/redux/store";
+import type { DashboardState, StoreDashboard } from "metabase/redux/store";
import {
createMockDashboardState,
createMockQueryBuilderState,
@@ -36,7 +36,7 @@ import {
createMockUser,
} from "metabase-types/api/mocks";
-import MainNavbar from "../MainNavbar";
+import { MainNavbar } from "../MainNavbar";
export type SetupOpts = {
pathname?: string;
@@ -172,12 +172,14 @@ export async function setup({
let dashboardId: DashboardId | null = null;
const dashboardsForState: DashboardState["dashboards"] = {};
const dashboardsForEntities: Dashboard[] = [];
+ let storeDashboard: StoreDashboard | undefined;
if (openDashboard) {
dashboardId = openDashboard.id;
- dashboardsForState[openDashboard.id] = {
+ storeDashboard = {
...openDashboard,
dashcards: openDashboard.dashcards.map((c) => c.id),
};
+ dashboardsForState[openDashboard.id] = storeDashboard;
dashboardsForEntities.push(openDashboard);
}
@@ -218,7 +220,9 @@ export async function setup({
renderWithProviders(
<Route
path={route}
- component={(props) => <MainNavbar {...props} isOpen />}
+ component={(props) => (
+ <MainNavbar {...props} isOpen dashboard={storeDashboard} />
+ )}
/>,
{
storeInitialState,
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/types.ts b/frontend/src/metabase/nav/containers/MainNavbar/types.ts
index a538383031a..3905b7190ae 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/types.ts
+++ b/frontend/src/metabase/nav/containers/MainNavbar/types.ts
@@ -1,5 +1,7 @@
import type { Location } from "history";
+import type { StoreDashboard } from "metabase/redux/store";
+
export interface MainNavbarOwnProps {
isOpen: boolean;
location: Location;
@@ -7,6 +9,7 @@ export interface MainNavbarOwnProps {
slug?: string;
pageId?: string;
};
+ dashboard?: StoreDashboard;
}
export interface MainNavbarDispatchProps {
diff --git a/frontend/src/metabase/nav/containers/QuestionLineage/QuestionLineage.tsx b/frontend/src/metabase/nav/containers/QuestionLineage/QuestionLineage.tsx
deleted file mode 100644
index 45c066e3b62..00000000000
--- a/frontend/src/metabase/nav/containers/QuestionLineage/QuestionLineage.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import {
- getOriginalQuestion,
- getQuestion,
-} from "metabase/query_builder/selectors";
-import { connect } from "metabase/redux";
-import type { State } from "metabase/redux/store";
-
-import QuestionLineage from "../../components/QuestionLineage";
-
-const mapStateToProps = (state: State) => ({
- question: getQuestion(state),
- originalQuestion: getOriginalQuestion(state),
-});
-
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export default connect(mapStateToProps)(QuestionLineage);
diff --git a/frontend/src/metabase/nav/containers/QuestionLineage/index.ts b/frontend/src/metabase/nav/containers/QuestionLineage/index.ts
deleted file mode 100644
index 81f0cf0ec50..00000000000
--- a/frontend/src/metabase/nav/containers/QuestionLineage/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-// eslint-disable-next-line import/no-default-export -- deprecated usage
-export { default } from "./QuestionLineage";
diff --git a/frontend/src/metabase/route-guards.tsx b/frontend/src/metabase/route-guards.tsx
index 8fb3c01f08e..097266dc818 100644
--- a/frontend/src/metabase/route-guards.tsx
+++ b/frontend/src/metabase/route-guards.tsx
@@ -1,11 +1,11 @@
import { routerActions } from "react-router-redux";
import { connectedReduxRedirect } from "redux-auth-wrapper/history3/redirect";
-import { getAdminPaths } from "metabase/admin/app/selectors";
import { canAccessDataStudio } from "metabase/data-studio/selectors";
import { PLUGIN_FEATURE_LEVEL_PERMISSIONS } from "metabase/plugins";
import { metabaseReduxContext } from "metabase/redux";
import type { State } from "metabase/redux/store";
+import { getAdminPaths } from "metabase/selectors/admin";
import { getSetting } from "metabase/selectors/settings";
import { isSameOrSiteUrlOrigin } from "metabase/utils/dom";
diff --git a/frontend/src/metabase/selectors/admin.ts b/frontend/src/metabase/selectors/admin.ts
new file mode 100644
index 00000000000..c68f18df517
--- /dev/null
+++ b/frontend/src/metabase/selectors/admin.ts
@@ -0,0 +1,5 @@
+import type { State } from "metabase/redux/store";
+
+export const getAdminPaths = (state: State) => {
+ return state.admin?.app?.paths ?? [];
+};