Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Improved theme activation warnings modal content
Browse files Browse the repository at this point in the history
closes TryGhost/Ghost#10627
- removed confusing/unnecessary message when activation was successful with warnings
- do not display "Warnings" sub-heading if there are no other errors to reduce duplication with the modal title
- changed "Close" button text to "Ok" so it feels more like a confirmation
- refactored modal template to have explicit `this` rather than implicit property lookup ([RFC](https://github.com/emberjs/rfcs/blob/e724c7087e21284f5a34dce9b5de0e5c65b11dbf/text/0308-deprecate-property-lookup-fallback.md))
  • Loading branch information
kevinansfield committed Mar 25, 2019
1 parent f0ad9dc commit efcecb8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 27 deletions.
13 changes: 2 additions & 11 deletions app/controllers/settings/design.js
Expand Up @@ -17,12 +17,11 @@ export default Controller.extend({
session: service(),
settings: service(),

newNavItem: null,

dirtyAttributes: false,

newNavItem: null,
themes: null,
themeToDelete: null,

init() {
this._super(...arguments);
this.set('newNavItem', NavigationItem.create({isNew: true}));
Expand Down Expand Up @@ -127,8 +126,6 @@ export default Controller.extend({

activateTheme(theme) {
return theme.activate().then((theme) => {
let themeName = theme.get('name');

if (!isEmpty(theme.get('warnings'))) {
this.set('themeWarnings', theme.get('warnings'));
this.set('showThemeWarningsModal', true);
Expand All @@ -138,12 +135,6 @@ export default Controller.extend({
this.set('themeErrors', theme.get('errors'));
this.set('showThemeWarningsModal', true);
}

if (this.themeErrors || this.themeWarnings) {
let message = `${themeName} activated successfully but some warnings/errors were detected.
You are still able to use and activate the theme. Here is your report...`;
this.set('message', message);
}
}).catch((error) => {
if (isThemeValidationError(error)) {
let errors = error.payload.errors[0].details;
Expand Down
25 changes: 10 additions & 15 deletions app/templates/components/modal-theme-warnings.hbs
@@ -1,51 +1,46 @@
<header class="modal-header">
<h1 data-test-theme-warnings-title>
{{#unless canActivate}}
{{title}}
{{#unless this.canActivate}}
{{this.title}}
{{else}}
{{title}} with {{#if errors}}errors{{else}}warnings{{/if}}
{{this.title}} with {{#if this.errors}}errors{{else}}warnings{{/if}}
{{/unless}}
</h1>
</header>
<a class="close" href="#" title="Close" {{action "closeModal"}}>{{svg-jar "close"}}<span class="hidden">Close</span></a>

<div class="modal-body">
<ul class="theme-validation-errors" data-test-theme-warnings>
{{#if message}}
<li>
<p data-test-theme-warnings-message>{{message}}</p>
</li>
{{/if}}
{{#if fatalErrors}}
{{#if this.fatalErrors}}
<div class="theme-validation-errordescription">
<h2 class="theme-validation-errortype fatal">Fatal Errors</h2>
<p><em>(Must-fix to activate theme)</em></p>
</div>
{{/if}}
{{#each fatalErrors as |error|}}
{{#each this.fatalErrors as |error|}}
<li class="theme-validation-item">
{{gh-theme-error-li error=error}}
</li>
{{/each}}

{{#if errors}}
{{#if this.errors}}
<div class="theme-validation-errordescription">
<h2 class="theme-validation-errortype">Errors</h2>
<p><em>(Very recommended to fix, functionality <span>could</span> be restricted)</em></p>
</div>
{{/if}}
{{#each errors as |error|}}
{{#each this.errors as |error|}}
<li class="theme-validation-item">
{{gh-theme-error-li error=error}}
</li>
{{/each}}

{{#if warnings}}
{{#if (and this.warnings (or this.fatalErrors this.errors))}}
<div class="theme-validation-errordescription">
<h2 class="theme-validation-errortype">Warnings</h2>
</div>
{{/if}}
{{#each warnings as |error|}}
{{#each this.warnings as |error|}}
<li class="theme-validation-item">
{{gh-theme-error-li error=error}}
</li>
Expand All @@ -56,6 +51,6 @@

<div class="modal-footer">
<button {{action "closeModal"}} class="gh-btn" data-test-modal-close-button>
<span>Close</span>
<span>Ok</span>
</button>
</div>
1 change: 0 additions & 1 deletion app/templates/settings/design.hbs
Expand Up @@ -153,7 +153,6 @@
title="Activation successful"
warnings=themeWarnings
errors=themeErrors
message=message
canActivate=true
)
close=(action "hideThemeWarningsModal")
Expand Down

0 comments on commit efcecb8

Please sign in to comment.