-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFE] Add the /api/product_info route with product and branding info #438
Conversation
So we want to return something like
from the |
@juliancheal do we really need all those things? Some of them aren't even available without login. |
@skateman Well i didn't mean all the things my mistake. |
@@ -1,7 +1,7 @@ | |||
module Api | |||
class ApiController < Api::BaseController | |||
def options | |||
head(:ok) | |||
render_resource :product, product_info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need this under a product_info element, maybe just render :json => { :product_info => product_info }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I need 3 more items Settings.server.custom_logo
, Settings.server.custom_login_logo
and Settings.server.custom_brand
(all boolean values). Do you have any idea how to structure them? Or is it okay to add it into product_info
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
product_info is more geared toward MiQ itself, above may fit better under server_info, or maybe even a new section like brand_info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can make use of ManageIQ/manageiq#17755 for the version info? I'm not sure what the rest of the information is.
Why do we want to return booleans for things like Settings.server.custom_logo
? (I don't know how it's used) Wouldn't it make more sense to have a logo
key with a value of the href to the image or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdunne we want them booleans because they are already booleans, in the OPS UI there's a checkbox for using the custom image. The image itself is on a fixed location, so the filename is static for all the three cases. So historical reasons, that's why :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abellotti I think I'll go with the brand_info
, so
{
:product_info => product_info,
:brand_info => ...
}
@juliancheal a "filtered" version of this would make sense, I'd definitely need some extra stuff from settings as well. The question here is if it's okay to use the OPTIONS for this? cc @abellotti @bdunne |
@skateman yes a filtered version would be perfect. I wonder if it could just be on |
@juliancheal the authorization is a |
Any reason that this wouldn't be under a new |
@bdunne sounds reasonable, and what about the structure of the data? |
768f931
to
da10619
Compare
da10619
to
e4dc9f6
Compare
@@ -20,6 +20,15 @@ def index | |||
render_resource :entrypoint, res | |||
end | |||
|
|||
def product_info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this be overridden by https://github.com/ManageIQ/manageiq-api/pull/438/files#diff-0ef0779741ad3209b46314a66c353351R89 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this also implying that we already have this endpoint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should not make PRs when I'm tired 😢 I'll fix this tomorrow 😕 😴
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, because the one below is private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, my bad ... fixed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fix it though? It seems this break API compatibility because the old product_info doesn't match the new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you're right, is it okay if I merge the branding_info
into product_info
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's a new thing.
{ | ||
:custom_brand => Settings.server.custom_brand, | ||
:custom_logo => Settings.server.custom_logo, | ||
:custom_login_logo => Settings.server.custom_login_logo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these settings and where do they come from? The only one in the settings template is the custom_logo
, and that one is just a boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fryguy ManageIQ/manageiq#17773 forgot to include, sorry
e4dc9f6
to
31220b5
Compare
{ | ||
:name => I18n.t("product.name"), | ||
:name_full => I18n.t("product.name_full"), | ||
:copyright => I18n.t("product.copyright"), | ||
:support_website => I18n.t("product.support_website"), | ||
:support_website_text => I18n.t("product.support_website_text"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason this changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope...reverting.
31220b5
to
96442f2
Compare
96442f2
to
d262868
Compare
@bdunne @Fryguy @abellotti any other issues? Can this be merged? |
d262868
to
f619326
Compare
Aside from the tests failing, it looks good to me |
@bdunne it seems like we cannot call What do you think about implementing a safe-lookup for the branding images? If the lookup error happens, i.e. assets aren't available, we don't have the UI and so we don't really need the branding at all, so we just don't return the fields in the response. And if there is no lookup error, the UI is intact and we return with the correct paths for the branding images. |
Calling (Unfortunately this will still take a while, we'll need to upgrade codemirror in the process.) So... I suggest adding |
Well, I don't think the API team will be happy about having yarn in their repo. But let's wait for their decision... |
@@ -20,6 +20,15 @@ def index | |||
render_resource :entrypoint, res | |||
end | |||
|
|||
def product_info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fix it though? It seems this break API compatibility because the old product_info doesn't match the new one.
f619326
to
074acc9
Compare
074acc9
to
9d01dbc
Compare
|
||
def branding_info | ||
{ | ||
:brand => branding_image_path(Settings.server.custom_brand, 'layout/brand.svg'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why pass Settings.server.custom_brand
into branding_image_path
if the method doesn't do anything with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand this, why it would not do anything with it? The branding_image_path
returns the path to the custom or default brand depending on what's available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the method need the branding_
prefix? It is not branding specific. If we don't need to look up the path for the value from settings, I would expect something like :brand => Settings.server.custom_brand || image_path('layout/brand.svg')
{ | ||
:brand => branding_image_path(Settings.server.custom_brand, 'layout/brand.svg'), | ||
:logo => branding_image_path(Settings.server.custom_logo, 'layout/login-screen-logo.png'), | ||
:login_logo => Settings.server.custom_login_logo ? Settings.server.custom_login_logo : nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the ternary operator here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes because it can also be false
and that's not caught by compact
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe Settings.server.custom_login_logo.presence
then? Sorry, I was expecting a string if it existed or nil
:identity => auth_identity, | ||
:server_info => server_info, | ||
:product_info => product_info_data, | ||
:branding_info => branding_info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this if it's also nested under product_info
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we need to be able to access this without a login, so the SUI login screen can consume it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't https://github.com/ManageIQ/manageiq-api/pull/438/files#diff-b4f92b4e361ffab4fbb91c68eb3f77bbR23 remove the requirement for being logged in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the /api
route isn't available without login as it contains the identity
part that needs a logged in user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this if it's also nested under product_info?
What I meant was that we'll have this, right?
get api_entrypoint_url
{
"name" : "ManageIQ",
"description" : "words",
...,
"product_info" : {
...,
"branding_info" : {...}
},
"branding_info" : {...}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh, you're right 🙄 I don't know why I left that line there 😢
9d01dbc
to
90fb60d
Compare
@bdunne just to clarify, the |
90fb60d
to
3687b7d
Compare
it 'product_info contains branding_info' do | ||
api_basic_authorize | ||
|
||
expect(ActionController::Base.helpers).to receive(:image_path).at_least(2).times.and_return("foo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the test above be modified or a new test added where this is not stubbed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update the test above!
3687b7d
to
7306993
Compare
spec/requests/entrypoint_spec.rb
Outdated
) | ||
) | ||
|
||
# This test will fail if you have the UI checked out and built with yarn | ||
expect(response.parsed_body['product_info']).not_to include('branding_info') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be there, but eq({})
and the test failure reflects that
7306993
to
4ff21f4
Compare
Checked commit skateman@4ff21f4 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 app/controllers/api/api_controller.rb
app/controllers/api/base_controller.rb
spec/requests/entrypoint_spec.rb
|
@skateman Can this be |
@miq-bot add_label hammer/yes |
[RFE] Add the /api/product_info route with product and branding info (cherry picked from commit a40b709) https://bugzilla.redhat.com/show_bug.cgi?id=1693757
Hammer backport details:
|
If we want to customize the product name and branding, it's necessary to have a request that returns the product info without authentication. Also I would like to use this for the about modal, so adding the branding to the
/api
route as well.@miq-bot add_reviewer @abellotti
RFE BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1471301