-
Notifications
You must be signed in to change notification settings - Fork 500
feat(webapp, api): allow updating sync frequency for a specific conne… #3881
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
base: master
Are you sure you want to change the base?
feat(webapp, api): allow updating sync frequency for a specific conne… #3881
Conversation
…ction via dashboard
This PR is stale because it has been open for 30 days with no activity. |
d905972
to
10ac2ed
Compare
packages/types/lib/sync/api.ts
Outdated
@@ -36,6 +36,21 @@ export type PostSyncVariant = Endpoint<{ | |||
Success: { id: string; name: string; variant: string }; | |||
}>; | |||
|
|||
export type UpdateSyncConnectionFrequency = Endpoint<{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have the name of the consistent with the endpoint path. wdyt?
export type UpdateSyncConnectionFrequency = Endpoint<{ | |
export type UpdateConnectionFrequency = Endpoint<{ |
|
||
const reg = value.match(frequencyRegex); | ||
if (!reg || !reg.groups) { | ||
setFrequencyError('Format should be "every (number) (unit)", e.g: "every 1 hour", "every 20 days"'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the regex allows to skip the every
const amount = parseInt(reg.groups['amount'], 10); | ||
|
||
if (unit.startsWith('s') && (amount < 30 || !amount)) { | ||
setFrequencyError('The minimum frequency is 30 seconds'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi the min value depends on the customer plan.
Hey @TBonnin I implemented the changes you requested. Just for context the regex was originally written by Samuel. I didn’t write it from scratch. I just abstracted it so it could be reused where I needed it. That said, I updated it exactly as you suggested and ran a bunch of test cases to verify. You were totally right, it works as expected now 🙌 Regarding the minimum frequency check: I based it on another part of the app (see attached screenshot), where it was already implemented like this. If we want to make it dynamic based on the customer’s plan, I’d be more than happy to help, but I assume that would involve a bit more work on the backend to expose the relevant data to the frontend. |
Thank you very much. The code doesn't seem to compile though.
We can keep it as it is for now. |
Issue
Currently, there's no way for users to edit the sync frequency of a connection directly from the dashboard UI. The only available methods are via the public API or Node SDK, which adds unnecessary friction compared to making the change directly in the interface. This limitation was highlighted in Slack by a user trying to modify the frequency for a Salesforce connection.
Fix
Adds support for editing the sync frequency of individual connections directly from the dashboard UI. Users can now click a pencil icon next to the frequency cell to open a dialog, enter a new frequency, validate it, and update it via the API.
Implements the
syncController.updateFrequencyForConnection
controller under the hood.Includes:
syncController.updateFrequencyForConnection
controllerTesting
every <number> <unit>
format).Preview
This PR introduces the ability for users to update the sync frequency for specific connections directly from the dashboard UI, addressing feedback that previously only allowed this via API or SDK. The update includes front-end modal interactions, validation logic, and back-end endpoint additions to securely support frequency changes on a per-connection basis without editing all connection frequencies at once.
Key Changes:
• Adds a pencil/edit icon to the sync frequency column on the Connections dashboard, which opens a modal for frequency input.
• Implements front-end validation for frequency input with a shared regex and improved user feedback (error handling, disabled save if invalid).
• Introduces apiUpdateSyncConnectionFrequency in webapp, and a unified frequencyRegex utility for input validation.
• Extends the /api/v1/sync/update-connection-frequency API with controller, route, and types for updating frequency on a per-connection basis.
• Ensures SWR cache invalidation for sync data after successful update.
• Refactors related UI and moves frequency regex to a utils/validation file for DRY validation across components.
Affected Areas:
• Dashboard UI (SyncRow in Connection page)
• API routes and type declarations (server/routes.private, types/lib/sync/api.ts)
• Custom hooks for connection management (useConnections.tsx)
• Validation utility (utils/validation.ts)
This summary was automatically generated by @propel-code-bot