-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Move activation to themes endpoint #8093
Conversation
requires TryGhost/Ghost#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
requires TryGhost/Ghost#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
requires TryGhost/Ghost#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
debug('got result'); | ||
return Promise.resolve({themes: result}); | ||
}, | ||
|
||
activate: function activate(options) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
requires TryGhost/Ghost#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
be75b50
to
a7bf0c4
Compare
- browse will now include the correct activated theme again - PUT /theme/:name/activate will activate a theme TODO: tests!
- tests now read from a temp directory not content/themes - all tests check errors and responses
a7bf0c4
to
8170d13
Compare
@kevinansfield this PR is ready. I updated the endpoints as we talked about (probably worth double checking against Ghost-Admin#561), then the Ghost-Admin PR is unblocked without requiring any DB fudgery for permissions. I will finish #8104 to add permissions and more API improvements a bit later, but before the alpha. The bonus to this change, for me, is that we now have 2 clear ways in which themes are activated:
Previously 2. was part of the settings edit endpoint, meaning there was no easy way too hook in. |
@@ -26,11 +27,24 @@ var debug = require('debug')('ghost:api:themes'), | |||
themes = { | |||
browse: function browse() { | |||
debug('browsing'); | |||
var result = packageUtils.filterPackages(themeList.getAll()); | |||
var result = themeList.toAPI(themeList.getAll(), settingsCache.get('activeTheme')); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@ErisDS when testing this the |
@kevinansfield ah yes, derp, will fix |
Fixed it + tests to catch this if I break it again |
requires TryGhost/Ghost#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
refs TryGhost#8093 - add permission to activate themes - update tests - also: update tests for invites TODO: change how the active theme setting is updated to reduce extra permissions
refs #8093 ✨ Add activate theme permission - add permission to activate themes - update tests - also: update tests for invites TODO: change how the active theme setting is updated to reduce extra permissions ✨ Move theme validation to gscan - add a new gscan validation method and use it for upload - update activate endpoint to do validation also using gscan - change to using SettingsModel instead of API so that we don't call validation or permissions on the settings API - remove validation from the settings model - remove the old validation function - add new invalid theme message to translations & remove a bunch of theme validation related unused keys 📖 Planned changes 🚨 Tests for theme activation API endpoint 🐛 Don't allow deleting the active theme 🚫 Prevent activeTheme being set via settings API - We want to control how this happens in future. - We still want to store the information in settings, via the model. - We just don't want to be able to change this info via the settings edit endpoint 🐛 ✨ Fix warnings for uploads & add for activations - warnings for uploads were broken in f8b498d - fix the response + adds tests to cover that warnings are correctly returned - add the same response to activations + more tests - activations now return a single theme object - the theme that was activated + any warnings 🎨 Improve how we generate theme API responses - remove the requirement to pass in the active theme! - move this to a specialist function, away from the list 🎨 Do not load gscan on boot
@kevinansfield this is a WIP PR to demo a new endpoint for themes
PUT /themes/:name/activate
Works the same as setting the active theme via settings.
Returns the entire
GET /themes/
listNOTE: this also readds the code needed to ensure that the active property is set on the correct theme for both the browse endpoint and this new endpoint.
If you think this PUT endpoint should return something different, let me know!
browse will now include the correct activated theme again
PUT /theme/:name/activate will activate a theme
TODO: tests!