Fixed error rendering for theme uploads (#20097)

ref https://linear.app/tryghost/issue/ENG-842/gluster-file-name-length-limit

- when uploading a theme, Admin did not always render errors properly, zip extraction errors for example
- with this change, we do not change the API responses but rather update Admin to handle both types of error responses
This commit is contained in:
Sag 2024-05-01 13:13:00 +02:00 committed by GitHub
parent 31bdef94cd
commit c790959e09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,7 +6,7 @@ import {ThemeProblem} from '@tryghost/admin-x-framework/api/themes';
type FatalError = {
details: {
errors: ThemeProblem[];
};
}|string;
};
export type FatalErrors = FatalError[];
@ -63,7 +63,15 @@ const InvalidThemeModal: React.FC<{
if (fatalErrors) {
warningPrompt = <div className="mt-10">
<List title="Errors">
{fatalErrors?.map(error => error?.details?.errors?.map(err => <ThemeProblemView problem={err} />))}
{fatalErrors.map((error) => {
if (typeof error.details === 'object' && error.details.errors && error.details.errors.length > 0) {
return error.details.errors.map(err => <ThemeProblemView problem={err} />);
} else if (typeof error.details === 'string') {
return <ListItem title={error.details} />;
} else {
return null;
}
})}
</List>
</div>;
}