mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-02 08:13:34 +03:00
640499af70
closes https://github.com/TryGhost/Ghost/issues/8127 - update theme activation to manually set other themes to `active: false` in the store now that we only the active theme back from `/themes/:name/activate` endpoint - move theme warning list item rendering into `{{gh-theme-error-li error=x}}` - add `theme-warnings` modal that accepts a warnings list, title, and optional message - after activating a theme, check if the theme has any warnings or errors and display an appropriate modal informing the user
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
import Model from 'ember-data/model';
|
|
import attr from 'ember-data/attr';
|
|
|
|
export default Model.extend({
|
|
name: attr('string'),
|
|
package: attr('raw'),
|
|
active: attr('boolean'),
|
|
warnings: attr('raw'),
|
|
|
|
activate() {
|
|
let adapter = this.store.adapterFor(this.constructor.modelName);
|
|
|
|
return adapter.activate(this).then(() => {
|
|
// the server only gives us the newly active theme back so we need
|
|
// to manually mark other themes as inactive in the store
|
|
let activeThemes = this.store.peekAll('theme').filterBy('active', true);
|
|
|
|
activeThemes.forEach((theme) => {
|
|
if (theme !== this) {
|
|
// store.push is necessary to avoid dirty records that cause
|
|
// problems when we get new data back in subsequent requests
|
|
this.store.push({data: {
|
|
id: theme.id,
|
|
type: 'theme',
|
|
attributes: {active: false}
|
|
}});
|
|
}
|
|
});
|
|
|
|
return this;
|
|
});
|
|
}
|
|
});
|