Skip to content
Snippets Groups Projects
Unverified Commit 4081e04e authored by github-automation-metabase's avatar github-automation-metabase Committed by GitHub
Browse files

:robot: backported "fix(webapp/sidenav): Move Browse sidebar section in between...

:robot:

 backported "fix(webapp/sidenav): Move Browse sidebar section in between Trash and other collections" (#46604)

* fix(webapp/sidenav): Move Browse sidebar section in between Trash and other collections (#46457)

* wip

* restore mainnavbarview

* fix(webapp/sidenav): Move Browse sidebar section below collections (#46457)

---------

Co-authored-by: default avatarRaphael Krut-Landau <raphael.kl@gmail.com>
parent 733dde5e
No related branches found
No related tags found
No related merge requests found
...@@ -61,7 +61,9 @@ describe("personal collections", () => { ...@@ -61,7 +61,9 @@ describe("personal collections", () => {
}); });
cy.visit("/collection/root"); cy.visit("/collection/root");
cy.findByRole("tree").findByText("Your personal collection"); cy.findAllByRole("tree")
.contains("Your personal collection")
.should("be.visible");
navigationSidebar().within(() => { navigationSidebar().within(() => {
cy.icon("ellipsis").click(); cy.icon("ellipsis").click();
}); });
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
import { Icon } from "metabase/ui"; import { Icon } from "metabase/ui";
import { SidebarLink } from "./SidebarItems"; import { SidebarLink } from "./SidebarItems";
import { ExpandToggleButton } from "./SidebarItems/SidebarItems.styled";
const openSidebarCSS = css` const openSidebarCSS = css`
width: ${NAV_SIDEBAR_WIDTH}; width: ${NAV_SIDEBAR_WIDTH};
...@@ -84,6 +85,12 @@ export const SidebarSection = styled.div` ...@@ -84,6 +85,12 @@ export const SidebarSection = styled.div`
padding-inline-end: ${space(2)}; padding-inline-end: ${space(2)};
`; `;
export const TrashSidebarSection = styled(SidebarSection)`
${ExpandToggleButton} {
width: 12px;
}
`;
export const SidebarHeadingWrapper = styled.div` export const SidebarHeadingWrapper = styled.div`
display: flex; display: flex;
align-items: center; align-items: center;
......
...@@ -3,6 +3,7 @@ import { useCallback } from "react"; ...@@ -3,6 +3,7 @@ import { useCallback } from "react";
import { t } from "ttag"; import { t } from "ttag";
import _ from "underscore"; import _ from "underscore";
import ErrorBoundary from "metabase/ErrorBoundary";
import { useUserSetting } from "metabase/common/hooks"; import { useUserSetting } from "metabase/common/hooks";
import { useHasTokenFeature } from "metabase/common/hooks/use-has-token-feature"; import { useHasTokenFeature } from "metabase/common/hooks/use-has-token-feature";
import { useIsAtHomepageDashboard } from "metabase/common/hooks/use-is-at-homepage-dashboard"; import { useIsAtHomepageDashboard } from "metabase/common/hooks/use-is-at-homepage-dashboard";
...@@ -122,76 +123,87 @@ function MainNavbarView({ ...@@ -122,76 +123,87 @@ function MainNavbarView({
); );
return ( return (
<SidebarContentRoot> <ErrorBoundary>
<div> <SidebarContentRoot>
<SidebarSection> <div>
<PaddedSidebarLink <SidebarSection>
isSelected={nonEntityItem?.url === "/"} <ErrorBoundary>
icon="home" <PaddedSidebarLink
onClick={handleHomeClick} isSelected={nonEntityItem?.url === "/"}
url="/" icon="home"
> onClick={handleHomeClick}
{t`Home`} url="/"
</PaddedSidebarLink> >
{t`Home`}
</PaddedSidebarLink>
{hasAttachedDWHFeature && uploadDbId && rootCollection && ( {hasAttachedDWHFeature && uploadDbId && rootCollection && (
<UploadCSV collection={rootCollection} /> <UploadCSV collection={rootCollection} />
)}
</SidebarSection>
<SidebarSection>
<BrowseNavSection
nonEntityItem={nonEntityItem}
onItemSelect={onItemSelect}
hasDataAccess={hasDataAccess}
/>
{hasDataAccess && (
<>
{!hasOwnDatabase && isAdmin && (
<AddYourOwnDataLink
icon="add"
url={ADD_YOUR_OWN_DATA_URL}
isSelected={nonEntityItem?.url?.startsWith(
ADD_YOUR_OWN_DATA_URL,
)}
onClick={onItemSelect}
>
{t`Add your own data`}
</AddYourOwnDataLink>
)} )}
</> </ErrorBoundary>
</SidebarSection>
{bookmarks.length > 0 && (
<SidebarSection>
<ErrorBoundary>
<BookmarkList
bookmarks={bookmarks}
selectedItem={cardItem ?? dashboardItem ?? collectionItem}
onSelect={onItemSelect}
reorderBookmarks={reorderBookmarks}
onToggle={setExpandBookmarks}
initialState={expandBookmarks ? "expanded" : "collapsed"}
/>
</ErrorBoundary>
</SidebarSection>
)} )}
</SidebarSection>
{bookmarks.length > 0 && (
<SidebarSection> <SidebarSection>
<BookmarkList <ErrorBoundary>
bookmarks={bookmarks} <CollectionSectionHeading
selectedItem={cardItem ?? dashboardItem ?? collectionItem} currentUser={currentUser}
onSelect={onItemSelect} handleCreateNewCollection={handleCreateNewCollection}
reorderBookmarks={reorderBookmarks} />
onToggle={setExpandBookmarks} <Tree
initialState={expandBookmarks ? "expanded" : "collapsed"} data={collections}
/> selectedId={collectionItem?.id}
onSelect={onItemSelect}
TreeNode={SidebarCollectionLink}
role="tree"
aria-label="collection-tree"
/>
</ErrorBoundary>
</SidebarSection> </SidebarSection>
)}
<SidebarSection> <SidebarSection>
<CollectionSectionHeading <ErrorBoundary>
currentUser={currentUser} <BrowseNavSection
handleCreateNewCollection={handleCreateNewCollection} nonEntityItem={nonEntityItem}
/> onItemSelect={onItemSelect}
<Tree hasDataAccess={hasDataAccess}
data={collections} />
selectedId={collectionItem?.id} {hasDataAccess && (
onSelect={onItemSelect} <>
TreeNode={SidebarCollectionLink} {!hasOwnDatabase && isAdmin && (
role="tree" <AddYourOwnDataLink
aria-label="collection-tree" icon="add"
/> url={ADD_YOUR_OWN_DATA_URL}
</SidebarSection> isSelected={nonEntityItem?.url?.startsWith(
</div> ADD_YOUR_OWN_DATA_URL,
<WhatsNewNotification /> )}
</SidebarContentRoot> onClick={onItemSelect}
>
{t`Add your own data`}
</AddYourOwnDataLink>
)}
</>
)}
</ErrorBoundary>
</SidebarSection>
</div>
<WhatsNewNotification />
</SidebarContentRoot>
</ErrorBoundary>
); );
} }
interface CollectionSectionHeadingProps { interface CollectionSectionHeadingProps {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment