After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 762733 - Prioritize important networks
Prioritize important networks
Status: RESOLVED FIXED
Product: polari
Classification: Applications
Component: general
3.19.x
Other Linux
: Normal normal
: ---
Assigned To: Polari maintainers
Polari maintainers
Depends on:
Blocks:
 
 
Reported: 2016-02-26 14:55 UTC by Florian Müllner
Modified: 2016-04-17 21:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
networksManager + connections: Networks can now be prioritized (3.25 KB, patch)
2016-04-03 21:15 UTC, Rares Visalom
none Details | Review
networksManager + connections: Networks can now be prioritized (3.25 KB, patch)
2016-04-04 12:56 UTC, Rares Visalom
needs-work Details | Review
networksManager: Add 'favorite' property to the networks (1.88 KB, patch)
2016-04-10 14:27 UTC, Rares Visalom
reviewed Details | Review
connections: Sort networks by importance and alphabetically (1.80 KB, patch)
2016-04-10 14:28 UTC, Rares Visalom
none Details | Review
connections: Sort networks by importance and alphabetically (2.09 KB, patch)
2016-04-14 18:08 UTC, Rares Visalom
none Details | Review
connections: Sort the connections list alphabetically (1.58 KB, patch)
2016-04-15 13:32 UTC, Rares Visalom
accepted-commit_now Details | Review
networksManager: Add "favorite" property to the networks and sort them accordingly (2.73 KB, patch)
2016-04-15 13:33 UTC, Rares Visalom
reviewed Details | Review
connections: Sort the connections list alphabetically (1.58 KB, patch)
2016-04-17 11:15 UTC, Rares Visalom
none Details | Review
networksManager: Prioritize favorite networks (2.77 KB, patch)
2016-04-17 11:15 UTC, Rares Visalom
none Details | Review
connections: Explicitly sort connections list alphabetically (1.53 KB, patch)
2016-04-17 11:21 UTC, Rares Visalom
committed Details | Review
networksManager: Prioritize favorite networks (2.77 KB, patch)
2016-04-17 18:18 UTC, Rares Visalom
committed Details | Review

Description Florian Müllner 2016-02-26 14:55:27 UTC
The list of predefined networks is quite long. We should pick the 5-6 we consider the most important and put them on top of the list, so users only need to fall back to filtering when they are looking for a more fringe one.
Comment 1 Rares Visalom 2016-04-03 21:15:26 UTC
Created attachment 325277 [details] [review]
networksManager + connections: Networks can now be prioritized

Added the 'prioritized' property to the network objects located in data/resources/networks.json and added a sorting function to the connections list so that prioritized networks are shown on top. The json objects can either have a 'prioritized' property set to true/false, or this property can be absent, in which case its value defaults to false.
Comment 2 Rares Visalom 2016-04-03 21:17:02 UTC
I have some small coding style issues. I will fix them in the next patch :)
Comment 3 Rares Visalom 2016-04-04 12:56:08 UTC
Created attachment 325331 [details] [review]
networksManager + connections: Networks can now be prioritized

Added the 'prioritized' property to the network objects located in data/resources/networks.json and added a sorting function to the connections list so that prioritized networks are shown on top. The json objects can either have a 'prioritized' property set to true/false, or this property can be absent, in which case its value defaults to false.
Comment 4 Florian Müllner 2016-04-07 12:49:42 UTC
Review of attachment 325331 [details] [review]:

We need to actually come up with a list of prioritized networks (as you mentioned yourself on IRC). Regarding the commit message:
  - only use a single prefix for the subject - either "connections" (to point to the main module),
    "connectionsList" (to point to the actual component that holds the main change) or "data" (to
    stress the changes to networks.json instead) are fine
  - git doesn't do automatic line-wrapping, so you need to add manual line breaks to the body
  - use present tense ("Add a 'prioritized' property ...")
  - try to focus on the reason for the change more than the change itself - it's fairly clear
    from reading the code that there's a 'prioritized' property that is used for sorting, but
    it's not immediately obvious *why* some networks should appear before others

::: src/connections.js
@@ +71,3 @@
         this._list.connect('row-activated',
                            Lang.bind(this, this._onRowActivated));
+

Gratuitous whitespace change

@@ +173,3 @@
+
+    _sort: function(row1, row2) {
+        let hasPriority1 = this._networksManager.getNetworkPriority(row1._id);

Don't access private properties from outside the class itself - should be row1.id instead.

@@ +178,3 @@
+        if (hasPriority1 != hasPriority2) {
+            return hasPriority1 ? -1 : 1;
+        }

Style nit: no braces

@@ +183,3 @@
+        let name2 = this._networksManager.getNetworkName(row2._id);
+
+        return name1.localeCompare(name2);

OK as-is, but if you want, you can split this out in a separate patch:

  connections: Sort networks list

  We currently list networks in the same order they appear in the data, which
  happens to be sorted alphabetically. Stop relying on that and sort the list
  explicitly by name instead.

::: src/networksManager.js
@@ +69,3 @@
     },
 
