Skip to content
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] Allow to upload and display a custom brand image on login/header #4376

Merged
merged 2 commits into from Sep 6, 2018

Conversation

skateman
Copy link
Member

@skateman skateman commented Jul 30, 2018

This PR creates a brand image upload feature under the custom logo tab, eliminating the need to manually change the html, css, and drop images into the public folder. The image appears on the login screen and the main header. The code in the area was awful, so I also did a little refactoring.

@miq-bot add_reviewer @epwinchell
@miq-bot add_reviewer @martinpovolny
@miq-bot add_label pending core

screenshot from 2018-08-01 17-34-10
screenshot from 2018-08-01 17-34-16
screenshot from 2018-08-01 17-34-36

Depends on: ManageIQ/manageiq#17773
RFE BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1471301

= render :partial => "shared/file_chooser", :locals => {:object_name => "brand", :method => "logo"}
.col-md-6
= submit_tag(_("Upload"), :class => "btn btn-default")
= _("* Requirements: File-type - PNG; Dimensions - AAAAxBBBB.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epwinchell I need the sizes from you here 😉 🍻

@epwinchell
Copy link
Contributor

@miq-bot add_reviewer @dclarizio

@miq-bot miq-bot requested a review from dclarizio July 30, 2018 13:50
@skateman skateman changed the title [WIP] Allow to upload and display a custom brand image on login/header [WIP] [RFE] Allow to upload and display a custom brand image on login/header Jul 30, 2018
@skateman skateman force-pushed the product-title branch 2 times, most recently from d227c3b to 130c2ba Compare July 31, 2018 16:27
@dclarizio dclarizio requested review from h-kataria and removed request for dclarizio July 31, 2018 20:58
@h-kataria
Copy link
Contributor

@skateman can you provide before/after screenshots

@skateman skateman changed the title [WIP] [RFE] Allow to upload and display a custom brand image on login/header [RFE] Allow to upload and display a custom brand image on login/header Aug 1, 2018
@miq-bot miq-bot removed the wip label Aug 1, 2018
@epwinchell
Copy link
Contributor

cc @bascar @Loicavenel

@Loicavenel
Copy link

Seems ok for me, can we get UX review ?

@epwinchell
Copy link
Contributor

@Loicavenel The upload UX hasn't changed. There's nothing new here from that perspective.

@Loicavenel
Copy link

@epwinchell logo was on the right before... and on the left

@epwinchell
Copy link
Contributor

epwinchell commented Aug 1, 2018

@Loicavenel This just creates an upload feature for the existing brand image on the top left. The custom logo on the top right hasn't changed.

@Loicavenel
Copy link

@epwinchell here my issue here:

1 - Now, we can have 2 logos one of the left, one of the right...

2 - We are removing Red Hat logo, I don't know the rules in RH for this.. it is why I want to UX involved.. I don't know if other products are doing this.

@Rohoover can you help me here...

@dclarizio
Copy link

@terezanovotna (CF UX), can you take a look at this as well? . . . I'm pretty sure we allow customers to totally use their own branding if they choose.
@Loicavenel @bascar don't we have VM hosting providers that use us under the covers with their own branding?

@bascar
Copy link

bascar commented Aug 2, 2018

We do have customers who do their own branding. They have for years and in the past, it was easier. Some recent changes have made that more difficult for re-branding and this change will allow them yet again to do this in an easier fashion. I spoke with Loic about his concern, however, in this case, this is a feature we want in and supports many customers.

@@ -1104,11 +1106,16 @@ def settings_set_form_vars_logos
if @edit[:current].config[:server][:custom_login_logo].nil?
@edit[:current].config[:server][:custom_login_logo] = false # Set default custom_logo flag
end
if @edit[:current].config[:server][:custom_brand].nil?
@edit[:current].config[:server][:custom_brand] = false # Set default custom_logo flag
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File.open(typ == "custom" ? @@logo_file : @@login_logo_file, "wb") { |f| f.write(fld[:logo].read) }
msg = typ == "custom" ? _('Custom logo file "%{name}" uploaded') : _('Custom login file "%{name}" uploaded')
add_flash(msg % {:name => fld[:logo].original_filename})
File.open(file, "wb") { |f| f.write(field[:logo].read) }
Copy link
Member

@Fryguy Fryguy Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little simpler File.write(field[:logo].read, :mode => "wb")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really make sense? Should I put this into the block, or replace the whole line? I haven't found any documentation for this.

private

def logo_dir
dir = File.expand_path(Rails.root.join('public', 'upload'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the Pathname object directly instead of relying on the File class methods

dir = Rails.root.join('public', 'upload').expand_path
Dir.mkdir(dir) unless dir.exist?
dir.to_s

@Fryguy
Copy link
Member

Fryguy commented Aug 6, 2018

@skateman Where is the code that sets the custom_login setting in the settings (just want to make sure it's being done accurately.

@terezanovotna
Copy link

From what I see, LGTM! It should be ok to remove RH branding and replace it with another. We should then say more about RH branding within the About Modal

@skateman
Copy link
Member Author

skateman commented Aug 7, 2018

@Fryguy I don't understand the question, everything should be in the files I touched.

@Rohoover
Copy link

Rohoover commented Aug 7, 2018

There is some valuable information here on cobranding:

https://brand.redhat.com/logos/cobranding/

That said, this isn't quite the same case (RH Logo + Partner logo on the same page). I would continue to do what was previously done, unless it directly runs counter to what's outlined in the link above.

@skateman
Copy link
Member Author

@miq-bot rm_label pending core

@epwinchell
Copy link
Contributor

@miq-bot add_label enhancement, gaprindashvili/yes

@epwinchell
Copy link
Contributor

@miq-bot add_label fine/yes

%label.col-md-2.control-label
= _("Use Custom Brand Image")
.col-md-8
= check_box_tag("server_usebrand", true, @edit[:new][:server][:custom_brand], :data => {:on_text => 'Yes', :off_text => 'No'})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing gettext in {:on_text => 'Yes', :off_text => 'No'}

msg = typ == "custom" ? _('Custom logo file "%{name}" uploaded') : _('Custom login file "%{name}" uploaded')
add_flash(msg % {:name => fld[:logo].original_filename})
File.open(file, "wb") { |f| f.write(field[:logo].read) }
add_flash('%{image} "%{name}" uploaded' % {:image => text, :name => field[:logo].original_filename})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing gettext.

msg = typ == "custom" ? _('Custom logo file "%{name}" uploaded') : _('Custom login file "%{name}" uploaded')
add_flash(msg % {:name => fld[:logo].original_filename})
File.open(file, "wb") { |f| f.write(field[:logo].read) }
add_flash(_('%{image} "%{name}" uploaded') % {:image => text, :name => field[:logo].original_filename})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%{} won't work in a '...' string, right? You have to use "..." here.

@miq-bot
Copy link
Member

miq-bot commented Sep 6, 2018

Checked commits skateman/manageiq-ui-classic@712c431~...da1cfb5 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
6 files checked, 2 offenses detected

**

  • 💣 💥 🔥 🚒 - Linter/Haml - Linter::Haml STDERR:
warning: parser/current is loading parser/ruby23, which recognizes
warning: 2.3.6-compliant syntax, but you are running 2.3.3.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.

app/controllers/ops_controller/settings/common.rb

  • ❗ - Line 9, Col 3 - Style/ClassVars - Replace class var @@login_brand_file with a class instance var.

@mzazrivec mzazrivec added this to the Sprint 94 Ending Sep 10, 2018 milestone Sep 6, 2018
@mzazrivec mzazrivec merged commit ab0c8e5 into ManageIQ:master Sep 6, 2018
@skateman skateman deleted the product-title branch September 6, 2018 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet