A platform for community discussion. Free, open, simple.
FIX: Only block local edits for git-sourced themes (#11450)
David Taylord1d37473d427
diff --git a/app/assets/javascripts/admin/addon/routes/admin-customize-themes-edit.js b/app/assets/javascripts/admin/addon/routes/admin-customize-themes-edit.jsindex 030645e445a..0d55baa6cee 100644--- a/app/assets/javascripts/admin/addon/routes/admin-customize-themes-edit.js+++ b/app/assets/javascripts/admin/addon/routes/admin-customize-themes-edit.js@@ -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;}diff --git a/app/assets/javascripts/admin/addon/templates/customize-themes-show.hbs b/app/assets/javascripts/admin/addon/templates/customize-themes-show.hbsindex dadbc7c3478..67981efc907 100644--- a/app/assets/javascripts/admin/addon/templates/customize-themes-show.hbs+++ b/app/assets/javascripts/admin/addon/templates/customize-themes-show.hbs@@ -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}}diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rbindex 43e63136ac4..a322918dbcb 100644--- a/app/controllers/admin/themes_controller.rb+++ b/app/controllers/admin/themes_controller.rb@@ -291,7 +291,7 @@ class Admin::ThemesController < Admin::AdminControllerenddef ban_for_remote_theme!- raise Discourse::InvalidAccess if @theme.remote_theme+ raise Discourse::InvalidAccess if @theme.remote_theme&.is_git?enddef add_relative_themes!(kind, ids)diff --git a/spec/requests/admin/themes_controller_spec.rb b/spec/requests/admin/themes_controller_spec.rbindex 602ab415335..36f7c97ad7e 100644--- a/spec/requests/admin/themes_controller_spec.rb+++ b/spec/requests/admin/themes_controller_spec.rb@@ -378,7 +378,7 @@ describe Admin::ThemesController dotheme: {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 doexpect(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' dochild_theme = Fabricate(:theme, component: true)put "/admin/themes/#{child_theme.id}.json", params: {