Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] Allow disabling Settings left pane items #20449

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions js_modules/dagster-ui/packages/ui-core/src/ui/SideNavItem.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {Box, Colors, IconWrapper, UnstyledButton} from '@dagster-io/ui-components';
import {Box, Colors, IconWrapper, Tooltip, UnstyledButton} from '@dagster-io/ui-components';
import {Link} from 'react-router-dom';
import styled from 'styled-components';

interface SideNavItemInterface {
key: string;
icon: React.ReactNode;
label: React.ReactNode;
disabled?: boolean;
rightElement?: React.ReactNode;
tooltip?: React.ReactNode;
tooltip?: string;
onClick?: () => void;
}

Expand All @@ -30,7 +31,7 @@ interface Props {

export const SideNavItem = (props: Props) => {
const {active = false, item} = props;
const {type, icon, label, rightElement} = item;
const {type, icon, label, rightElement, tooltip = '', disabled = false} = item;
const content = (
<Box
padding={{vertical: 4, left: 12, right: 8}}
Expand All @@ -44,15 +45,23 @@ export const SideNavItem = (props: Props) => {
</Box>
);

if (type === 'link') {
if (type === 'link' && !disabled) {
return (
<StyledSideNavLink to={item.path} $active={active}>
{content}
</StyledSideNavLink>
<Tooltip canShow={!!tooltip} content={tooltip} placement="right" display="block">
<StyledSideNavLink to={item.path} $active={active}>
{content}
</StyledSideNavLink>
</Tooltip>
);
}

return <StyledSideNavButton onClick={item.onClick}>{content}</StyledSideNavButton>;
return (
<Tooltip canShow={!!tooltip} content={tooltip} placement="right" display="block">
<StyledSideNavButton disabled={disabled} onClick={item.onClick}>
{content}
</StyledSideNavButton>
</Tooltip>
);
};

const StyledSideNavLink = styled(Link)<{$active: boolean}>`
Expand Down Expand Up @@ -91,6 +100,7 @@ const StyledSideNavButton = styled(UnstyledButton)`
border-radius: 8px;
color: ${Colors.textDefault()};
display: block;
font-size: 14px;
line-height: 20px;
text-decoration: none;
transition: 100ms background-color linear;
Expand Down
Loading