{icon &&
}
-
{children}
+ {children}
{target === '_blank' && (
@@ -66,10 +66,10 @@ export function NavBarMenuItem({ children, icon, isActive, isChild, onClick, tar
);
}
- return
{element};
+ return
{element}
;
}
-NavBarMenuItem.displayName = 'NavBarMenuItem';
+MegaMenuItemText.displayName = 'MegaMenuItemText';
const getStyles = (theme: GrafanaTheme2, isActive: Props['isActive'], isChild: Props['isActive']) => ({
button: css({
@@ -83,11 +83,6 @@ const getStyles = (theme: GrafanaTheme2, isActive: Props['isActive'], isChild: P
height: '100%',
width: '100%',
}),
- linkText: css({
- textOverflow: 'ellipsis',
- overflow: 'hidden',
- whiteSpace: 'nowrap',
- }),
externalLinkIcon: css({
color: theme.colors.text.secondary,
}),
@@ -127,7 +122,7 @@ const getStyles = (theme: GrafanaTheme2, isActive: Props['isActive'], isChild: P
backgroundImage: theme.colors.gradients.brandVertical,
},
}),
- listItem: css({
+ wrapper: css({
boxSizing: 'border-box',
position: 'relative',
display: 'flex',
diff --git a/public/app/core/components/AppChrome/DockedMegaMenu/NavBarMenuItemWrapper.tsx b/public/app/core/components/AppChrome/DockedMegaMenu/NavBarMenuItemWrapper.tsx
deleted file mode 100644
index 04e4e010576..00000000000
--- a/public/app/core/components/AppChrome/DockedMegaMenu/NavBarMenuItemWrapper.tsx
+++ /dev/null
@@ -1,112 +0,0 @@
-import { css } from '@emotion/css';
-import React from 'react';
-
-import { GrafanaTheme2, NavModelItem } from '@grafana/data';
-import { useStyles2 } from '@grafana/ui';
-
-import { NavBarMenuItem } from './NavBarMenuItem';
-import { NavBarMenuSection } from './NavBarMenuSection';
-import { isMatchOrChildMatch } from './utils';
-
-export function NavBarMenuItemWrapper({
- link,
- activeItem,
- onClose,
-}: {
- link: NavModelItem;
- activeItem?: NavModelItem;
- onClose: () => void;
-}) {
- const styles = useStyles2(getStyles);
-
- if (link.emptyMessage && !linkHasChildren(link)) {
- return (
-
-
-
- );
- }
-
- return (
-
- {linkHasChildren(link) && (
-
- {link.children.map((childLink) => {
- return linkHasChildren(childLink) ? (
-
- ) : (
- !childLink.isCreateAction && (
- {
- childLink.onClick?.();
- onClose();
- }}
- target={childLink.target}
- url={childLink.url}
- >
- {childLink.text}
-
- )
- );
- })}
-
- )}
-
- );
-}
-
-const getStyles = (theme: GrafanaTheme2) => ({
- children: css({
- display: 'flex',
- flexDirection: 'column',
- }),
- flex: css({
- display: 'flex',
- }),
- itemWithoutMenu: css({
- position: 'relative',
- placeItems: 'inherit',
- justifyContent: 'start',
- display: 'flex',
- flexGrow: 1,
- alignItems: 'center',
- }),
- fullWidth: css({
- height: '100%',
- width: '100%',
- }),
- iconContainer: css({
- display: 'flex',
- placeContent: 'center',
- }),
- itemWithoutMenuContent: css({
- display: 'grid',
- gridAutoFlow: 'column',
- gridTemplateColumns: `${theme.spacing(7)} auto`,
- alignItems: 'center',
- height: '100%',
- }),
- linkText: css({
- fontSize: theme.typography.pxToRem(14),
- justifySelf: 'start',
- }),
- emptyMessage: css({
- color: theme.colors.text.secondary,
- fontStyle: 'italic',
- padding: theme.spacing(1, 1.5, 1, 7),
- }),
-});
-
-function linkHasChildren(link: NavModelItem): link is NavModelItem & { children: NavModelItem[] } {
- return Boolean(link.children && link.children.length > 0);
-}
diff --git a/public/app/core/components/Indent/Indent.tsx b/public/app/core/components/Indent/Indent.tsx
new file mode 100644
index 00000000000..3f4647a4df3
--- /dev/null
+++ b/public/app/core/components/Indent/Indent.tsx
@@ -0,0 +1,26 @@
+import { css } from '@emotion/css';
+import React from 'react';
+
+import { GrafanaTheme2, ThemeSpacingTokens } from '@grafana/data';
+import { useStyles2 } from '@grafana/ui';
+import { getResponsiveStyle, ResponsiveProp } from '@grafana/ui/src/components/Layout/utils/responsiveness';
+
+interface IndentProps {
+ children?: React.ReactNode;
+ level: number;
+ spacing: ResponsiveProp
;
+}
+
+export function Indent({ children, spacing, level }: IndentProps) {
+ const styles = useStyles2(getStyles, spacing, level);
+
+ return {children};
+}
+
+const getStyles = (theme: GrafanaTheme2, spacing: IndentProps['spacing'], level: IndentProps['level']) => ({
+ indentor: css(
+ getResponsiveStyle(theme, spacing, (val) => ({
+ paddingLeft: theme.spacing(val * level),
+ }))
+ ),
+});
diff --git a/public/app/core/components/NestedFolderPicker/NestedFolderList.tsx b/public/app/core/components/NestedFolderPicker/NestedFolderList.tsx
index 36c69fc02bf..f0874362c93 100644
--- a/public/app/core/components/NestedFolderPicker/NestedFolderList.tsx
+++ b/public/app/core/components/NestedFolderPicker/NestedFolderList.tsx
@@ -8,8 +8,8 @@ import { GrafanaTheme2 } from '@grafana/data';
import { IconButton, useStyles2 } from '@grafana/ui';
import { getSvgSize } from '@grafana/ui/src/components/Icon/utils';
import { Text } from '@grafana/ui/src/components/Text/Text';
+import { Indent } from 'app/core/components/Indent/Indent';
import { Trans } from 'app/core/internationalization';
-import { Indent } from 'app/features/browse-dashboards/components/Indent';
import { childrenByParentUIDSelector, rootItemsSelector } from 'app/features/browse-dashboards/state';
import { DashboardsTreeItem } from 'app/features/browse-dashboards/types';
import { DashboardViewItem } from 'app/features/search/types';
@@ -153,7 +153,7 @@ function Row({ index, style: virtualStyles, data }: RowProps) {
if (item.kind === 'ui' && item.uiKind === 'pagination-placeholder') {
return (
-
+
);
@@ -190,7 +190,7 @@ function Row({ index, style: virtualStyles, data }: RowProps) {
id={getDOMId(idPrefix, item.uid)}
>
-
+
{foldersAreOpenable ? (
+
{headerGroups.map((headerGroup) => {
const { key, ...headerGroupProps } = headerGroup.getHeaderGroupProps({
style: { width },
@@ -213,15 +207,6 @@ function VirtualListRow({ index, style, data }: VirtualListRowProps) {
const getStyles = (theme: GrafanaTheme2) => {
return {
- tableRoot: css({
- // Responsively
- [INDENT_AMOUNT_CSS_VAR]: theme.spacing(1),
-
- [theme.breakpoints.up('md')]: {
- [INDENT_AMOUNT_CSS_VAR]: theme.spacing(3),
- },
- }),
-
// Column flex properties (cell sizing) are set by customFlexTableLayout.ts
row: css({
diff --git a/public/app/features/browse-dashboards/components/Indent.tsx b/public/app/features/browse-dashboards/components/Indent.tsx
deleted file mode 100644
index d8edb362b6f..00000000000
--- a/public/app/features/browse-dashboards/components/Indent.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import React from 'react';
-
-import { useTheme2 } from '@grafana/ui';
-
-import { INDENT_AMOUNT_CSS_VAR } from '../types';
-
-interface IndentProps {
- children?: React.ReactNode;
- level: number;
-}
-
-export function Indent({ children, level }: IndentProps) {
- const theme = useTheme2();
-
- // DashboardsTree responsively sets the value of INDENT_AMOUNT_CSS_VAR
- // but we also have a fallback just in case it's not set for some reason...
- const space = `var(${INDENT_AMOUNT_CSS_VAR}, ${theme.spacing(2)})`;
-
- return {children};
-}
diff --git a/public/app/features/browse-dashboards/components/NameCell.tsx b/public/app/features/browse-dashboards/components/NameCell.tsx
index 59d50312645..69ee47be2f2 100644
--- a/public/app/features/browse-dashboards/components/NameCell.tsx
+++ b/public/app/features/browse-dashboards/components/NameCell.tsx
@@ -9,11 +9,10 @@ import { Icon, IconButton, Link, Spinner, useStyles2, Text } from '@grafana/ui';
import { getSvgSize } from '@grafana/ui/src/components/Icon/utils';
import { getIconForKind } from 'app/features/search/service/utils';
+import { Indent } from '../../../core/components/Indent/Indent';
import { useChildrenByParentUIDState } from '../state';
import { DashboardsTreeItem } from '../types';
-import { Indent } from './Indent';
-
const CHEVRON_SIZE = 'md';
const ICON_SIZE = 'sm';
@@ -31,7 +30,13 @@ export function NameCell({ row: { original: data }, onFolderClick }: NameCellPro
if (item.kind === 'ui') {
return (
<>
-
+
{item.uiKind === 'empty-folder' ? (
@@ -48,7 +53,13 @@ export function NameCell({ row: { original: data }, onFolderClick }: NameCellPro
return (
<>
-
+
{item.kind === 'folder' ? (