Create ESLint rule to discourage usage of navigate() and prefer Link (#5642)
### Description Create ESLint rule to discourage usage of navigate() and prefer Link ### Refs #5468 ### Demo   Fixes #5468 --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Link } from 'react-router-dom';
|
||||
import styled from '@emotion/styled';
|
||||
import { H2Title, IconCalendarEvent, IconMailCog } from 'twenty-ui';
|
||||
|
||||
@ -6,6 +6,7 @@ import { SettingsNavigationCard } from '@/settings/components/SettingsNavigation
|
||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
||||
import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { Section } from '@/ui/layout/section/components/Section';
|
||||
import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink';
|
||||
|
||||
const StyledCardsContainer = styled.div`
|
||||
display: flex;
|
||||
@ -14,8 +15,6 @@ const StyledCardsContainer = styled.div`
|
||||
`;
|
||||
|
||||
export const SettingsAccountsSettingsSection = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<Section>
|
||||
<H2Title
|
||||
@ -23,24 +22,16 @@ export const SettingsAccountsSettingsSection = () => {
|
||||
description="Configure your emails and calendar settings."
|
||||
/>
|
||||
<StyledCardsContainer>
|
||||
<SettingsNavigationCard
|
||||
Icon={IconMailCog}
|
||||
title="Emails"
|
||||
onClick={() =>
|
||||
navigate(getSettingsPagePath(SettingsPath.AccountsEmails))
|
||||
}
|
||||
>
|
||||
Set email visibility, manage your blocklist and more.
|
||||
</SettingsNavigationCard>
|
||||
<SettingsNavigationCard
|
||||
Icon={IconCalendarEvent}
|
||||
title="Calendar"
|
||||
onClick={() =>
|
||||
navigate(getSettingsPagePath(SettingsPath.AccountsCalendars))
|
||||
}
|
||||
>
|
||||
Configure and customize your calendar preferences.
|
||||
</SettingsNavigationCard>
|
||||
<UndecoratedLink to={getSettingsPagePath(SettingsPath.AccountsEmails)}>
|
||||
<SettingsNavigationCard Icon={IconMailCog} title="Emails">
|
||||
Set email visibility, manage your blocklist and more.
|
||||
</SettingsNavigationCard>
|
||||
</UndecoratedLink>
|
||||
<Link to={getSettingsPagePath(SettingsPath.AccountsCalendars)}>
|
||||
<SettingsNavigationCard Icon={IconCalendarEvent} title="Calendar">
|
||||
Configure and customize your calendar preferences.
|
||||
</SettingsNavigationCard>
|
||||
</Link>
|
||||
</StyledCardsContainer>
|
||||
</Section>
|
||||
);
|
||||
|
||||
@ -27,10 +27,6 @@ export const SettingsIntegrationDatabaseConnectionShowContainer = () => {
|
||||
navigate(`${settingsIntegrationsPagePath}/${databaseKey}`);
|
||||
};
|
||||
|
||||
const onEdit = () => {
|
||||
navigate('./edit');
|
||||
};
|
||||
|
||||
const settingsIntegrationsPagePath = getSettingsPagePath(
|
||||
SettingsPath.Integrations,
|
||||
);
|
||||
@ -57,7 +53,6 @@ export const SettingsIntegrationDatabaseConnectionShowContainer = () => {
|
||||
connectionId={connection.id}
|
||||
connectionLabel={connection.label}
|
||||
onRemove={deleteConnection}
|
||||
onEdit={onEdit}
|
||||
/>
|
||||
</Section>
|
||||
<Section>
|
||||
|
||||
@ -7,6 +7,7 @@ import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
||||
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
||||
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
|
||||
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
||||
import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink';
|
||||
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
|
||||
|
||||
type SettingsIntegrationDatabaseConnectionSummaryCardProps = {
|
||||
@ -14,7 +15,6 @@ type SettingsIntegrationDatabaseConnectionSummaryCardProps = {
|
||||
connectionId: string;
|
||||
connectionLabel: string;
|
||||
onRemove: () => void;
|
||||
onEdit: () => void;
|
||||
};
|
||||
|
||||
const StyledDatabaseLogoContainer = styled.div`
|
||||
@ -34,7 +34,6 @@ export const SettingsIntegrationDatabaseConnectionSummaryCard = ({
|
||||
connectionId,
|
||||
connectionLabel,
|
||||
onRemove,
|
||||
onEdit,
|
||||
}: SettingsIntegrationDatabaseConnectionSummaryCardProps) => {
|
||||
const dropdownId =
|
||||
'settings-integration-database-connection-summary-card-dropdown';
|
||||
@ -69,11 +68,9 @@ export const SettingsIntegrationDatabaseConnectionSummaryCard = ({
|
||||
text="Remove"
|
||||
onClick={onRemove}
|
||||
/>
|
||||
<MenuItem
|
||||
LeftIcon={IconPencil}
|
||||
text="Edit"
|
||||
onClick={onEdit}
|
||||
/>
|
||||
<UndecoratedLink to="./edit">
|
||||
<MenuItem LeftIcon={IconPencil} text="Edit" />
|
||||
</UndecoratedLink>
|
||||
</DropdownMenuItemsContainer>
|
||||
</DropdownMenu>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user