mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:21:12 +08:00
FIX: Load admin-specific JS when compiling via ember-cli (#18086)
The previous sprockets implementation was including admin-specific JS in the plugin's main JS file, which would be served to all users regardless of admin status. This commit achieves the same result under the ember-cli plugin asset compiler with one difference: the admin js is compiled into a separate file. That means that in future, we'll be able to make it loaded only for admins. For now though, it's loaded for everyone, just like before.
This commit is contained in:
@ -382,7 +382,7 @@ module Discourse
|
||||
|
||||
def self.find_plugin_js_assets(args)
|
||||
plugins = self.find_plugins(args).select do |plugin|
|
||||
plugin.js_asset_exists? || plugin.extra_js_asset_exists?
|
||||
plugin.js_asset_exists? || plugin.extra_js_asset_exists? || plugin.admin_js_asset_exists?
|
||||
end
|
||||
|
||||
plugins = apply_asset_filters(plugins, :js, args[:request])
|
||||
@ -391,6 +391,8 @@ module Discourse
|
||||
assets = []
|
||||
assets << "plugins/#{plugin.directory_name}" if plugin.js_asset_exists?
|
||||
assets << "plugins/#{plugin.directory_name}_extra" if plugin.extra_js_asset_exists?
|
||||
# TODO: make admin asset only load for admins
|
||||
assets << "plugins/#{plugin.directory_name}_admin" if plugin.admin_js_asset_exists?
|
||||
assets
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user