0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00

Fixed errors not displaying when uploading broken theme in Admin X (#18350)

refs https://ghost.slack.com/archives/C0568LN2CGJ/p1695716107796769

- The main culprit here was that now since we moved to using some model data from Ember as opposed to just the API, the errors key had to be renamed to gscan_errors  as that's how it's named in the Ember theme model.

---

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 4bca3ee</samp>

Updated the theme modal and the theme installed modal to use the new
`gscan_errors` property for theme validation. This improves the accuracy
and consistency of the feedback given to users when they upload or
activate themes.
This commit is contained in:
Ronald Langeveld 2023-09-26 16:57:50 +07:00 committed by GitHub
parent 84ae5f58d2
commit 4f3b35e4dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View file

@ -15,7 +15,7 @@ export type Theme = {
} }
export type InstalledTheme = Theme & { export type InstalledTheme = Theme & {
errors?: ThemeProblem<'error'>[]; gscan_errors?: ThemeProblem<'error'>[];
warnings?: ThemeProblem<'warning'>[]; warnings?: ThemeProblem<'warning'>[];
} }

View file

@ -98,8 +98,8 @@ const ThemeToolbar: React.FC<ThemeToolbarProps> = ({
</>; </>;
} }
if (uploadedTheme.errors?.length || uploadedTheme.warnings?.length) { if (uploadedTheme?.gscan_errors?.length || uploadedTheme.warnings?.length) {
const hasErrors = uploadedTheme.errors?.length; const hasErrors = uploadedTheme?.gscan_errors?.length;
title = `Upload successful with ${hasErrors ? 'errors' : 'warnings'}`; title = `Upload successful with ${hasErrors ? 'errors' : 'warnings'}`;
prompt = <> prompt = <>
@ -286,8 +286,8 @@ const ChangeThemeModal = () => {
</>; </>;
} }
if (newlyInstalledTheme.errors?.length || newlyInstalledTheme.warnings?.length) { if (newlyInstalledTheme.gscan_errors?.length || newlyInstalledTheme.warnings?.length) {
const hasErrors = newlyInstalledTheme.errors?.length; const hasErrors = newlyInstalledTheme.gscan_errors?.length;
title = `Installed with ${hasErrors ? 'errors' : 'warnings'}`; title = `Installed with ${hasErrors ? 'errors' : 'warnings'}`;
prompt = <> prompt = <>

View file

@ -49,10 +49,10 @@ const ThemeInstalledModal: React.FC<{
const {mutateAsync: activateTheme} = useActivateTheme(); const {mutateAsync: activateTheme} = useActivateTheme();
let errorPrompt = null; let errorPrompt = null;
if (installedTheme.errors) { if (installedTheme.gscan_errors) {
errorPrompt = <div className="mt-6"> errorPrompt = <div className="mt-6">
<List hint={<>Highly recommended to fix, functionality <strong>could</strong> be restricted</>} title="Errors"> <List hint={<>Highly recommended to fix, functionality <strong>could</strong> be restricted</>} title="Errors">
{installedTheme.errors?.map(error => <ThemeProblemView problem={error} />)} {installedTheme.gscan_errors?.map(error => <ThemeProblemView problem={error} />)}
</List> </List>
</div>; </div>;
} }
@ -66,7 +66,7 @@ const ThemeInstalledModal: React.FC<{
</div>; </div>;
} }
let okLabel = `Activate${installedTheme.errors?.length ? ' with errors' : ''}`; let okLabel = `Activate${installedTheme.gscan_errors?.length ? ' with errors' : ''}`;
if (installedTheme.active) { if (installedTheme.active) {
okLabel = 'OK'; okLabel = 'OK';