Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Remotes] Add connection label in form #5599

Closed
Tracked by #3920
thomtrp opened this issue May 27, 2024 · 1 comment
Closed
Tracked by #3920

[Remotes] Add connection label in form #5599

thomtrp opened this issue May 27, 2024 · 1 comment
Assignees

Comments

@thomtrp
Copy link
Contributor

thomtrp commented May 27, 2024

  • Add a label field on database
  • Ask for it in frontend
  • Make it editable
Copy link
Contributor

greptile-apps bot commented May 27, 2024

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 :).

To add a connection label in the form, follow these steps:

  1. Update Form Schema: Modify the form schema to include a label field.

  2. Edit Form Component: Update the form components to include an input for the label field.

  3. Handle Save: Ensure the handleSave function processes the label field.

Implementation Steps:

1. Update Form Schema

In /packages/twenty-front/src/modules/settings/integrations/database-connection/utils/editDatabaseConnection.ts, add the label field to the schema:

const editConnectionSchema = z.object({
  // existing fields
  label: z.string().nonempty('Label is required'),
});

2. Edit Form Component

In /packages/twenty-front/src/modules/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionForm.tsx, add an input for the label field:

<FormProvider {...formConfig}>
  <TextField
    label="Label"
    {...formConfig.register('label')}
    error={!!formConfig.formState.errors.label}
    helperText={formConfig.formState.errors.label?.message}
  />
  {/* existing fields */}
</FormProvider>

3. Handle Save

In /packages/twenty-front/src/modules/settings/integrations/database-connection/components/SettingsIntegrationEditDatabaseConnectionContent.tsx, update the handleSave function to include the label field:

const handleSave = async () => {
  const formValues = formConfig.getValues();
  const dirtyFieldKeys = Object.keys(formConfig.formState.dirtyFields) as (keyof SettingsIntegrationEditConnectionFormValues)[];

  try {
    await updateOneDatabaseConnection({
      ...formatValuesForUpdate({
        databaseKey,
        formValues: pick(formValues, dirtyFieldKeys),
      }),
      id: connection?.id ?? '',
      label: formValues.label, // include label
    });

    navigate(`${settingsIntegrationsPagePath}/${databaseKey}/${connection?.id}`);
  } catch (error) {
    enqueueSnackBar((error as Error).message, {
      variant: SnackBarVariant.Error,
    });
  }
};

Repeat similar steps for the new connection form in /packages/twenty-front/src/pages/settings/integrations/SettingsIntegrationNewDatabaseConnection.tsx.

References

/packages/twenty-front/src/modules/settings/integrations/database-connection/components/SettingsIntegrationEditDatabaseConnectionContent.tsx
/packages/twenty-front/src/modules/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionsListCard.tsx
/packages/twenty-front/src/modules/settings/integrations/database-connection/components/SettingsIntegrationDatabaseConnectionSummaryCard.tsx
/packages/twenty-front/src/pages/settings/integrations/SettingsIntegrationNewDatabaseConnection.tsx

Ask Greptile

@thomtrp thomtrp moved this from 🆕 New to 🔖 Planned in 🎯 Roadmap & Sprints May 27, 2024
@thomtrp thomtrp moved this from 🔖 Planned to 👀 In review in 🎯 Roadmap & Sprints May 27, 2024
@thomtrp thomtrp moved this from 👀 In review to 🏗 In progress in 🎯 Roadmap & Sprints May 27, 2024
@thomtrp thomtrp moved this from 🏗 In progress to 👀 In review in 🎯 Roadmap & Sprints May 28, 2024
@thomtrp thomtrp closed this as completed May 28, 2024
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in 🎯 Roadmap & Sprints May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

1 participant