Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Refactor contributionStatement.js with Aphrodite #7887

Merged
merged 1 commit into from
Apr 5, 2017
Merged

Refactor contributionStatement.js with Aphrodite #7887

merged 1 commit into from
Apr 5, 2017

Conversation

luixxiul
Copy link
Contributor

@luixxiul luixxiul commented Mar 25, 2017

Closes #7883

  • Remove contributionStatement.less
  • Replace inlined braveLogo with a PNG file, verifiedIcon with a SVG file
  • Introduce constants for margins, borders, paddings, light gray, etc

Auditors:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

Test Plan:

  1. npm run add-simulated-payment-history
  2. Open about:preferences#payments
  3. Display the payments history
  4. Save the PDF file
  5. Open it and make sure it is successfully rendered

@luixxiul
Copy link
Contributor Author

luixxiul commented Mar 25, 2017

The brave logo PNG file and the verified SVG icon are not displayed on PDF file. Could I know how to display them? Do I have to inline them?

@luixxiul luixxiul added the help wanted The PR/issue opener needs help to complete/report the task. label Mar 25, 2017
@luixxiul luixxiul requested a review from willy-b March 25, 2017 12:44
@luixxiul luixxiul self-assigned this Mar 27, 2017
Copy link
Contributor

@willy-b willy-b left a comment

Choose a reason for hiding this comment

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

Hey @luixxiul,
This looks great. I see two things.

(1) Inline images are required for PDF generation, I think.
At least the final rendered HTML will need images inlined as data URIs for a PDF to be generated properly with existing code. You may be able to keep the data URI in a separate file and require it as you have done with the images here, though.

(2) Page breaks were lost with this change, need 1 line added to CSS (pageBreakAfter: 'always' incontributionStatement__page), see below

