-
Notifications
You must be signed in to change notification settings - Fork 138
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
Adds table missing alert to destination cards on Job page #3184
Conversation
alishakawaguchi
commented
Jan 23, 2025
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
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.
this is awesome, left a comment regarding maybe moving the validation from usemutation to usequery for simpler code
@@ -159,10 +221,43 @@ export default function DestinationConnectionCard({ | |||
<FormDescription> | |||
The location of the destination data set. | |||
</FormDescription> | |||
<FormMessage /> | |||
{/* <FormMessage /> */} |
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.
🤔
async function validateMappings(connectionId: string) { | ||
if (!jobmappings || jobmappings.length == 0) { | ||
return; | ||
} | ||
try { | ||
const body = create(ValidateJobMappingsRequestSchema, { | ||
accountId: account?.id, | ||
mappings: jobmappings, | ||
virtualForeignKeys: [], | ||
connectionId: connectionId, | ||
}); | ||
const res = await validateJobMappingsAsync(body); | ||
setValidateMappingsResponse(res); | ||
} catch (error) { | ||
console.error('Failed to validate job mappings:', error); | ||
toast.error('Unable to validate job mappings', { | ||
description: getErrorMessage(error), | ||
}); | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
if (!account?.id || !destination.connectionId || jobmappingsLength === 0) { | ||
return; | ||
} | ||
const validateJobMappings = async () => { | ||
await validateMappings(destination.connectionId); | ||
}; | ||
validateJobMappings(); | ||
}, [account?.id, destination.connectionId, jobmappingsLength]); |
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.
Hm, why isn't this just a useQuery
? All queries can be conditionally enabled anyways, which is basically your if condition.
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.
Another thought is that we could also conditionally invoke only if the init table schema is not enabled? maybe that is unnecessary though.
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.
copy paste 😭
tableErrors && | ||
tableErrors.length > 0 && ( |
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.
probably worth adding a loading state/skeleton here from the query for larger databases where the validation may take a while.
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.
sick
@@ -195,7 +172,7 @@ export default function DestinationConnectionCard({ | |||
shouldValidate: true, | |||
} | |||
); | |||
validateMappings(value); | |||
// validateMappings(value); |
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.
remove