Add extra locales to bootstrap.json
This allows an app (such as Ember CLI) to get the full list of locales for a user, including admin and overrides.
This commit is contained in:
parent
3684337e4a
commit
1976306539
|
@ -34,6 +34,14 @@ class BootstrapController < ApplicationController
|
||||||
end
|
end
|
||||||
add_style(mobile_view? ? :mobile_theme : :desktop_theme) if theme_ids.present?
|
add_style(mobile_view? ? :mobile_theme : :desktop_theme) if theme_ids.present?
|
||||||
|
|
||||||
|
extra_locales = []
|
||||||
|
if ExtraLocalesController.client_overrides_exist?
|
||||||
|
extra_locales << ExtraLocalesController.url('overrides')
|
||||||
|
end
|
||||||
|
if staff?
|
||||||
|
extra_locales << ExtraLocalesController.url('admin')
|
||||||
|
end
|
||||||
|
|
||||||
bootstrap = {
|
bootstrap = {
|
||||||
theme_ids: theme_ids,
|
theme_ids: theme_ids,
|
||||||
title: SiteSetting.title,
|
title: SiteSetting.title,
|
||||||
|
@ -41,8 +49,9 @@ class BootstrapController < ApplicationController
|
||||||
locale_script: locale,
|
locale_script: locale,
|
||||||
stylesheets: @stylesheets,
|
stylesheets: @stylesheets,
|
||||||
setup_data: client_side_setup_data,
|
setup_data: client_side_setup_data,
|
||||||
preloaded: @preloaded
|
preloaded: @preloaded,
|
||||||
}
|
}
|
||||||
|
bootstrap[:extra_locales] = extra_locales if extra_locales.present?
|
||||||
|
|
||||||
render_json_dump(bootstrap: bootstrap)
|
render_json_dump(bootstrap: bootstrap)
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,4 +39,16 @@ describe BootstrapController do
|
||||||
expect(preloaded['topicTrackingStates']).to be_present
|
expect(preloaded['topicTrackingStates']).to be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns extra locales (admin) when staff" do
|
||||||
|
user = Fabricate(:admin)
|
||||||
|
sign_in(user)
|
||||||
|
get "/bootstrap.json"
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
|
json = response.parsed_body
|
||||||
|
expect(json).to be_present
|
||||||
|
|
||||||
|
bootstrap = json['bootstrap']
|
||||||
|
expect(bootstrap['extra_locales']).to be_present
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue