twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
Other
20.27k stars 2.25k forks source link

Handle distant table column data type change #5611

Closed ijreilly closed 1 month ago

ijreilly commented 5 months ago

Update - Remote objects project is on hold for now.

greptile-apps[bot] commented 5 months ago

Disclaimer: This comment was automatically generated with AI. It can give some useful hints as to where to look for, but sometimes it can also give very inaccurate answers so takes this with a pinch of salt :).

Implementation Steps

  1. Modify TableOptionsDropdownContent:

    • Add the new "Add field Item" using a MenuItem component.
      // File: src/components/TableOptionsDropdownContent.js
      <MenuItem onClick={() => setIsAddingField(true)}>Add field</MenuItem>
  2. Create internal state isAddingField:

    • Track the progress in the flow. Set this state to true on "Add field Item" onClick.
      // File: src/components/TableOptionsDropdownContent.js
      const [isAddingField, setIsAddingField] = useState(false);
  3. Modify RecordTableHeaderPlusButtonContent:

    • Update to show the "Add custom field option" when isAddingField is true.
      // File: src/components/RecordTableHeaderPlusButtonContent.js
      {isAddingField && <AddCustomFieldOption />}
  4. Update useTableColumns hook:

    • Ensure it only returns visible columns.
      // File: src/hooks/useTableColumns.js
      const visibleColumns = columns.filter(column => column.isVisible);
  5. Modify SettingsObjectDetail and SettingsObjectNewFieldStep1:

    • Ensure these components handle the new custom field addition flow.
      // File: src/components/SettingsObjectDetail.js
      if (isAddingField) {
      return <SettingsObjectNewFieldStep1 />;
      }
  6. Update dropdown menu components:

    • Ensure the menu swaps correctly to show the "field type" menu when adding a custom field.
      // File: src/components/DropdownMenu.js
      {isAddingField ? <FieldTypeMenu /> : <DefaultMenu />}

References