FIX: Remove custom 'error' action on build-category-route/discovery (#11425)

The root cause of the issue was that the route was overriding the 'error' action from the correctly implemented handler in routes/application.js.

Remove the custom handler, and the duplicated template logic for displaying the errorHtml.

Fixes: e16b3da04a
This commit is contained in:
Kane York 2020-12-08 11:58:36 -08:00 committed by GitHub
parent a446e0fde1
commit 59ef48c0b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 55 deletions

View File

@ -66,17 +66,12 @@ export default (filterArg, params) => {
parts.pop();
}
return Category.reloadBySlugPath(parts.join("/"))
.then((result) => {
const record = this.store.createRecord("category", result.category);
record.setupGroupsAndPermissions();
this.site.updateCategory(record);
return { category: record, modelParams };
})
.catch(() => {
// afterModel will call replaceWith(/404)
return null;
});
return Category.reloadBySlugPath(parts.join("/")).then((result) => {
const record = this.store.createRecord("category", result.category);
record.setupGroupsAndPermissions();
this.site.updateCategory(record);
return { category: record, modelParams };
});
}
if (category) {
@ -244,18 +239,6 @@ export default (filterArg, params) => {
},
actions: {
error(err) {
const json = err.jqXHR.responseJSON;
if (json && json.extras && json.extras.html) {
this.controllerFor("discovery").set(
"errorHtml",
err.jqXHR.responseJSON.extras.html
);
} else {
this.replaceWith("exception");
}
},
setNotification(notification_level) {
this.currentModel.setNotification(notification_level);
},

View File

@ -1,41 +1,37 @@
{{#if errorHtml}}
{{html-safe errorHtml}}
{{else}}
<div class="container">
{{discourse-banner user=currentUser banner=site.banner}}
{{#unless viewingCategoriesList}}
{{category-read-only-banner category=category readOnly=navigationCategory.cannotCreateTopicOnCategory}}
{{/unless}}
</div>
<div class="list-controls">
<div class="container">
{{discourse-banner user=currentUser banner=site.banner}}
{{#unless viewingCategoriesList}}
{{category-read-only-banner category=category readOnly=navigationCategory.cannotCreateTopicOnCategory}}
{{/unless}}
{{outlet "navigation-bar"}}
</div>
</div>
<div class="list-controls">
<div class="container">
{{outlet "navigation-bar"}}
</div>
</div>
{{conditional-loading-spinner condition=loading}}
{{conditional-loading-spinner condition=loading}}
{{plugin-outlet name="discovery-above"}}
{{plugin-outlet name="discovery-above"}}
<div class="container list-container {{if loading "hidden"}}">
<div class="row">
<div class="full-width">
<div id="header-list-area">
{{outlet "header-list-container"}}
</div>
</div>
</div>
<div class="row">
<div class="full-width">
<div id="list-area">
{{plugin-outlet name="discovery-list-container-top"
args=(hash category=category listLoading=loading)}}
{{outlet "list-container"}}
</div>
<div class="container list-container {{if loading "hidden"}}">
<div class="row">
<div class="full-width">
<div id="header-list-area">
{{outlet "header-list-container"}}
</div>
</div>
</div>
<div class="row">
<div class="full-width">
<div id="list-area">
{{plugin-outlet name="discovery-list-container-top"
args=(hash category=category listLoading=loading)}}
{{outlet "list-container"}}
</div>
</div>
</div>
</div>
{{plugin-outlet name="discovery-below"}}
{{/if}}
{{plugin-outlet name="discovery-below"}}