// ContributionStatementPage
contributionStatement__page: {
display: 'flex',
flexFlow: 'column nowrap'
Copy link
Contributor

Choose a reason for hiding this comment

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

Should add pageBreakAfter: 'always' here in contributionStatement__page so that there is a page break in PDF between pages.

Current code:
bravecontribstatementaphroditeprobs_cropped_2

With pageBreakAfter: 'always':
bravecontribstatementaphroditefixed_2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your feedback @willy-b! I'll ping you again later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you fixed this in next commit which was force pushed over this and the previous one, but pageBrakeAfter here (2f16bbd#diff-dfc3cf3000430cbd1575b0223b06163fR630) should be replaced with pageBreakAfter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Silly mistake.. I updated here: 0164a4d#diff-dfc3cf3000430cbd1575b0223b06163fR630

@luixxiul
Copy link
Contributor Author

luixxiul commented Apr 1, 2017

@willy-b Updated. The files were not displayed because npm run watch had been killed. I confirmed it worked as it was.

screenshot 2017-04-02 2 21 52

@luixxiul luixxiul removed the help wanted The PR/issue opener needs help to complete/report the task. label Apr 1, 2017
@willy-b
Copy link
Contributor

willy-b commented Apr 1, 2017

Glad it's working for you now. One issue: I still don't see the images in the generated PDF with your latest revision.

The footer text also continues to have extra characters in it, which seem to be have been fixed in your latest screenshot. Are you sure that screenshot is of 0164a4d?

@luixxiul
Copy link
Contributor Author

luixxiul commented Apr 2, 2017

Would you try rm -rf ~/.electron && rm -rf node_modules and npm i? Maybe something has been fixed.

@willy-b
Copy link
Contributor

willy-b commented Apr 2, 2017

Sure. I just re-installed: Still don't see any images in the generated PDF (which I can attach if you like).
Though I can confirm that page-breaking is fixed (#7887 (comment))

@luixxiul
Copy link
Contributor Author

luixxiul commented Apr 2, 2017

I'm not sure where the issue is...

  1. create payment history
  2. npm run watch
  3. npm start
  4. open about:preferences#payments
  5. show payment history
  6. click a pdf
  7. preview it

contribution

@willy-b
Copy link
Contributor

willy-b commented Apr 2, 2017

It looks like you're using the Print dialog manually to print to PDF and open the PDF in preview? That actually works for me too.

But what about the auto-popup for saving the PDF that is triggered by current code? That does not work (it uses a data URI internally and so the generated PDF lacks images). (Did you turn this off in your local for making the screencapture?) We could replace that with asking user to use Print -> Print to PDF and choose their own filename.

@luixxiul
Copy link
Contributor Author

luixxiul commented Apr 2, 2017

the auto-popup for saving the PDF that is triggered by current code?

Actually I haven't seen it for a while, though I'm running on the latest code. Is it disabled??

@willy-b
Copy link
Contributor

willy-b commented Apr 2, 2017

I see the auto-popup save dialog in a fresh build from your commit 0164a4d :
pull-7887-2-trimmed

As you can see in my screencap, the images are missing from the downloaded PDF (opened from downloads bar).

I wonder why you're not seeing the Download PDF auto-popup dialog anymore?

If I do a manual File->Print->Print to PDF of the contribution statement HTML page, as you show in your screencap, then the images are preserved for me too.
We could get rid of the auto-popup and just tell people to do that if you want.

@luixxiul
Copy link
Contributor Author

luixxiul commented Apr 2, 2017

I'm on macOS. Is it related with Muon or something? / CC @darkdh @bsclifton

@darkdh
Copy link
Member

darkdh commented Apr 2, 2017

I think it related to our 57 upgrade. There will be PREVIEW_FAIL error on both windows and macOS.

@luixxiul
Copy link
Contributor Author

luixxiul commented Apr 2, 2017

PREVIEW_FAIL

Yeah I see it on macOS!

@luixxiul
Copy link
Contributor Author

luixxiul commented Apr 3, 2017

@willy-b For me, not displaying the pop up is not that bad; in fact I felt quite natural, since I was not forced to save the statement in PDF. I could save, print, copy or just read through the statement of my own will.

I could imagine some would say, "please do not display the save pop up window as it is annoying."

@bsclifton
Copy link
Member

@luixxiul is this ready for review? or are you still working out a few things?

@luixxiul
Copy link
Contributor Author

luixxiul commented Apr 3, 2017

Except inlining the PNG and SVG files, it's ready for review.

If it is impossible to add the external files with printToPDF, I would inline them. / CC @darkdh

@cezaraugusto cezaraugusto merged commit 7c32ef1 into brave:master Apr 5, 2017
@luixxiul
Copy link
Contributor Author

luixxiul commented Apr 5, 2017

@willy-b would you please work on the fix? thanks!

@luixxiul luixxiul deleted the contributionStatement-aphrodite branch April 5, 2017 18:22
@cezaraugusto
Copy link
Contributor

@willy-b sorry I missed your last comment before merging. Please feel free to open an issue, not sure which STR to repro error you mentioned

@luixxiul
Copy link
Contributor Author

luixxiul commented Apr 5, 2017

@willy-b
Copy link
Contributor

willy-b commented Apr 5, 2017

no worries @cezaraugusto . quick question: does the final version you merged use inline images or not?

@cezaraugusto
Copy link
Contributor

no inline-images.

A fix I can think of is to convert images to base64 before rendering, but feel free to apply any method you find best and lmk if you need anything. Thanks for following-up :)

@cezaraugusto
Copy link
Contributor

btw auto-popup doesn't show on macOS

@luixxiul
Copy link
Contributor Author

luixxiul commented Apr 5, 2017

it has been mentioned here: #7887 (comment)

@willy-b
Copy link
Contributor

willy-b commented Apr 5, 2017

okay so we just broke this, just so we could avoid inline images? fair enough.
still seems to me we should have done that in a separate PR.

@darkdh is fixing the popup on MacOS, I think.

@darkdh
Copy link
Member

darkdh commented Apr 5, 2017

It's been fixed in brave/muon@9d32f7f
Just needs a new muon build

@willy-b
Copy link
Contributor

willy-b commented Apr 5, 2017

awesome @darkdh.

so then the popup will be on MacOS and images will be broken in the PDF. you guys sure you don't want to merge @luixxiul's other commit which restores inline images temporarily so this is not broken?

@cezaraugusto
Copy link
Contributor

@willy-b I'm looking for an alternative but yes we'll end up inlining images just not very happy with hard-coding it. If time gets shorter and we can't make it we'll eventually go back to @luixxiul fix.

@willy-b
Copy link
Contributor

willy-b commented Apr 5, 2017

ok, so you're going to restore inline images and reopen #8062 to pull them out once we make them unnecessary?

@darkdh
Copy link
Member

darkdh commented Apr 5, 2017

@willy-b , I think image problem will also be fixed in that commit

@willy-b
Copy link
Contributor

willy-b commented Apr 5, 2017

unfortunately it won't. the image issue is not in Muon. it's in our use of a data URI here: 7c32ef1#diff-dfc3cf3000430cbd1575b0223b06163fR120

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants