Merge lp:~nataliabidart/ubuntuone-control-panel/out-of-space-notif into lp:ubuntuone-control-panel

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 86
Merged at revision: 84
Proposed branch: lp:~nataliabidart/ubuntuone-control-panel/out-of-space-notif
Merge into: lp:ubuntuone-control-panel
Diff against target: 132 lines (+45/-17)
2 files modified
ubuntuone/controlpanel/gtk/gui.py (+15/-7)
ubuntuone/controlpanel/gtk/tests/test_gui.py (+30/-10)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-control-panel/out-of-space-notif
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
Martin Albisetti (community) Approve
Review via email: mp+51484@code.launchpad.net

Commit message

  - Quota usage is now red when user is over quota (LP: #701729).
  - File sync status is now centered (LP: #715715).

Description of the change

Screenshot of how this looks IRL is: http://ubuntuone.com/p/fMq/

To post a comment you must log in.
Revision history for this message
Martin Albisetti (beuno) wrote :

14:46 < nessita> beuno: http://ubuntuone.com/p/fMq/
14:47 < beuno> nessita, looks good to me
14:48 < beuno> do we only want to go red when they're >= 100?
14:48 < beuno> maybe 98/99 is enough?
14:48 < nessita> beuno: hum, good idea
14:48 < nessita> beuno: maybe >= 95
14:48 < nessita> beuno: that's a very good idea!

\o/

review: Approve
85. By Natalia Bidart

Setting red quota label when usage reaches or exceeds QUOTA_THRESHOLD.

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Quota usage 95% percent: http://ubuntuone.com/p/fNr/
Quota usage 94% percent: http://ubuntuone.com/p/fNs/

86. By Natalia Bidart

Merged trunk in.

Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looking good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/controlpanel/gtk/gui.py'
2--- ubuntuone/controlpanel/gtk/gui.py 2011-02-28 20:02:28 +0000
3+++ ubuntuone/controlpanel/gtk/gui.py 2011-02-28 22:22:10 +0000
4@@ -1161,7 +1161,7 @@
5 ControlPanelMixin.__init__(self)
6
7 self.label = LabelLoading(LOADING)
8- self.pack_start(self.label, expand=False)
9+ self.pack_start(self.label, expand=True)
10
11 self.button = gtk.LinkButton(uri='')
12 self.button.connect('clicked', self._on_button_clicked)
13@@ -1309,7 +1309,8 @@
14 gobject.TYPE_NONE, ()),
15 }
16
17- QUOTA_LABEL = _('Using %(used)s of %(total)s (%(percentage).1f%%)')
18+ QUOTA_LABEL = _('Using %(used)s of %(total)s (%(percentage).0f%%)')
19+ QUOTA_THRESHOLD = 0.95
20 DASHBOARD_BUTTON_NAME = 'Account'
21 SERVICES_BUTTON_NAME = 'Devices' # Intentional until the theme is fixed
22
23@@ -1339,7 +1340,7 @@
24 self.quota_box.reorder_child(self.quota_label, 0)
25
26 self.status_label = FileSyncStatus()
27- self.status_box.pack_end(self.status_label, expand=False)
28+ self.status_box.pack_end(self.status_label, expand=True)
29
30 self.dashboard = DashboardPanel(main_window=main_window)
31 self.volumes = VolumesPanel(main_window=main_window)
32@@ -1375,15 +1376,22 @@
33
34 def _update_quota(self, msg, data=None):
35 """Update the quota info."""
36- self.quota_label.set_markup(msg)
37- self.quota_label.stop()
38-
39 fraction = 0.0
40 if data is not None:
41 fraction = data.get('percentage', 0.0) / 100
42 if fraction > 0 and fraction < 0.05:
43 fraction = 0.05
44- self.quota_progressbar.set_fraction(fraction)
45+ else:
46+ fraction = round(fraction, 2)
47+
48+ logger.debug('ManagementPanel: updating quota to %r.', fraction)
49+ if fraction >= self.QUOTA_THRESHOLD:
50+ self.quota_label.set_markup(WARNING_MARKUP % msg)
51+ else:
52+ self.quota_label.set_markup(msg)
53+ self.quota_label.stop()
54+
55+ self.quota_progressbar.set_fraction(min(fraction, 1))
56
57 def load(self):
58 """Load the account info and file sync status list."""
59
60=== modified file 'ubuntuone/controlpanel/gtk/tests/test_gui.py'
61--- ubuntuone/controlpanel/gtk/tests/test_gui.py 2011-02-28 19:53:50 +0000
62+++ ubuntuone/controlpanel/gtk/tests/test_gui.py 2011-02-28 22:22:10 +0000
63@@ -2281,15 +2281,18 @@
64 """Check that the displayed account info matches 'info'."""
65 used = int(info['quota_used'])
66 total = int(info['quota_total'])
67- percentage = (used / total) * 100
68+ percentage = round((used / total) * 100, 2)
69 expected = {'used': self.ui.humanize(used),
70 'total': self.ui.humanize(total),
71 'percentage': percentage}
72- self.assertEqual(self.ui.quota_label.get_text(),
73- self.ui.QUOTA_LABEL % expected)
74+ msg = self.ui.QUOTA_LABEL % expected
75+ self.assertEqual(self.ui.quota_label.get_text(), msg)
76+
77+ if percentage >= self.ui.QUOTA_THRESHOLD * 100:
78+ self.assert_warning_correct(self.ui.quota_label, msg)
79
80 if progressbar_fraction is None:
81- progressbar_fraction = percentage / 100
82+ progressbar_fraction = min(percentage / 100, 1)
83 self.assertEqual(self.ui.quota_progressbar.get_fraction(),
84 progressbar_fraction)
85
86@@ -2408,16 +2411,13 @@
87 """The account info is processed when ready."""
88 self.ui.on_account_info_ready(FAKE_ACCOUNT_INFO)
89 self.assert_account_info_correct(FAKE_ACCOUNT_INFO)
90-
91- for widget in (self.ui.quota_label,):
92- self.assertFalse(widget.active)
93+ self.assertFalse(self.ui.quota_label.active)
94
95 def test_on_account_info_error(self):
96 """The account info couldn't be retrieved."""
97 self.ui.on_account_info_error()
98- for widget in (self.ui.quota_label,):
99- self.assert_warning_correct(widget, gui.VALUE_ERROR)
100- self.assertFalse(widget.active)
101+ self.assert_warning_correct(self.ui.quota_label, gui.VALUE_ERROR)
102+ self.assertFalse(self.ui.quota_label.active)
103
104 def test_on_account_info_ready_quota_unused(self):
105 """The used quota is correct when unused."""
106@@ -2434,6 +2434,26 @@
107
108 self.assert_account_info_correct(info, progressbar_fraction=0.05)
109
110+ def test_on_account_info_ready_quota_used_at_threshold(self):
111+ """Show red notification when quota usage is same as threshold."""
112+ info = FAKE_ACCOUNT_INFO.copy()
113+
114+ info['quota_total'] = '12345678'
115+ info['quota_used'] = str(int(int(info['quota_total']) *
116+ self.ui.QUOTA_THRESHOLD))
117+ self.ui.on_account_info_ready(info)
118+
119+ self.assert_account_info_correct(info)
120+
121+ def test_on_account_info_ready_quota_over_threshold(self):
122+ """Show red notification when quota usage is higher than threshold."""
123+ info = FAKE_ACCOUNT_INFO.copy()
124+ info['quota_total'] = '12345678'
125+ info['quota_used'] = info['quota_total'] + '0'
126+ self.ui.on_account_info_ready(info)
127+
128+ self.assert_account_info_correct(info)
129+
130 def test_file_sync_status(self):
131 """The file sync status is shown correctly."""
132 self.assertIsInstance(self.ui.status_label, gui.FileSyncStatus)

Subscribers

People subscribed via source and target branches