96743e64cd
requires https://github.com/TryGhost/Ghost/pull/8093 - adds `theme.activate()` method and associated adapter method for activating themes rather than relying on `settings.activeTheme` - minor refactors to the `modals/upload-theme` component to use a full theme model
41 lines
1.0 KiB
JavaScript
41 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);
|
|
themes.findBy({name: params.theme}).update({active: true});
|
|
|
|
return themes.all();
|
|
});
|
|
}
|