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

DOM nesting validation #2967

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cypress/e2e/projects.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ describe('Projects', () => {
cy.get(projectListItemTitle.query).should('contain.text', testProjectTitle);
cy.get(dashboardLoadMore.query).click();
cy.get(`[href="${routes.project(testProjectKey)}"]`).should('exist');
cy.get(projectListItemTitle.query).filter(`:contains(${testProjectTitle})`).last().click({ force: true });
cy.visit(exactUrl(routes.project(testProjectKey)));
// wait for correct page
cy.get(filtersPanelTitle.query).should('contain', testProjectTitle);
cy.url().should('equal', exactUrl(routes.project(testProjectKey)));
Expand Down
6 changes: 3 additions & 3 deletions src/components/DashboardPage/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import { useGoalPreview } from '../GoalPreview/GoalPreviewProvider';
import { useFMPMetric } from '../../utils/telemetry';
import { LoadMoreButton } from '../LoadMoreButton/LoadMoreButton';
import { ProjectListItemCollapsable } from '../ProjectListItemCollapsable/ProjectListItemCollapsable';
import { routes } from '../../hooks/router';
import { GoalTableList, mapToRenderProps } from '../GoalTableList/GoalTableList';
import { PresetModals } from '../PresetModals';
import { FiltersPanel } from '../FiltersPanel/FiltersPanel';
import { Kanban, buildKanban } from '../Kanban/Kanban';
import { NoGoalsText } from '../NoGoalsText/NoGoalsText';
import { safeUserData } from '../../utils/getUserName';
import { routes } from '../../hooks/router';

import { tr } from './DashboardPage.i18n';

Expand Down Expand Up @@ -152,11 +152,11 @@ export const DashboardPage = ({ user, ssrTime, defaultPresetFallback }: External

return (
<ProjectListItemCollapsable
href={routes.project(project.id, view ? `view=${view}` : undefined)}
key={project.id}
interactive={false}
interactive
visible
project={project}
href={routes.project(project.id, view ? `view=${view}` : undefined)}
goals={children}
actionButtonView="icons"
>
Expand Down
36 changes: 16 additions & 20 deletions src/components/ExploreProjectsPage/ExploreProjectsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { nullable } from '@taskany/bricks';
import { Table, Link } from '@taskany/bricks/harmony';
import NextLink from 'next/link';
import { Table } from '@taskany/bricks/harmony';

import { ExternalPageProps } from '../../utils/declareSsrProps';
import { routes } from '../../hooks/router';
Expand All @@ -22,24 +21,21 @@ export const ExploreProjectsPage = ({ user, ssrTime }: ExternalPageProps) => {
<Table>
{data.projects.map((project) =>
nullable(project, (p) => (
<NextLink key={p.id} href={routes.project(p.id)} passHref legacyBehavior>
<Link>
<TableRowItem title={<TableRowItemTitle size="l">{p.title}</TableRowItemTitle>}>
<ProjectListItem
id={p.id}
title={p.title}
flowId={p.flowId}
stargizers={p._count.stargizers}
owner={p.activity}
starred={p._isStarred}
watching={p._isWatching}
participants={p.participants}
averageScore={p.averageScore}
actionButtonView="icons"
/>
</TableRowItem>
</Link>
</NextLink>
<TableRowItem title={<TableRowItemTitle size="l">{p.title}</TableRowItemTitle>}>
<ProjectListItem
href={routes.project(p.id)}
id={p.id}
title={p.title}
flowId={p.flowId}
stargizers={p._count.stargizers}
owner={p.activity}
starred={p._isStarred}
watching={p._isWatching}
participants={p.participants}
averageScore={p.averageScore}
actionButtonView="icons"
/>
</TableRowItem>
)),
)}
</Table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,21 @@ export const ExploreProjectsStarredPage = ({ user, ssrTime }: ExternalPageProps)
<Table>
{projects.map((project) =>
nullable(project, (p) => (
<NextLink key={p.id} href={routes.project(p.id)} passHref legacyBehavior>
<Link>
<TableRowItem
title={<TableRowItemTitle size="l">{p.title}</TableRowItemTitle>}
>
<ProjectListItem
title={p.title}
flowId={p.flowId}
id={p.id}
stargizers={p._count.stargizers}
owner={p.activity}
starred={!!p._isStarred}
watching={!!p._isWatching}
participants={p.participants as ActivityByIdReturnType[]}
averageScore={p.averageScore}
actionButtonView="icons"
/>
</TableRowItem>
</Link>
</NextLink>
<TableRowItem title={<TableRowItemTitle size="l">{p.title}</TableRowItemTitle>}>
<ProjectListItem
href={routes.project(p.id)}
title={p.title}
flowId={p.flowId}
id={p.id}
stargizers={p._count.stargizers}
owner={p.activity}
starred={!!p._isStarred}
watching={!!p._isWatching}
participants={p.participants as ActivityByIdReturnType[]}
averageScore={p.averageScore}
actionButtonView="icons"
/>
</TableRowItem>
)),
)}
</Table>
Expand Down
36 changes: 16 additions & 20 deletions src/components/ExploreTopProjectsPage/ExploreTopProjectsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { nullable } from '@taskany/bricks';
import { Table, Link } from '@taskany/bricks/harmony';
import NextLink from 'next/link';
import { Table } from '@taskany/bricks/harmony';

import { ExternalPageProps } from '../../utils/declareSsrProps';
import { routes } from '../../hooks/router';
Expand All @@ -22,24 +21,21 @@ export const ExploreProjectsPage = ({ user, ssrTime }: ExternalPageProps) => {
<Table>
{projects.data.map((project) =>
nullable(project, (p) => (
<NextLink key={p.id} href={routes.project(p.id)} passHref legacyBehavior>
<Link>
<TableRowItem title={<TableRowItemTitle size="l">{p.title}</TableRowItemTitle>}>
<ProjectListItem
title={p.title}
flowId={p.flowId}
id={p.id}
stargizers={p._count.stargizers}
owner={p.activity}
starred={p._isStarred}
watching={p._isWatching}
participants={p.participants}
averageScore={p.averageScore}
actionButtonView="icons"
/>
</TableRowItem>
</Link>
</NextLink>
<TableRowItem title={<TableRowItemTitle size="l">{p.title}</TableRowItemTitle>}>
<ProjectListItem
href={routes.project(p.id)}
title={p.title}
flowId={p.flowId}
id={p.id}
stargizers={p._count.stargizers}
owner={p.activity}
starred={p._isStarred}
watching={p._isWatching}
participants={p.participants}
averageScore={p.averageScore}
actionButtonView="icons"
/>
</TableRowItem>
)),
)}
</Table>
Expand Down
5 changes: 3 additions & 2 deletions src/components/ProjectListItem/ProjectListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { ActivityByIdReturnType } from '../../../trpc/inferredTypes';
import { ProjectSubscriptionButtons } from '../ProjectSubscriptionButtons/ProjectSubscriptionButtons';
import { safeUserData } from '../../utils/getUserName';
import { participants as participantsDO } from '../../utils/domObjects';
import { routes } from '../../hooks/router';

import s from './ProjectListItem.module.css';

interface ProjectListItemProps {
href?: string;
id: string;
stargizers: number;
flowId: string;
Expand All @@ -36,6 +36,7 @@ export const ProjectListItem: React.FC<ProjectListItemProps & ComponentProps<typ
averageScore,
className,
actionButtonView,
href,
...attrs
}) => {
const ownerUserGroup = useMemo(() => [owner].map(safeUserData).filter(Boolean), [owner]);
Expand Down Expand Up @@ -67,7 +68,7 @@ export const ProjectListItem: React.FC<ProjectListItemProps & ComponentProps<typ
view={actionButtonView}
watching={watching}
stargizersCounter={stargizers}
href={routes.project(id)}
href={href}
/>
</TableCell>
</TableRow>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { ComponentProps, MouseEventHandler, ReactNode } from 'react';
import NextLink from 'next/link';
import { nullable } from '@taskany/bricks';
import { TreeView, TreeViewNode, Text, Link } from '@taskany/bricks/harmony';
import { TreeView, TreeViewNode, Text } from '@taskany/bricks/harmony';
import { IconServersOutline } from '@taskany/icons';

import { DashboardProjectV2 } from '../../../trpc/inferredTypes';
Expand Down Expand Up @@ -58,6 +57,7 @@ export const ProjectListItemCollapsable: React.FC<ProjectListItemCollapsableProp
>
<ProjectListItem
id={project.id}
href={href}
flowId={project.flowId}
title={project.title}
stargizers={project._count.stargizers}
Expand All @@ -73,19 +73,7 @@ export const ProjectListItemCollapsable: React.FC<ProjectListItemCollapsableProp

return (
<TreeView className={className} {...projectListItem.attr}>
<TreeViewNode
interactive={interactive}
title={nullable(
href,
(h) => (
<NextLink href={h} passHref legacyBehavior>
<Link>{projectComponent}</Link>
</NextLink>
),
projectComponent,
)}
{...props}
>
<TreeViewNode interactive={interactive} title={projectComponent} {...props}>
{goals}
{children}
</TreeViewNode>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.NewTabButton {
height: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { createGoalInlineControl } from '../../utils/domObjects';
import { NextLink } from '../NextLink';

import { tr } from './ProjectSubscriptionButtons.i18n';
import s from './ProjectSubscriptionButtons.module.css';

interface ProjectSubscriptionButtonsProps {
project: {
Expand All @@ -21,7 +22,7 @@ interface ProjectSubscriptionButtonsProps {
starred?: boolean;
watching?: boolean;
stargizersCounter: number;
href: string;
href?: string;
view?: 'default' | 'icons';
}

Expand Down Expand Up @@ -65,9 +66,9 @@ export const ProjectSubscriptionButtons: FC<ProjectSubscriptionButtonsProps> = (
onClick={onAddClick}
/>,
)}
{nullable(view === 'icons', () => (
<NextLink href={href} target="_blank" onClick={onNewTabClick}>
<Button view="clear" iconLeft={<IconTopRightOutline size="s" />} />
{nullable(view === 'icons' && href, (h) => (
<NextLink href={h} target="_blank" onClick={onNewTabClick}>
<Button className={s.NewTabButton} view="clear" iconLeft={<IconTopRightOutline size="s" />} />
</NextLink>
))}
</>
Expand Down
Loading