twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
15.68k stars 1.69k forks source link

Timeline Log: Display "Empty" When Field Value Deleted #6288

Closed Bonapara closed 1 month ago

Bonapara commented 1 month ago

Current behavior

When deleting the value of a field, the timeline log looks buggy as there is no value next to the arrow

CleanShot 2024-07-16 at 16 28 10

Desired Behavior

We should display "Empty" and not an empty string

CleanShot 2024-07-16 at 16 30 39

greptile-apps[bot] commented 1 month ago

Modify EventRowMainObjectUpdated.tsx to handle empty field values:

const diffEntries = Object.entries(diff).map(([key, value]) => {
  if (value.after === '') {
    value.after = 'Empty';
  }
  return [key, value];
});

Update EventFieldDiffContainer.tsx to ensure 'Empty' is displayed:

const EventFieldDiffContainer = ({
  mainObjectMetadataItem,
  diffKey,
  diffValue,
  eventId,
  fieldMetadataItemMap,
}: EventFieldDiffContainerProps) => {
  const fieldMetadataItem = fieldMetadataItemMap[diffKey];

  if (!fieldMetadataItem) {
    throw new Error(
      `Cannot find field metadata item for field name ${diffKey} on object ${mainObjectMetadataItem.nameSingular}`,
    );
  }

  const diffArtificialRecordStoreId = eventId + '--' + fieldMetadataItem.id;

  return (
    <EventFieldDiff
      key={diffArtificialRecordStoreId}
      diffRecord={diffValue === '' ? 'Empty' : diffValue}
      fieldMetadataItem={fieldMetadataItem}
      mainObjectMetadataItem={mainObjectMetadataItem}
      diffArtificialRecordStoreId={diffArtificialRecordStoreId}
    />
  );
};

References

/packages/twenty-front/src/modules/activities/timelineActivities/rows/main-object/components/EventRowMainObjectUpdated.tsx /packages/twenty-front/src/modules/activities/timelineActivities/rows/main-object/components/EventFieldDiffContainer.tsx

#### About Greptile This response provides a starting point for your research, not a precise solution. Help us improve! Please leave a ๐Ÿ‘ if this is helpful and ๐Ÿ‘Ž if it is irrelevant. [Ask Greptile](https://app.greptile.com/chat/github/twentyhq/twenty/main) ยท [Edit Issue Bot Settings](https://app.greptile.com/apps/github)