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:
parent
31bdef94cd
commit
c790959e09
@ -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>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user