mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 09:03:44 +08:00
FIX: Only block local edits for git-sourced themes (#11450)
Themes uploaded as zip files are given a row in the `remote_themes` table to store metadata, even though they are not truly remote.
This commit is contained in:
parent
0116897ac9
commit
d1d37473d4
|
@ -28,7 +28,7 @@ export default Route.extend({
|
|||
const fields = wrapper.model
|
||||
.get("fields")
|
||||
[wrapper.target].map((f) => f.name);
|
||||
if (wrapper.model.remote_theme) {
|
||||
if (wrapper.model.remote_theme && wrapper.model.remote_theme.is_git) {
|
||||
this.transitionTo("adminCustomizeThemes.index");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@
|
|||
{{/d-section}}
|
||||
{{/if}}
|
||||
|
||||
{{#unless model.remote_theme}}
|
||||
{{#unless model.remote_theme.is_git}}
|
||||
<div class="control-unit">
|
||||
<div class="mini-title">{{i18n "admin.customize.theme.css_html"}}</div>
|
||||
{{#if model.hasEditedFields}}
|
||||
|
|
|
@ -291,7 +291,7 @@ class Admin::ThemesController < Admin::AdminController
|
|||
end
|
||||
|
||||
def ban_for_remote_theme!
|
||||
raise Discourse::InvalidAccess if @theme.remote_theme
|
||||
raise Discourse::InvalidAccess if @theme.remote_theme&.is_git?
|
||||
end
|
||||
|
||||
def add_relative_themes!(kind, ids)
|
||||
|
|
|
@ -378,7 +378,7 @@ describe Admin::ThemesController do
|
|||
theme: {
|
||||
theme_fields: [
|
||||
{ name: 'scss', target: 'common', value: '' },
|
||||
{ name: 'test', target: 'common', value: 'filename.jpg', upload_id: 4 }
|
||||
{ name: 'header', target: 'common', value: 'filename.jpg', upload_id: 4 }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -386,6 +386,22 @@ describe Admin::ThemesController do
|
|||
expect(response.status).to eq(403)
|
||||
end
|
||||
|
||||
it 'allows zip-imported theme fields to be locally edited' do
|
||||
r = RemoteTheme.create!(remote_url: "")
|
||||
theme.update!(remote_theme_id: r.id)
|
||||
|
||||
put "/admin/themes/#{theme.id}.json", params: {
|
||||
theme: {
|
||||
theme_fields: [
|
||||
{ name: 'scss', target: 'common', value: '' },
|
||||
{ name: 'header', target: 'common', value: 'filename.jpg', upload_id: 4 }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it 'updates a child theme' do
|
||||
child_theme = Fabricate(:theme, component: true)
|
||||
put "/admin/themes/#{child_theme.id}.json", params: {
|
||||
|
|
Loading…
Reference in New Issue
Block a user