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.js index 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.hbs index 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}}
{{i18n "admin.customize.theme.css_html"}}
{{#if model.hasEditedFields}} diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rb index 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::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) diff --git a/spec/requests/admin/themes_controller_spec.rb b/spec/requests/admin/themes_controller_spec.rb index 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 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: {