mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 09:22:49 +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
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
import {Response} from 'ember-cli-mirage';
|
|
|
|
let themeCount = 1;
|
|
|
|
export default function mockThemes(server) {
|
|
server.get('/themes');
|
|
|
|
server.post('/themes/upload/', function ({themes}) {
|
|
// pretender/mirage doesn't currently process FormData so we can't use
|
|
// any info passed in through the request
|
|
let theme = {
|
|
name: `test-${themeCount}`,
|
|
package: {
|
|
name: `Test ${themeCount}`,
|
|
version: '0.1'
|
|
}
|
|
};
|
|
|
|
themeCount++;
|
|
|
|
theme = themes.create(theme);
|
|
|
|
return {themes: [theme]};
|
|
});
|
|
|
|
server.del('/themes/:theme/', function ({themes}, {params}) {
|
|
themes.findBy({name: params.theme}).destroy();
|
|
|
|
return new Response(204, {}, null);
|
|
});
|
|
|
|
server.put('/themes/:theme/activate/', function ({themes}, {params}) {
|
|
themes.all().update('active', false);
|
|
let theme = themes.findBy({name: params.theme}).update({active: true});
|
|
|
|
return {themes: [theme]};
|
|
});
|
|
}
|