Skip to content

Commit

Permalink
UX - Display release candidate link if available in the online JSON file
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Jun 20, 2024
1 parent 7ad1a65 commit eb60480
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 59 deletions.
3 changes: 3 additions & 0 deletions lizmap/definitions/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ def __lt__(self, other):
@classmethod
def find(cls, status_string: str):
"""Return the release status from the string."""
if status_string == 'feature_freeze':
status_string = 'ReleaseCandidate'
status_string = status_string.lower()
for status in cls.__members__.values():
if str(status.value).lower() == status_string:
return status
Expand Down
101 changes: 52 additions & 49 deletions lizmap/resources/ui/ui_lizmap.ui
Original file line number Diff line number Diff line change
Expand Up @@ -537,55 +537,58 @@ QListWidget::item::selected {
</widget>
</item>
<item>
<widget class="QLabel" name="lwc_version_latest">
<property name="text">
<string>Unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lwc_version_oldest">
<property name="text">
<string>Unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_63">
<item>
<widget class="QLabel" name="label_53">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lwc_version_latest_changelog">
<property name="text">
<string notr="true">CHANGELOG NEW</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lwc_version_oldest_changelog">
<property name="text">
<string notr="true">CHANGELOG OLD</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout_11">
<item row="1" column="0">
<widget class="QLabel" name="lwc_version_latest">
<property name="text">
<string>Unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lwc_version_feature_freeze">
<property name="text">
<string>Unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lwc_version_oldest">
<property name="text">
<string>Unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="lwc_version_latest_changelog">
<property name="text">
<string notr="true">CHANGELOG NEW</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="lwc_version_oldest_changelog">
<property name="text">
<string notr="true">CHANGELOG OLD</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
Expand Down
7 changes: 6 additions & 1 deletion lizmap/test/test_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import unittest

from lizmap.definitions.definitions import LwcVersions
from lizmap.definitions.definitions import LwcVersions, ReleaseStatus


class TestDefinitions(unittest.TestCase):
Expand Down Expand Up @@ -40,3 +40,8 @@ def test_version_comparaison(self):
self.assertTrue(LwcVersions.Lizmap_3_5 < LwcVersions.Lizmap_3_6)
self.assertTrue(LwcVersions.Lizmap_3_5 <= LwcVersions.Lizmap_3_5)
self.assertFalse(LwcVersions.Lizmap_3_5 < LwcVersions.Lizmap_3_4)

def test_release_status(self):
""" Test to retrieve release status. """
self.assertEqual(ReleaseStatus.find('feature_freeze'), ReleaseStatus.ReleaseCandidate)
self.assertEqual(ReleaseStatus.find('stable'), ReleaseStatus.Stable)
26 changes: 17 additions & 9 deletions lizmap/version_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def update_lwc_releases(self, released_versions: dict):
template = (
'<a href="https://github.com/3liz/lizmap-web-client/releases/tag/{tag}">'
'{tag} - {date}'
'</a>')
'</a>'
)

self.dialog.lwc_version_latest_changelog.setVisible(False)
self.dialog.lwc_version_oldest_changelog.setVisible(False)
Expand All @@ -139,6 +140,7 @@ def update_lwc_releases(self, released_versions: dict):
# During a few months, we can have two stable versions
# But, we might have as well now a single one
single_stable_version_release = True
self.dialog.lwc_version_feature_freeze.setVisible(False)
for json_version in released_versions:

# The is_dev flag is to raise an exception only for developers
Expand All @@ -164,12 +166,22 @@ def update_lwc_releases(self, released_versions: dict):
link = None
changelog_url = None

if status == ReleaseStatus.ReleaseCandidate:
template_release = (
'<a href="https://github.com/3liz/lizmap-web-client/releases/">'
'{tag} - {version}'
'</a>'
).format(tag=tr("Release candidate"), version=lwc_version.value)
self.dialog.lwc_version_feature_freeze.setText(template_release)
self.dialog.lwc_version_feature_freeze.setVisible(True)

text = template.format(
tag=json_version['latest_release_version'],
date=date_string,
)

if status == ReleaseStatus.Stable:
if i == 0:
text = template.format(
tag=json_version['latest_release_version'],
date=date_string,
)
self.dialog.lwc_version_latest.setText(text)
self.date_newest_release_branch = qdate
self.newest_release_branch = json_version['latest_release_version']
Expand All @@ -188,10 +200,6 @@ def update_lwc_releases(self, released_versions: dict):

elif i == 1:
single_stable_version_release = False
text = template.format(
tag=json_version['latest_release_version'],
date=date_string,
)
self.dialog.lwc_version_oldest.setText(text)
self.date_oldest_release_branch = qdate
self.oldest_release_branche = json_version['latest_release_version']
Expand Down

0 comments on commit eb60480

Please sign in to comment.