A platform for community discussion. Free, open, simple.
DEV: Add additional hooks for theme-creator plugin
David Taylor59640ef37305
diff --git a/app/assets/javascripts/admin/controllers/modals/admin-import-theme.js.es6 b/app/assets/javascripts/admin/controllers/modals/admin-import-theme.js.es6index 325cc4af174..1c7752e7158 100644--- a/app/assets/javascripts/admin/controllers/modals/admin-import-theme.js.es6+++ b/app/assets/javascripts/admin/controllers/modals/admin-import-theme.js.es6@@ -76,6 +76,11 @@ export default Ember.Controller.extend(ModalFunctionality, {}}+ if (this.get("model.user_id")) {+ // Used by theme-creator+ options.data["user_id"] = this.get("model.user_id");+ }+this.set("loading", true);ajax(this.get("importUrl"), options).then(result => {diff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rbindex 31bda272ded..edf6fa470d6 100644--- a/app/controllers/admin/themes_controller.rb+++ b/app/controllers/admin/themes_controller.rb@@ -17,7 +17,7 @@ class Admin::ThemesController < Admin::AdminControllerhijack doFile.open(path) do |file|filename = params[:file]&.original_filename || File.basename(path)- upload = UploadCreator.new(file, filename, for_theme: true).create_for(current_user.id)+ upload = UploadCreator.new(file, filename, for_theme: true).create_for(theme_user.id)if upload.errors.count > 0render_json_error uploadelse@@ -44,7 +44,7 @@ class Admin::ThemesController < Admin::AdminControllerjson = JSON::parse(params[:theme].read)theme = json['theme']- @theme = Theme.new(name: theme["name"], user_id: current_user.id)+ @theme = Theme.new(name: theme["name"], user_id: theme_user.id)theme["theme_fields"]&.each do |field|if field["raw_upload"]@@ -54,7 +54,7 @@ class Admin::ThemesController < Admin::AdminControllerfile = Base64.decode64(field["raw_upload"])tmp.write(file)tmp.rewind- upload = UploadCreator.new(tmp, field["filename"]).create_for(current_user.id)+ upload = UploadCreator.new(tmp, field["filename"]).create_for(theme_user.id)field["upload_id"] = upload.idensuretmp.unlink@@ -79,7 +79,7 @@ class Admin::ThemesController < Admin::AdminControllerelsif params[:remote]beginbranch = params[:branch] ? params[:branch] : nil- @theme = RemoteTheme.import_theme(params[:remote], current_user, private_key: params[:private_key], branch: branch)+ @theme = RemoteTheme.import_theme(params[:remote], theme_user, private_key: params[:private_key], branch: branch)render json: @theme, status: :createdrescue RemoteTheme::ImportError => erender_json_error e.message@@ -90,7 +90,7 @@ class Admin::ThemesController < Admin::AdminControllertheme_id = params[:theme_id]match_theme_by_name = !!params[:bundle] && !params.key?(:theme_id) # Old theme CLI behavior, match by name. Remove Jan 2020begin- @theme = RemoteTheme.update_tgz_theme(bundle.path, match_theme: match_theme_by_name, user: current_user, theme_id: theme_id)+ @theme = RemoteTheme.update_tgz_theme(bundle.path, match_theme: match_theme_by_name, user: theme_user, theme_id: theme_id)log_theme_change(nil, @theme)render json: @theme, status: :createdrescue RemoteTheme::ImportError => e@@ -129,7 +129,7 @@ class Admin::ThemesController < Admin::AdminControllerdef create@theme = Theme.new(name: theme_params[:name],- user_id: current_user.id,+ user_id: theme_user.id,user_selectable: theme_params[:user_selectable] || false,color_scheme_id: theme_params[:color_scheme_id],component: [true, "true"].include?(theme_params[:component]))@@ -316,4 +316,9 @@ class Admin::ThemesController < Admin::AdminController@theme.switch_to_component!endend++ # Overridden by theme-creator plugin+ def theme_user+ current_user+ endend