fix #5660 standardized relation icon (#6504)

fix #5660 

- updated One to many [1:N] icon across app
- created many to one icon [N:1] , and added it in app


![download
(2)](https://github.com/user-attachments/assets/35ce05be-0f5f-4cd0-a1b7-7ab9062f74a0)
![download
(1)](https://github.com/user-attachments/assets/57316e49-c931-4ab5-ad4b-d04b241724c3)

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
NitinPSingh 2024-08-05 19:17:25 +05:30 committed by GitHub
parent fe9144a4a7
commit fa738ec373
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 52 additions and 10 deletions

View File

@ -1,6 +1,7 @@
import { import {
IconComponent, IconComponent,
IconLayersLinked, IconRelationManyToOne,
IconRelationOneToMany,
IconRelationOneToOne, IconRelationOneToOne,
} from 'twenty-ui'; } from 'twenty-ui';
@ -21,7 +22,7 @@ export const RELATION_TYPES: Record<
> = { > = {
[RelationMetadataType.OneToMany]: { [RelationMetadataType.OneToMany]: {
label: 'Has many', label: 'Has many',
Icon: IconLayersLinked, Icon: IconRelationOneToMany,
imageSrc: OneToManySvg, imageSrc: OneToManySvg,
}, },
[RelationMetadataType.OneToOne]: { [RelationMetadataType.OneToOne]: {
@ -31,7 +32,7 @@ export const RELATION_TYPES: Record<
}, },
MANY_TO_ONE: { MANY_TO_ONE: {
label: 'Belongs to one', label: 'Belongs to one',
Icon: IconLayersLinked, Icon: IconRelationManyToOne,
imageSrc: OneToManySvg, imageSrc: OneToManySvg,
isImageFlipped: true, isImageFlipped: true,
}, },

View File

@ -1,6 +1,6 @@
import { ReactNode, useMemo } from 'react';
import { useTheme } from '@emotion/react'; import { useTheme } from '@emotion/react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { ReactNode, useMemo } from 'react';
import { Nullable, useIcons } from 'twenty-ui'; import { Nullable, useIcons } from 'twenty-ui';
import { useGetRelationMetadata } from '@/object-metadata/hooks/useGetRelationMetadata'; import { useGetRelationMetadata } from '@/object-metadata/hooks/useGetRelationMetadata';
@ -13,6 +13,7 @@ import { TableRow } from '@/ui/layout/table/components/TableRow';
import { RELATION_TYPES } from '../../constants/RelationTypes'; import { RELATION_TYPES } from '../../constants/RelationTypes';
import { RelationMetadataType } from '~/generated-metadata/graphql';
import { SettingsObjectFieldDataType } from './SettingsObjectFieldDataType'; import { SettingsObjectFieldDataType } from './SettingsObjectFieldDataType';
type SettingsObjectFieldItemTableRowProps = { type SettingsObjectFieldItemTableRowProps = {
@ -89,7 +90,12 @@ export const SettingsObjectFieldItemTableRow = ({
<TableCell> <TableCell>
<SettingsObjectFieldDataType <SettingsObjectFieldDataType
Icon={RelationIcon} Icon={RelationIcon}
label={relationObjectMetadataItem?.labelPlural} label={
relationType === RelationMetadataType.ManyToOne ||
relationType === RelationMetadataType.OneToOne
? relationObjectMetadataItem?.labelSingular
: relationObjectMetadataItem?.labelPlural
}
to={ to={
relationObjectMetadataItem?.namePlural && relationObjectMetadataItem?.namePlural &&
!relationObjectMetadataItem.isSystem !relationObjectMetadataItem.isSystem

View File

@ -0,0 +1,17 @@
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M3 5m0 2a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z" />
<path d="M16 10h1v4" />
<path d="M7 14v-4l3 4v-4" />
<path d="M13 10.5l0 .01" />
<path d="M13 13.5l0 .01" />
</svg>

After

Width:  |  Height:  |  Size: 419 B

View File

@ -0,0 +1,16 @@
import { useTheme } from '@emotion/react';
import IconRelationManyToOneRaw from '@ui/display/icon/assets/many-to-one.svg?react';
import { IconComponentProps } from '@ui/display/icon/types/IconComponent';
type IconRelationManyToOneProps = Pick<IconComponentProps, 'size' | 'stroke'>;
export const IconRelationManyToOne = (props: IconRelationManyToOneProps) => {
const theme = useTheme();
const size = props.size ?? 24;
const stroke = props.stroke ?? theme.icon.stroke.md;
return (
<IconRelationManyToOneRaw height={size} width={size} strokeWidth={stroke} />
);
};

View File

@ -3,6 +3,7 @@ export {
Icon123, Icon123,
IconAlertCircle, IconAlertCircle,
IconAlertTriangle, IconAlertTriangle,
IconApi,
IconApps, IconApps,
IconArchive, IconArchive,
IconArchiveOff, IconArchiveOff,
@ -51,7 +52,9 @@ export {
IconColorSwatch, IconColorSwatch,
IconMessageCircle as IconComment, IconMessageCircle as IconComment,
IconCopy, IconCopy,
IconCreativeCommonsSa,
IconCreditCard, IconCreditCard,
IconCsv,
IconCurrencyBaht, IconCurrencyBaht,
IconCurrencyDirham, IconCurrencyDirham,
IconCurrencyDollar, IconCurrencyDollar,
@ -85,8 +88,8 @@ export {
IconFilter, IconFilter,
IconFilterOff, IconFilterOff,
IconFocusCentered, IconFocusCentered,
IconFunction,
IconForbid, IconForbid,
IconFunction,
IconGripVertical, IconGripVertical,
IconH1, IconH1,
IconH2, IconH2,
@ -169,9 +172,7 @@ export {
IconVideo, IconVideo,
IconWand, IconWand,
IconWorld, IconWorld,
IconX, IconX
IconCreativeCommonsSa,
IconApi,
IconCsv,
} from '@tabler/icons-react'; } from '@tabler/icons-react';
export type { TablerIconsProps } from '@tabler/icons-react'; export type { TablerIconsProps } from '@tabler/icons-react';

View File

@ -15,6 +15,7 @@ export * from './icon/components/IconGmail';
export * from './icon/components/IconGoogle'; export * from './icon/components/IconGoogle';
export * from './icon/components/IconGoogleCalendar'; export * from './icon/components/IconGoogleCalendar';
export * from './icon/components/IconMicrosoft'; export * from './icon/components/IconMicrosoft';
export * from './icon/components/IconRelationManyToOne';
export * from './icon/components/IconTwentyStar'; export * from './icon/components/IconTwentyStar';
export * from './icon/components/IconTwentyStarFilled'; export * from './icon/components/IconTwentyStarFilled';
export * from './icon/components/TablerIcons'; export * from './icon/components/TablerIcons';