- Notifications
You must be signed in to change notification settings - Fork926
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Collaborator
|
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: 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, | ||
Uh oh!
There was an error while loading.Please reload this page.