Skip to content

Commit

Permalink
refactor(ProjectSubscriptionButtons): remove component icon button, a…
Browse files Browse the repository at this point in the history
…dd new icon variant
  • Loading branch information
IgorGoryany committed Aug 12, 2024
1 parent 5be3a0d commit a703395
Show file tree
Hide file tree
Showing 21 changed files with 177 additions and 266 deletions.
18 changes: 12 additions & 6 deletions cypress/fixtures/langs.json
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,12 @@
"en": "Create"
}
},
"NoGoalsText": {
"No goals yet": {
"ru": "",
"en": ""
}
},
"OfflineBanner": {
"You are currently offline. Check connection.": {
"ru": "Вы сейчас не в сети. Проверьте подключение.",
Expand Down Expand Up @@ -1047,12 +1053,6 @@
"en": "Create"
}
},
"ProjectListItem": {
"Create Goal": {
"ru": "",
"en": ""
}
},
"ProjectPage": {
"title": {
"ru": "Taskany — {project}",
Expand Down Expand Up @@ -1209,6 +1209,12 @@
"en": "Ok, got it"
}
},
"ProjectSubscriptionButtons": {
"Create goal": {
"ru": "Создать цель",
"en": ""
}
},
"ProjectSwitchPublicConfirmModal": {
"You are going to make project public": {
"ru": "Вы собираетесь сделать проект публичным",
Expand Down
128 changes: 4 additions & 124 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@sentry/nextjs": "7.99.0",
"@tanstack/react-query": "4.29.5",
"@tanstack/react-query-devtools": "4.29.6",
"@taskany/bricks": "5.43.0",
"@taskany/bricks": "5.44.0",
"@taskany/colors": "1.13.0",
"@taskany/icons": "2.0.7",
"@tippyjs/react": "4.2.6",
Expand Down
7 changes: 4 additions & 3 deletions src/components/DashboardPage/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import { Page } from '../Page/Page';
import { useGoalPreview } from '../GoalPreview/GoalPreviewProvider';
import { useFMPMetric } from '../../utils/telemetry';
import { LoadMoreButton } from '../LoadMoreButton/LoadMoreButton';
import { InlineCreateGoalControl } from '../InlineCreateGoalControl/InlineCreateGoalControl';
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 { tr } from './DashboardPage.i18n';
Expand Down Expand Up @@ -151,10 +151,11 @@ export const DashboardPage = ({ user, ssrTime, defaultPresetFallback }: External
project={project}
href={routes.project(project.id, view ? `view=${view}` : undefined)}
goals={children}
canCreateGoal
actionButtonView="icons"
editable
>
{nullable(!goals?.length, () => (
<InlineCreateGoalControl project={project} />
<NoGoalsText />
))}
</ProjectListItemCollapsable>
);
Expand Down
3 changes: 3 additions & 0 deletions src/components/NoGoalsText/NoGoalsText.i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"No goals yet": ""
}
17 changes: 17 additions & 0 deletions src/components/NoGoalsText/NoGoalsText.i18n/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable */
// Do not edit, use generator to update
import { i18n, fmt, I18nLangSet } from 'easy-typed-intl';
import getLang from '../../../utils/getLang';

import ru from './ru.json';
import en from './en.json';

export type I18nKey = keyof typeof ru & keyof typeof en;
type I18nLang = 'ru' | 'en';

const keyset: I18nLangSet<I18nKey> = {};

keyset['ru'] = ru;
keyset['en'] = en;

export const tr = i18n<I18nLang, I18nKey>(keyset, fmt, getLang);
3 changes: 3 additions & 0 deletions src/components/NoGoalsText/NoGoalsText.i18n/ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"No goals yet": "Пока нет целей"
}
7 changes: 7 additions & 0 deletions src/components/NoGoalsText/NoGoalsText.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Text } from '@taskany/bricks/harmony';

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

export const NoGoalsText = () => {
return <Text size="m">{tr('No goals yet')}</Text>;
};
22 changes: 7 additions & 15 deletions src/components/ProjectListItem/ProjectListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import cn from 'classnames';
import { IconStarSolid, IconEyeOutline } from '@taskany/icons';
import { ComponentProps, useMemo } from 'react';

import { ProjectSubscriptionIconButtons } from '../ProjectSubscriptionIconButtons/ProjectSubscriptionIconButtons';
import { ActivityByIdReturnType } from '../../../trpc/inferredTypes';
import { ProjectSubscriptionButtons } from '../ProjectSubscriptionButtons';
import { ProjectSubscriptionButtons } from '../ProjectSubscriptionButtons/ProjectSubscriptionButtons';
import { safeUserData } from '../../utils/getUserName';
import { watch, participants as participantsDO } from '../../utils/domObjects';

