PopupZLevel,
} from 'design-system';
import * as React from 'react';
-import Tooltip from '../../../../components/controls/Tooltip';
+import { useLocation } from '../../../../components/hoc/withRouter';
import { DEFAULT_ISSUES_QUERY } from '../../../../components/shared/utils';
import { getBranchLikeQuery, isPullRequest } from '../../../../helpers/branch-like';
import { hasMessage, translate, translateWithParameters } from '../../../../helpers/l10n';
type Query = BranchParameters & { id: string };
-export function Menu(props: Props) {
+export function Menu(props: Readonly<Props>) {
const { component, isInProgress, isPending } = props;
const { extensions = [], canBrowseAllChildProjects, qualifier, configuration = {} } = component;
const { data: { branchLikes, branchLike } = { branchLikes: [] } } = useBranchesQuery(component);
const isApplicationChildInaccessble = isApplication(qualifier) && !canBrowseAllChildProjects;
+ const location = useLocation();
+
const hasAnalysis = () => {
const hasBranches = branchLikes.length > 1;
return hasBranches || isInProgress || isPending || component.analysisDate !== undefined;
return { id: component.key, ...getBranchLikeQuery(branchLike) };
};
- const renderLinkWhenInaccessibleChild = (label: React.ReactNode) => {
+ const renderLinkWhenInaccessibleChild = (label: string) => {
return (
- <li>
- <Tooltip
- overlay={translateWithParameters(
- 'layout.all_project_must_be_accessible',
- translate('qualifier', qualifier),
- )}
- >
- <a aria-disabled="true" className="disabled-link">
- {label}
- </a>
- </Tooltip>
- </li>
+ <DisabledTabLink
+ overlay={translateWithParameters(
+ 'layout.all_project_must_be_accessible',
+ translate('qualifier', qualifier),
+ )}
+ label={label}
+ />
);
};
) : null;
}
+ const showingTutorial = location.pathname.includes('/tutorials');
+
+ if (showingTutorial) {
+ return (
+ <DisabledTabLink
+ overlay={translate('layout.must_be_configured')}
+ label={translate('overview.page')}
+ />
+ );
+ }
+
if (isApplicationChildInaccessble) {
return renderLinkWhenInaccessibleChild(translate('overview.page'));
}
analysisDate: undefined,
},
});
- expect(screen.getByRole('link', { name: 'overview.page' })).toBeInTheDocument();
- expect(screen.queryByRole('link', { name: 'issues.page' })).toHaveClass('disabled-link');
- expect(screen.queryByRole('link', { name: 'layout.measures' })).toHaveClass('disabled-link');
+
+ expect(screen.queryByRole('link', { name: 'issues.page' })).toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ );
+ expect(screen.queryByRole('link', { name: 'layout.measures' })).toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ );
expect(screen.getByRole('link', { name: 'project.info.title' })).toBeInTheDocument();
});
canBrowseAllChildProjects: false,
},
});
- expect(screen.queryByRole('link', { name: 'overview.page' })).not.toBeInTheDocument();
- expect(screen.queryByRole('link', { name: 'issues.page' })).not.toBeInTheDocument();
- expect(screen.queryByRole('link', { name: 'layout.measures' })).not.toBeInTheDocument();
+ expect(screen.queryByRole('link', { name: 'overview.page' })).toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ );
+ expect(screen.queryByRole('link', { name: 'issues.page' })).toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ );
+ expect(screen.queryByRole('link', { name: 'layout.measures' })).toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ );
expect(screen.queryByRole('button', { name: 'application.info.title' })).not.toBeInTheDocument();
});