-
Notifications
You must be signed in to change notification settings - Fork 875
fix(site): show error on template upload failure #15558
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { getErrorMessage } from "api/errors"; | ||
import { uploadFile } from "api/queries/files"; | ||
import { | ||
JobError, | ||
templateVersionLogs, | ||
templateVersionVariables, | ||
} from "api/queries/templates"; | ||
import { displayError } from "components/GlobalSnackbar/utils"; | ||
import { useDashboard } from "modules/dashboard/useDashboard"; | ||
import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility"; | ||
import type { FC } from "react"; | ||
|
@@ -51,7 +53,14 @@ export const UploadTemplateView: FC<CreateTemplatePageViewProps> = ({ | |
jobError={isJobError ? error.job.error : undefined} | ||
logs={templateVersionLogsQuery.data} | ||
upload={{ | ||
onUpload: uploadFileMutation.mutateAsync, | ||
onUpload: async (file: File) => { | ||
try { | ||
await uploadFileMutation.mutateAsync(file); | ||
} catch (error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with this query library, but what I found is that even though you can set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You did it correctly. We usually use |
||
displayError(getErrorMessage(error, "Failed to upload file")); | ||
uploadFileMutation.reset(); | ||
} | ||
}, | ||
isUploading: uploadFileMutation.isLoading, | ||
onRemove: uploadFileMutation.reset, | ||
file: uploadFileMutation.variables, | ||
|
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.
Nice test 👍