Expand All @@ -23,7 +22,7 @@ interface ProjectListItemProps {
starred?: boolean;
watching?: boolean;
averageScore: number | null;
canCreateGoal?: boolean;
actionButtonView?: 'default' | 'icons';
}

export const ProjectListItem: React.FC<ProjectListItemProps & ComponentProps<typeof TableRow>> = ({
Expand All @@ -38,7 +37,7 @@ export const ProjectListItem: React.FC<ProjectListItemProps & ComponentProps<typ
averageScore,
className,
editable,
canCreateGoal,
actionButtonView,
...attrs
}) => {
const ownerUserGroup = useMemo(() => [owner].map(safeUserData).filter(Boolean), [owner]);
Expand Down Expand Up @@ -66,10 +65,10 @@ export const ProjectListItem: React.FC<ProjectListItemProps & ComponentProps<typ
<TableCell
width={40}
className={cn(s.ProjectListItemIcons, {
[s.ProjectListItemIcons_editable]: editable || canCreateGoal,
[s.ProjectListItemIcons_editable]: editable,
})}
>
{nullable(!canCreateGoal && !editable, () => (
{nullable(!editable, () => (
<>
{nullable(starred, () => (
<IconStarSolid size="s" />
Expand All @@ -81,20 +80,13 @@ export const ProjectListItem: React.FC<ProjectListItemProps & ComponentProps<typ
))}
{nullable(editable, () => (
<ProjectSubscriptionButtons
id={id}
project={{ flowId, id, title }}
starred={starred}
view={actionButtonView}
watching={watching}
stargizersCounter={stargizers}
/>
))}

{nullable(canCreateGoal, () => (
<ProjectSubscriptionIconButtons
starred={starred}
watching={watching}
project={{ flowId, id, title }}
/>
))}
</TableCell>
</TableRow>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface ProjectListItemCollapsableProps extends Omit<ComponentProps<typeof Tre
onClick?: MouseEventHandler<HTMLElement>;
titleSize?: 'm' | 'l';
editable?: boolean;
canCreateGoal?: boolean;
actionButtonView?: 'default' | 'icons';
}

export const ProjectListItemCollapsable: React.FC<ProjectListItemCollapsableProps> = ({
Expand All @@ -33,8 +33,8 @@ export const ProjectListItemCollapsable: React.FC<ProjectListItemCollapsableProp
className,
titleSize = 'l',
interactive = true,
actionButtonView,
onClick,
canCreateGoal,
...props
}) => {
const projectComponent = (
Expand Down Expand Up @@ -68,7 +68,7 @@ export const ProjectListItemCollapsable: React.FC<ProjectListItemCollapsableProp
watching={project._isWatching}
averageScore={project.averageScore}
editable={editable}
canCreateGoal={canCreateGoal}
actionButtonView={actionButtonView}
/>
</TableRowItem>
);
Expand Down
7 changes: 2 additions & 5 deletions src/components/ProjectListItemConnected.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { safeUserData } from '../utils/getUserName';

import { GoalTableList, mapToRenderProps } from './GoalTableList/GoalTableList';
import { ProjectListItemCollapsable } from './ProjectListItemCollapsable/ProjectListItemCollapsable';
import { InlineCreateGoalControl } from './InlineCreateGoalControl/InlineCreateGoalControl';
import { useGoalPreview } from './GoalPreview/GoalPreviewProvider';
import { Kanban, buildKanban } from './Kanban/Kanban';
import { NoGoalsText } from './NoGoalsText/NoGoalsText';

interface ProjectListItemConnectedProps extends ComponentProps<typeof ProjectListItemCollapsable> {
parent?: ComponentProps<typeof ProjectListItemCollapsable>['project'];
Expand Down Expand Up @@ -133,10 +133,7 @@ export const ProjectListItemConnected: FC<ProjectListItemConnectedProps> = ({
{...props}
>
<TreeViewElement>
{nullable(
!projectDeepInfo?.goals.length,
() => !isLoading && <InlineCreateGoalControl project={project} />,
)}
{nullable(!projectDeepInfo?.goals.length, () => !isLoading && <NoGoalsText />)}
</TreeViewElement>
{nullable(view !== 'kanban', () => subNodes)}
</ProjectListItemCollapsable>
Expand Down
Loading

0 comments on commit a703395

Please sign in to comment.