mirror of
https://github.com/discourse/discourse.git
synced 2025-02-11 14:23:17 +08:00
![Régis Hanol](/assets/img/avatar_default.png)
- new "show-footer" mixins - converted most of the routes to ES6 - FIX: handling of "indexStream" in user pages There will now be a footer on all the following pages - /exception - /about - /latest - /new - /unread - /starred - /top - /categories - /c/:category - /c/:category/l/latest - /c/:category/l/new - /c/:category/l/unread - /c/:category/l/top - /t/:topic/:id - /groups/:name/members - /user/activity - /user/activity/topics - /user/activity/posts - /user/activity/replies - /user/activity/likes-given - /user/activity/likes-received - /user/activity/bookmarks - /user/activity/starred - /user/badges - /user/notifications - /user/flagged-posts - /user/deleted-posts - /user/private-messages - /user/private-messages/mine - /user/private-messages/unread - /user/invited - /user/:username/preferences - /faq (static pages) - /badges - /badges/:id/:badge
103 lines
2.9 KiB
JavaScript
103 lines
2.9 KiB
JavaScript
import ObjectController from 'discourse/controllers/object';
|
|
|
|
var ButtonBackBright = {
|
|
classes: "btn-primary",
|
|
action: "back",
|
|
key: "errors.buttons.back"
|
|
},
|
|
ButtonBackDim = {
|
|
classes: "",
|
|
action: "back",
|
|
key: "errors.buttons.back"
|
|
},
|
|
ButtonTryAgain = {
|
|
classes: "btn-primary",
|
|
action: "tryLoading",
|
|
key: "errors.buttons.again"
|
|
},
|
|
ButtonLoadPage = {
|
|
classes: "btn-primary",
|
|
action: "tryLoading",
|
|
key: "errors.buttons.fixed"
|
|
};
|
|
|
|
// The controller for the nice error page
|
|
export default ObjectController.extend({
|
|
thrown: null,
|
|
lastTransition: null,
|
|
|
|
isNetwork: function() {
|
|
// never made it on the wire
|
|
if (this.get('thrown.readyState') === 0) return true;
|
|
// timed out
|
|
if (this.get('thrown.jqTextStatus') === "timeout") return true;
|
|
return false;
|
|
}.property(),
|
|
isForbidden: Em.computed.equal('thrown.status', 403),
|
|
isServer: Em.computed.gte('thrown.status', 500),
|
|
isUnknown: Em.computed.none('isNetwork', 'isServer'),
|
|
|
|
// TODO
|
|
// make ajax requests to /srv/status with exponential backoff
|
|
// if one succeeds, set networkFixed to true, which puts a "Fixed!" message on the page
|
|
networkFixed: false,
|
|
loading: false,
|
|
|
|
_init: function() {
|
|
this.set('loading', false);
|
|
}.on('init'),
|
|
|
|
reason: function() {
|
|
if (this.get('isNetwork')) {
|
|
return I18n.t('errors.reasons.network');
|
|
} else if (this.get('isServer')) {
|
|
return I18n.t('errors.reasons.server');
|
|
} else if (this.get('isForbidden')) {
|
|
return I18n.t('errors.reasons.forbidden');
|
|
} else {
|
|
// TODO
|
|
return I18n.t('errors.reasons.unknown');
|
|
}
|
|
}.property('isNetwork', 'isServer', 'isUnknown'),
|
|
|
|
requestUrl: Em.computed.alias('thrown.requestedUrl'),
|
|
|
|
desc: function() {
|
|
if (this.get('networkFixed')) {
|
|
return I18n.t('errors.desc.network_fixed');
|
|
} else if (this.get('isNetwork')) {
|
|
return I18n.t('errors.desc.network');
|
|
} else if (this.get('isServer')) {
|
|
return I18n.t('errors.desc.server', { status: this.get('thrown.status') + " " + this.get('thrown.statusText') });
|
|
} else {
|
|
// TODO
|
|
return I18n.t('errors.desc.unknown');
|
|
}
|
|
}.property('networkFixed', 'isNetwork', 'isServer', 'isUnknown'),
|
|
|
|
enabledButtons: function() {
|
|
if (this.get('networkFixed')) {
|
|
return [ButtonLoadPage];
|
|
} else if (this.get('isNetwork')) {
|
|
return [ButtonBackDim, ButtonTryAgain];
|
|
} else {
|
|
return [ButtonBackBright, ButtonTryAgain];
|
|
}
|
|
}.property('networkFixed', 'isNetwork', 'isServer', 'isUnknown'),
|
|
|
|
actions: {
|
|
back: function() {
|
|
window.history.back();
|
|
},
|
|
|
|
tryLoading: function() {
|
|
this.set('loading', true);
|
|
var self = this;
|
|
Em.run.schedule('afterRender', function() {
|
|
self.get('lastTransition').retry();
|
|
self.set('loading', false);
|
|
});
|
|
}
|
|
}
|
|
});
|