Skip to content

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

Add border to top of Document page when sidebar is open (#62577)

Nick Fitzpatrick849be9e03747
diff --git a/enterprise/frontend/src/metabase-enterprise/documents/index.ts b/enterprise/frontend/src/metabase-enterprise/documents/index.ts
index ca6bb12b841..bab2bd77684 100644
--- a/enterprise/frontend/src/metabase-enterprise/documents/index.ts
+++ b/enterprise/frontend/src/metabase-enterprise/documents/index.ts
@@ -8,12 +8,13 @@ import { hasPremiumFeature } from "metabase-enterprise/settings";
import { documentsReducer } from "./documents.slice";
import { getRoutes } from "./routes";
-import { getCurrentDocument } from "./selectors";
+import { getCurrentDocument, getSidebarOpen } from "./selectors";
if (hasPremiumFeature("documents")) {
PLUGIN_DOCUMENTS.getRoutes = getRoutes;
PLUGIN_DOCUMENTS.shouldShowDocumentInNewItemMenu = () => true;
PLUGIN_DOCUMENTS.getCurrentDocument = getCurrentDocument;
+ PLUGIN_DOCUMENTS.getSidebarOpen = getSidebarOpen;
PLUGIN_REDUCERS.documents = documentsReducer;
diff --git a/enterprise/frontend/src/metabase-enterprise/documents/selectors.ts b/enterprise/frontend/src/metabase-enterprise/documents/selectors.ts
index c0df1feaa1c..842df1d8554 100644
--- a/enterprise/frontend/src/metabase-enterprise/documents/selectors.ts
+++ b/enterprise/frontend/src/metabase-enterprise/documents/selectors.ts
@@ -19,6 +19,9 @@ export const getSelectedQuestionId = createSelector(
},
);
+export const getSidebarOpen = (state: DocumentsStoreState) =>
+ state.plugins?.documents?.selectedEmbedIndex !== null;
+
export const getCardEmbeds = createSelector(
getDocumentsState,
(documents) => documents?.cardEmbeds ?? [],
diff --git a/frontend/src/metabase/nav/components/AppBar/AppBar.tsx b/frontend/src/metabase/nav/components/AppBar/AppBar.tsx
index e619e461a65..a1c1308f0f4 100644
--- a/frontend/src/metabase/nav/components/AppBar/AppBar.tsx
+++ b/frontend/src/metabase/nav/components/AppBar/AppBar.tsx
@@ -16,6 +16,7 @@ export interface AppBarProps {
isNavBarOpen?: boolean;
isNavBarEnabled?: boolean;
isMetabotVisible?: boolean;
+ isDocumentSidebarOpen?: boolean;
isLogoVisible?: boolean;
isSearchVisible?: boolean;
isEmbeddingIframe?: boolean;
diff --git a/frontend/src/metabase/nav/components/AppBar/AppBarLarge.tsx b/frontend/src/metabase/nav/components/AppBar/AppBarLarge.tsx
index b2ff357913c..5f8d2293dea 100644
--- a/frontend/src/metabase/nav/components/AppBar/AppBarLarge.tsx
+++ b/frontend/src/metabase/nav/components/AppBar/AppBarLarge.tsx
@@ -28,6 +28,7 @@ export interface AppBarLargeProps {
isNavBarOpen?: boolean;
isNavBarEnabled?: boolean;
isMetabotVisible?: boolean;
+ isDocumentSidebarOpen?: boolean;
isLogoVisible?: boolean;
isSearchVisible?: boolean;
isEmbeddingIframe?: boolean;
@@ -45,6 +46,7 @@ const AppBarLarge = ({
isNavBarOpen,
isNavBarEnabled,
isMetabotVisible,
+ isDocumentSidebarOpen,
isLogoVisible,
isSearchVisible,
isEmbeddingIframe,
@@ -58,7 +60,11 @@ const AppBarLarge = ({
const isNavBarVisible = isNavBarOpen && isNavBarEnabled;
return (
- <AppBarRoot hasSidebarOpen={isNavBarVisible || isMetabotVisible}>
+ <AppBarRoot
+ hasSidebarOpen={
+ isNavBarVisible || isMetabotVisible || isDocumentSidebarOpen
+ }
+ >
<AppBarLeftContainer>
<AppBarToggle
isNavBarEnabled={isNavBarEnabled}
diff --git a/frontend/src/metabase/nav/containers/AppBar/AppBar.tsx b/frontend/src/metabase/nav/containers/AppBar/AppBar.tsx
index 4f71d81122a..54c60dcc6e2 100644
--- a/frontend/src/metabase/nav/containers/AppBar/AppBar.tsx
+++ b/frontend/src/metabase/nav/containers/AppBar/AppBar.tsx
@@ -4,7 +4,7 @@ import _ from "underscore";
import { logout } from "metabase/auth/actions";
import Collections from "metabase/entities/collections";
import { connect } from "metabase/lib/redux";
-import { PLUGIN_METABOT } from "metabase/plugins";
+import { PLUGIN_DOCUMENTS, PLUGIN_METABOT } from "metabase/plugins";
import { closeNavbar, toggleNavbar } from "metabase/redux/app";
import type { RouterProps } from "metabase/selectors/app";
import {
@@ -30,6 +30,7 @@ const mapStateToProps = (state: State, props: RouterProps) => ({
isNavBarOpen: getIsNavbarOpen(state),
isNavBarEnabled: getIsNavBarEnabled(state, props),
isMetabotVisible: PLUGIN_METABOT.getMetabotVisible(state),
+ isDocumentSidebarOpen: PLUGIN_DOCUMENTS.getSidebarOpen(state),
isLogoVisible: getIsLogoVisible(state),
isSearchVisible: getIsSearchVisible(state),
isEmbeddingIframe: getIsEmbeddingIframe(state),
diff --git a/frontend/src/metabase/plugins/index.ts b/frontend/src/metabase/plugins/index.ts
index ffc8431c8d1..83d4690084e 100644
--- a/frontend/src/metabase/plugins/index.ts
+++ b/frontend/src/metabase/plugins/index.ts
@@ -812,6 +812,7 @@ export const PLUGIN_DOCUMENTS = {
getRoutes: () => null as React.ReactElement | null,
shouldShowDocumentInNewItemMenu: () => false,
getCurrentDocument: (_state: any) => null as Document | null,
+ getSidebarOpen: (_state: any) => false,
};
export const PLUGIN_ENTITIES = {