Ghost/ghost/admin/mirage/config/themes.js
Kevin Ansfield 919ec733e7
Moved onboarding display check into new onboarding service (#19938)
refs
https://linear.app/tryghost/issue/IPC-92/add-logic-for-completing-steps

- added `onboarding` service to manage logic and state for the onboarding display and it's various steps
- added basic "display onboarding checklist" state to replicate the basic feature flag toggle along with making sure it's only shown to owners
- added acceptance test file and missing mirage endpoints needed for the dashboard to load without error
2024-03-27 17:37:37 +00:00

66 lines
1.7 KiB
JavaScript

import {Response} from 'miragejs';
let themeCount = 1;
export default function mockThemes(server) {
server.get('/themes');
server.get('/themes/active/', function ({themes}) {
const theme = themes.findBy({active: true});
return {themes: [theme]};
});
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 += 1;
theme = themes.create(theme);
return {themes: [theme]};
});
server.del('/themes/:theme/', function ({themes}, {params}) {
themes.findBy({name: params.theme}).destroy();
return new Response(204);
});
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]};
});
server.post('/themes/install/', function ({themes}, {queryParams}) {
themes.all().update('active', false);
const themeName = queryParams.ref.replace('TryGhost/', '');
let theme = themes.findBy({name: themeName});
if (theme) {
theme.update({active: true});
} else {
theme = themes.create({
name: themeName,
package: {
name: themeName,
version: '0.1'
}
});
}
return {themes: [theme]};
});
}