Skip to content

Commit

Permalink
feat(core): show hostname of device on the home page - closes #128
Browse files Browse the repository at this point in the history
  • Loading branch information
sassanh committed Jul 19, 2024
1 parent bf82d7b commit 700d467
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- refactor(core): make the power-off menu, a sub-menu with power-off and reboot action items - closes #123
- fix(core): headed menus not showing the first item in the list - closes #144
- refactor(system): generate the hostname of the device based on a hash of its serial number
- feat(core): show hostname of device on the home page - closes #128

## Version 0.15.4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@
}
],
"placeholder": null,
"title": "Dashboard"
"title": "󰋜test-hostname.local"
},
"path": [
"Dashboard"
"󰋜test-hostname.local"
],
"settings_items_priorities": {}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@
}
],
"placeholder": null,
"title": "Dashboard"
"title": "󰋜test-hostname.local"
},
"path": [
"Dashboard"
"󰋜test-hostname.local"
],
"settings_items_priorities": {}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// window-desktop-000
8aabfba03d3c1d0d0c02b677ab67175cf3624e1c9be491e044dea59b97d4a065
f01c8c31e23986fc788412f94a90c811765b446290ad9754217d02a67f08dc31
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// window-rpi-000
e31cb3d093970af305337e294664e803554ce642c40a26e5974f26a12890aba2
541be70b6889a2116a6e4bb0d731b41ff14d9512af8786ceb4fb32b4adf594a4
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,10 @@
}
],
"placeholder": null,
"title": "Dashboard"
"title": "󰋜test-hostname.local"
},
"path": [
"Dashboard"
"󰋜test-hostname.local"
],
"settings_items_priorities": {
"Docker": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,10 @@
}
],
"placeholder": null,
"title": "Dashboard"
"title": "󰋜test-hostname.local"
},
"path": [
"Dashboard"
"󰋜test-hostname.local"
],
"settings_items_priorities": {
"Docker": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// window-desktop-000
25ac0c93a16f853d638f94b08a363395992d5d1f2472579d79f7bee063727cd4
518a5aaa6762abbdbda7276cc7b15c68a28926b17a79fd26c342e4c3bba18456
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// window-rpi-000
b0b77ab002f411df0c0ba87b11db783733f678a852c9e3c0735b05b45836e8fb
b64fc25d16a3142afc786cd59c2700fc0b0abbb85ed8ea209e3faaff64c73713
2 changes: 2 additions & 0 deletions tests/monkeypatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def _monkeypatch_socket(monkeypatch: pytest.MonkeyPatch) -> None:

from ubo_app.utils.fake import Fake

monkeypatch.setattr(socket, 'gethostname', lambda: 'test-hostname')

monkeypatch.setattr(
socket,
'create_connection',
Expand Down
3 changes: 2 additions & 1 deletion ubo_app/store/core/_menus.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import functools
import socket
from dataclasses import replace
from datetime import UTC, datetime
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -131,7 +132,7 @@ def notifications_color(unread_count: int) -> str:


HOME_MENU = HeadlessMenu(
title='Dashboard',
title=f'󰋜{socket.gethostname()}.local',
items=[
SubMenuItem(
label='',
Expand Down
2 changes: 0 additions & 2 deletions ubo_app/store/update_manager/reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
UpdateStatus,
)

ABOUT_MENU_PATH = ['Dashboard', 'Main', 'About']


def reducer(
state: UpdateManagerState | None,
Expand Down
5 changes: 3 additions & 2 deletions ubo_app/store/update_manager/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
UpdateManagerState,
UpdateStatus,
)
from ubo_app.store.update_manager.reducer import ABOUT_MENU_PATH
from ubo_app.utils.eeprom import read_serial_number

CURRENT_VERSION = importlib.metadata.version('ubo_app')
Expand Down Expand Up @@ -57,7 +56,9 @@ async def check_version() -> None:
dispatch(
with_state=lambda state: UpdateManagerSetVersionsAction(
flash_notification=state is None
or state.main.path[:3] != ABOUT_MENU_PATH,
# TODO(Sassan): We need a better approach for # noqa: FIX002, TD003
# serializing and checking paths of menus
or state.main.path[1:3] != ['Main', 'About'],
current_version=CURRENT_VERSION,
latest_version=latest_version,
serial_number=serial_number,
Expand Down

0 comments on commit 700d467

Please sign in to comment.