+    getNetworkPriority: function(id) {

"priority" doesn't suggest a boolean. If we stick with "prioritized", getNetworkIsPrioritized() is a better name.

@@ +73,3 @@
+
+        if(network.hasOwnProperty("prioritized")) {
+            return network['prioritized'];

I don't like 'prioritized' too much - maybe "important" or "favorite"?

@@ +87,3 @@
         let server = sslServers.length > 0 ? sslServers[0]
                                            : network.servers[0];
+

Gratuitous whitespace change
Comment 5 Rares Visalom 2016-04-10 14:27:48 UTC
Created attachment 325667 [details] [review]
networksManager: Add 'favorite' property to the networks

Using the 'favorite' property enables us to flag specific networks as
important. So far Polari displays networks alphabetically, but having
this property will make it possible for us to implement network
prioritization
Comment 6 Rares Visalom 2016-04-10 14:28:19 UTC
Created attachment 325668 [details] [review]
connections: Sort networks by importance and alphabetically

Polari displays networks as they appear in the networks.json file.
In order for the favorite networks to appear first in the list, a
sorting function is necessary. Important networks now appear first,
ordered alphabetically, then all other networks are displayed
alphabetically.
Comment 7 Florian Müllner 2016-04-13 14:51:53 UTC
Review of attachment 325667 [details] [review]:

The code of the two patches looks good to me, but the split is a bit odd. IMHO, the two main things the patches do are:
 - sort the list explicitly instead of relying
   on the order of networks in the data
 - prioritize "important" networks

As said before, it would be fine to use a single commit as before, but with the above split, we can provide separate answers for:
  - why we add a sort() function instead of reordering the networks
  - why we want to prioritize some networks
Comment 8 Rares Visalom 2016-04-14 18:08:53 UTC
Created attachment 326045 [details] [review]
connections: Sort networks by importance and alphabetically

Polari displays networks as they appear in the networks.json file.
This order is unreliable, therefore we cannot always count on the
fact that the networks are already ordered alphabetically. Moreover
we want to be able to dynamicaly select favorite networks, rather
than reordering the json file every time a new network becomes
a favorite one. The same applies for adding a new network to the
list.

A sorting function will fix this issue. The favorite networks are
displayed on the top of the list in order to make it easier for
new users to quickly setup their connections.
Comment 9 Rares Visalom 2016-04-14 18:10:59 UTC
(In reply to Florian Müllner from comment #7)
> Review of attachment 325667 [details] [review] [review]:
> 
> The code of the two patches looks good to me, but the split is a bit odd.
> IMHO, the two main things the patches do are:
>  - sort the list explicitly instead of relying
>    on the order of networks in the data
>  - prioritize "important" networks
> 
> As said before, it would be fine to use a single commit as before, but with
> the above split, we can provide separate answers for:
>   - why we add a sort() function instead of reordering the networks
>   - why we want to prioritize some networks

Questions answered!
Comment 10 Florian Müllner 2016-04-15 10:33:19 UTC
(In reply to Rares Visalom from comment #9)
> Questions answered!

Sorry, but what I was saying was: Either address those questions in a squashed patch, or make the split match the questions.
Comment 11 Rares Visalom 2016-04-15 13:32:40 UTC
Created attachment 326098 [details] [review]
connections: Sort the connections list alphabetically

At the moment, Polari displays the networks in the exact order
that they appear in the networks.json file.

We cannot always rely on the fact that those networks will
be sorted, so we need to sort them using a function.
That way, we don't need to reorder the file every time we add
a new network to it.
Comment 12 Rares Visalom 2016-04-15 13:33:07 UTC
Created attachment 326099 [details] [review]
networksManager: Add "favorite" property to the networks and sort them accordingly

Using the "favorite" property enables us to flag specific
networks as important. We want this property because we need
to display favorite networks first in the connetions list,
so that new users could be aided in the process of setting up
their first connection.

Moreover, the sorting function implemented in patch 9dcb30e
is updated in order to consider the "favorite" property in
the sorting process.
Comment 13 Florian Müllner 2016-04-15 15:08:57 UTC
Review of attachment 326098 [details] [review]:

OK as-is, but I'll add some random thoughts on the commit message anyway (feel free to ignore):

 - the subject isn't wrong, but it sounds like the list
   wasn't sorted alphabetically before; something like
   "connections: Explicitly sort connections list" is slightly
   clearer (and maybe use "networks" instead of "connections list"
   to avoid word repetition)

 - "we cannot rely" isn't quite correct, as we are in control
   of the data - similar, we don't need to reorder the file when
   making additions, but be careful where we add new entries. My
   suggestion:

   "At the moment, Polari displays the networks in the exact order
    as they appear in the networks.json file. As a result, any future
    change to the list may break the order if not done carefully.
    Avoid that risk by setting an appropriate sort function."
Comment 14 Florian Müllner 2016-04-15 15:09:06 UTC
Review of attachment 326099 [details] [review]:

Some nits with the commit message:
 - the summary is too long
   (see the recommendations in [0]); I'd suggest
   a simple "networksManager: Prioritize some networks"

 - the commit hash in the last paragraph refers to the
   commit in your local tree, so you would need to update
   the commit message after pushing the first patch;
   you can avoid this by saying "last patch" instead, though
   in this case I'd just drop the whole sentence: "Change the
   sort function to change the ordering" is kinda obvious ;-)

 - the commit message is still a bit vague - what this is fixing
   is that the list is unwieldily long, so it makes sense to put
   the most likely picks on top to not overwhelm the user

 - optionally, you could mention that the current designs for
   initial setup sport a very reduced list of networks, so this
   will be useful there as well

[0] https://wiki.gnome.org/Git/CommitMessages

::: src/networksManager.js
@@ +69,3 @@
     },
 
+    getIsFavorite: function(id) {

The other functions have "Network" in the name to make it clear that the function doesn't refer to the manager object (i.e. "getNetworkName()" instead of "getName()"), so "getNetworkIsFavorite" would be more consistent.

@@ +72,3 @@
+        let network = this._lookupNetwork(id);
+
+        if(network.hasOwnProperty("favorite")) {

Nits: Space after if, no braces
Comment 15 Rares Visalom 2016-04-17 11:15:07 UTC
Created attachment 326190 [details] [review]
connections: Sort the connections list alphabetically

At the moment, Polari displays the networks in the exact order
that they appear in the networks.json file.

We cannot always rely on the fact that those networks will
be sorted, so we need to sort them using a function.
That way, we don't need to reorder the file every time we add
a new network to it.
Comment 16 Rares Visalom 2016-04-17 11:15:32 UTC
Created attachment 326191 [details] [review]
networksManager: Prioritize favorite networks

Using the "favorite" property enables us to flag specific
networks as important. We want this property because the
networks list is long and naturally, we want to put the
favorite ones on top of the list. Furthermore, the current
designs for initial setup use a reduced list of networks,
thus prioritization would make it easier to display the new
list.

Moreover, the sorting function is changed in order to account
for the favorite proprty first, and then the alphabetic order.
Comment 17 Rares Visalom 2016-04-17 11:17:24 UTC
I still have to edit the first commit message. I'll do that right away
Comment 18 Rares Visalom 2016-04-17 11:21:34 UTC
Created attachment 326192 [details] [review]
connections: Explicitly sort connections list alphabetically

At the moment, Polari displays the networks in the exact order
that they appear in the networks.json file. As a result, any
future change to the list may break the order if not done
carefully. Avoid that risk by setting an appropriate
sort function.
Comment 19 Rares Visalom 2016-04-17 11:22:43 UTC
Done
Comment 20 Florian Müllner 2016-04-17 18:07:11 UTC
Review of attachment 326192 [details] [review]:

LGTM
Comment 21 Florian Müllner 2016-04-17 18:08:23 UTC
Review of attachment 326191 [details] [review]:

One more style nit - just fix that up before pushing, no need for another review round

::: src/networksManager.js
@@ +72,3 @@
+        let network = this._lookupNetwork(id);
+
+        if (network.hasOwnProperty("favorite"))

Sorry I overlooked that earlier:
By convention, double quotes are used for translatable string, single quotes otherwise.
Comment 22 Rares Visalom 2016-04-17 18:18:20 UTC
Created attachment 326209 [details] [review]
networksManager: Prioritize favorite networks

Using the "favorite" property enables us to flag specific
networks as important. We want this property because the
networks list is long and naturally, we want to put the
favorite ones on top of the list. Furthermore, the current
designs for initial setup use a reduced list of networks,
thus prioritization would make it easier to display the new
list.

Moreover, the sorting function is changed in order to account
for the favorite proprty first, and then the alphabetic order.
Comment 23 Rares Visalom 2016-04-17 18:20:39 UTC
Fixed
Comment 24 Florian Müllner 2016-04-17 18:24:19 UTC
Review of attachment 326209 [details] [review]:

Gah, I said no more review, push it already :-p
Comment 25 Rares Visalom 2016-04-17 18:25:16 UTC
I don't think i have rights for that :D
Comment 26 Florian Müllner 2016-04-17 18:37:55 UTC
Oh, OK. I'll push the patches when I get home later then.

Meanwhile, feel free to ask for git access[0].

[0] https://wiki.gnome.org/AccountsTeam/NewAccounts
Comment 27 Rares Visalom 2016-04-17 18:38:41 UTC
On it!
Comment 28 Florian Müllner 2016-04-17 21:32:22 UTC
Attachment 326192 [details] pushed as c73741c - connections: Explicitly sort connections list alphabetically
Attachment 326209 [details] pushed as 3bea70e - networksManager: Prioritize favorite networks