-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Conversation
Quick update: I have been working on displaying the full extension upon click, the trick has been changing only that description and not all of them. Once I get that, then I can work on toggling between the two. I'm sure I'll get it working very soon. |
@larz0 I've got the toggle actions you requested implemented, if you would want to look at it. I doubt this is the final code implementation, but that should not effect the look. I made a quick GIF overview for you too. :) |
description = entry.installInfo ? entry.installInfo.metadata.shortdescription : entry.registryInfo.metadata.shortdescription; | ||
} | ||
|
||
$(element).toggleClass("expand-desc trunc-desc"); |
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.
This was the only way I could figure out how to trigger the appropriate hide/show actions.
Cool. Looks good! Thanks for the gif. |
|
||
// To prevent awkward addition of ellipsis, try to truncate the description | ||
// at the end of the last whole word | ||
if (description.lastIndexOf(" ") < descriptionLimit && description.lastIndexOf(" ") > -1) { |
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's better to set a var to description.lastIndexOf(" ")
and use it instead of calling the function 3 times.
@SAplayer Changes pushed. Do you still want me to move the truncate function to StringUtils for more general-purpose usage? The way I had to access the function in test/spec/ExtensionManager-test.js feels a bit hacky to me. |
* @param {boolean} short true if short description should be shown, false for full length. | ||
*/ | ||
function toggleDescription(id, element, short) { | ||
var description, linkTitle, |
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's usually one variable per line
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.
You can use more than one in he first line. JSLint allows you to do that. I often do that so that you don't get lines with just a variable name.
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 was unsure about this, so I checked and just double checked the coding conventions, and I found nothing about single/multiple variables per line. Should I leave it or initialize them as null
or something?
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 think it is fine how it is now. Those are initialized to undefined by JavaScript anyway.
Changes pushed, except for the |
linkTitle = Strings.VIEW_TRUNCATED_DESCRIPTION; | ||
} | ||
|
||
$element.toggleClass("expand-desc trunc-desc") |
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.
The old comment is gone. So i'll reply here.
You are not really using the classes to style the element, so maybe you shouldn't use a class. To store data in the DOM use the data attributes. You can just have a single data-*
attribute and change i'ts value.
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.
Or if that doesn't work, you can use 2 toggles.
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.
The data-*
method works. Now what to show it? data-toggle-desc
?
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 know. I didn't wrote because I couldn't think of a good name for it.
Changes pushed. I ended up calling it |
@@ -156,6 +189,10 @@ define(function (require, exports, module) { | |||
ExtensionManager.markForRemoval($target.attr("data-extension-id"), true); | |||
} else if ($target.hasClass("undo-update")) { | |||
ExtensionManager.removeUpdate($target.attr("data-extension-id")); | |||
} else if ($target.attr("data-toggle-desc") === "expand-desc") { |
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.
Just to let you know, jQuery has a .data() method to get the data attributes, which makes the code look a bit cleaner.
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, but all the other code in that same if-else-if block uses .attr()
to access the data-
attributes. So I guess the question of which one to use comes down to consistency with the rest of the code around it for better method.
Also, I can't seem to get .data()
to work correctly. It will pick up the expand-desc
value but not the trunc-desc
value, so the description expands but never contracts.
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 didn't saw the use of .attr()
in this file. I've been using .data()
for data attributes. Maybe to make it work you need to also add the data attributes with .data()
? Anyway it was a minor nit.
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.
Alrighty then. I'll leave it as-is.
Thanks for reviewing this, everyone. The only questions I have now are
That first one is important, as right now in order to fix the current unit test for description view (test/spec/ExtensionManager-test.js, line 776) makes a new instance of |
@le717 If you want you can do that but since no other module uses it, I am not sure if is required. My concern is about having the description duplicated for almost every extension, since |
I'm just thinking about efficiency and good practice, as I could change it to where it shortened the description, check if it is different, and only if it is different will it be added to the extension details. This way, for most of the extensions only one copy of the description will be present. |
{{^metadata.description}} | ||
<p class="muted"><em>{{Strings.EXTENSION_NO_DESCRIPTION}}</em></p> | ||
{{/metadata.description}} | ||
<span class="ext-full-description"> |
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 looked up the Mustache syntax, and I think this how all this should work.
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.
This is fine, but maybe a some indentation will make the code look better like:
{{#hasShortDescription}}
{{metadata.shortdescription}}
{{/hasShortDescription}}
{{^hasShortDescription}}
{{#metadata.description}}
{{metadata.description}}
{{/metadata.description}}
{{^metadata.description}}
<p class="muted"><em>{{Strings.EXTENSION_NO_DESCRIPTION}}</em></p>
{{/metadata.description}}
{{/hasShortDescription}}
@le717 Sorry for not getting back to you earlier. This is looking good, I think that we can do those few changes and then merge it. You also need to merge with master. |
@TomMalbran No problem. I understand not being able to do this stuff all the time. :) Changes for all but the test pushed. I will fix that ASAP, can't code anymore today. So, my updated TODO for the code review now looks like:
|
if (lastSpaceChar < len && lastSpaceChar > -1) { | ||
str = str.substr(0, lastSpaceChar); | ||
} | ||
return str; |
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.
Wrong indentation
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.
Fixed.
@TomMalbran Changes pushed, ready for rereview. The original description unit test is broken for some reason, not sure how to to fix it quite yet. EDIT And for some reason Travis does not build my PR at all anymore... |
@TomMalbran Unit tests fixed, ready for review. I'm doing my best to get this in for Release 42 so the extension manager doesn't so odd now that #7995 is merged. :) |
|
||
|
||
if (info.metadata.description !== undefined) { | ||
context.hasShortDescription = StringUtils.truncate(info.metadata.description, 140); |
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 doesn't look like we need hasShortDescription
. We could just have info.metadata.shortdescription = StringUtils.truncate(info.metadata.description, 140);
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 did this so an info.metadata.shortdescription
key would not be created for every extension (like you wanted). Without it, most of the info.metadata.shortdescription
keys will have a value of undefined
.
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, but right now it works different from before. So it can be changed again. Before shortDesc and desc where the same for most, which meant duplicated strings. But now it is undefined, so that is fine.
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.
Fixed and pushed.
You still need to fix the merge issue. You can merge with master and then fix it. |
@@ -1 +1 @@ | |||
Subproject commit 6c0cd2b56b50837a010bd27f322a57edfbe9fee9 | |||
Subproject commit 64bee5830b6f838c2c9be6dded98a5dac794dbcd |
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.
This shouldn't be there. You need to update the submodules
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.
Yikes. I was watching for that but it seems I missed 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.
Fixed.
I think this is almost ready besides those last comments. But I noticed that most short descriptions are just a few chars shorter. Maybe we could allow more chars before using a short description. |
We are about to branch to release, so I am not sure if it can fit into release 41. We have to be sure that is bug-free and that it does not causes any other bug if we want to merge it right now. |
@TomMalbran How much longer should it be? @larz0 suggested it be the 140 character limit. I've been using this branch as my Brackets version since I started the PR with no issues. |
@le717 Figuring the best length might be an issue too. I tried with 200 and it feels a bit better. The descriptions are still short enough, and there are less with a short description. |
@TomMalbran 200 looks good and knocks out mainly the overly long descriptions now. I think @larz0 liked 140 because I mentioned that is the Twitter character limit and devs can (usually) describe their extension within that limit. @larz0 Do you have any further input on this? |
I personally find 140 characters to be painfully limited. 200 seems reasonable. |
I see. 140 is a good limit, but since is a recent thing, I see several extensions that extend just a little bit more than that, so 200 seems to fit better with us at this point. |
@TomMalbran @dangoor Limit increased to 200 characters and change pushed. |
Truncate extension descriptions
Thanks. Merged :) |
I have such a huge smile on my face right now I probably look silly. :D |
Hehe :) |
This is for #8216.