Closed Bug 1525589 Opened 5 years ago Closed 5 years ago

[de-xbl] convert download to custom element

Categories

(Thunderbird :: General, task)

task
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 67.0

People

(Reporter: khushil324, Assigned: khushil324)

References

Details

Attachments

(1 file, 4 obsolete files)

No description provided.
Assignee: nobody → khushil324
Status: NEW → ASSIGNED
Attached patch De-XBL_richlist-download.patch (obsolete) — Splinter Review
Attachment #9043711 - Flags: review?(mkmelin+mozilla)

I was facing CSS issue with the image of the downloaded item. Height was not getting set up properly(32px here). It was taking the height of the whole container so the image was getting skewed. So I have used max-height CSS attribute here.

Comment on attachment 9043711 [details] [diff] [review]
De-XBL_richlist-download.patch

Review of attachment 9043711 [details] [diff] [review]:
-----------------------------------------------------------------

::: mail/components/downloads/content/download.js
@@ +3,5 @@
> +  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
> +
> +"use strict";
> +/**
> + * The MozDownloadView widget displays information about the downloaded file:

this isn't a really a view, it's an item in a view

@@ +6,5 @@
> +/**
> + * The MozDownloadView widget displays information about the downloaded file:
> + * e.g. downloaded file type, name, size, date and sender's name.
> + * It is shown in the Saved Files view as an item of the downloaded items list.
> + */

this documentation needs to be directly before the class definition

@@ +49,5 @@
> +    this.appendChild(this._vbox);
> +    this.appendChild(this._sender);
> +
> +    this._updateAttributes();
> +  }

I'd think it's enough to do this._updateAttributes() in the connectedCallback, no?

@@ +83,5 @@
> +MozXULElement.implementCustomInterface(
> +  MozDownloadView,
> +  [Ci.nsIDOMXULSelectControlItemElement]
> +);
> +

prefer this formatting:

MozXULElement.implementCustomInterface(
  MozDownloadView,  [Ci.nsIDOMXULSelectControlItemElement]
);

@@ +84,5 @@
> +  MozDownloadView,
> +  [Ci.nsIDOMXULSelectControlItemElement]
> +);
> +
> +customElements.define("download-view", MozDownloadView, {

I'd suggest downloades-view-item

@@ +86,5 @@
> +);
> +
> +customElements.define("download-view", MozDownloadView, {
> +  extends: "richlistitem",
> +});

for easier greppability, you can put stuff things like these that would only slightly go over 80ch on to one line, as

customElements.define("download-view", MozDownloadView, { extends: "richlistitem"} );

::: mail/themes/linux/mail/downloads/aboutDownloads.css
@@ +24,4 @@
>  }
>  
>  #msgDownloadsRichListBox > richlistitem.download {
> +  display: -webkit-inline-box;

we don't put -webbit css properties into internal code, ever

It's apparently a deprecated property anyway, you should use something from the recent flexbox spec if you need it.
Attachment #9043711 - Flags: review?(mkmelin+mozilla)

And how did the investigation go as for the feasibility of using what toolkit did in bug 1452626?

(In reply to Magnus Melin [:mkmelin] from comment #4)

And how did the investigation go as for the feasibility of using what toolkit did in bug 1452626?

I tried it. I understood how we can do it. It will take little time for me to code. But I thought these components are isolated and fairly straight forward in terms of implementation. so we can go with CE and try to implement toolkit methods in some other components. What do you think?

Sure, let's go with the CE approach.

Attached patch De-XBL_richlist-download.patch (obsolete) — Splinter Review
Attachment #9043711 - Attachment is obsolete: true
Attachment #9044011 - Flags: review?(mkmelin+mozilla)
Comment on attachment 9044011 [details] [diff] [review]
De-XBL_richlist-download.patch

Review of attachment 9044011 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good. r=mkmelin with the below addressed

::: mail/components/downloads/content/aboutDownloads.xul
@@ +23,5 @@
>            src="chrome://global/content/globalOverlay.js"/>
>    <script type="application/javascript"
>            src="chrome://messenger/content/downloads/aboutDownloads.js"/>
> +  <script type="application/javascript"
> +          src="chrome://messenger/content/downloads/download.js"/>

please make the file also be named download-view-item.js

::: mail/components/downloads/content/download.js
@@ +3,5 @@
> +  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
> +
> +"use strict";
> +
> +/* global MozElements, MozXULElement, Ci */

Ci is in the global ignore list for mozilla
Attachment #9044011 - Flags: review?(mkmelin+mozilla) → review+
Attached patch De-XBL_richlist-download.patch (obsolete) — Splinter Review
Attachment #9044011 - Attachment is obsolete: true
Attachment #9044320 - Flags: review+

Please still change MozDownloadViewItem to MozDownloadsViewItem, and the download-view-item.js to downloads-view-item.js

It's downloads with an s. A view of downloads.

Attached patch De-XBL_richlist-download.patch (obsolete) — Splinter Review
Attachment #9044320 - Attachment is obsolete: true
Attachment #9044487 - Flags: review+

Shouldn't you do a try run here? We have tests for downloads.

https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=228952387&repo=try-comm-central&lineNumber=1802
TEST-UNEXPECTED-FAIL | /builds/worker/workspace/build/tests/mozmill/downloads/test-about-downloads.js | test-about-downloads.js::test_remove_file
TEST-UNEXPECTED-FAIL | /builds/worker/workspace/build/tests/mozmill/downloads/test-about-downloads.js | test-about-downloads.js::test_remove_multiple_files

Keywords: checkin-needed

I'm not sure this works now: https://searchfox.org/comm-central/source/mail/components/downloads/content/aboutDownloads.js#237

Also make sure firstElement is what's expected: https://searchfox.org/comm-central/source/mail/test/mozmill/downloads/test-about-downloads.js#197

So to debug, go to your obj-dir, then run
make SOLO_TEST=downloads/test-about-downloads.js mozmill-one

I found that it was an issue related to accessing firstElement. I have updated the test accordingly.

Attachment #9044487 - Attachment is obsolete: true
Attachment #9046112 - Flags: review?(mkmelin+mozilla)
Comment on attachment 9046112 [details] [diff] [review]
De-XBL_richlist-download.patch

Review of attachment 9046112 [details] [diff] [review]:
-----------------------------------------------------------------

Verified the test works locally. r=mkmelin
Attachment #9046112 - Flags: review?(mkmelin+mozilla) → review+
Comment on attachment 9046112 [details] [diff] [review]
De-XBL_richlist-download.patch

Review of attachment 9046112 [details] [diff] [review]:
-----------------------------------------------------------------

For future bugs, please add a " - " after the bug number in the commit message. Like

Bug 1525589 - convert download binding to custom element downloads-view-item. r=mkmelin

Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/50e9f0078bdd
De-XBL: convert download binding to custom element. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 67.0

Since there's only one usage, you could have built the markup directly into the only callsite instead of creating a whole custom element.

See bug 1520924 and bug 1522279 for some examples how to do that.

Thanks Tim, agreed that could have been a good alternative. I'm not sure it matters much especially as this is only loaded for the downloads tab.

Khushil, can you still file a follow-up bug to directly build the markup instead? It looks like it would be fairly easy to move over.

Sure, I have submitted the new bug: Bug 1537934. Will post the updates there.

Type: enhancement → task
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: