mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-03-24 02:13:38 +00:00
Compare commits
36 Commits
2.20.0rc5
...
feature/ss
| Author | SHA1 | Date | |
|---|---|---|---|
| c2e3ef9405 | |||
| 1c312bb528 | |||
| e39194e9f6 | |||
| 21cc029c18 | |||
| 40671b99d5 | |||
| 3ad2c494af | |||
| 34014d1cdd | |||
| 93ed2b864b | |||
| cca931ccd0 | |||
| 5e090cebdb | |||
| d7984c12f0 | |||
| 96684d7ddd | |||
| 2e9837b70d | |||
| ac4a8fb2cd | |||
| 1db8eb0ac4 | |||
| dc394f7df9 | |||
| 058f784b05 | |||
| f688768ca7 | |||
| a09ad7617d | |||
| 81aeb56ba3 | |||
| 2cd4ef5e86 | |||
| 998ed48dde | |||
| 021d88dc4c | |||
| 9012ee7144 | |||
| 945ddb2942 | |||
| 9cd0926588 | |||
| f5c12d03ec | |||
| 606ee2fb0e | |||
| 875e9cf58a | |||
| a809a4b67f | |||
| 437ae2c16c | |||
| 10661f3127 | |||
| 88ac3d82a0 | |||
| 386765ab4e | |||
| 78998182b8 | |||
| 2563391aaf |
77
docs/_static/architecture.dot
vendored
77
docs/_static/architecture.dot
vendored
@@ -138,11 +138,12 @@ digraph G {
|
||||
ahriman_core_http [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nhttp",shape="box"];
|
||||
ahriman_core_http_sync_ahriman_client [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nhttp\.\nsync_ahriman_client",shape="box"];
|
||||
ahriman_core_http_sync_http_client [fillcolor="#933f24",fontcolor="#ffffff",label="ahriman\.\ncore\.\nhttp\.\nsync_http_client"];
|
||||
ahriman_core_log [fillcolor="#e53b05",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog"];
|
||||
ahriman_core_log [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nlog",shape="box"];
|
||||
ahriman_core_log_http_log_handler [fillcolor="#914730",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog\.\nhttp_log_handler"];
|
||||
ahriman_core_log_journal_handler [fillcolor="#ac6149",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog\.\njournal_handler"];
|
||||
ahriman_core_log_lazy_logging [fillcolor="#b85a3d",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog\.\nlazy_logging"];
|
||||
ahriman_core_log_log_loader [fillcolor="#82402b",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog\.\nlog_loader"];
|
||||
ahriman_core_log_lazy_logging [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nlog\.\nlazy_logging",shape="box"];
|
||||
ahriman_core_log_log_context [fillcolor="#db582f",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog\.\nlog_context"];
|
||||
ahriman_core_log_log_loader [fillcolor="#7a3c28",fontcolor="#ffffff",label="ahriman\.\ncore\.\nlog\.\nlog_loader"];
|
||||
ahriman_core_module_loader [fillcolor="#ce5e3b",fontcolor="#ffffff",label="ahriman\.\ncore\.\nmodule_loader"];
|
||||
ahriman_core_report [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nreport",shape="box"];
|
||||
ahriman_core_report_console [fillcolor="blue",fontcolor="white",label="ahriman\.\ncore\.\nreport\.\nconsole",shape="box"];
|
||||
@@ -242,10 +243,11 @@ digraph G {
|
||||
ahriman_web_apispec_info [fillcolor="#a14f35",fontcolor="#ffffff",label="ahriman\.\nweb\.\napispec\.\ninfo"];
|
||||
ahriman_web_cors [fillcolor="#b0573a",fontcolor="#ffffff",label="ahriman\.\nweb\.\ncors"];
|
||||
ahriman_web_keys [fillcolor="#823017",fontcolor="#ffffff",label="ahriman\.\nweb\.\nkeys"];
|
||||
ahriman_web_middlewares [fillcolor="#e9410c",fontcolor="#ffffff",label="ahriman\.\nweb\.\nmiddlewares"];
|
||||
ahriman_web_middlewares [fillcolor="#ef3e06",fontcolor="#ffffff",label="ahriman\.\nweb\.\nmiddlewares"];
|
||||
ahriman_web_middlewares_auth_handler [fillcolor="#733826",fontcolor="#ffffff",label="ahriman\.\nweb\.\nmiddlewares\.\nauth_handler"];
|
||||
ahriman_web_middlewares_exception_handler [fillcolor="#994b33",fontcolor="#ffffff",label="ahriman\.\nweb\.\nmiddlewares\.\nexception_handler"];
|
||||
ahriman_web_middlewares_metrics_handler [fillcolor="#a34628",fontcolor="#ffffff",label="ahriman\.\nweb\.\nmiddlewares\.\nmetrics_handler"];
|
||||
ahriman_web_middlewares_request_id_handler [fillcolor="#8a442e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nmiddlewares\.\nrequest_id_handler"];
|
||||
ahriman_web_routes [fillcolor="#8a442e",fontcolor="#ffffff",label="ahriman\.\nweb\.\nroutes"];
|
||||
ahriman_web_schemas [fillcolor="blue",fontcolor="white",label="ahriman\.\nweb\.\nschemas",shape="box"];
|
||||
ahriman_web_schemas_any_schema [fillcolor="#b85a3d",fontcolor="#ffffff",label="ahriman\.\nweb\.\nschemas\.\nany_schema"];
|
||||
@@ -493,6 +495,7 @@ digraph G {
|
||||
ahriman_core -> ahriman_models_worker [fillcolor="#ef3e06",minlen="2"];
|
||||
ahriman_core -> ahriman_web_keys [fillcolor="#ef3e06",minlen="2"];
|
||||
ahriman_core -> ahriman_web_middlewares_auth_handler [fillcolor="#ef3e06",minlen="3"];
|
||||
ahriman_core -> ahriman_web_middlewares_request_id_handler [fillcolor="#ef3e06",minlen="3"];
|
||||
ahriman_core -> ahriman_web_routes [fillcolor="#ef3e06",minlen="2"];
|
||||
ahriman_core -> ahriman_web_server_info [fillcolor="#ef3e06",minlen="2"];
|
||||
ahriman_core -> ahriman_web_views_api_docs [fillcolor="#ef3e06",minlen="3"];
|
||||
@@ -848,35 +851,39 @@ digraph G {
|
||||
ahriman_core_http_sync_ahriman_client -> ahriman_core_http [fillcolor="blue",weight="3"];
|
||||
ahriman_core_http_sync_http_client -> ahriman_core_http [fillcolor="#933f24",weight="3"];
|
||||
ahriman_core_http_sync_http_client -> ahriman_core_http_sync_ahriman_client [fillcolor="#933f24",weight="3"];
|
||||
ahriman_core_log -> ahriman_application_application_application_properties [fillcolor="#e53b05",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_application_workers_updater [fillcolor="#e53b05",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_handlers_handler [fillcolor="#e53b05",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_lock [fillcolor="#e53b05",minlen="2"];
|
||||
ahriman_core_log -> ahriman_core_alpm_pacman [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_alpm_repo [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_archive_archive_tree [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_auth_auth [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_build_tools_package_version [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_build_tools_sources [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_build_tools_task [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_database_migrations [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_database_operations_operations [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_distributed_workers_cache [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_gitremote_remote_pull [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_gitremote_remote_push [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_http_sync_http_client [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_report_report [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_repository_repository_properties [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_spawn [fillcolor="#e53b05",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_status_watcher [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_triggers_trigger [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_triggers_trigger_loader [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_upload_upload [fillcolor="#e53b05",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_models_package [fillcolor="#e53b05",minlen="2"];
|
||||
ahriman_core_log -> ahriman_models_repository_paths [fillcolor="#e53b05",minlen="2"];
|
||||
ahriman_core_log -> ahriman_application_application_application_properties [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_application_workers_updater [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_handlers_handler [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_log -> ahriman_application_lock [fillcolor="blue",minlen="2"];
|
||||
ahriman_core_log -> ahriman_core_alpm_pacman [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_alpm_repo [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_archive_archive_tree [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_auth_auth [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_build_tools_package_version [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_build_tools_sources [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_build_tools_task [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_database_migrations [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_database_operations_operations [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_distributed_workers_cache [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_gitremote_remote_pull [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_gitremote_remote_push [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_http_sync_http_client [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_report_report [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_repository_repository_properties [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_spawn [fillcolor="blue",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_status_watcher [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_triggers_trigger [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_triggers_trigger_loader [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_core_upload_upload [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_core_log -> ahriman_models_package [fillcolor="blue",minlen="2"];
|
||||
ahriman_core_log -> ahriman_models_repository_paths [fillcolor="blue",minlen="2"];
|
||||
ahriman_core_log -> ahriman_web_middlewares_request_id_handler [fillcolor="blue",minlen="3"];
|
||||
ahriman_core_log_http_log_handler -> ahriman_core_log_log_loader [fillcolor="#914730",weight="3"];
|
||||
ahriman_core_log_lazy_logging -> ahriman_core_log [fillcolor="#b85a3d",weight="3"];
|
||||
ahriman_core_log_log_loader -> ahriman_application_handlers_handler [fillcolor="#82402b",minlen="3"];
|
||||
ahriman_core_log_lazy_logging -> ahriman_core_log [fillcolor="blue",weight="3"];
|
||||
ahriman_core_log_log_context -> ahriman_core_log_lazy_logging [fillcolor="#db582f",weight="3"];
|
||||
ahriman_core_log_log_context -> ahriman_core_log_log_loader [fillcolor="#db582f",weight="3"];
|
||||
ahriman_core_log_log_context -> ahriman_web_middlewares_request_id_handler [fillcolor="#db582f",minlen="3"];
|
||||
ahriman_core_log_log_loader -> ahriman_application_handlers_handler [fillcolor="#7a3c28",minlen="3"];
|
||||
ahriman_core_module_loader -> ahriman_application_ahriman [fillcolor="#ce5e3b",minlen="2"];
|
||||
ahriman_core_module_loader -> ahriman_web_routes [fillcolor="#ce5e3b",minlen="2"];
|
||||
ahriman_core_report_console -> ahriman_core_report_report [fillcolor="blue",weight="3"];
|
||||
@@ -1779,12 +1786,13 @@ digraph G {
|
||||
ahriman_web_keys -> ahriman_web_apispec_info [fillcolor="#823017",minlen="2",weight="2"];
|
||||
ahriman_web_keys -> ahriman_web_views_base [fillcolor="#823017",minlen="2",weight="2"];
|
||||
ahriman_web_keys -> ahriman_web_web [fillcolor="#823017",weight="2"];
|
||||
ahriman_web_middlewares -> ahriman_web_views_v1_status_metrics [fillcolor="#e9410c",minlen="2",weight="2"];
|
||||
ahriman_web_middlewares -> ahriman_web_web [fillcolor="#e9410c",weight="2"];
|
||||
ahriman_web_middlewares -> ahriman_web_views_v1_status_metrics [fillcolor="#ef3e06",minlen="2",weight="2"];
|
||||
ahriman_web_middlewares -> ahriman_web_web [fillcolor="#ef3e06",weight="2"];
|
||||
ahriman_web_middlewares_auth_handler -> ahriman_web_web [fillcolor="#733826",minlen="2",weight="2"];
|
||||
ahriman_web_middlewares_exception_handler -> ahriman_web_web [fillcolor="#994b33",minlen="2",weight="2"];
|
||||
ahriman_web_middlewares_metrics_handler -> ahriman_web_views_v1_status_metrics [fillcolor="#a34628",minlen="2",weight="2"];
|
||||
ahriman_web_middlewares_metrics_handler -> ahriman_web_web [fillcolor="#a34628",minlen="2",weight="2"];
|
||||
ahriman_web_middlewares_request_id_handler -> ahriman_web_web [fillcolor="#8a442e",minlen="2",weight="2"];
|
||||
ahriman_web_routes -> ahriman_web_web [fillcolor="#8a442e",weight="2"];
|
||||
ahriman_web_schemas -> ahriman_web_apispec_decorators [fillcolor="blue",minlen="2",weight="2"];
|
||||
ahriman_web_schemas -> ahriman_web_views_v1_auditlog_events [fillcolor="blue",minlen="2",weight="2"];
|
||||
@@ -1939,6 +1947,7 @@ digraph G {
|
||||
aiohttp -> ahriman_web_middlewares_auth_handler [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_middlewares_exception_handler [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_middlewares_metrics_handler [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_middlewares_request_id_handler [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_routes [fillcolor="#f9b506",minlen="2"];
|
||||
aiohttp -> ahriman_web_views_api_swagger [fillcolor="#f9b506",minlen="3"];
|
||||
aiohttp -> ahriman_web_views_base [fillcolor="#f9b506",minlen="3"];
|
||||
|
||||
@@ -12,6 +12,14 @@ ahriman.application.handlers.add module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.archives module
|
||||
--------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.application.handlers.archives
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.backup module
|
||||
------------------------------------------
|
||||
|
||||
@@ -76,6 +84,14 @@ ahriman.application.handlers.help module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.hold module
|
||||
----------------------------------------
|
||||
|
||||
.. automodule:: ahriman.application.handlers.hold
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.key\_import module
|
||||
-----------------------------------------------
|
||||
|
||||
@@ -92,6 +108,14 @@ ahriman.application.handlers.patch module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.pkgbuild module
|
||||
--------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.application.handlers.pkgbuild
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.rebuild module
|
||||
-------------------------------------------
|
||||
|
||||
@@ -140,6 +164,14 @@ ahriman.application.handlers.restore module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.rollback module
|
||||
--------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.application.handlers.rollback
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.application.handlers.run module
|
||||
---------------------------------------
|
||||
|
||||
|
||||
@@ -28,6 +28,14 @@ ahriman.core.alpm.pacman\_database module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.alpm.pacman\_handle module
|
||||
---------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.alpm.pacman_handle
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.alpm.pkgbuild\_parser module
|
||||
-----------------------------------------
|
||||
|
||||
|
||||
@@ -140,6 +140,22 @@ ahriman.core.database.migrations.m016\_archive module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.database.migrations.m017\_pkgbuild module
|
||||
------------------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.database.migrations.m017_pkgbuild
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.database.migrations.m018\_package\_hold module
|
||||
-----------------------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.database.migrations.m018_package_hold
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
|
||||
@@ -76,6 +76,14 @@ ahriman.core.formatters.patch\_printer module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.formatters.pkgbuild\_printer module
|
||||
------------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.formatters.pkgbuild_printer
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.formatters.printer module
|
||||
--------------------------------------
|
||||
|
||||
|
||||
@@ -28,6 +28,14 @@ ahriman.core.log.lazy\_logging module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.log.log\_context module
|
||||
------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.log.log_context
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.log.log\_loader module
|
||||
-----------------------------------
|
||||
|
||||
|
||||
@@ -12,6 +12,14 @@ ahriman.web.middlewares.auth\_handler module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.middlewares.etag\_handler module
|
||||
--------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.middlewares.etag_handler
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.middlewares.exception\_handler module
|
||||
-------------------------------------------------
|
||||
|
||||
@@ -28,6 +36,14 @@ ahriman.web.middlewares.metrics\_handler module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.middlewares.request\_id\_handler module
|
||||
---------------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.middlewares.request_id_handler
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
|
||||
@@ -116,6 +116,14 @@ ahriman.web.schemas.file\_schema module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.hold\_schema module
|
||||
---------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.schemas.hold_schema
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.info\_schema module
|
||||
---------------------------------------
|
||||
|
||||
@@ -244,6 +252,14 @@ ahriman.web.schemas.package\_version\_schema module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.packager\_schema module
|
||||
-------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.schemas.packager_schema
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.pagination\_schema module
|
||||
---------------------------------------------
|
||||
|
||||
@@ -324,6 +340,14 @@ ahriman.web.schemas.repository\_stats\_schema module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.rollback\_schema module
|
||||
-------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.schemas.rollback_schema
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.schemas.search\_schema module
|
||||
-----------------------------------------
|
||||
|
||||
|
||||
@@ -4,6 +4,14 @@ ahriman.web.views.v1.packages package
|
||||
Submodules
|
||||
----------
|
||||
|
||||
ahriman.web.views.v1.packages.archives module
|
||||
---------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.views.v1.packages.archives
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.views.v1.packages.changes module
|
||||
--------------------------------------------
|
||||
|
||||
@@ -20,6 +28,14 @@ ahriman.web.views.v1.packages.dependencies module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.views.v1.packages.hold module
|
||||
-----------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.views.v1.packages.hold
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.views.v1.packages.logs module
|
||||
-----------------------------------------
|
||||
|
||||
|
||||
@@ -68,6 +68,14 @@ ahriman.web.views.v1.service.request module
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.views.v1.service.rollback module
|
||||
--------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.web.views.v1.service.rollback
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.web.views.v1.service.search module
|
||||
------------------------------------------
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ Packages have strict rules of importing:
|
||||
* ``ahriman.application`` package must not be used outside of this package.
|
||||
* ``ahriman.core`` and ``ahriman.models`` packages don't have any import restriction. Actually we would like to totally restrict importing of ``core`` package from ``models``, but it is impossible at the moment.
|
||||
* ``ahriman.web`` package is allowed to be imported from ``ahriman.application`` (web handler only, only ``ahriman.web.web`` methods).
|
||||
* The idea remains the same for all imports, if an package requires some specific dependencies, it must be imported locally to keep dependencies optional.
|
||||
|
||||
The idea remains the same for all imports, if a package requires some specific dependencies, it must be imported locally to keep dependencies optional.
|
||||
|
||||
Full dependency diagram:
|
||||
|
||||
@@ -42,7 +43,7 @@ This package contains everything required for the most of application actions an
|
||||
* ``ahriman.core.gitremote`` is a package with remote PKGBUILD triggers. Should not be called directly.
|
||||
* ``ahriman.core.housekeeping`` package provides few triggers for removing old data.
|
||||
* ``ahriman.core.http`` package provides HTTP clients which can be used later by other classes.
|
||||
* ``ahriman.core.log`` is a log utils package. It includes logger loader class, custom HTTP based logger and some wrappers.
|
||||
* ``ahriman.core.log`` is a log utils package. It includes logger loader class, custom HTTP based logger, log context for injecting context variables into log records and some wrappers.
|
||||
* ``ahriman.core.report`` is a package with reporting triggers. Should not be called directly.
|
||||
* ``ahriman.core.repository`` contains several traits and base repository (``ahriman.core.repository.Repository`` class) implementation.
|
||||
* ``ahriman.core.sign`` package provides sign feature (only gpg calls are available).
|
||||
@@ -85,6 +86,7 @@ Application run
|
||||
#. Call ``Handler.execute`` method.
|
||||
#. Define list of architectures to run. In case if there is more than one architecture specified run several subprocesses or continue in current process otherwise. Class attribute ``ALLOW_MULTI_ARCHITECTURE_RUN`` controls whether the application can be run in multiple processes or not - this feature is required for some handlers (e.g. ``Config``, which utilizes stdout to print messages).
|
||||
#. In each child process call lock functions.
|
||||
#. Load configuration and install logging.
|
||||
#. After success checks pass control to ``Handler.run`` method defined by specific handler class.
|
||||
#. Return result (success or failure) of each subprocess and exit from application.
|
||||
#. Some handlers may override their status and throw ``ExitCode`` exception. This exception is just silently suppressed and changes application exit code to ``1``.
|
||||
@@ -159,12 +161,12 @@ Having default root as ``/var/lib/ahriman`` (differs from container though), the
|
||||
├── aur.files -> aur.files.tar.gz
|
||||
└── aur.files.tar.gz
|
||||
|
||||
There are multiple subdirectories, some of them are commons for any repository, but some of them are not.
|
||||
There are multiple subdirectories, some of them are common for any repository, but some of them are not.
|
||||
|
||||
* ``archive`` is the package archive directory. It is common for all repositories and architectures and contains two subdirectories:
|
||||
|
||||
* ``archive/packages/{first_letter}/{package_base}`` stores the actual built package files and their signatures.
|
||||
* ``archive/repos/{YYYY}/{MM}/{DD}/{repository}/{architecture}`` contains daily repository snapshots. Each snapshot is a repository database with symlinks pointing to the corresponding packages in the ``archive/packages`` tree.
|
||||
* ``archive/repos/{YYYY}/{MM}/{DD}/{repository}/{architecture}`` contains daily repository snapshots. Each snapshot is a repository database with symlinks pointing to the corresponding packages in the ``archive/packages`` tree. These directories only appear if ``ahriman.core.archive.ArchiveTrigger`` is enabled.
|
||||
|
||||
The archive also allows the build process to skip rebuilding a package if a matching version already exists.
|
||||
|
||||
@@ -233,15 +235,27 @@ Remove packages
|
||||
|
||||
This flow removes package from filesystem, updates repository database and also runs synchronization and reporting methods.
|
||||
|
||||
Rollback packages
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
This flow restores a package to a previously built version:
|
||||
|
||||
#. Load the current package definition from the repository database.
|
||||
#. Replace its version with the requested rollback target.
|
||||
#. Search the archive directory for built artifacts (packages and signatures) matching the target version.
|
||||
#. Add the found artifacts to the repository via the same path as ``package-add`` with ``PackageSource.Archive``.
|
||||
#. Trigger an immediate update to process the added packages.
|
||||
#. If ``--hold`` is enabled (the default), mark the package as held in the database to prevent automatic updates from overriding the rollback.
|
||||
|
||||
Check outdated packages
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
There are few ways for packages to be marked as out-of-date and hence requiring rebuild. Those are following:
|
||||
|
||||
#. User requested update of the package. It can be caused by calling ``package-add`` subcommand (or ``package-update`` with arguments).
|
||||
#. The most common way for packages to be marked as out-of-dated is that the version in AUR (or the official repositories) is newer than in the repository.
|
||||
#. The most common way for packages to be marked as out-of-date is that the version in AUR (or the official repositories) is newer than in the repository.
|
||||
#. In addition to the above, if package is named as VCS (e.g. has suffix ``-git``) and the last update was more than specified threshold ago, the service will also try to fetch sources and check if the revision is newer than the built one.
|
||||
#. In addition, there is ability to check if the dependencies of the package have been updated (e.g. if linked library has been renamed or the modules directory - e.g. in case of python and ruby packages - has been changed). And if so, the package will be marked as out-of-dated as well.
|
||||
#. In addition, there is ability to check if the dependencies of the package have been updated (e.g. if linked library has been renamed or the modules directory - e.g. in case of python and ruby packages - has been changed). And if so, the package will be marked as out-of-date as well.
|
||||
|
||||
Update packages
|
||||
^^^^^^^^^^^^^^^
|
||||
@@ -255,6 +269,7 @@ This feature is divided into the following stages: check AUR for updates and run
|
||||
|
||||
#. Download package data from AUR.
|
||||
#. Bump ``pkgrel`` if there is duplicate version in the local repository (see explanation below).
|
||||
#. Check if there is already built package of the same version in archive (cross-repository support). If so, then just copy built archives and skip steps below.
|
||||
#. Build every package in clean chroot.
|
||||
#. Sign packages if required.
|
||||
#. Add packages to database and sign database if required.
|
||||
@@ -313,7 +328,7 @@ Having the initial dependencies tree, the application is looking for packages wh
|
||||
|
||||
Those paths are also filtered by regular expressions set in the configuration.
|
||||
|
||||
All those implicit dependencies are stored in the database and extracted on each check. In case if any of the repository packages doesn't contain any entry anymore (e.g. so version has been changed or modules directory has been changed), the dependent package will be marked as out-of-dated.
|
||||
All those implicit dependencies are stored in the database and extracted on each check. In case if any of the repository packages doesn't contain any entry anymore (e.g. so version has been changed or modules directory has been changed), the dependent package will be marked as out-of-date.
|
||||
|
||||
Core functions reference
|
||||
------------------------
|
||||
@@ -344,6 +359,8 @@ The ``_Context`` class itself mimics default collection interface (as is ``Mappi
|
||||
|
||||
In order to provide statically typed interface, the ``ahriman.models.context_key.ContextKey`` class is used for both ``_Content.get`` and ``_Content.set`` methods; the context instance itself, however, does not store information about types.
|
||||
|
||||
Logging module has its own context variables, which are required to be registered in advance to avoid possible race conditions.
|
||||
|
||||
Submodules
|
||||
^^^^^^^^^^
|
||||
|
||||
@@ -370,7 +387,7 @@ Passwords must be stored in database as ``hash(password + salt)``, where ``passw
|
||||
|
||||
means that there is user ``username`` with ``read`` access and password ``password`` hashed by ``sha512`` with salt ``salt``.
|
||||
|
||||
OAuth provider uses library definitions (``aioauth-client``) in order *authenticate* users. It still requires user permission to be set in database, thus it inherits mapping provider without any changes. Whereas we could override ``check_credentials`` (authentication method) by something custom, OAuth flow is a bit more complex than just forward request, thus we have to implement the flow in login form.
|
||||
OAuth provider uses library definitions (``aioauth-client``) in order to *authenticate* users. It still requires user permission to be set in database, thus it inherits mapping provider without any changes. Whereas we could override ``check_credentials`` (authentication method) by something custom, OAuth flow is a bit more complex than just forward request, thus we have to implement the flow in login form.
|
||||
|
||||
OAuth's implementation also allows authenticating users via username + password (in the same way as mapping does) though it is not recommended for end-users and password must be left blank. In particular this feature can be used by service reporting (aka robots).
|
||||
|
||||
@@ -383,7 +400,7 @@ Triggers
|
||||
|
||||
Triggers are extensions which can be used in order to perform any actions on application start, after the update process and, finally, before the application exit.
|
||||
|
||||
The main idea is to load classes by their full path (e.g. ``ahriman.core.upload.UploadTrigger``) by using ``importlib``: get the last part of the import and treat it as class name, join remain part by ``.`` and interpret as module path, import module and extract attribute from it.
|
||||
The main idea is to load classes by their full path (e.g. ``ahriman.core.upload.UploadTrigger``) by using ``importlib``: get the last part of the import and treat it as class name, join the remaining part by ``.`` and interpret as module path, import module and extract attribute from it.
|
||||
|
||||
The loaded triggers will be called with ``ahriman.models.result.Result`` and ``list[Packages]`` arguments, which describes the process result and current repository packages respectively. Any exception raised will be suppressed and will generate an exception message in logs.
|
||||
|
||||
@@ -407,7 +424,7 @@ PKGBUILD parsing
|
||||
|
||||
The application provides a house-made shell parser ``ahriman.core.alpm.pkgbuild_parser.PkgbuildParser`` to process PKGBUILDs and extract package data from them. It relies on the ``shlex.shlex`` parser with some configuration tweaks and adds some token post-processing.
|
||||
|
||||
#. During the parser process, firstly, it extract next token from the source file (basically, the word) and tries to match it to the variable assignment. If so, then just processes accordingly.
|
||||
#. During the parser process, firstly, it extracts the next token from the source file (basically, the word) and tries to match it to the variable assignment. If so, then just processes accordingly.
|
||||
#. If it is not an assignment, the parser checks if the token was quoted.
|
||||
#. If it wasn't quoted then the parser tries to match the array starts (two consecutive tokens like ``array=`` and ``(``) or it is function (``function``, ``()`` and ``{``).
|
||||
#. The arrays are processed until the next closing bracket ``)``. After extraction, the parser tries to expand an array according to bash rules (``prefix{first,second}suffix`` constructions).
|
||||
@@ -420,6 +437,15 @@ The PKGBUILD class also provides some additional functions on top of that:
|
||||
* Ability to extract fields defined inside ``package*()`` functions, which are in particular used for the multi-packages.
|
||||
* Shell substitution, which supports constructions ``$var`` (including ``${var}``), ``${var#(#)pattern}``, ``${var%(%)pattern}`` and ``${var/(/)pattern/replacement}`` (including ``#pattern`` and ``%pattern``).
|
||||
|
||||
HTTP client
|
||||
^^^^^^^^^^^
|
||||
|
||||
The ``ahriman.core.http`` package provides a HTTP client built on top of the ``requests`` library.
|
||||
|
||||
The base class ``ahriman.core.http.SyncHttpClient`` wraps ``requests.Session`` and provides common features for all HTTP interactions: configurable timeouts, retry policies with exponential backoff (using ``urllib3.util.retry.Retry``), basic authentication, custom User-Agent header, error processing, and ``make_request`` method. The session is lazily created (via ``cached_property``).
|
||||
|
||||
On top of that, ``ahriman.core.http.SyncAhrimanClient`` extends the base client for communication with the ahriman web service specifically. It adds automatic login on session creation (using configured credentials), ``X-Request-ID`` header injection and Unix socket transport support (via ``requests-unixsocket2``) if required.
|
||||
|
||||
Additional features
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -445,7 +471,7 @@ Web application requires the following python packages to be installed:
|
||||
Middlewares
|
||||
^^^^^^^^^^^
|
||||
|
||||
Service provides some custom middlewares, e.g. logging every exception (except for user ones) and user authorization.
|
||||
Service provides some custom middlewares, e.g. logging every exception (except for user ones), user authorization and request tracing via ``X-Request-ID`` header.
|
||||
|
||||
HEAD and OPTIONS requests
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -457,7 +483,7 @@ On the other side, ``OPTIONS`` method is implemented in the ``ahriman.web.middle
|
||||
Web views
|
||||
^^^^^^^^^
|
||||
|
||||
All web views are defined in separated package and derived from ``ahriman.web.views.base.Base`` class which provides typed interfaces for web application.
|
||||
All web views are defined in a separate package and derived from ``ahriman.web.views.base.Base`` class which provides typed interfaces for web application.
|
||||
|
||||
REST API supports only JSON data.
|
||||
|
||||
@@ -476,7 +502,7 @@ The views are also divided by supporting API versions (e.g. ``v1``, ``v2``).
|
||||
Templating
|
||||
^^^^^^^^^^
|
||||
|
||||
Package provides base jinja templates which can be overridden by settings. Vanilla templates actively use bootstrap library.
|
||||
Package provides base jinja templates which can be overridden by settings. The default web interface is a React application. The classic bootstrap-based template is still available as ``build-status-classic.jinja2`` and can be enabled via the ``web.template`` configuration option.
|
||||
|
||||
Requests and scopes
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -180,6 +180,10 @@ Web server settings. This feature requires ``aiohttp`` libraries to be installed
|
||||
|
||||
* ``address`` - optional address in form ``proto://host:port`` (``port`` can be omitted in case of default ``proto`` ports), will be used instead of ``http://{host}:{port}`` in case if set, string, optional. This option is required in case if ``OAuth`` provider is used.
|
||||
* ``autorefresh_intervals`` - enable page auto refresh options, space separated list of integers, optional. The first defined interval will be used as default. If no intervals set, the auto refresh buttons will be disabled. If first element of the list equals ``0``, auto refresh will be disabled by default.
|
||||
* ``cors_allow_headers`` - allowed CORS headers, space separated list of strings, optional.
|
||||
* ``cors_allow_methods`` - allowed CORS methods, space separated list of strings, optional.
|
||||
* ``cors_allow_origins`` - allowed CORS origins, space separated list of strings, optional, default ``*``.
|
||||
* ``cors_expose_headers`` - exposed CORS headers, space separated list of strings, optional.
|
||||
* ``enable_archive_upload`` - allow to upload packages via HTTP (i.e. call of ``/api/v1/service/upload`` uri), boolean, optional, default ``no``.
|
||||
* ``host`` - host to bind, string, optional.
|
||||
* ``index_url`` - full URL of the repository index page, string, optional.
|
||||
|
||||
@@ -33,3 +33,28 @@ The service provides several commands aim to do easy repository backup and resto
|
||||
.. code-block:: shell
|
||||
|
||||
sudo -u ahriman ahriman repo-rebuild --from-database
|
||||
|
||||
Package rollback
|
||||
================
|
||||
|
||||
If the ``archive.keep_built_packages`` option is enabled, the service keeps previously built package files in the archive directory. These archives can be used to rollback a package to a previous successfully built version.
|
||||
|
||||
#.
|
||||
List available archive versions for a package:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
ahriman package-archives ahriman
|
||||
|
||||
#.
|
||||
Rollback the package to the desired version:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
sudo -u ahriman ahriman package-rollback ahriman 2.19.0-1
|
||||
|
||||
By default, the ``--hold`` flag is enabled, which prevents the package from being automatically updated on subsequent ``repo-update`` runs. To rollback without holding the package use:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
sudo -u ahriman ahriman package-rollback ahriman 2.19.0-1 --no-hold
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import js from "@eslint/js";
|
||||
import stylistic from "@stylistic/eslint-plugin";
|
||||
import react from "eslint-plugin-react";
|
||||
import reactHooks from "eslint-plugin-react-hooks";
|
||||
import reactRefresh from "eslint-plugin-react-refresh";
|
||||
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
||||
@@ -8,7 +9,11 @@ import tseslint from "typescript-eslint";
|
||||
export default tseslint.config(
|
||||
{ ignores: ["dist"] },
|
||||
{
|
||||
extends: [js.configs.recommended, ...tseslint.configs.recommendedTypeChecked],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
react.configs.flat.recommended,
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
],
|
||||
files: ["src/**/*.{ts,tsx}"],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
@@ -17,31 +22,37 @@ export default tseslint.config(
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
"@stylistic": stylistic,
|
||||
"react-hooks": reactHooks,
|
||||
"react-refresh": reactRefresh,
|
||||
"simple-import-sort": simpleImportSort,
|
||||
"@stylistic": stylistic,
|
||||
},
|
||||
rules: {
|
||||
...reactHooks.configs.recommended.rules,
|
||||
"react/react-in-jsx-scope": "off",
|
||||
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
|
||||
|
||||
// imports
|
||||
"simple-import-sort/imports": "error",
|
||||
"simple-import-sort/exports": "error",
|
||||
"simple-import-sort/imports": "error",
|
||||
|
||||
// brackets
|
||||
// core
|
||||
"curly": "error",
|
||||
"@stylistic/brace-style": ["error", "1tbs"],
|
||||
"eqeqeq": "error",
|
||||
"no-console": ["warn", { allow: ["warn", "error"] }],
|
||||
"no-eval": "error",
|
||||
|
||||
// stylistic
|
||||
"@stylistic/array-bracket-spacing": ["error", "never"],
|
||||
"@stylistic/arrow-parens": ["error", "as-needed"],
|
||||
"@stylistic/brace-style": ["error", "1tbs"],
|
||||
"@stylistic/comma-dangle": ["error", "always-multiline"],
|
||||
"@stylistic/comma-spacing": ["error", { before: false, after: true }],
|
||||
"@stylistic/eol-last": ["error", "always"],
|
||||
"@stylistic/indent": ["error", 4],
|
||||
"@stylistic/jsx-curly-brace-presence": ["error", { props: "never", children: "never" }],
|
||||
"@stylistic/jsx-quotes": ["error", "prefer-double"],
|
||||
"@stylistic/jsx-self-closing-comp": ["error", { component: true, html: true }],
|
||||
"@stylistic/max-len": ["error", {
|
||||
code: 120,
|
||||
ignoreComments: true,
|
||||
@@ -49,6 +60,7 @@ export default tseslint.config(
|
||||
ignoreTemplateLiterals: true,
|
||||
ignoreUrls: true,
|
||||
}],
|
||||
"@stylistic/member-delimiter-style": ["error", { multiline: { delimiter: "semi" }, singleline: { delimiter: "semi" } }],
|
||||
"@stylistic/no-extra-parens": ["error", "all"],
|
||||
"@stylistic/no-multi-spaces": "error",
|
||||
"@stylistic/no-multiple-empty-lines": ["error", { max: 1 }],
|
||||
@@ -58,10 +70,15 @@ export default tseslint.config(
|
||||
"@stylistic/semi": ["error", "always"],
|
||||
|
||||
// typescript
|
||||
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
||||
"@typescript-eslint/consistent-type-imports": ["error", { prefer: "type-imports" }],
|
||||
"@typescript-eslint/explicit-function-return-type": ["error", { allowExpressions: true }],
|
||||
"@typescript-eslint/no-deprecated": "error",
|
||||
"@typescript-eslint/no-floating-promises": "error",
|
||||
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
|
||||
"@typescript-eslint/prefer-nullish-coalescing": "error",
|
||||
"@typescript-eslint/prefer-optional-chain": "error",
|
||||
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,8 +1,36 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@emotion/react": ">=11.14.0 <11.15.0",
|
||||
"@emotion/styled": ">=11.14.0 <11.15.0",
|
||||
"@mui/icons-material": ">=7.3.0 <7.4.0",
|
||||
"@mui/material": ">=7.3.0 <7.4.0",
|
||||
"@mui/x-data-grid": ">=8.28.0 <8.29.0",
|
||||
"@tanstack/react-query": ">=5.94.0 <5.95.0",
|
||||
"chart.js": ">=4.5.0 <4.6.0",
|
||||
"react": ">=19.2.0 <19.3.0",
|
||||
"react-chartjs-2": ">=5.3.0 <5.4.0",
|
||||
"react-dom": ">=19.2.0 <19.3.0",
|
||||
"react-error-boundary": ">=6.1.0 <6.2.0",
|
||||
"react-syntax-highlighter": ">=16.1.0 <16.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": ">=9.39.0 <9.40.0",
|
||||
"@stylistic/eslint-plugin": ">=5.10.0 <5.11.0",
|
||||
"@types/react": ">=19.2.0 <19.3.0",
|
||||
"@types/react-dom": ">=19.2.0 <19.3.0",
|
||||
"@types/react-syntax-highlighter": ">=15.5.0 <15.6.0",
|
||||
"@vitejs/plugin-react": ">=6.0.0 <6.1.0",
|
||||
"eslint": ">=9.39.0 <9.40.0",
|
||||
"eslint-plugin-react": ">=7.37.0 <7.38.0",
|
||||
"eslint-plugin-react-hooks": ">=7.0.0 <7.1.0",
|
||||
"eslint-plugin-react-refresh": ">=0.5.0 <0.6.0",
|
||||
"eslint-plugin-simple-import-sort": ">=12.1.0 <12.2.0",
|
||||
"typescript": ">=5.9.0 <5.10.0",
|
||||
"typescript-eslint": ">=8.57.0 <8.58.0",
|
||||
"vite": ">=8.0.0 <8.1.0"
|
||||
},
|
||||
"name": "ahriman-frontend",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "2.20.0-rc4",
|
||||
"scripts": {
|
||||
"build": "tsc && vite build",
|
||||
"dev": "vite",
|
||||
@@ -10,33 +38,6 @@
|
||||
"lint:fix": "eslint --fix src/",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.11.0",
|
||||
"@emotion/styled": "^11.11.0",
|
||||
"@mui/icons-material": "^7.3.8",
|
||||
"@mui/material": "^7.3.8",
|
||||
"@mui/x-data-grid": "^8.27.3",
|
||||
"@tanstack/react-query": "^5.0.0",
|
||||
"chart.js": "^4.5.0",
|
||||
"react": "^19.2.4",
|
||||
"react-chartjs-2": "^5.2.0",
|
||||
"react-dom": "^19.2.4",
|
||||
"react-syntax-highlighter": "^16.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.3",
|
||||
"@stylistic/eslint-plugin": "^5.9.0",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@types/react-syntax-highlighter": "^15.5.13",
|
||||
"@vitejs/plugin-react": "^5.0.0",
|
||||
"eslint": "^9.39.3",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.2",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"typescript": "^5.3.0",
|
||||
"typescript-eslint": "^8.56.1",
|
||||
"vite": "^7.3.1",
|
||||
"vite-tsconfig-paths": "^6.1.1"
|
||||
}
|
||||
"type": "module",
|
||||
"version": "2.20.0"
|
||||
}
|
||||
|
||||
@@ -17,30 +17,27 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import CssBaseline from "@mui/material/CssBaseline";
|
||||
import { ThemeProvider } from "@mui/material/styles";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import AppLayout from "components/layout/AppLayout";
|
||||
import { AuthProvider } from "contexts/AuthProvider";
|
||||
import { ClientProvider } from "contexts/ClientProvider";
|
||||
import { NotificationProvider } from "contexts/NotificationProvider";
|
||||
import { RepositoryProvider } from "contexts/RepositoryProvider";
|
||||
import { ThemeProvider } from "contexts/ThemeProvider";
|
||||
import type React from "react";
|
||||
import Theme from "theme/Theme";
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
staleTime: 30_000,
|
||||
retry: 1,
|
||||
staleTime: 30_000,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default function App(): React.JSX.Element {
|
||||
return <QueryClientProvider client={queryClient}>
|
||||
<ThemeProvider theme={Theme}>
|
||||
<CssBaseline />
|
||||
<ThemeProvider>
|
||||
<NotificationProvider>
|
||||
<ClientProvider>
|
||||
<AuthProvider>
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
export class ApiError extends Error {
|
||||
|
||||
body: string;
|
||||
status: number;
|
||||
statusText: string;
|
||||
body: string;
|
||||
|
||||
constructor(status: number, statusText: string, body: string) {
|
||||
super(`${status} ${statusText}`);
|
||||
|
||||
@@ -40,6 +40,7 @@ export class Client {
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
Accept: "application/json",
|
||||
"X-Request-ID": crypto.randomUUID?.() ?? Date.now().toString(),
|
||||
};
|
||||
if (json !== undefined) {
|
||||
headers["Content-Type"] = "application/json";
|
||||
@@ -49,7 +50,7 @@ export class Client {
|
||||
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
||||
|
||||
const requestInit: RequestInit = {
|
||||
method: method || (json ? "POST" : "GET"),
|
||||
method: method ?? (json ? "POST" : "GET"),
|
||||
headers,
|
||||
signal: controller.signal,
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@ import type { Event } from "models/Event";
|
||||
import type { InfoResponse } from "models/InfoResponse";
|
||||
import type { InternalStatus } from "models/InternalStatus";
|
||||
import type { LogRecord } from "models/LogRecord";
|
||||
import type { Package } from "models/Package";
|
||||
import type { PackageStatus } from "models/PackageStatus";
|
||||
import type { Patch } from "models/Patch";
|
||||
import { RepositoryId } from "models/RepositoryId";
|
||||
@@ -42,6 +43,12 @@ export class FetchClient {
|
||||
});
|
||||
}
|
||||
|
||||
async fetchPackageArtifacts(packageBase: string, repository: RepositoryId): Promise<Package[]> {
|
||||
return this.client.request<Package[]>(`/api/v1/packages/${encodeURIComponent(packageBase)}/archives`, {
|
||||
query: repository.toQuery(),
|
||||
});
|
||||
}
|
||||
|
||||
async fetchPackageChanges(packageBase: string, repository: RepositoryId): Promise<Changes> {
|
||||
return this.client.request<Changes>(`/api/v1/packages/${encodeURIComponent(packageBase)}/changes`, {
|
||||
query: repository.toQuery(),
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
export interface RequestOptions {
|
||||
json?: unknown;
|
||||
method?: string;
|
||||
query?: Record<string, string | number | boolean>;
|
||||
json?: unknown;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import type { PackageActionRequest } from "models/PackageActionRequest";
|
||||
import type { PGPKey } from "models/PGPKey";
|
||||
import type { PGPKeyRequest } from "models/PGPKeyRequest";
|
||||
import type { RepositoryId } from "models/RepositoryId";
|
||||
import type { RollbackRequest } from "models/RollbackRequest";
|
||||
|
||||
export class ServiceClient {
|
||||
|
||||
@@ -36,6 +37,14 @@ export class ServiceClient {
|
||||
return this.client.request("/api/v1/service/add", { method: "POST", query: repository.toQuery(), json: data });
|
||||
}
|
||||
|
||||
async servicePackageHold(packageBase: string, repository: RepositoryId, isHeld: boolean): Promise<void> {
|
||||
return this.client.request(`/api/v1/packages/${encodeURIComponent(packageBase)}/hold`, {
|
||||
method: "POST",
|
||||
query: repository.toQuery(),
|
||||
json: { is_held: isHeld },
|
||||
});
|
||||
}
|
||||
|
||||
async servicePackagePatchRemove(packageBase: string, key: string): Promise<void> {
|
||||
return this.client.request(`/api/v1/packages/${encodeURIComponent(packageBase)}/patches/${encodeURIComponent(key)}`, {
|
||||
method: "DELETE",
|
||||
@@ -58,6 +67,14 @@ export class ServiceClient {
|
||||
});
|
||||
}
|
||||
|
||||
async servicePackageRollback(repository: RepositoryId, data: RollbackRequest): Promise<void> {
|
||||
return this.client.request("/api/v1/service/rollback", {
|
||||
method: "POST",
|
||||
query: repository.toQuery(),
|
||||
json: data,
|
||||
});
|
||||
}
|
||||
|
||||
async servicePackageSearch(query: string): Promise<AURPackage[]> {
|
||||
return this.client.request<AURPackage[]>("/api/v1/service/search", { query: { for: query } });
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { blue } from "@mui/material/colors";
|
||||
import type { Event } from "models/Event";
|
||||
import type React from "react";
|
||||
import { Line } from "react-chartjs-2";
|
||||
@@ -31,9 +32,11 @@ export default function EventDurationLineChart({ events }: EventDurationLineChar
|
||||
labels: updateEvents.map(event => new Date(event.created * 1000).toISOStringShort()),
|
||||
datasets: [
|
||||
{
|
||||
label: "update duration, s",
|
||||
data: updateEvents.map(event => event.data?.took ?? 0),
|
||||
backgroundColor: blue[200],
|
||||
borderColor: blue[500],
|
||||
cubicInterpolationMode: "monotone" as const,
|
||||
data: updateEvents.map(event => event.data?.took ?? 0),
|
||||
label: "update duration, s",
|
||||
tension: 0.4,
|
||||
},
|
||||
],
|
||||
|
||||
@@ -29,26 +29,26 @@ interface PackageCountBarChartProps {
|
||||
export default function PackageCountBarChart({ stats }: PackageCountBarChartProps): React.JSX.Element {
|
||||
return <Bar
|
||||
data={{
|
||||
labels: ["packages"],
|
||||
datasets: [
|
||||
{
|
||||
label: "archives",
|
||||
data: [stats.packages ?? 0],
|
||||
backgroundColor: blue[500],
|
||||
backgroundColor: indigo[300],
|
||||
data: [stats.bases ?? 0],
|
||||
label: "bases",
|
||||
},
|
||||
{
|
||||
label: "bases",
|
||||
data: [stats.bases ?? 0],
|
||||
backgroundColor: indigo[300],
|
||||
backgroundColor: blue[500],
|
||||
data: [stats.packages ?? 0],
|
||||
label: "archives",
|
||||
},
|
||||
],
|
||||
labels: ["packages"],
|
||||
}}
|
||||
options={{
|
||||
maintainAspectRatio: false,
|
||||
responsive: true,
|
||||
scales: {
|
||||
x: { stacked: true },
|
||||
y: { stacked: true },
|
||||
y: { stacked: false },
|
||||
},
|
||||
}}
|
||||
/>;
|
||||
|
||||
@@ -30,14 +30,14 @@ interface StatusPieChartProps {
|
||||
export default function StatusPieChart({ counters }: StatusPieChartProps): React.JSX.Element {
|
||||
const labels = ["unknown", "pending", "building", "failed", "success"] as BuildStatus[];
|
||||
const data = {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: "packages in status",
|
||||
data: labels.map(label => counters[label]),
|
||||
backgroundColor: labels.map(label => StatusColors[label]),
|
||||
data: labels.map(label => counters[label]),
|
||||
label: "packages in status",
|
||||
},
|
||||
],
|
||||
labels: labels,
|
||||
};
|
||||
|
||||
return <Pie data={data} options={{ responsive: true }} />;
|
||||
|
||||
@@ -25,14 +25,14 @@ import type { AutoRefreshInterval } from "models/AutoRefreshInterval";
|
||||
import React, { useState } from "react";
|
||||
|
||||
interface AutoRefreshControlProps {
|
||||
intervals: AutoRefreshInterval[];
|
||||
currentInterval: number;
|
||||
intervals: AutoRefreshInterval[];
|
||||
onIntervalChange: (interval: number) => void;
|
||||
}
|
||||
|
||||
export default function AutoRefreshControl({
|
||||
intervals,
|
||||
currentInterval,
|
||||
intervals,
|
||||
onIntervalChange,
|
||||
}: AutoRefreshControlProps): React.JSX.Element | null {
|
||||
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
||||
@@ -46,24 +46,25 @@ export default function AutoRefreshControl({
|
||||
return <>
|
||||
<Tooltip title="Auto-refresh">
|
||||
<IconButton
|
||||
size="small"
|
||||
onClick={event => setAnchorEl(event.currentTarget)}
|
||||
aria-label="Auto-refresh"
|
||||
color={enabled ? "primary" : "default"}
|
||||
onClick={event => setAnchorEl(event.currentTarget)}
|
||||
size="small"
|
||||
>
|
||||
{enabled ? <TimerIcon fontSize="small" /> : <TimerOffIcon fontSize="small" />}
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Menu
|
||||
anchorEl={anchorEl}
|
||||
open={Boolean(anchorEl)}
|
||||
onClose={() => setAnchorEl(null)}
|
||||
open={Boolean(anchorEl)}
|
||||
>
|
||||
<MenuItem
|
||||
selected={!enabled}
|
||||
onClick={() => {
|
||||
onIntervalChange(0);
|
||||
setAnchorEl(null);
|
||||
}}
|
||||
selected={!enabled}
|
||||
>
|
||||
<ListItemIcon>
|
||||
{!enabled && <CheckIcon fontSize="small" />}
|
||||
@@ -73,11 +74,11 @@ export default function AutoRefreshControl({
|
||||
{intervals.map(interval =>
|
||||
<MenuItem
|
||||
key={interval.interval}
|
||||
selected={enabled && interval.interval === currentInterval}
|
||||
onClick={() => {
|
||||
onIntervalChange(interval.interval);
|
||||
setAnchorEl(null);
|
||||
}}
|
||||
selected={enabled && interval.interval === currentInterval}
|
||||
>
|
||||
<ListItemIcon>
|
||||
{enabled && interval.interval === currentInterval && <CheckIcon fontSize="small" />}
|
||||
|
||||
@@ -17,47 +17,54 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { Box } from "@mui/material";
|
||||
import "components/common/syntaxLanguages";
|
||||
|
||||
import { Box, useTheme } from "@mui/material";
|
||||
import CopyButton from "components/common/CopyButton";
|
||||
import { useThemeMode } from "hooks/useThemeMode";
|
||||
import React, { type RefObject } from "react";
|
||||
import { Light as SyntaxHighlighter } from "react-syntax-highlighter";
|
||||
import { githubGist, vs2015 } from "react-syntax-highlighter/dist/esm/styles/hljs";
|
||||
|
||||
interface CodeBlockProps {
|
||||
preRef?: RefObject<HTMLElement | null>;
|
||||
getText: () => string;
|
||||
content: string;
|
||||
height?: number | string;
|
||||
language?: string;
|
||||
onScroll?: () => void;
|
||||
wordBreak?: boolean;
|
||||
preRef?: RefObject<HTMLElement | null>;
|
||||
}
|
||||
|
||||
export default function CodeBlock({
|
||||
preRef,
|
||||
getText,
|
||||
content,
|
||||
height,
|
||||
language = "text",
|
||||
onScroll,
|
||||
wordBreak,
|
||||
preRef,
|
||||
}: CodeBlockProps): React.JSX.Element {
|
||||
const { mode } = useThemeMode();
|
||||
const theme = useTheme();
|
||||
|
||||
return <Box sx={{ position: "relative" }}>
|
||||
<Box
|
||||
ref={preRef}
|
||||
component="pre"
|
||||
onScroll={onScroll}
|
||||
sx={{
|
||||
backgroundColor: "grey.100",
|
||||
p: 2,
|
||||
borderRadius: 1,
|
||||
overflow: "auto",
|
||||
height,
|
||||
fontSize: "0.8rem",
|
||||
fontFamily: "monospace",
|
||||
...wordBreak ? { whiteSpace: "pre-wrap", wordBreak: "break-all" } : {},
|
||||
}}
|
||||
ref={preRef}
|
||||
sx={{ overflow: "auto", height }}
|
||||
>
|
||||
<code>
|
||||
{getText()}
|
||||
</code>
|
||||
</Box>
|
||||
<Box sx={{ position: "absolute", top: 8, right: 8 }}>
|
||||
<CopyButton getText={getText} />
|
||||
<SyntaxHighlighter
|
||||
customStyle={{
|
||||
borderRadius: `${theme.shape.borderRadius}px`,
|
||||
fontSize: "0.8rem",
|
||||
padding: theme.spacing(2),
|
||||
}}
|
||||
language={language}
|
||||
style={mode === "dark" ? vs2015 : githubGist}
|
||||
wrapLongLines
|
||||
>
|
||||
{content}
|
||||
</SyntaxHighlighter>
|
||||
</Box>
|
||||
{content && <Box sx={{ position: "absolute", right: 8, top: 8 }}>
|
||||
<CopyButton text={content} />
|
||||
</Box>}
|
||||
</Box>;
|
||||
}
|
||||
|
||||
@@ -23,24 +23,24 @@ import { IconButton, Tooltip } from "@mui/material";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
|
||||
interface CopyButtonProps {
|
||||
getText: () => string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
export default function CopyButton({ getText }: CopyButtonProps): React.JSX.Element {
|
||||
export default function CopyButton({ text }: CopyButtonProps): React.JSX.Element {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const timer = useRef<ReturnType<typeof setTimeout>>(undefined);
|
||||
|
||||
useEffect(() => () => clearTimeout(timer.current), []);
|
||||
|
||||
const handleCopy: () => Promise<void> = async () => {
|
||||
await navigator.clipboard.writeText(getText());
|
||||
await navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
clearTimeout(timer.current);
|
||||
timer.current = setTimeout(() => setCopied(false), 2000);
|
||||
};
|
||||
|
||||
return <Tooltip title={copied ? "Copied!" : "Copy"}>
|
||||
<IconButton size="small" aria-label={copied ? "Copied" : "Copy"} onClick={() => void handleCopy()}>
|
||||
<IconButton aria-label={copied ? "Copied" : "Copy"} onClick={() => void handleCopy()} size="small">
|
||||
{copied ? <CheckIcon fontSize="small" /> : <ContentCopyIcon fontSize="small" />}
|
||||
</IconButton>
|
||||
</Tooltip>;
|
||||
|
||||
@@ -28,7 +28,7 @@ interface DialogHeaderProps {
|
||||
}
|
||||
|
||||
export default function DialogHeader({ children, onClose, sx }: DialogHeaderProps): React.JSX.Element {
|
||||
return <DialogTitle sx={{ display: "flex", alignItems: "center", justifyContent: "space-between", ...sx }}>
|
||||
return <DialogTitle sx={{ alignItems: "center", display: "flex", justifyContent: "space-between", ...sx }}>
|
||||
{children}
|
||||
<IconButton aria-label="Close" onClick={onClose} size="small" sx={{ color: "inherit" }}>
|
||||
<CloseIcon />
|
||||
|
||||
55
frontend/src/components/common/ErrorBoundary.tsx
Normal file
55
frontend/src/components/common/ErrorBoundary.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { Box, Button, Typography } from "@mui/material";
|
||||
import type React from "react";
|
||||
import type { FallbackProps } from "react-error-boundary";
|
||||
|
||||
interface ErrorDetails {
|
||||
message: string;
|
||||
stack: string | undefined;
|
||||
}
|
||||
|
||||
export default function ErrorFallback({ error }: FallbackProps): React.JSX.Element {
|
||||
|
||||
const details: ErrorDetails = error instanceof Error
|
||||
? { message: error.message, stack: error.stack }
|
||||
: { message: String(error), stack: undefined };
|
||||
|
||||
return <Box role="alert" sx={{ color: "text.primary", minHeight: "100vh", p: 6 }}>
|
||||
<Typography sx={{ fontWeight: 700 }} variant="h4">
|
||||
Something went wrong
|
||||
</Typography>
|
||||
|
||||
<Typography color="error" sx={{ fontFamily: "monospace", mt: 2 }}>
|
||||
{details.message}
|
||||
</Typography>
|
||||
|
||||
{details.stack && <Typography
|
||||
component="pre"
|
||||
sx={{ color: "text.secondary", fontFamily: "monospace", fontSize: "0.75rem", mt: 3, whiteSpace: "pre-wrap", wordBreak: "break-word" }}
|
||||
>
|
||||
{details.stack}
|
||||
</Typography>}
|
||||
|
||||
<Box sx={{ display: "flex", gap: 2, mt: 4 }}>
|
||||
<Button onClick={() => window.location.reload()} variant="outlined">Reload page</Button>
|
||||
</Box>
|
||||
</Box>;
|
||||
}
|
||||
@@ -35,12 +35,12 @@ export default function NotificationItem({ notification, onClose }: Notification
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Slide direction="down" in={show} mountOnEnter unmountOnExit onExited={() => onClose(notification.id)}>
|
||||
<Slide direction="down" in={show} mountOnEnter onExited={() => onClose(notification.id)} unmountOnExit>
|
||||
<Alert
|
||||
onClose={() => setShow(false)}
|
||||
severity={notification.severity}
|
||||
variant="filled"
|
||||
sx={{ width: "100%", pointerEvents: "auto" }}
|
||||
variant="filled"
|
||||
>
|
||||
<strong>{notification.title}</strong>
|
||||
{notification.message && ` - ${notification.message}`}
|
||||
|
||||
@@ -25,14 +25,14 @@ import type React from "react";
|
||||
export default function RepositorySelect({
|
||||
repositorySelect,
|
||||
}: { repositorySelect: SelectedRepositoryResult }): React.JSX.Element {
|
||||
const { repositories, current } = useRepository();
|
||||
const { repositories, currentRepository } = useRepository();
|
||||
|
||||
return <FormControl fullWidth margin="normal">
|
||||
<InputLabel>repository</InputLabel>
|
||||
<Select
|
||||
value={repositorySelect.selectedKey || (current?.key ?? "")}
|
||||
label="repository"
|
||||
onChange={event => repositorySelect.setSelectedKey(event.target.value)}
|
||||
value={repositorySelect.selectedKey || (currentRepository?.key ?? "")}
|
||||
>
|
||||
{repositories.map(repository =>
|
||||
<MenuItem key={repository.key} value={repository.key}>
|
||||
|
||||
27
frontend/src/components/common/syntaxLanguages.ts
Normal file
27
frontend/src/components/common/syntaxLanguages.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { Light as SyntaxHighlighter } from "react-syntax-highlighter";
|
||||
import bash from "react-syntax-highlighter/dist/esm/languages/hljs/bash";
|
||||
import diff from "react-syntax-highlighter/dist/esm/languages/hljs/diff";
|
||||
import plaintext from "react-syntax-highlighter/dist/esm/languages/hljs/plaintext";
|
||||
|
||||
SyntaxHighlighter.registerLanguage("bash", bash);
|
||||
SyntaxHighlighter.registerLanguage("diff", diff);
|
||||
SyntaxHighlighter.registerLanguage("text", plaintext);
|
||||
@@ -30,23 +30,23 @@ import type React from "react";
|
||||
import { StatusHeaderStyles } from "theme/StatusColors";
|
||||
|
||||
interface DashboardDialogProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
open: boolean;
|
||||
}
|
||||
|
||||
export default function DashboardDialog({ open, onClose }: DashboardDialogProps): React.JSX.Element {
|
||||
export default function DashboardDialog({ onClose, open }: DashboardDialogProps): React.JSX.Element {
|
||||
const client = useClient();
|
||||
const { current } = useRepository();
|
||||
const { currentRepository } = useRepository();
|
||||
|
||||
const { data: status } = useQuery<InternalStatus>({
|
||||
queryKey: current ? QueryKeys.status(current) : ["status"],
|
||||
queryFn: current ? () => client.fetch.fetchServerStatus(current) : skipToken,
|
||||
enabled: open,
|
||||
queryFn: currentRepository ? () => client.fetch.fetchServerStatus(currentRepository) : skipToken,
|
||||
queryKey: currentRepository ? QueryKeys.status(currentRepository) : ["status"],
|
||||
});
|
||||
|
||||
const headerStyle = status ? StatusHeaderStyles[status.status.status] : {};
|
||||
|
||||
return <Dialog open={open} onClose={onClose} maxWidth="lg" fullWidth>
|
||||
return <Dialog fullWidth maxWidth="lg" onClose={onClose} open={open}>
|
||||
<DialogHeader onClose={onClose} sx={headerStyle}>
|
||||
System health
|
||||
</DialogHeader>
|
||||
@@ -55,43 +55,43 @@ export default function DashboardDialog({ open, onClose }: DashboardDialogProps)
|
||||
{status &&
|
||||
<>
|
||||
<Grid container spacing={2} sx={{ mt: 1 }}>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Typography variant="body2" color="text.secondary" align="right">Repository name</Typography>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Typography align="right" color="text.secondary" variant="body2">Repository name</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Typography variant="body2">{status.repository}</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Typography variant="body2" color="text.secondary" align="right">Repository architecture</Typography>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Typography align="right" color="text.secondary" variant="body2">Repository architecture</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Typography variant="body2">{status.architecture}</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid container spacing={2} sx={{ mt: 1 }}>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Typography variant="body2" color="text.secondary" align="right">Current status</Typography>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Typography align="right" color="text.secondary" variant="body2">Current status</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Typography variant="body2">{status.status.status}</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Typography variant="body2" color="text.secondary" align="right">Updated at</Typography>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Typography align="right" color="text.secondary" variant="body2">Updated at</Typography>
|
||||
</Grid>
|
||||
<Grid size={{ xs: 6, md: 3 }}>
|
||||
<Grid size={{ md: 3, xs: 6 }}>
|
||||
<Typography variant="body2">{new Date(status.status.timestamp * 1000).toISOStringShort()}</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid container spacing={2} sx={{ mt: 2 }}>
|
||||
<Grid size={{ xs: 12, md: 6 }}>
|
||||
<Box sx={{ maxHeight: 300 }}>
|
||||
<Grid size={{ md: 6, xs: 12 }}>
|
||||
<Box sx={{ height: 300 }}>
|
||||
<PackageCountBarChart stats={status.stats} />
|
||||
</Box>
|
||||
</Grid>
|
||||
<Grid size={{ xs: 12, md: 6 }}>
|
||||
<Box sx={{ maxHeight: 300, display: "flex", justifyContent: "center", alignItems: "center" }}>
|
||||
<Grid size={{ md: 6, xs: 12 }}>
|
||||
<Box sx={{ alignItems: "center", display: "flex", height: 300, justifyContent: "center" }}>
|
||||
<StatusPieChart counters={status.packages} />
|
||||
</Box>
|
||||
</Grid>
|
||||
|
||||
@@ -35,11 +35,11 @@ import { useNotification } from "hooks/useNotification";
|
||||
import React, { useState } from "react";
|
||||
|
||||
interface KeyImportDialogProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
open: boolean;
|
||||
}
|
||||
|
||||
export default function KeyImportDialog({ open, onClose }: KeyImportDialogProps): React.JSX.Element {
|
||||
export default function KeyImportDialog({ onClose, open }: KeyImportDialogProps): React.JSX.Element {
|
||||
const client = useClient();
|
||||
const { showSuccess, showError } = useNotification();
|
||||
|
||||
@@ -54,7 +54,7 @@ export default function KeyImportDialog({ open, onClose }: KeyImportDialogProps)
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleFetch: () => Promise<void> = async () => {
|
||||
const handleFetch = async (): Promise<void> => {
|
||||
if (!fingerprint || !server) {
|
||||
return;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ export default function KeyImportDialog({ open, onClose }: KeyImportDialogProps)
|
||||
}
|
||||
};
|
||||
|
||||
const handleImport: () => Promise<void> = async () => {
|
||||
const handleImport = async (): Promise<void> => {
|
||||
if (!fingerprint || !server) {
|
||||
return;
|
||||
}
|
||||
@@ -81,38 +81,38 @@ export default function KeyImportDialog({ open, onClose }: KeyImportDialogProps)
|
||||
}
|
||||
};
|
||||
|
||||
return <Dialog open={open} onClose={handleClose} maxWidth="lg" fullWidth>
|
||||
return <Dialog fullWidth maxWidth="lg" onClose={handleClose} open={open}>
|
||||
<DialogHeader onClose={handleClose}>
|
||||
Import key from PGP server
|
||||
</DialogHeader>
|
||||
|
||||
<DialogContent>
|
||||
<TextField
|
||||
label="fingerprint"
|
||||
placeholder="PGP key fingerprint"
|
||||
fullWidth
|
||||
label="fingerprint"
|
||||
margin="normal"
|
||||
value={fingerprint}
|
||||
onChange={event => setFingerprint(event.target.value)}
|
||||
placeholder="PGP key fingerprint"
|
||||
value={fingerprint}
|
||||
/>
|
||||
<TextField
|
||||
label="key server"
|
||||
placeholder="PGP key server"
|
||||
fullWidth
|
||||
label="key server"
|
||||
margin="normal"
|
||||
value={server}
|
||||
onChange={event => setServer(event.target.value)}
|
||||
placeholder="PGP key server"
|
||||
value={server}
|
||||
/>
|
||||
{keyBody &&
|
||||
<Box sx={{ mt: 2 }}>
|
||||
<CodeBlock getText={() => keyBody} height={300} />
|
||||
<CodeBlock height={300} content={keyBody} />
|
||||
</Box>
|
||||
}
|
||||
</DialogContent>
|
||||
|
||||
<DialogActions>
|
||||
<Button onClick={() => void handleImport()} variant="contained" startIcon={<PlayArrowIcon />}>import</Button>
|
||||
<Button onClick={() => void handleFetch()} variant="contained" color="success" startIcon={<RefreshIcon />}>fetch</Button>
|
||||
<Button onClick={() => void handleImport()} startIcon={<PlayArrowIcon />} variant="contained">import</Button>
|
||||
<Button color="success" onClick={() => void handleFetch()} startIcon={<RefreshIcon />} variant="contained">fetch</Button>
|
||||
</DialogActions>
|
||||
</Dialog>;
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ import { useNotification } from "hooks/useNotification";
|
||||
import React, { useState } from "react";
|
||||
|
||||
interface LoginDialogProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
open: boolean;
|
||||
}
|
||||
|
||||
export default function LoginDialog({ open, onClose }: LoginDialogProps): React.JSX.Element {
|
||||
export default function LoginDialog({ onClose, open }: LoginDialogProps): React.JSX.Element {
|
||||
const [username, setUsername] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
@@ -54,7 +54,7 @@ export default function LoginDialog({ open, onClose }: LoginDialogProps): React.
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleSubmit: () => Promise<void> = async () => {
|
||||
const handleSubmit = async (): Promise<void> => {
|
||||
if (!username || !password) {
|
||||
return;
|
||||
}
|
||||
@@ -72,26 +72,24 @@ export default function LoginDialog({ open, onClose }: LoginDialogProps): React.
|
||||
}
|
||||
};
|
||||
|
||||
return <Dialog open={open} onClose={handleClose} maxWidth="xs" fullWidth>
|
||||
return <Dialog fullWidth maxWidth="xs" onClose={handleClose} open={open}>
|
||||
<DialogHeader onClose={handleClose}>
|
||||
Login
|
||||
</DialogHeader>
|
||||
|
||||
<DialogContent>
|
||||
<TextField
|
||||
label="username"
|
||||
fullWidth
|
||||
margin="normal"
|
||||
value={username}
|
||||
onChange={event => setUsername(event.target.value)}
|
||||
autoFocus
|
||||
fullWidth
|
||||
label="username"
|
||||
margin="normal"
|
||||
onChange={event => setUsername(event.target.value)}
|
||||
value={username}
|
||||
/>
|
||||
<TextField
|
||||
label="password"
|
||||
fullWidth
|
||||
label="password"
|
||||
margin="normal"
|
||||
type={showPassword ? "text" : "password"}
|
||||
value={password}
|
||||
onChange={event => setPassword(event.target.value)}
|
||||
onKeyDown={event => {
|
||||
if (event.key === "Enter") {
|
||||
@@ -102,17 +100,24 @@ export default function LoginDialog({ open, onClose }: LoginDialogProps): React.
|
||||
input: {
|
||||
endAdornment:
|
||||
<InputAdornment position="end">
|
||||
<IconButton aria-label={showPassword ? "Hide password" : "Show password"} onClick={() => setShowPassword(!showPassword)} edge="end" size="small">
|
||||
<IconButton
|
||||
aria-label={showPassword ? "Hide password" : "Show password"}
|
||||
edge="end"
|
||||
onClick={() => setShowPassword(!showPassword)}
|
||||
size="small"
|
||||
>
|
||||
{showPassword ? <VisibilityOffIcon /> : <VisibilityIcon />}
|
||||
</IconButton>
|
||||
</InputAdornment>,
|
||||
},
|
||||
}}
|
||||
type={showPassword ? "text" : "password"}
|
||||
value={password}
|
||||
/>
|
||||
</DialogContent>
|
||||
|
||||
<DialogActions>
|
||||
<Button onClick={() => void handleSubmit()} variant="contained" startIcon={<PersonIcon />}>login</Button>
|
||||
<Button onClick={() => void handleSubmit()} startIcon={<PersonIcon />} variant="contained">login</Button>
|
||||
</DialogActions>
|
||||
</Dialog>;
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ interface EnvironmentVariable {
|
||||
}
|
||||
|
||||
interface PackageAddDialogProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
open: boolean;
|
||||
}
|
||||
|
||||
export default function PackageAddDialog({ open, onClose }: PackageAddDialogProps): React.JSX.Element {
|
||||
export default function PackageAddDialog({ onClose, open }: PackageAddDialogProps): React.JSX.Element {
|
||||
const client = useClient();
|
||||
const { showSuccess, showError } = useNotification();
|
||||
const repositorySelect = useSelectedRepository();
|
||||
@@ -77,9 +77,9 @@ export default function PackageAddDialog({ open, onClose }: PackageAddDialogProp
|
||||
const debouncedSearch = useDebounce(packageName, 500);
|
||||
|
||||
const { data: searchResults = [] } = useQuery<AURPackage[]>({
|
||||
queryKey: QueryKeys.search(debouncedSearch),
|
||||
queryFn: () => client.service.servicePackageSearch(debouncedSearch),
|
||||
enabled: debouncedSearch.length >= 3,
|
||||
queryFn: () => client.service.servicePackageSearch(debouncedSearch),
|
||||
queryKey: QueryKeys.search(debouncedSearch),
|
||||
});
|
||||
|
||||
const handleSubmit = async (action: "add" | "request"): Promise<void> => {
|
||||
@@ -107,7 +107,7 @@ export default function PackageAddDialog({ open, onClose }: PackageAddDialogProp
|
||||
}
|
||||
};
|
||||
|
||||
return <Dialog open={open} onClose={handleClose} maxWidth="md" fullWidth>
|
||||
return <Dialog fullWidth maxWidth="md" onClose={handleClose} open={open}>
|
||||
<DialogHeader onClose={handleClose}>
|
||||
Add new packages
|
||||
</DialogHeader>
|
||||
@@ -117,20 +117,18 @@ export default function PackageAddDialog({ open, onClose }: PackageAddDialogProp
|
||||
|
||||
<Autocomplete
|
||||
freeSolo
|
||||
options={searchResults.map(pkg => pkg.package)}
|
||||
inputValue={packageName}
|
||||
onInputChange={(_, value) => setPackageName(value)}
|
||||
options={searchResults.map(pkg => pkg.package)}
|
||||
renderInput={params =>
|
||||
<TextField {...params} label="package" margin="normal" placeholder="AUR package" />
|
||||
}
|
||||
renderOption={(props, option) => {
|
||||
const pkg = searchResults.find(pkg => pkg.package === option);
|
||||
return (
|
||||
<li {...props} key={option}>
|
||||
return <li {...props} key={option}>
|
||||
{option}{pkg ? ` (${pkg.description})` : ""}
|
||||
</li>
|
||||
);
|
||||
</li>;
|
||||
}}
|
||||
renderInput={params =>
|
||||
<TextField {...params} label="package" placeholder="AUR package" margin="normal" />
|
||||
}
|
||||
/>
|
||||
|
||||
<FormControlLabel
|
||||
@@ -140,45 +138,50 @@ export default function PackageAddDialog({ open, onClose }: PackageAddDialogProp
|
||||
|
||||
<Button
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
startIcon={<AddIcon />}
|
||||
onClick={() => {
|
||||
const id = variableIdCounter.current++;
|
||||
setEnvironmentVariables(prev => [...prev, { id, key: "", value: "" }]);
|
||||
}}
|
||||
startIcon={<AddIcon />}
|
||||
sx={{ mt: 1 }}
|
||||
variant="outlined"
|
||||
>
|
||||
add environment variable
|
||||
</Button>
|
||||
|
||||
{environmentVariables.map(variable =>
|
||||
<Box key={variable.id} sx={{ display: "flex", gap: 1, mt: 1, alignItems: "center" }}>
|
||||
<Box key={variable.id} sx={{ alignItems: "center", display: "flex", gap: 1, mt: 1 }}>
|
||||
<TextField
|
||||
size="small"
|
||||
placeholder="name"
|
||||
value={variable.key}
|
||||
onChange={event => {
|
||||
const newKey = event.target.value;
|
||||
setEnvironmentVariables(prev =>
|
||||
prev.map(entry => entry.id === variable.id ? { ...entry, key: newKey } : entry),
|
||||
);
|
||||
}}
|
||||
placeholder="name"
|
||||
size="small"
|
||||
sx={{ flex: 1 }}
|
||||
value={variable.key}
|
||||
/>
|
||||
<Box>=</Box>
|
||||
<TextField
|
||||
size="small"
|
||||
placeholder="value"
|
||||
value={variable.value}
|
||||
onChange={event => {
|
||||
const newValue = event.target.value;
|
||||
setEnvironmentVariables(prev =>
|
||||
prev.map(entry => entry.id === variable.id ? { ...entry, value: newValue } : entry),
|
||||
);
|
||||
}}
|
||||
size="small"
|
||||
sx={{ flex: 1 }}
|
||||
value={variable.value}
|
||||
/>
|
||||
<IconButton size="small" color="error" aria-label="Remove variable" onClick={() => setEnvironmentVariables(prev => prev.filter(entry => entry.id !== variable.id))}>
|
||||
<IconButton
|
||||
aria-label="Remove variable"
|
||||
color="error"
|
||||
onClick={() => setEnvironmentVariables(prev => prev.filter(entry => entry.id !== variable.id))}
|
||||
size="small"
|
||||
>
|
||||
<DeleteIcon />
|
||||
</IconButton>
|
||||
</Box>,
|
||||
@@ -186,8 +189,8 @@ export default function PackageAddDialog({ open, onClose }: PackageAddDialogProp
|
||||
</DialogContent>
|
||||
|
||||
<DialogActions>
|
||||
<Button onClick={() => void handleSubmit("add")} variant="contained" startIcon={<PlayArrowIcon />}>add</Button>
|
||||
<Button onClick={() => void handleSubmit("request")} variant="contained" color="success" startIcon={<AddIcon />}>request</Button>
|
||||
<Button onClick={() => void handleSubmit("add")} startIcon={<PlayArrowIcon />} variant="contained">add</Button>
|
||||
<Button color="success" onClick={() => void handleSubmit("request")} startIcon={<AddIcon />} variant="contained">request</Button>
|
||||
</DialogActions>
|
||||
</Dialog>;
|
||||
}
|
||||
|
||||
@@ -21,12 +21,15 @@ import { Box, Dialog, DialogContent, Tab, Tabs } from "@mui/material";
|
||||
import { skipToken, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { ApiError } from "api/client/ApiError";
|
||||
import DialogHeader from "components/common/DialogHeader";
|
||||
import ArtifactsTab from "components/package/ArtifactsTab";
|
||||
import BuildLogsTab from "components/package/BuildLogsTab";
|
||||
import ChangesTab from "components/package/ChangesTab";
|
||||
import EventsTab from "components/package/EventsTab";
|
||||
import PackageDetailsGrid from "components/package/PackageDetailsGrid";
|
||||
import PackageInfoActions from "components/package/PackageInfoActions";
|
||||
import PackagePatchesList from "components/package/PackagePatchesList";
|
||||
import PkgbuildTab from "components/package/PkgbuildTab";
|
||||
import { type TabKey, tabs } from "components/package/TabKey";
|
||||
import { QueryKeys } from "hooks/QueryKeys";
|
||||
import { useAuth } from "hooks/useAuth";
|
||||
import { useAutoRefresh } from "hooks/useAutoRefresh";
|
||||
@@ -42,20 +45,20 @@ import { StatusHeaderStyles } from "theme/StatusColors";
|
||||
import { defaultInterval } from "utils";
|
||||
|
||||
interface PackageInfoDialogProps {
|
||||
packageBase: string | null;
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
autoRefreshIntervals: AutoRefreshInterval[];
|
||||
onClose: () => void;
|
||||
open: boolean;
|
||||
packageBase: string | null;
|
||||
}
|
||||
|
||||
export default function PackageInfoDialog({
|
||||
packageBase,
|
||||
open,
|
||||
onClose,
|
||||
autoRefreshIntervals,
|
||||
onClose,
|
||||
open,
|
||||
packageBase,
|
||||
}: PackageInfoDialogProps): React.JSX.Element {
|
||||
const client = useClient();
|
||||
const { current } = useRepository();
|
||||
const { currentRepository } = useRepository();
|
||||
const { isAuthorized } = useAuth();
|
||||
const { showSuccess, showError } = useNotification();
|
||||
const queryClient = useQueryClient();
|
||||
@@ -65,11 +68,11 @@ export default function PackageInfoDialog({
|
||||
setLocalPackageBase(packageBase);
|
||||
}
|
||||
|
||||
const [tabIndex, setTabIndex] = useState(0);
|
||||
const [activeTab, setActiveTab] = useState<TabKey>("logs");
|
||||
const [refreshDatabase, setRefreshDatabase] = useState(true);
|
||||
|
||||
const handleClose = (): void => {
|
||||
setTabIndex(0);
|
||||
setActiveTab("logs");
|
||||
setRefreshDatabase(true);
|
||||
onClose();
|
||||
};
|
||||
@@ -77,48 +80,50 @@ export default function PackageInfoDialog({
|
||||
const autoRefresh = useAutoRefresh("package-info-autoreload-button", defaultInterval(autoRefreshIntervals));
|
||||
|
||||
const { data: packageData } = useQuery<PackageStatus[]>({
|
||||
queryKey: localPackageBase && current ? QueryKeys.package(localPackageBase, current) : ["packages"],
|
||||
queryFn: localPackageBase && current ? () => client.fetch.fetchPackage(localPackageBase, current) : skipToken,
|
||||
enabled: open,
|
||||
queryFn: localPackageBase && currentRepository ?
|
||||
() => client.fetch.fetchPackage(localPackageBase, currentRepository) : skipToken,
|
||||
queryKey: localPackageBase && currentRepository ? QueryKeys.package(localPackageBase, currentRepository) : ["packages"],
|
||||
refetchInterval: autoRefresh.interval > 0 ? autoRefresh.interval : false,
|
||||
});
|
||||
|
||||
const { data: dependencies } = useQuery<Dependencies>({
|
||||
queryKey: localPackageBase && current ? QueryKeys.dependencies(localPackageBase, current) : ["dependencies"],
|
||||
queryFn: localPackageBase && current
|
||||
? () => client.fetch.fetchPackageDependencies(localPackageBase, current) : skipToken,
|
||||
enabled: open,
|
||||
queryFn: localPackageBase && currentRepository ?
|
||||
() => client.fetch.fetchPackageDependencies(localPackageBase, currentRepository) : skipToken,
|
||||
queryKey: localPackageBase && currentRepository ? QueryKeys.dependencies(localPackageBase, currentRepository) : ["dependencies"],
|
||||
});
|
||||
|
||||
const { data: patches = [] } = useQuery<Patch[]>({
|
||||
queryKey: localPackageBase ? QueryKeys.patches(localPackageBase) : ["patches"],
|
||||
queryFn: localPackageBase ? () => client.fetch.fetchPackagePatches(localPackageBase) : skipToken,
|
||||
enabled: open,
|
||||
queryFn: localPackageBase ? () => client.fetch.fetchPackagePatches(localPackageBase) : skipToken,
|
||||
queryKey: localPackageBase ? QueryKeys.patches(localPackageBase) : ["patches"],
|
||||
});
|
||||
|
||||
const description: PackageStatus | undefined = packageData?.[0];
|
||||
const description = packageData?.[0];
|
||||
const pkg = description?.package;
|
||||
const status = description?.status;
|
||||
const headerStyle = status ? StatusHeaderStyles[status.status] : {};
|
||||
|
||||
const handleUpdate: () => Promise<void> = async () => {
|
||||
if (!localPackageBase || !current) {
|
||||
const handleUpdate = async (): Promise<void> => {
|
||||
if (!localPackageBase || !currentRepository) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await client.service.servicePackageAdd(current, { packages: [localPackageBase], refresh: refreshDatabase });
|
||||
await client.service.servicePackageAdd(
|
||||
currentRepository, { packages: [localPackageBase], refresh: refreshDatabase });
|
||||
showSuccess("Success", `Run update for packages ${localPackageBase}`);
|
||||
} catch (exception) {
|
||||
showError("Action failed", `Package update failed: ${ApiError.errorDetail(exception)}`);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemove: () => Promise<void> = async () => {
|
||||
if (!localPackageBase || !current) {
|
||||
const handleRemove = async (): Promise<void> => {
|
||||
if (!localPackageBase || !currentRepository) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await client.service.servicePackageRemove(current, [localPackageBase]);
|
||||
await client.service.servicePackageRemove(currentRepository, [localPackageBase]);
|
||||
showSuccess("Success", `Packages ${localPackageBase} have been removed`);
|
||||
onClose();
|
||||
} catch (exception) {
|
||||
@@ -126,7 +131,20 @@ export default function PackageInfoDialog({
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeletePatch: (key: string) => Promise<void> = async key => {
|
||||
const handleHoldToggle = async (): Promise<void> => {
|
||||
if (!localPackageBase || !currentRepository) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const newHeldStatus = !(status?.is_held ?? false);
|
||||
await client.service.servicePackageHold(localPackageBase, currentRepository, newHeldStatus);
|
||||
void queryClient.invalidateQueries({ queryKey: QueryKeys.package(localPackageBase, currentRepository) });
|
||||
} catch (exception) {
|
||||
showError("Action failed", `Could not update hold status: ${ApiError.errorDetail(exception)}`);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeletePatch = async (key: string): Promise<void> => {
|
||||
if (!localPackageBase) {
|
||||
return;
|
||||
}
|
||||
@@ -138,7 +156,7 @@ export default function PackageInfoDialog({
|
||||
}
|
||||
};
|
||||
|
||||
return <Dialog open={open} onClose={handleClose} maxWidth="lg" fullWidth>
|
||||
return <Dialog fullWidth maxWidth="lg" onClose={handleClose} open={open}>
|
||||
<DialogHeader onClose={handleClose} sx={headerStyle}>
|
||||
{pkg && status
|
||||
? `${pkg.base} ${status.status} at ${new Date(status.timestamp * 1000).toISOStringShort()}`
|
||||
@@ -148,47 +166,57 @@ export default function PackageInfoDialog({
|
||||
<DialogContent>
|
||||
{pkg &&
|
||||
<>
|
||||
<PackageDetailsGrid pkg={pkg} dependencies={dependencies} />
|
||||
<PackageDetailsGrid dependencies={dependencies} pkg={pkg} />
|
||||
<PackagePatchesList
|
||||
patches={patches}
|
||||
editable={isAuthorized}
|
||||
onDelete={key => void handleDeletePatch(key)}
|
||||
patches={patches}
|
||||
/>
|
||||
|
||||
<Box sx={{ borderBottom: 1, borderColor: "divider", mt: 2 }}>
|
||||
<Tabs value={tabIndex} onChange={(_, index: number) => setTabIndex(index)}>
|
||||
<Tab label="Build logs" />
|
||||
<Tab label="Changes" />
|
||||
<Tab label="Events" />
|
||||
<Tabs onChange={(_, tab: TabKey) => setActiveTab(tab)} value={activeTab}>
|
||||
{tabs.map(({ key, label }) => <Tab key={key} label={label} value={key} />)}
|
||||
</Tabs>
|
||||
</Box>
|
||||
|
||||
{tabIndex === 0 && localPackageBase && current &&
|
||||
{activeTab === "logs" && localPackageBase && currentRepository &&
|
||||
<BuildLogsTab
|
||||
packageBase={localPackageBase}
|
||||
repository={current}
|
||||
refreshInterval={autoRefresh.interval}
|
||||
repository={currentRepository}
|
||||
/>
|
||||
}
|
||||
{tabIndex === 1 && localPackageBase && current &&
|
||||
<ChangesTab packageBase={localPackageBase} repository={current} />
|
||||
{activeTab === "changes" && localPackageBase && currentRepository &&
|
||||
<ChangesTab packageBase={localPackageBase} repository={currentRepository} />
|
||||
}
|
||||
{tabIndex === 2 && localPackageBase && current &&
|
||||
<EventsTab packageBase={localPackageBase} repository={current} />
|
||||
{activeTab === "pkgbuild" && localPackageBase && currentRepository &&
|
||||
<PkgbuildTab packageBase={localPackageBase} repository={currentRepository} />
|
||||
}
|
||||
{activeTab === "events" && localPackageBase && currentRepository &&
|
||||
<EventsTab packageBase={localPackageBase} repository={currentRepository} />
|
||||
}
|
||||
{activeTab === "artifacts" && localPackageBase && currentRepository &&
|
||||
<ArtifactsTab
|
||||
currentVersion={pkg.version}
|
||||
packageBase={localPackageBase}
|
||||
repository={currentRepository}
|
||||
/>
|
||||
}
|
||||
</>
|
||||
}
|
||||
</DialogContent>
|
||||
|
||||
<PackageInfoActions
|
||||
isAuthorized={isAuthorized}
|
||||
refreshDatabase={refreshDatabase}
|
||||
onRefreshDatabaseChange={setRefreshDatabase}
|
||||
onUpdate={() => void handleUpdate()}
|
||||
onRemove={() => void handleRemove()}
|
||||
autoRefreshIntervals={autoRefreshIntervals}
|
||||
autoRefreshInterval={autoRefresh.interval}
|
||||
autoRefreshIntervals={autoRefreshIntervals}
|
||||
isAuthorized={isAuthorized}
|
||||
isHeld={status?.is_held ?? false}
|
||||
onAutoRefreshIntervalChange={autoRefresh.setInterval}
|
||||
onHoldToggle={() => void handleHoldToggle()}
|
||||
onRefreshDatabaseChange={setRefreshDatabase}
|
||||
onRemove={() => void handleRemove()}
|
||||
onUpdate={() => void handleUpdate()}
|
||||
refreshDatabase={refreshDatabase}
|
||||
/>
|
||||
</Dialog>;
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ import { useSelectedRepository } from "hooks/useSelectedRepository";
|
||||
import React, { useState } from "react";
|
||||
|
||||
interface PackageRebuildDialogProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
open: boolean;
|
||||
}
|
||||
|
||||
export default function PackageRebuildDialog({ open, onClose }: PackageRebuildDialogProps): React.JSX.Element {
|
||||
export default function PackageRebuildDialog({ onClose, open }: PackageRebuildDialogProps): React.JSX.Element {
|
||||
const client = useClient();
|
||||
const { showSuccess, showError } = useNotification();
|
||||
const repositorySelect = useSelectedRepository();
|
||||
@@ -45,7 +45,7 @@ export default function PackageRebuildDialog({ open, onClose }: PackageRebuildDi
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleRebuild: () => Promise<void> = async () => {
|
||||
const handleRebuild = async (): Promise<void> => {
|
||||
if (!dependency) {
|
||||
return;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ export default function PackageRebuildDialog({ open, onClose }: PackageRebuildDi
|
||||
}
|
||||
};
|
||||
|
||||
return <Dialog open={open} onClose={handleClose} maxWidth="md" fullWidth>
|
||||
return <Dialog fullWidth maxWidth="md" onClose={handleClose} open={open}>
|
||||
<DialogHeader onClose={handleClose}>
|
||||
Rebuild depending packages
|
||||
</DialogHeader>
|
||||
@@ -72,17 +72,17 @@ export default function PackageRebuildDialog({ open, onClose }: PackageRebuildDi
|
||||
<RepositorySelect repositorySelect={repositorySelect} />
|
||||
|
||||
<TextField
|
||||
label="dependency"
|
||||
placeholder="packages dependency"
|
||||
fullWidth
|
||||
label="dependency"
|
||||
margin="normal"
|
||||
value={dependency}
|
||||
placeholder="packages dependency"
|
||||
onChange={event => setDependency(event.target.value)}
|
||||
value={dependency}
|
||||
/>
|
||||
</DialogContent>
|
||||
|
||||
<DialogActions>
|
||||
<Button onClick={() => void handleRebuild()} variant="contained" startIcon={<PlayArrowIcon />}>rebuild</Button>
|
||||
<Button onClick={() => void handleRebuild()} startIcon={<PlayArrowIcon />} variant="contained">rebuild</Button>
|
||||
</DialogActions>
|
||||
</Dialog>;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { Box, Container } from "@mui/material";
|
||||
import Brightness4Icon from "@mui/icons-material/Brightness4";
|
||||
import Brightness7Icon from "@mui/icons-material/Brightness7";
|
||||
import { Box, Container, IconButton, Tooltip } from "@mui/material";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import LoginDialog from "components/dialogs/LoginDialog";
|
||||
import Footer from "components/layout/Footer";
|
||||
@@ -27,6 +29,7 @@ import { QueryKeys } from "hooks/QueryKeys";
|
||||
import { useAuth } from "hooks/useAuth";
|
||||
import { useClient } from "hooks/useClient";
|
||||
import { useRepository } from "hooks/useRepository";
|
||||
import { useThemeMode } from "hooks/useThemeMode";
|
||||
import type { InfoResponse } from "models/InfoResponse";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
@@ -34,11 +37,12 @@ export default function AppLayout(): React.JSX.Element {
|
||||
const client = useClient();
|
||||
const { setAuthState } = useAuth();
|
||||
const { setRepositories } = useRepository();
|
||||
const { mode, toggleTheme } = useThemeMode();
|
||||
const [loginOpen, setLoginOpen] = useState(false);
|
||||
|
||||
const { data: info } = useQuery<InfoResponse>({
|
||||
queryKey: QueryKeys.info,
|
||||
queryFn: () => client.fetch.fetchServerInfo(),
|
||||
queryKey: QueryKeys.info,
|
||||
staleTime: Infinity,
|
||||
});
|
||||
|
||||
@@ -51,26 +55,29 @@ export default function AppLayout(): React.JSX.Element {
|
||||
}, [info, setAuthState, setRepositories]);
|
||||
|
||||
return <Container maxWidth="xl">
|
||||
<Box sx={{ display: "flex", alignItems: "center", py: 1, gap: 1 }}>
|
||||
<a href="https://github.com/arcan1s/ahriman" title="logo">
|
||||
<img src="/static/logo.svg" width={30} height={30} alt="" />
|
||||
<Box sx={{ alignItems: "center", display: "flex", gap: 1, py: 1 }}>
|
||||
<a href="https://ahriman.readthedocs.io/" title="logo">
|
||||
<img alt="" height={30} src="/static/logo.svg" width={30} />
|
||||
</a>
|
||||
<Box sx={{ flex: 1 }}>
|
||||
<Navbar />
|
||||
</Box>
|
||||
<Tooltip title="Toggle theme">
|
||||
<IconButton aria-label="Toggle theme" onClick={toggleTheme}>
|
||||
{mode === "dark" ? <Brightness7Icon /> : <Brightness4Icon />}
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
|
||||
<PackageTable
|
||||
autoRefreshIntervals={info?.autorefresh_intervals ?? []}
|
||||
/>
|
||||
<PackageTable autoRefreshIntervals={info?.autorefresh_intervals ?? []} />
|
||||
|
||||
<Footer
|
||||
version={info?.version ?? ""}
|
||||
docsEnabled={info?.docs_enabled ?? false}
|
||||
indexUrl={info?.index_url}
|
||||
onLoginClick={() => info?.auth.external ? window.location.assign("/api/v1/login") : setLoginOpen(true)}
|
||||
version={info?.version ?? ""}
|
||||
/>
|
||||
|
||||
<LoginDialog open={loginOpen} onClose={() => setLoginOpen(false)} />
|
||||
<LoginDialog onClose={() => setLoginOpen(false)} open={loginOpen} />
|
||||
</Container>;
|
||||
}
|
||||
|
||||
@@ -26,41 +26,41 @@ import { useAuth } from "hooks/useAuth";
|
||||
import type React from "react";
|
||||
|
||||
interface FooterProps {
|
||||
version: string;
|
||||
docsEnabled: boolean;
|
||||
indexUrl?: string;
|
||||
onLoginClick: () => void;
|
||||
version: string;
|
||||
}
|
||||
|
||||
export default function Footer({ version, docsEnabled, indexUrl, onLoginClick }: FooterProps): React.JSX.Element {
|
||||
export default function Footer({ docsEnabled, indexUrl, onLoginClick, version }: FooterProps): React.JSX.Element {
|
||||
const { enabled: authEnabled, username, logout } = useAuth();
|
||||
|
||||
return <Box
|
||||
component="footer"
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
borderColor: "divider",
|
||||
borderTop: 1,
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
borderTop: 1,
|
||||
borderColor: "divider",
|
||||
mt: 2,
|
||||
py: 1,
|
||||
}}
|
||||
>
|
||||
<Box sx={{ display: "flex", gap: 2, alignItems: "center" }}>
|
||||
<Link href="https://github.com/arcan1s/ahriman" underline="hover" color="inherit" sx={{ display: "flex", alignItems: "center", gap: 0.5 }}>
|
||||
<Box sx={{ alignItems: "center", display: "flex", gap: 2 }}>
|
||||
<Link color="inherit" href="https://github.com/arcan1s/ahriman" sx={{ alignItems: "center", display: "flex", gap: 0.5 }} underline="hover">
|
||||
<GitHubIcon fontSize="small" />
|
||||
<Typography variant="body2">ahriman {version}</Typography>
|
||||
</Link>
|
||||
<Link href="https://github.com/arcan1s/ahriman/releases" underline="hover" color="text.secondary" variant="body2">
|
||||
<Link color="text.secondary" href="https://github.com/arcan1s/ahriman/releases" underline="hover" variant="body2">
|
||||
releases
|
||||
</Link>
|
||||
<Link href="https://github.com/arcan1s/ahriman/issues" underline="hover" color="text.secondary" variant="body2">
|
||||
<Link color="text.secondary" href="https://github.com/arcan1s/ahriman/issues" underline="hover" variant="body2">
|
||||
report a bug
|
||||
</Link>
|
||||
{docsEnabled &&
|
||||
<Link href="/api-docs" underline="hover" color="text.secondary" variant="body2">
|
||||
<Link color="text.secondary" href="/api-docs" underline="hover" variant="body2">
|
||||
api
|
||||
</Link>
|
||||
}
|
||||
@@ -68,7 +68,7 @@ export default function Footer({ version, docsEnabled, indexUrl, onLoginClick }:
|
||||
|
||||
{indexUrl &&
|
||||
<Box>
|
||||
<Link href={indexUrl} underline="hover" color="inherit" sx={{ display: "flex", alignItems: "center", gap: 0.5 }}>
|
||||
<Link color="inherit" href={indexUrl} underline="hover" sx={{ alignItems: "center", display: "flex", gap: 0.5 }}>
|
||||
<HomeIcon fontSize="small" />
|
||||
<Typography variant="body2">repo index</Typography>
|
||||
</Link>
|
||||
@@ -78,11 +78,11 @@ export default function Footer({ version, docsEnabled, indexUrl, onLoginClick }:
|
||||
{authEnabled &&
|
||||
<Box>
|
||||
{username ?
|
||||
<Button size="small" startIcon={<LogoutIcon />} onClick={() => void logout()} sx={{ textTransform: "none" }}>
|
||||
<Button onClick={() => void logout()} size="small" startIcon={<LogoutIcon />} sx={{ textTransform: "none" }}>
|
||||
logout ({username})
|
||||
</Button>
|
||||
:
|
||||
<Button size="small" startIcon={<LoginIcon />} onClick={onLoginClick} sx={{ textTransform: "none" }}>
|
||||
<Button onClick={onLoginClick} size="small" startIcon={<LoginIcon />} sx={{ textTransform: "none" }}>
|
||||
login
|
||||
</Button>
|
||||
}
|
||||
|
||||
@@ -22,27 +22,28 @@ import { useRepository } from "hooks/useRepository";
|
||||
import type React from "react";
|
||||
|
||||
export default function Navbar(): React.JSX.Element | null {
|
||||
const { repositories, current, setCurrent } = useRepository();
|
||||
const { repositories, currentRepository, setCurrentRepository } = useRepository();
|
||||
|
||||
if (repositories.length === 0 || !current) {
|
||||
if (repositories.length === 0 || !currentRepository) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const currentIndex = repositories.findIndex(repository =>
|
||||
repository.architecture === current.architecture && repository.repository === current.repository,
|
||||
repository.architecture === currentRepository.architecture &&
|
||||
repository.repository === currentRepository.repository,
|
||||
);
|
||||
|
||||
return <Box sx={{ borderBottom: 1, borderColor: "divider" }}>
|
||||
<Tabs
|
||||
value={currentIndex >= 0 ? currentIndex : 0}
|
||||
onChange={(_, newValue: number) => {
|
||||
const repository = repositories[newValue];
|
||||
if (repository) {
|
||||
setCurrent(repository);
|
||||
setCurrentRepository(repository);
|
||||
}
|
||||
}}
|
||||
variant="scrollable"
|
||||
scrollButtons="auto"
|
||||
value={currentIndex >= 0 ? currentIndex : 0}
|
||||
variant="scrollable"
|
||||
>
|
||||
{repositories.map(repository =>
|
||||
<Tab
|
||||
|
||||
119
frontend/src/components/package/ArtifactsTab.tsx
Normal file
119
frontend/src/components/package/ArtifactsTab.tsx
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import RestoreIcon from "@mui/icons-material/Restore";
|
||||
import { Box, IconButton, Tooltip } from "@mui/material";
|
||||
import { DataGrid, type GridColDef } from "@mui/x-data-grid";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { ApiError } from "api/client/ApiError";
|
||||
import { QueryKeys } from "hooks/QueryKeys";
|
||||
import { useAuth } from "hooks/useAuth";
|
||||
import { useClient } from "hooks/useClient";
|
||||
import { useNotification } from "hooks/useNotification";
|
||||
import type { RepositoryId } from "models/RepositoryId";
|
||||
import type React from "react";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { DETAIL_TABLE_PROPS } from "utils";
|
||||
|
||||
interface ArtifactsTabProps {
|
||||
currentVersion: string;
|
||||
packageBase: string;
|
||||
repository: RepositoryId;
|
||||
}
|
||||
|
||||
interface ArtifactRow {
|
||||
id: string;
|
||||
packager: string;
|
||||
packages: string[];
|
||||
version: string;
|
||||
}
|
||||
|
||||
const staticColumns: GridColDef<ArtifactRow>[] = [
|
||||
{ align: "right", field: "version", flex: 1, headerAlign: "right", headerName: "version" },
|
||||
{
|
||||
field: "packages",
|
||||
flex: 2,
|
||||
headerName: "packages",
|
||||
renderCell: params =>
|
||||
<Box sx={{ whiteSpace: "pre-line" }}>{params.row.packages.join("\n")}</Box>,
|
||||
},
|
||||
{ field: "packager", flex: 1, headerName: "packager" },
|
||||
];
|
||||
|
||||
export default function ArtifactsTab({
|
||||
currentVersion,
|
||||
packageBase,
|
||||
repository,
|
||||
}: ArtifactsTabProps): React.JSX.Element {
|
||||
const client = useClient();
|
||||
const queryClient = useQueryClient();
|
||||
const { isAuthorized } = useAuth();
|
||||
const { showSuccess, showError } = useNotification();
|
||||
|
||||
const { data: rows = [] } = useQuery<ArtifactRow[]>({
|
||||
enabled: !!packageBase,
|
||||
queryFn: async () => {
|
||||
const packages = await client.fetch.fetchPackageArtifacts(packageBase, repository);
|
||||
return packages.map(artifact => ({
|
||||
id: artifact.version,
|
||||
packager: artifact.packager ?? "",
|
||||
packages: Object.keys(artifact.packages).sort(),
|
||||
version: artifact.version,
|
||||
})).reverse();
|
||||
},
|
||||
queryKey: QueryKeys.artifacts(packageBase, repository),
|
||||
});
|
||||
|
||||
const handleRollback = useCallback(async (version: string): Promise<void> => {
|
||||
try {
|
||||
await client.service.servicePackageRollback(repository, { package: packageBase, version });
|
||||
void queryClient.invalidateQueries({ queryKey: QueryKeys.artifacts(packageBase, repository) });
|
||||
void queryClient.invalidateQueries({ queryKey: QueryKeys.package(packageBase, repository) });
|
||||
showSuccess("Success", `Rollback ${packageBase} to ${version} has been started`);
|
||||
} catch (exception) {
|
||||
showError("Action failed", `Rollback failed: ${ApiError.errorDetail(exception)}`);
|
||||
}
|
||||
}, [client, repository, packageBase, queryClient, showSuccess, showError]);
|
||||
|
||||
const columns = useMemo<GridColDef<ArtifactRow>[]>(() => [
|
||||
...staticColumns,
|
||||
...isAuthorized ? [{
|
||||
field: "actions",
|
||||
filterable: false,
|
||||
headerName: "",
|
||||
renderCell: params =>
|
||||
<Tooltip title={params.row.version === currentVersion ? "Current version" : "Rollback to this version"}>
|
||||
<span>
|
||||
<IconButton
|
||||
disabled={params.row.version === currentVersion}
|
||||
onClick={() => void handleRollback(params.row.version)}
|
||||
size="small"
|
||||
>
|
||||
<RestoreIcon fontSize="small" />
|
||||
</IconButton>
|
||||
</span>
|
||||
</Tooltip>,
|
||||
width: 60,
|
||||
} satisfies GridColDef<ArtifactRow>] : [],
|
||||
], [isAuthorized, currentVersion, handleRollback]);
|
||||
|
||||
return <Box sx={{ mt: 1 }}>
|
||||
<DataGrid columns={columns} getRowHeight={() => "auto"} rows={rows} {...DETAIL_TABLE_PROPS} />
|
||||
</Box>;
|
||||
}
|
||||
@@ -29,16 +29,16 @@ import type { RepositoryId } from "models/RepositoryId";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
|
||||
interface Logs {
|
||||
version: string;
|
||||
processId: string;
|
||||
created: number;
|
||||
logs: string;
|
||||
processId: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
interface BuildLogsTabProps {
|
||||
packageBase: string;
|
||||
repository: RepositoryId;
|
||||
refreshInterval: number;
|
||||
repository: RepositoryId;
|
||||
}
|
||||
|
||||
function convertLogs(records: LogRecord[], filter?: (record: LogRecord) => boolean): string {
|
||||
@@ -50,17 +50,17 @@ function convertLogs(records: LogRecord[], filter?: (record: LogRecord) => boole
|
||||
|
||||
export default function BuildLogsTab({
|
||||
packageBase,
|
||||
repository,
|
||||
refreshInterval,
|
||||
repository,
|
||||
}: BuildLogsTabProps): React.JSX.Element {
|
||||
const client = useClient();
|
||||
const [selectedVersionKey, setSelectedVersionKey] = useState<string | null>(null);
|
||||
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
||||
|
||||
const { data: allLogs } = useQuery<LogRecord[]>({
|
||||
queryKey: QueryKeys.logs(packageBase, repository),
|
||||
queryFn: () => client.fetch.fetchPackageLogs(packageBase, repository),
|
||||
enabled: !!packageBase,
|
||||
queryFn: () => client.fetch.fetchPackageLogs(packageBase, repository),
|
||||
queryKey: QueryKeys.logs(packageBase, repository),
|
||||
refetchInterval: refreshInterval > 0 ? refreshInterval : false,
|
||||
});
|
||||
|
||||
@@ -84,13 +84,13 @@ export default function BuildLogsTab({
|
||||
return Object.values(grouped)
|
||||
.sort((left, right) => right.minCreated - left.minCreated)
|
||||
.map(record => ({
|
||||
version: record.version,
|
||||
processId: record.process_id,
|
||||
created: record.minCreated,
|
||||
logs: convertLogs(
|
||||
allLogs,
|
||||
right => record.version === right.version && record.process_id === right.process_id,
|
||||
),
|
||||
processId: record.process_id,
|
||||
version: record.version,
|
||||
}));
|
||||
}, [allLogs]);
|
||||
|
||||
@@ -110,13 +110,13 @@ export default function BuildLogsTab({
|
||||
|
||||
// Refresh active version logs
|
||||
const { data: versionLogs } = useQuery<LogRecord[]>({
|
||||
queryKey: QueryKeys.logsVersion(packageBase, repository, activeVersion?.version ?? "", activeVersion?.processId ?? ""),
|
||||
placeholderData: keepPreviousData,
|
||||
queryFn: activeVersion
|
||||
? () => client.fetch.fetchPackageLogs(
|
||||
packageBase, repository, activeVersion.version, activeVersion.processId,
|
||||
)
|
||||
: skipToken,
|
||||
placeholderData: keepPreviousData,
|
||||
queryKey: QueryKeys.logsVersion(packageBase, repository, activeVersion?.version ?? "", activeVersion?.processId ?? ""),
|
||||
refetchInterval: refreshInterval > 0 ? refreshInterval : false,
|
||||
});
|
||||
|
||||
@@ -143,25 +143,25 @@ export default function BuildLogsTab({
|
||||
return <Box sx={{ display: "flex", gap: 1, mt: 1 }}>
|
||||
<Box>
|
||||
<Button
|
||||
size="small"
|
||||
aria-label="Select version"
|
||||
startIcon={<ListIcon />}
|
||||
onClick={event => setAnchorEl(event.currentTarget)}
|
||||
size="small"
|
||||
startIcon={<ListIcon />}
|
||||
/>
|
||||
<Menu
|
||||
anchorEl={anchorEl}
|
||||
open={Boolean(anchorEl)}
|
||||
onClose={() => setAnchorEl(null)}
|
||||
open={Boolean(anchorEl)}
|
||||
>
|
||||
{versions.map((logs, index) =>
|
||||
<MenuItem
|
||||
key={`${logs.version}-${logs.processId}`}
|
||||
selected={index === activeIndex}
|
||||
onClick={() => {
|
||||
setSelectedVersionKey(`${logs.version}-${logs.processId}`);
|
||||
setAnchorEl(null);
|
||||
resetScroll();
|
||||
}}
|
||||
selected={index === activeIndex}
|
||||
>
|
||||
<Typography variant="body2">{new Date(logs.created * 1000).toISOStringShort()}</Typography>
|
||||
</MenuItem>,
|
||||
@@ -174,11 +174,10 @@ export default function BuildLogsTab({
|
||||
|
||||
<Box sx={{ flex: 1 }}>
|
||||
<CodeBlock
|
||||
preRef={preRef}
|
||||
getText={() => displayedLogs}
|
||||
content={displayedLogs}
|
||||
height={400}
|
||||
onScroll={handleScroll}
|
||||
wordBreak
|
||||
preRef={preRef}
|
||||
/>
|
||||
</Box>
|
||||
</Box>;
|
||||
|
||||
@@ -17,19 +17,10 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { Box } from "@mui/material";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import CopyButton from "components/common/CopyButton";
|
||||
import { QueryKeys } from "hooks/QueryKeys";
|
||||
import { useClient } from "hooks/useClient";
|
||||
import type { Changes } from "models/Changes";
|
||||
import CodeBlock from "components/common/CodeBlock";
|
||||
import { usePackageChanges } from "hooks/usePackageChanges";
|
||||
import type { RepositoryId } from "models/RepositoryId";
|
||||
import React from "react";
|
||||
import { Light as SyntaxHighlighter } from "react-syntax-highlighter";
|
||||
import diff from "react-syntax-highlighter/dist/esm/languages/hljs/diff";
|
||||
import { githubGist } from "react-syntax-highlighter/dist/esm/styles/hljs";
|
||||
|
||||
SyntaxHighlighter.registerLanguage("diff", diff);
|
||||
|
||||
interface ChangesTabProps {
|
||||
packageBase: string;
|
||||
@@ -37,34 +28,7 @@ interface ChangesTabProps {
|
||||
}
|
||||
|
||||
export default function ChangesTab({ packageBase, repository }: ChangesTabProps): React.JSX.Element {
|
||||
const client = useClient();
|
||||
const data = usePackageChanges(packageBase, repository);
|
||||
|
||||
const { data } = useQuery<Changes>({
|
||||
queryKey: QueryKeys.changes(packageBase, repository),
|
||||
queryFn: () => client.fetch.fetchPackageChanges(packageBase, repository),
|
||||
enabled: !!packageBase,
|
||||
});
|
||||
|
||||
const changesText = data?.changes ?? "";
|
||||
|
||||
return <Box sx={{ position: "relative", mt: 1 }}>
|
||||
<SyntaxHighlighter
|
||||
language="diff"
|
||||
style={githubGist}
|
||||
customStyle={{
|
||||
padding: "16px",
|
||||
borderRadius: "4px",
|
||||
overflow: "auto",
|
||||
height: 400,
|
||||
fontSize: "0.8rem",
|
||||
fontFamily: "monospace",
|
||||
margin: 0,
|
||||
}}
|
||||
>
|
||||
{changesText}
|
||||
</SyntaxHighlighter>
|
||||
<Box sx={{ position: "absolute", top: 8, right: 8 }}>
|
||||
<CopyButton getText={() => changesText} />
|
||||
</Box>
|
||||
</Box>;
|
||||
return <CodeBlock content={data?.changes ?? ""} height={400} language="diff" />;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import type { Event } from "models/Event";
|
||||
import type { RepositoryId } from "models/RepositoryId";
|
||||
import type React from "react";
|
||||
import { useMemo } from "react";
|
||||
import { DETAIL_TABLE_PROPS } from "utils";
|
||||
|
||||
interface EventsTabProps {
|
||||
packageBase: string;
|
||||
@@ -34,46 +35,36 @@ interface EventsTabProps {
|
||||
}
|
||||
|
||||
interface EventRow {
|
||||
id: number;
|
||||
timestamp: string;
|
||||
event: string;
|
||||
id: number;
|
||||
message: string;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
const columns: GridColDef<EventRow>[] = [
|
||||
{ field: "timestamp", headerName: "date", width: 180, align: "right", headerAlign: "right" },
|
||||
{ field: "event", headerName: "event", flex: 1 },
|
||||
{ field: "message", headerName: "description", flex: 2 },
|
||||
{ align: "right", field: "timestamp", headerAlign: "right", headerName: "date", width: 180 },
|
||||
{ field: "event", flex: 1, headerName: "event" },
|
||||
{ field: "message", flex: 2, headerName: "description" },
|
||||
];
|
||||
|
||||
export default function EventsTab({ packageBase, repository }: EventsTabProps): React.JSX.Element {
|
||||
const client = useClient();
|
||||
|
||||
const { data: events = [] } = useQuery<Event[]>({
|
||||
queryKey: QueryKeys.events(repository, packageBase),
|
||||
queryFn: () => client.fetch.fetchPackageEvents(repository, packageBase, 30),
|
||||
enabled: !!packageBase,
|
||||
queryFn: () => client.fetch.fetchPackageEvents(repository, packageBase, 30),
|
||||
queryKey: QueryKeys.events(repository, packageBase),
|
||||
});
|
||||
|
||||
const rows = useMemo<EventRow[]>(() => events.map((event, index) => ({
|
||||
id: index,
|
||||
timestamp: new Date(event.created * 1000).toISOStringShort(),
|
||||
event: event.event,
|
||||
id: index,
|
||||
message: event.message ?? "",
|
||||
timestamp: new Date(event.created * 1000).toISOStringShort(),
|
||||
})), [events]);
|
||||
|
||||
return <Box sx={{ mt: 1 }}>
|
||||
<EventDurationLineChart events={events} />
|
||||
<DataGrid
|
||||
rows={rows}
|
||||
columns={columns}
|
||||
density="compact"
|
||||
initialState={{
|
||||
sorting: { sortModel: [{ field: "timestamp", sort: "desc" }] },
|
||||
}}
|
||||
pageSizeOptions={[10, 25]}
|
||||
sx={{ height: 400, mt: 1 }}
|
||||
disableRowSelectionOnClick
|
||||
/>
|
||||
<DataGrid columns={columns} rows={rows} {...DETAIL_TABLE_PROPS} />
|
||||
</Box>;
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ import type { Package } from "models/Package";
|
||||
import React from "react";
|
||||
|
||||
interface PackageDetailsGridProps {
|
||||
pkg: Package;
|
||||
dependencies?: Dependencies;
|
||||
pkg: Package;
|
||||
}
|
||||
|
||||
export default function PackageDetailsGrid({ pkg, dependencies }: PackageDetailsGridProps): React.JSX.Element {
|
||||
export default function PackageDetailsGrid({ dependencies, pkg }: PackageDetailsGridProps): React.JSX.Element {
|
||||
const packagesList = Object.entries(pkg.packages)
|
||||
.map(([name, properties]) => `${name}${properties.description ? ` (${properties.description})` : ""}`);
|
||||
|
||||
@@ -65,50 +65,50 @@ export default function PackageDetailsGrid({ pkg, dependencies }: PackageDetails
|
||||
|
||||
return <>
|
||||
<Grid container spacing={1} sx={{ mt: 1 }}>
|
||||
<Grid size={{ xs: 4, md: 1 }}><Typography variant="body2" color="text.secondary" align="right">packages</Typography></Grid>
|
||||
<Grid size={{ xs: 8, md: 5 }}><Typography variant="body2" sx={{ whiteSpace: "pre-line" }}>{packagesList.unique().join("\n")}</Typography></Grid>
|
||||
<Grid size={{ xs: 4, md: 1 }}><Typography variant="body2" color="text.secondary" align="right">version</Typography></Grid>
|
||||
<Grid size={{ xs: 8, md: 5 }}><Typography variant="body2">{pkg.version}</Typography></Grid>
|
||||
<Grid size={{ md: 1, xs: 4 }}><Typography align="right" color="text.secondary" variant="body2">packages</Typography></Grid>
|
||||
<Grid size={{ md: 5, xs: 8 }}><Typography variant="body2" sx={{ whiteSpace: "pre-line" }}>{packagesList.unique().join("\n")}</Typography></Grid>
|
||||
<Grid size={{ md: 1, xs: 4 }}><Typography align="right" color="text.secondary" variant="body2">version</Typography></Grid>
|
||||
<Grid size={{ md: 5, xs: 8 }}><Typography variant="body2">{pkg.version}</Typography></Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid container spacing={1} sx={{ mt: 0.5 }}>
|
||||
<Grid size={{ xs: 4, md: 1 }}><Typography variant="body2" color="text.secondary" align="right">packager</Typography></Grid>
|
||||
<Grid size={{ xs: 8, md: 5 }}><Typography variant="body2">{pkg.packager ?? ""}</Typography></Grid>
|
||||
<Grid size={{ xs: 4, md: 1 }} />
|
||||
<Grid size={{ xs: 8, md: 5 }} />
|
||||
<Grid size={{ md: 1, xs: 4 }}><Typography align="right" color="text.secondary" variant="body2">packager</Typography></Grid>
|
||||
<Grid size={{ md: 5, xs: 8 }}><Typography variant="body2">{pkg.packager ?? ""}</Typography></Grid>
|
||||
<Grid size={{ md: 1, xs: 4 }} />
|
||||
<Grid size={{ md: 5, xs: 8 }} />
|
||||
</Grid>
|
||||
|
||||
<Grid container spacing={1} sx={{ mt: 0.5 }}>
|
||||
<Grid size={{ xs: 4, md: 1 }}><Typography variant="body2" color="text.secondary" align="right">groups</Typography></Grid>
|
||||
<Grid size={{ xs: 8, md: 5 }}><Typography variant="body2" sx={{ whiteSpace: "pre-line" }}>{groups.unique().join("\n")}</Typography></Grid>
|
||||
<Grid size={{ xs: 4, md: 1 }}><Typography variant="body2" color="text.secondary" align="right">licenses</Typography></Grid>
|
||||
<Grid size={{ xs: 8, md: 5 }}><Typography variant="body2" sx={{ whiteSpace: "pre-line" }}>{licenses.unique().join("\n")}</Typography></Grid>
|
||||
<Grid size={{ md: 1, xs: 4 }}><Typography align="right" color="text.secondary" variant="body2">groups</Typography></Grid>
|
||||
<Grid size={{ md: 5, xs: 8 }}><Typography variant="body2" sx={{ whiteSpace: "pre-line" }}>{groups.unique().join("\n")}</Typography></Grid>
|
||||
<Grid size={{ md: 1, xs: 4 }}><Typography align="right" color="text.secondary" variant="body2">licenses</Typography></Grid>
|
||||
<Grid size={{ md: 5, xs: 8 }}><Typography variant="body2" sx={{ whiteSpace: "pre-line" }}>{licenses.unique().join("\n")}</Typography></Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid container spacing={1} sx={{ mt: 0.5 }}>
|
||||
<Grid size={{ xs: 4, md: 1 }}><Typography variant="body2" color="text.secondary" align="right">upstream</Typography></Grid>
|
||||
<Grid size={{ xs: 8, md: 5 }}>
|
||||
<Grid size={{ md: 1, xs: 4 }}><Typography align="right" color="text.secondary" variant="body2">upstream</Typography></Grid>
|
||||
<Grid size={{ md: 5, xs: 8 }}>
|
||||
{upstreamUrls.map(url =>
|
||||
<Link key={url} href={url} target="_blank" rel="noopener noreferrer" underline="hover" display="block" variant="body2">
|
||||
<Link display="block" href={url} key={url} rel="noopener noreferrer" target="_blank" underline="hover" variant="body2">
|
||||
{url}
|
||||
</Link>,
|
||||
)}
|
||||
</Grid>
|
||||
<Grid size={{ xs: 4, md: 1 }}><Typography variant="body2" color="text.secondary" align="right">AUR</Typography></Grid>
|
||||
<Grid size={{ xs: 8, md: 5 }}>
|
||||
<Grid size={{ md: 1, xs: 4 }}><Typography align="right" color="text.secondary" variant="body2">AUR</Typography></Grid>
|
||||
<Grid size={{ md: 5, xs: 8 }}>
|
||||
<Typography variant="body2">
|
||||
{aurUrl &&
|
||||
<Link href={aurUrl} target="_blank" rel="noopener noreferrer" underline="hover">AUR link</Link>
|
||||
<Link href={aurUrl} rel="noopener noreferrer" target="_blank" underline="hover">AUR link</Link>
|
||||
}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid container spacing={1} sx={{ mt: 0.5 }}>
|
||||
<Grid size={{ xs: 4, md: 1 }}><Typography variant="body2" color="text.secondary" align="right">depends</Typography></Grid>
|
||||
<Grid size={{ xs: 8, md: 5 }}><Typography variant="body2" sx={{ whiteSpace: "pre-line" }}>{allDepends.join("\n")}</Typography></Grid>
|
||||
<Grid size={{ xs: 4, md: 1 }}><Typography variant="body2" color="text.secondary" align="right">implicitly depends</Typography></Grid>
|
||||
<Grid size={{ xs: 8, md: 5 }}><Typography variant="body2" sx={{ whiteSpace: "pre-line" }}>{implicitDepends.unique().join("\n")}</Typography></Grid>
|
||||
<Grid size={{ md: 1, xs: 4 }}><Typography align="right" color="text.secondary" variant="body2">depends</Typography></Grid>
|
||||
<Grid size={{ md: 5, xs: 8 }}><Typography variant="body2" sx={{ whiteSpace: "pre-line" }}>{allDepends.join("\n")}</Typography></Grid>
|
||||
<Grid size={{ md: 1, xs: 4 }}><Typography align="right" color="text.secondary" variant="body2">implicitly depends</Typography></Grid>
|
||||
<Grid size={{ md: 5, xs: 8 }}><Typography variant="body2" sx={{ whiteSpace: "pre-line" }}>{implicitDepends.unique().join("\n")}</Typography></Grid>
|
||||
</Grid>
|
||||
</>;
|
||||
}
|
||||
|
||||
@@ -18,32 +18,38 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import DeleteIcon from "@mui/icons-material/Delete";
|
||||
import PauseCircleIcon from "@mui/icons-material/PauseCircle";
|
||||
import PlayArrowIcon from "@mui/icons-material/PlayArrow";
|
||||
import PlayCircleIcon from "@mui/icons-material/PlayCircle";
|
||||
import { Button, Checkbox, DialogActions, FormControlLabel } from "@mui/material";
|
||||
import AutoRefreshControl from "components/common/AutoRefreshControl";
|
||||
import type { AutoRefreshInterval } from "models/AutoRefreshInterval";
|
||||
import type React from "react";
|
||||
|
||||
interface PackageInfoActionsProps {
|
||||
isAuthorized: boolean;
|
||||
refreshDatabase: boolean;
|
||||
onRefreshDatabaseChange: (checked: boolean) => void;
|
||||
onUpdate: () => void;
|
||||
onRemove: () => void;
|
||||
autoRefreshIntervals: AutoRefreshInterval[];
|
||||
autoRefreshInterval: number;
|
||||
autoRefreshIntervals: AutoRefreshInterval[];
|
||||
isAuthorized: boolean;
|
||||
isHeld: boolean;
|
||||
onAutoRefreshIntervalChange: (interval: number) => void;
|
||||
onHoldToggle: () => void;
|
||||
onRefreshDatabaseChange: (checked: boolean) => void;
|
||||
onRemove: () => void;
|
||||
onUpdate: () => void;
|
||||
refreshDatabase: boolean;
|
||||
}
|
||||
|
||||
export default function PackageInfoActions({
|
||||
isAuthorized,
|
||||
refreshDatabase,
|
||||
onRefreshDatabaseChange,
|
||||
onUpdate,
|
||||
onRemove,
|
||||
autoRefreshIntervals,
|
||||
autoRefreshInterval,
|
||||
autoRefreshIntervals,
|
||||
isAuthorized,
|
||||
isHeld,
|
||||
onAutoRefreshIntervalChange,
|
||||
onHoldToggle,
|
||||
onRefreshDatabaseChange,
|
||||
onRemove,
|
||||
onUpdate,
|
||||
refreshDatabase,
|
||||
}: PackageInfoActionsProps): React.JSX.Element {
|
||||
return <DialogActions sx={{ flexWrap: "wrap", gap: 1 }}>
|
||||
{isAuthorized &&
|
||||
@@ -52,17 +58,20 @@ export default function PackageInfoActions({
|
||||
control={<Checkbox checked={refreshDatabase} onChange={(_, checked) => onRefreshDatabaseChange(checked)} size="small" />}
|
||||
label="update pacman databases"
|
||||
/>
|
||||
<Button onClick={onUpdate} variant="contained" color="success" startIcon={<PlayArrowIcon />} size="small">
|
||||
<Button color="warning" onClick={onHoldToggle} size="small" startIcon={isHeld ? <PlayCircleIcon /> : <PauseCircleIcon />} variant="outlined">
|
||||
{isHeld ? "unhold" : "hold"}
|
||||
</Button>
|
||||
<Button color="success" onClick={onUpdate} size="small" startIcon={<PlayArrowIcon />} variant="contained">
|
||||
update
|
||||
</Button>
|
||||
<Button onClick={onRemove} variant="contained" color="error" startIcon={<DeleteIcon />} size="small">
|
||||
<Button color="error" onClick={onRemove} size="small" startIcon={<DeleteIcon />} variant="contained">
|
||||
remove
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
<AutoRefreshControl
|
||||
intervals={autoRefreshIntervals}
|
||||
currentInterval={autoRefreshInterval}
|
||||
intervals={autoRefreshIntervals}
|
||||
onIntervalChange={onAutoRefreshIntervalChange}
|
||||
/>
|
||||
</DialogActions>;
|
||||
|
||||
@@ -23,39 +23,39 @@ import type { Patch } from "models/Patch";
|
||||
import type React from "react";
|
||||
|
||||
interface PackagePatchesListProps {
|
||||
patches: Patch[];
|
||||
editable: boolean;
|
||||
onDelete: (key: string) => void;
|
||||
patches: Patch[];
|
||||
}
|
||||
|
||||
export default function PackagePatchesList({
|
||||
patches,
|
||||
editable,
|
||||
onDelete,
|
||||
patches,
|
||||
}: PackagePatchesListProps): React.JSX.Element | null {
|
||||
if (patches.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <Box sx={{ mt: 2 }}>
|
||||
<Typography variant="h6" gutterBottom>Environment variables</Typography>
|
||||
<Typography gutterBottom variant="h6">Environment variables</Typography>
|
||||
{patches.map(patch =>
|
||||
<Box key={patch.key} sx={{ display: "flex", alignItems: "center", gap: 1, mb: 0.5 }}>
|
||||
<Box key={patch.key} sx={{ alignItems: "center", display: "flex", gap: 1, mb: 0.5 }}>
|
||||
<TextField
|
||||
size="small"
|
||||
value={patch.key}
|
||||
disabled
|
||||
size="small"
|
||||
sx={{ flex: 1 }}
|
||||
value={patch.key}
|
||||
/>
|
||||
<Box>=</Box>
|
||||
<TextField
|
||||
size="small"
|
||||
value={JSON.stringify(patch.value)}
|
||||
disabled
|
||||
value={JSON.stringify(patch.value)}
|
||||
size="small"
|
||||
sx={{ flex: 1 }}
|
||||
/>
|
||||
{editable &&
|
||||
<IconButton size="small" color="error" onClick={() => onDelete(patch.key)}>
|
||||
<IconButton aria-label="Remove patch" color="error" onClick={() => onDelete(patch.key)} size="small">
|
||||
<DeleteIcon fontSize="small" />
|
||||
</IconButton>
|
||||
}
|
||||
|
||||
34
frontend/src/components/package/PkgbuildTab.tsx
Normal file
34
frontend/src/components/package/PkgbuildTab.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import CodeBlock from "components/common/CodeBlock";
|
||||
import { usePackageChanges } from "hooks/usePackageChanges";
|
||||
import type { RepositoryId } from "models/RepositoryId";
|
||||
import React from "react";
|
||||
|
||||
interface PkgbuildTabProps {
|
||||
packageBase: string;
|
||||
repository: RepositoryId;
|
||||
}
|
||||
|
||||
export default function PkgbuildTab({ packageBase, repository }: PkgbuildTabProps): React.JSX.Element {
|
||||
const data = usePackageChanges(packageBase, repository);
|
||||
|
||||
return <CodeBlock content={data?.pkgbuild ?? ""} height={400} language="bash" />;
|
||||
}
|
||||
28
frontend/src/components/package/TabKey.ts
Normal file
28
frontend/src/components/package/TabKey.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
export type TabKey = "logs" | "changes" | "pkgbuild" | "events" | "artifacts";
|
||||
|
||||
export const tabs: { key: TabKey; label: string }[] = [
|
||||
{ key: "logs", label: "Build logs" },
|
||||
{ key: "changes", label: "Changes" },
|
||||
{ key: "pkgbuild", label: "PKGBUILD" },
|
||||
{ key: "events", label: "Events" },
|
||||
{ key: "artifacts", label: "Artifacts" },
|
||||
];
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
GRID_CHECKBOX_SELECTION_COL_DEF,
|
||||
type GridColDef,
|
||||
type GridFilterModel,
|
||||
type GridRenderCellParams,
|
||||
type GridRowId,
|
||||
useGridApiRef,
|
||||
} from "@mui/x-data-grid";
|
||||
@@ -44,8 +43,6 @@ interface PackageTableProps {
|
||||
autoRefreshIntervals: AutoRefreshInterval[];
|
||||
}
|
||||
|
||||
const PAGE_SIZE_OPTIONS = [10, 25, 50, 100];
|
||||
|
||||
function createListColumn(
|
||||
field: keyof PackageRow,
|
||||
headerName: string,
|
||||
@@ -55,10 +52,10 @@ function createListColumn(
|
||||
field,
|
||||
headerName,
|
||||
...options,
|
||||
valueGetter: (value: string[]) => (value ?? []).join(" "),
|
||||
renderCell: (params: GridRenderCellParams<PackageRow>) =>
|
||||
renderCell: params =>
|
||||
<Box sx={{ whiteSpace: "pre-line" }}>{((params.row[field] as string[]) ?? []).join("\n")}</Box>,
|
||||
sortComparator: (left: string, right: string) => left.localeCompare(right),
|
||||
valueGetter: (value: string[]) => (value ?? []).join(" "),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -79,35 +76,30 @@ export default function PackageTable({ autoRefreshIntervals }: PackageTableProps
|
||||
() => [
|
||||
{
|
||||
field: "base",
|
||||
headerName: "package base",
|
||||
flex: 1,
|
||||
headerName: "package base",
|
||||
minWidth: 150,
|
||||
renderCell: (params: GridRenderCellParams<PackageRow>) =>
|
||||
renderCell: params =>
|
||||
params.row.webUrl ?
|
||||
<Link href={params.row.webUrl} target="_blank" rel="noopener noreferrer" underline="hover">
|
||||
<Link href={params.row.webUrl} rel="noopener noreferrer" target="_blank" underline="hover">
|
||||
{params.value as string}
|
||||
</Link>
|
||||
: params.value as string,
|
||||
},
|
||||
{ field: "version", headerName: "version", width: 180, align: "right", headerAlign: "right" },
|
||||
{ align: "right", field: "version", headerAlign: "right", headerName: "version", width: 180 },
|
||||
createListColumn("packages", "packages", { flex: 1, minWidth: 120 }),
|
||||
createListColumn("groups", "groups", { width: 150 }),
|
||||
createListColumn("licenses", "licenses", { width: 150 }),
|
||||
{ field: "packager", headerName: "packager", width: 150 },
|
||||
{ align: "right", field: "timestamp", headerName: "last update", headerAlign: "right", width: 180 },
|
||||
{
|
||||
field: "timestamp",
|
||||
headerName: "last update",
|
||||
width: 180,
|
||||
align: "right",
|
||||
headerAlign: "right",
|
||||
},
|
||||
{
|
||||
field: "status",
|
||||
headerName: "status",
|
||||
width: 120,
|
||||
align: "center",
|
||||
field: "status",
|
||||
headerAlign: "center",
|
||||
renderCell: (params: GridRenderCellParams<PackageRow>) => <StatusCell status={params.row.status} />,
|
||||
headerName: "status",
|
||||
renderCell: params =>
|
||||
<StatusCell isHeld={params.row.isHeld} status={params.row.status} />,
|
||||
width: 120,
|
||||
},
|
||||
],
|
||||
[],
|
||||
@@ -115,56 +107,42 @@ export default function PackageTable({ autoRefreshIntervals }: PackageTableProps
|
||||
|
||||
return <Box sx={{ display: "flex", flexDirection: "column", width: "100%" }}>
|
||||
<PackageTableToolbar
|
||||
hasSelection={table.selectionModel.length > 0}
|
||||
isAuthorized={table.isAuthorized}
|
||||
status={table.status}
|
||||
searchText={table.searchText}
|
||||
onSearchChange={table.setSearchText}
|
||||
actions={{
|
||||
onAddClick: () => table.setDialogOpen("add"),
|
||||
onDashboardClick: () => table.setDialogOpen("dashboard"),
|
||||
onExportClick: () => apiRef.current?.exportDataAsCsv(),
|
||||
onKeyImportClick: () => table.setDialogOpen("keyImport"),
|
||||
onRebuildClick: () => table.setDialogOpen("rebuild"),
|
||||
onRefreshDatabaseClick: () => void table.handleRefreshDatabase(),
|
||||
onReloadClick: table.handleReload,
|
||||
onRemoveClick: () => void table.handleRemove(),
|
||||
onUpdateClick: () => void table.handleUpdate(),
|
||||
}}
|
||||
autoRefresh={{
|
||||
autoRefreshIntervals,
|
||||
currentInterval: table.autoRefreshInterval,
|
||||
onIntervalChange: table.onAutoRefreshIntervalChange,
|
||||
}}
|
||||
actions={{
|
||||
onDashboardClick: () => table.setDialogOpen("dashboard"),
|
||||
onAddClick: () => table.setDialogOpen("add"),
|
||||
onUpdateClick: () => void table.handleUpdate(),
|
||||
onRefreshDatabaseClick: () => void table.handleRefreshDatabase(),
|
||||
onRebuildClick: () => table.setDialogOpen("rebuild"),
|
||||
onRemoveClick: () => void table.handleRemove(),
|
||||
onKeyImportClick: () => table.setDialogOpen("keyImport"),
|
||||
onReloadClick: table.handleReload,
|
||||
onExportClick: () => apiRef.current?.exportDataAsCsv(),
|
||||
}}
|
||||
isAuthorized={table.isAuthorized}
|
||||
hasSelection={table.selectionModel.length > 0}
|
||||
onSearchChange={table.setSearchText}
|
||||
searchText={table.searchText}
|
||||
status={table.status}
|
||||
/>
|
||||
|
||||
<DataGrid
|
||||
apiRef={apiRef}
|
||||
rows={table.rows}
|
||||
columns={columns}
|
||||
loading={table.isLoading}
|
||||
getRowHeight={() => "auto"}
|
||||
checkboxSelection
|
||||
disableRowSelectionOnClick
|
||||
rowSelectionModel={{ type: "include", ids: new Set<GridRowId>(table.selectionModel) }}
|
||||
onRowSelectionModelChange={model => {
|
||||
if (model.type === "exclude") {
|
||||
const excludeIds = new Set([...model.ids].map(String));
|
||||
table.setSelectionModel(table.rows.map(row => row.id).filter(id => !excludeIds.has(id)));
|
||||
} else {
|
||||
table.setSelectionModel([...model.ids].map(String));
|
||||
}
|
||||
}}
|
||||
paginationModel={table.paginationModel}
|
||||
onPaginationModelChange={table.setPaginationModel}
|
||||
pageSizeOptions={PAGE_SIZE_OPTIONS}
|
||||
columnVisibilityModel={table.columnVisibility}
|
||||
onColumnVisibilityModelChange={table.setColumnVisibility}
|
||||
columns={columns}
|
||||
density="compact"
|
||||
disableRowSelectionOnClick
|
||||
filterModel={effectiveFilterModel}
|
||||
onFilterModelChange={table.setFilterModel}
|
||||
getRowHeight={() => "auto"}
|
||||
initialState={{
|
||||
sorting: { sortModel: [{ field: "base", sort: "asc" }] },
|
||||
}}
|
||||
loading={table.isLoading}
|
||||
onCellClick={(params, event) => {
|
||||
// Don't open info dialog when clicking checkbox or link
|
||||
if (params.field === GRID_CHECKBOX_SELECTION_COL_DEF.field) {
|
||||
@@ -175,22 +153,32 @@ export default function PackageTable({ autoRefreshIntervals }: PackageTableProps
|
||||
}
|
||||
table.setSelectedPackage(String(params.id));
|
||||
}}
|
||||
sx={{
|
||||
flex: 1,
|
||||
"& .MuiDataGrid-row": { cursor: "pointer" },
|
||||
onColumnVisibilityModelChange={table.setColumnVisibility}
|
||||
onFilterModelChange={table.setFilterModel}
|
||||
onPaginationModelChange={table.setPaginationModel}
|
||||
onRowSelectionModelChange={model => {
|
||||
if (model.type === "exclude") {
|
||||
const excludeIds = new Set([...model.ids].map(String));
|
||||
table.setSelectionModel(table.rows.map(row => row.id).filter(id => !excludeIds.has(id)));
|
||||
} else {
|
||||
table.setSelectionModel([...model.ids].map(String));
|
||||
}
|
||||
}}
|
||||
density="compact"
|
||||
paginationModel={table.paginationModel}
|
||||
rowSelectionModel={{ type: "include", ids: new Set<GridRowId>(table.selectionModel) }}
|
||||
rows={table.rows}
|
||||
sx={{ flex: 1 }}
|
||||
/>
|
||||
|
||||
<DashboardDialog open={table.dialogOpen === "dashboard"} onClose={() => table.setDialogOpen(null)} />
|
||||
<PackageAddDialog open={table.dialogOpen === "add"} onClose={() => table.setDialogOpen(null)} />
|
||||
<PackageRebuildDialog open={table.dialogOpen === "rebuild"} onClose={() => table.setDialogOpen(null)} />
|
||||
<KeyImportDialog open={table.dialogOpen === "keyImport"} onClose={() => table.setDialogOpen(null)} />
|
||||
<DashboardDialog onClose={() => table.setDialogOpen(null)} open={table.dialogOpen === "dashboard"} />
|
||||
<PackageAddDialog onClose={() => table.setDialogOpen(null)} open={table.dialogOpen === "add"} />
|
||||
<PackageRebuildDialog onClose={() => table.setDialogOpen(null)} open={table.dialogOpen === "rebuild"} />
|
||||
<KeyImportDialog onClose={() => table.setDialogOpen(null)} open={table.dialogOpen === "keyImport"} />
|
||||
<PackageInfoDialog
|
||||
packageBase={table.selectedPackage}
|
||||
open={table.selectedPackage !== null}
|
||||
onClose={() => table.setSelectedPackage(null)}
|
||||
autoRefreshIntervals={autoRefreshIntervals}
|
||||
onClose={() => table.setSelectedPackage(null)}
|
||||
open={table.selectedPackage !== null}
|
||||
packageBase={table.selectedPackage}
|
||||
/>
|
||||
</Box>;
|
||||
}
|
||||
|
||||
@@ -43,47 +43,47 @@ export interface AutoRefreshProps {
|
||||
}
|
||||
|
||||
export interface ToolbarActions {
|
||||
onDashboardClick: () => void;
|
||||
onAddClick: () => void;
|
||||
onUpdateClick: () => void;
|
||||
onRefreshDatabaseClick: () => void;
|
||||
onRebuildClick: () => void;
|
||||
onRemoveClick: () => void;
|
||||
onKeyImportClick: () => void;
|
||||
onReloadClick: () => void;
|
||||
onDashboardClick: () => void;
|
||||
onExportClick: () => void;
|
||||
onKeyImportClick: () => void;
|
||||
onRebuildClick: () => void;
|
||||
onRefreshDatabaseClick: () => void;
|
||||
onReloadClick: () => void;
|
||||
onRemoveClick: () => void;
|
||||
onUpdateClick: () => void;
|
||||
}
|
||||
|
||||
interface PackageTableToolbarProps {
|
||||
actions: ToolbarActions;
|
||||
autoRefresh: AutoRefreshProps;
|
||||
hasSelection: boolean;
|
||||
isAuthorized: boolean;
|
||||
status?: BuildStatus;
|
||||
searchText: string;
|
||||
onSearchChange: (text: string) => void;
|
||||
autoRefresh: AutoRefreshProps;
|
||||
actions: ToolbarActions;
|
||||
searchText: string;
|
||||
status?: BuildStatus;
|
||||
}
|
||||
|
||||
export default function PackageTableToolbar({
|
||||
actions,
|
||||
autoRefresh,
|
||||
hasSelection,
|
||||
isAuthorized,
|
||||
status,
|
||||
searchText,
|
||||
onSearchChange,
|
||||
autoRefresh,
|
||||
actions,
|
||||
searchText,
|
||||
status,
|
||||
}: PackageTableToolbarProps): React.JSX.Element {
|
||||
const [packagesAnchorEl, setPackagesAnchorEl] = useState<HTMLElement | null>(null);
|
||||
|
||||
return <Box sx={{ display: "flex", gap: 1, mb: 1, flexWrap: "wrap", alignItems: "center" }}>
|
||||
return <Box sx={{ alignItems: "center", display: "flex", flexWrap: "wrap", gap: 1, mb: 1 }}>
|
||||
<Tooltip title="System health">
|
||||
<IconButton
|
||||
aria-label="System health"
|
||||
onClick={actions.onDashboardClick}
|
||||
sx={{
|
||||
borderColor: status ? StatusColors[status] : undefined,
|
||||
borderWidth: 1,
|
||||
borderStyle: "solid",
|
||||
borderWidth: 1,
|
||||
color: status ? StatusColors[status] : undefined,
|
||||
}}
|
||||
>
|
||||
@@ -94,16 +94,16 @@ export default function PackageTableToolbar({
|
||||
{isAuthorized &&
|
||||
<>
|
||||
<Button
|
||||
variant="contained"
|
||||
startIcon={<InventoryIcon />}
|
||||
onClick={event => setPackagesAnchorEl(event.currentTarget)}
|
||||
startIcon={<InventoryIcon />}
|
||||
variant="contained"
|
||||
>
|
||||
packages
|
||||
</Button>
|
||||
<Menu
|
||||
anchorEl={packagesAnchorEl}
|
||||
open={Boolean(packagesAnchorEl)}
|
||||
onClose={() => setPackagesAnchorEl(null)}
|
||||
open={Boolean(packagesAnchorEl)}
|
||||
>
|
||||
<MenuItem onClick={() => {
|
||||
setPackagesAnchorEl(null); actions.onAddClick();
|
||||
@@ -126,58 +126,58 @@ export default function PackageTableToolbar({
|
||||
<ReplayIcon fontSize="small" sx={{ mr: 1 }} /> rebuild
|
||||
</MenuItem>
|
||||
<Divider />
|
||||
<MenuItem onClick={() => {
|
||||
<MenuItem disabled={!hasSelection} onClick={() => {
|
||||
setPackagesAnchorEl(null); actions.onRemoveClick();
|
||||
}} disabled={!hasSelection}>
|
||||
}}>
|
||||
<DeleteIcon fontSize="small" sx={{ mr: 1 }} /> remove
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
<Button variant="contained" color="info" startIcon={<VpnKeyIcon />} onClick={actions.onKeyImportClick}>
|
||||
<Button color="info" onClick={actions.onKeyImportClick} startIcon={<VpnKeyIcon />} variant="contained">
|
||||
import key
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
|
||||
<Button variant="outlined" color="secondary" startIcon={<RefreshIcon />} onClick={actions.onReloadClick}>
|
||||
<Button color="secondary" onClick={actions.onReloadClick} startIcon={<RefreshIcon />} variant="outlined">
|
||||
reload
|
||||
</Button>
|
||||
|
||||
<AutoRefreshControl
|
||||
intervals={autoRefresh.autoRefreshIntervals}
|
||||
currentInterval={autoRefresh.currentInterval}
|
||||
intervals={autoRefresh.autoRefreshIntervals}
|
||||
onIntervalChange={autoRefresh.onIntervalChange}
|
||||
/>
|
||||
|
||||
<Box sx={{ flexGrow: 1 }} />
|
||||
|
||||
<TextField
|
||||
size="small"
|
||||
aria-label="Search packages"
|
||||
placeholder="search packages..."
|
||||
value={searchText}
|
||||
onChange={event => onSearchChange(event.target.value)}
|
||||
placeholder="search packages..."
|
||||
size="small"
|
||||
slotProps={{
|
||||
input: {
|
||||
endAdornment: searchText ?
|
||||
<InputAdornment position="end">
|
||||
<IconButton aria-label="Clear search" onClick={() => onSearchChange("")} size="small">
|
||||
<ClearIcon fontSize="small" />
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
: undefined,
|
||||
startAdornment:
|
||||
<InputAdornment position="start">
|
||||
<SearchIcon fontSize="small" />
|
||||
</InputAdornment>
|
||||
,
|
||||
endAdornment: searchText ?
|
||||
<InputAdornment position="end">
|
||||
<IconButton size="small" aria-label="Clear search" onClick={() => onSearchChange("")}>
|
||||
<ClearIcon fontSize="small" />
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
: undefined,
|
||||
},
|
||||
}}
|
||||
sx={{ minWidth: 200 }}
|
||||
value={searchText}
|
||||
/>
|
||||
|
||||
<Tooltip title="Export CSV">
|
||||
<IconButton size="small" aria-label="Export CSV" onClick={actions.onExportClick}>
|
||||
<IconButton aria-label="Export CSV" onClick={actions.onExportClick} size="small">
|
||||
<FileDownloadIcon fontSize="small" />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
|
||||
@@ -17,17 +17,20 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import PauseCircleIcon from "@mui/icons-material/PauseCircle";
|
||||
import { Chip } from "@mui/material";
|
||||
import type { BuildStatus } from "models/BuildStatus";
|
||||
import type React from "react";
|
||||
import { StatusColors } from "theme/StatusColors";
|
||||
|
||||
interface StatusCellProps {
|
||||
isHeld?: boolean;
|
||||
status: BuildStatus;
|
||||
}
|
||||
|
||||
export default function StatusCell({ status }: StatusCellProps): React.JSX.Element {
|
||||
export default function StatusCell({ isHeld, status }: StatusCellProps): React.JSX.Element {
|
||||
return <Chip
|
||||
icon={isHeld ? <PauseCircleIcon /> : undefined}
|
||||
label={status}
|
||||
size="small"
|
||||
sx={{
|
||||
|
||||
@@ -26,9 +26,9 @@ interface AuthState {
|
||||
|
||||
export interface AuthContextValue extends AuthState {
|
||||
isAuthorized: boolean;
|
||||
setAuthState: (state: AuthState) => void;
|
||||
login: (username: string, password: string) => Promise<void>;
|
||||
logout: () => Promise<void>;
|
||||
setAuthState: (state: AuthState) => void;
|
||||
}
|
||||
|
||||
export const AuthContext = createContext<AuthContextValue | null>(null);
|
||||
|
||||
@@ -24,9 +24,7 @@ import React, { type ReactNode, useMemo } from "react";
|
||||
export function ClientProvider({ children }: { children: ReactNode }): React.JSX.Element {
|
||||
const client = useMemo(() => new AhrimanClient(), []);
|
||||
|
||||
return (
|
||||
<ClientContext.Provider value={client}>
|
||||
return <ClientContext.Provider value={client}>
|
||||
{children}
|
||||
</ClientContext.Provider>
|
||||
);
|
||||
</ClientContext.Provider>;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
import { createContext } from "react";
|
||||
|
||||
export interface NotificationContextValue {
|
||||
showSuccess: (title: string, message: string) => void;
|
||||
showError: (title: string, message: string) => void;
|
||||
showSuccess: (title: string, message: string) => void;
|
||||
}
|
||||
|
||||
export const NotificationContext = createContext<NotificationContextValue | null>(null);
|
||||
|
||||
@@ -55,17 +55,17 @@ export function NotificationProvider({ children }: { children: ReactNode }): Rea
|
||||
{children}
|
||||
<Box
|
||||
sx={{
|
||||
position: "fixed",
|
||||
top: 16,
|
||||
left: "50%",
|
||||
transform: "translateX(-50%)",
|
||||
zIndex: theme => theme.zIndex.snackbar,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: 1,
|
||||
left: "50%",
|
||||
maxWidth: 500,
|
||||
width: "100%",
|
||||
pointerEvents: "none",
|
||||
position: "fixed",
|
||||
top: 16,
|
||||
transform: "translateX(-50%)",
|
||||
width: "100%",
|
||||
zIndex: theme => theme.zIndex.snackbar,
|
||||
}}
|
||||
>
|
||||
{notifications.map(notification =>
|
||||
|
||||
@@ -21,10 +21,10 @@ import type { RepositoryId } from "models/RepositoryId";
|
||||
import { createContext } from "react";
|
||||
|
||||
export interface RepositoryContextValue {
|
||||
currentRepository: RepositoryId | null;
|
||||
repositories: RepositoryId[];
|
||||
current: RepositoryId | null;
|
||||
setCurrentRepository: (repository: RepositoryId) => void;
|
||||
setRepositories: (repositories: RepositoryId[]) => void;
|
||||
setCurrent: (repository: RepositoryId) => void;
|
||||
}
|
||||
|
||||
export const RepositoryContext = createContext<RepositoryContextValue | null>(null);
|
||||
|
||||
@@ -34,20 +34,20 @@ export function RepositoryProvider({ children }: { children: ReactNode }): React
|
||||
const [repositories, setRepositories] = useState<RepositoryId[]>([]);
|
||||
const hash = useSyncExternalStore(subscribeToHash, getHashSnapshot);
|
||||
|
||||
const current = useMemo(() => {
|
||||
const currentRepository = useMemo(() => {
|
||||
if (repositories.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return repositories.find(repository => repository.key === hash) ?? repositories[0] ?? null;
|
||||
}, [repositories, hash]);
|
||||
|
||||
const setCurrent = useCallback((repository: RepositoryId) => {
|
||||
const setCurrentRepository = useCallback((repository: RepositoryId) => {
|
||||
window.location.hash = repository.key;
|
||||
}, []);
|
||||
|
||||
const value = useMemo(() => ({
|
||||
repositories, current, setRepositories, setCurrent,
|
||||
}), [repositories, current, setCurrent]);
|
||||
repositories, currentRepository, setRepositories, setCurrentRepository,
|
||||
}), [repositories, currentRepository, setCurrentRepository]);
|
||||
|
||||
return <RepositoryContext.Provider value={value}>{children}</RepositoryContext.Provider>;
|
||||
}
|
||||
|
||||
27
frontend/src/contexts/ThemeContext.ts
Normal file
27
frontend/src/contexts/ThemeContext.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { createContext } from "react";
|
||||
|
||||
export interface ThemeContextValue {
|
||||
mode: "light" | "dark";
|
||||
toggleTheme: () => void;
|
||||
}
|
||||
|
||||
export const ThemeContext = createContext<ThemeContextValue | null>(null);
|
||||
54
frontend/src/contexts/ThemeProvider.tsx
Normal file
54
frontend/src/contexts/ThemeProvider.tsx
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import CssBaseline from "@mui/material/CssBaseline";
|
||||
import { ThemeProvider as MuiThemeProvider } from "@mui/material/styles";
|
||||
import { defaults as chartDefaults } from "chart.js";
|
||||
import { ThemeContext } from "contexts/ThemeContext";
|
||||
import { useLocalStorage } from "hooks/useLocalStorage";
|
||||
import React, { useCallback, useEffect, useMemo } from "react";
|
||||
import { createAppTheme } from "theme/Theme";
|
||||
|
||||
function systemPreference(): "light" | "dark" {
|
||||
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||
}
|
||||
|
||||
export function ThemeProvider({ children }: { children: React.ReactNode }): React.JSX.Element {
|
||||
const [mode, setMode] = useLocalStorage<"light" | "dark">("theme-mode", systemPreference());
|
||||
|
||||
const toggleTheme = useCallback(() => {
|
||||
setMode(prev => prev === "light" ? "dark" : "light");
|
||||
}, [setMode]);
|
||||
|
||||
const theme = useMemo(() => createAppTheme(mode), [mode]);
|
||||
|
||||
useEffect(() => {
|
||||
chartDefaults.color = mode === "dark" ? "rgba(255,255,255,0.7)" : "rgba(0,0,0,0.7)";
|
||||
chartDefaults.borderColor = mode === "dark" ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.1)";
|
||||
}, [mode]);
|
||||
|
||||
const value = useMemo(() => ({ mode, toggleTheme }), [mode, toggleTheme]);
|
||||
|
||||
return <ThemeContext.Provider value={value}>
|
||||
<MuiThemeProvider theme={theme}>
|
||||
<CssBaseline />
|
||||
{children}
|
||||
</MuiThemeProvider>
|
||||
</ThemeContext.Provider>;
|
||||
}
|
||||
@@ -21,6 +21,8 @@ import type { RepositoryId } from "models/RepositoryId";
|
||||
|
||||
export const QueryKeys = {
|
||||
|
||||
artifacts: (packageBase: string, repository: RepositoryId) => ["artifacts", repository.key, packageBase] as const,
|
||||
|
||||
changes: (packageBase: string, repository: RepositoryId) => ["changes", repository.key, packageBase] as const,
|
||||
|
||||
dependencies: (packageBase: string, repository: RepositoryId) => ["dependencies", repository.key, packageBase] as const,
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
import { type RefObject, useCallback, useRef } from "react";
|
||||
|
||||
interface UseAutoScrollResult {
|
||||
preRef: RefObject<HTMLElement | null>;
|
||||
handleScroll: () => void;
|
||||
scrollToBottom: () => void;
|
||||
preRef: RefObject<HTMLElement | null>;
|
||||
resetScroll: () => void;
|
||||
scrollToBottom: () => void;
|
||||
}
|
||||
|
||||
export function useAutoScroll(): UseAutoScrollResult {
|
||||
@@ -59,5 +59,5 @@ export function useAutoScroll(): UseAutoScrollResult {
|
||||
}
|
||||
}, []);
|
||||
|
||||
return { preRef, handleScroll, scrollToBottom, resetScroll };
|
||||
return { handleScroll, preRef, resetScroll, scrollToBottom };
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ import { useRepository } from "hooks/useRepository";
|
||||
import type { RepositoryId } from "models/RepositoryId";
|
||||
|
||||
export interface UsePackageActionsResult {
|
||||
handleReload: () => void;
|
||||
handleUpdate: () => Promise<void>;
|
||||
handleRefreshDatabase: () => Promise<void>;
|
||||
handleReload: () => void;
|
||||
handleRemove: () => Promise<void>;
|
||||
handleUpdate: () => Promise<void>;
|
||||
}
|
||||
|
||||
export function usePackageActions(
|
||||
@@ -37,7 +37,7 @@ export function usePackageActions(
|
||||
setSelectionModel: (model: string[]) => void,
|
||||
): UsePackageActionsResult {
|
||||
const client = useClient();
|
||||
const { current } = useRepository();
|
||||
const { currentRepository } = useRepository();
|
||||
const { showSuccess, showError } = useNotification();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -50,22 +50,22 @@ export function usePackageActions(
|
||||
action: (repository: RepositoryId) => Promise<string>,
|
||||
errorMessage: string,
|
||||
): Promise<void> => {
|
||||
if (!current) {
|
||||
if (!currentRepository) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const successMessage = await action(current);
|
||||
const successMessage = await action(currentRepository);
|
||||
showSuccess("Success", successMessage);
|
||||
invalidate(current);
|
||||
invalidate(currentRepository);
|
||||
setSelectionModel([]);
|
||||
} catch (exception) {
|
||||
showError("Action failed", `${errorMessage}: ${ApiError.errorDetail(exception)}`);
|
||||
}
|
||||
};
|
||||
|
||||
const handleReload: () => void = () => {
|
||||
if (current !== null) {
|
||||
invalidate(current);
|
||||
const handleReload = (): void => {
|
||||
if (currentRepository !== null) {
|
||||
invalidate(currentRepository);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -80,11 +80,11 @@ export function usePackageActions(
|
||||
|
||||
const handleRefreshDatabase = (): Promise<void> => performAction(async (repository): Promise<string> => {
|
||||
await client.service.servicePackageUpdate(repository, {
|
||||
packages: [],
|
||||
refresh: true,
|
||||
aur: false,
|
||||
local: false,
|
||||
manual: false,
|
||||
packages: [],
|
||||
refresh: true,
|
||||
});
|
||||
return "Pacman database update has been requested";
|
||||
}, "Could not update pacman databases");
|
||||
@@ -100,9 +100,9 @@ export function usePackageActions(
|
||||
};
|
||||
|
||||
return {
|
||||
handleReload,
|
||||
handleUpdate,
|
||||
handleRefreshDatabase,
|
||||
handleReload,
|
||||
handleRemove,
|
||||
handleUpdate,
|
||||
};
|
||||
}
|
||||
|
||||
36
frontend/src/hooks/usePackageChanges.ts
Normal file
36
frontend/src/hooks/usePackageChanges.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { QueryKeys } from "hooks/QueryKeys";
|
||||
import { useClient } from "hooks/useClient";
|
||||
import type { Changes } from "models/Changes";
|
||||
import type { RepositoryId } from "models/RepositoryId";
|
||||
|
||||
export function usePackageChanges(packageBase: string, repository: RepositoryId): Changes | undefined {
|
||||
const client = useClient();
|
||||
|
||||
const { data } = useQuery<Changes>({
|
||||
enabled: !!packageBase,
|
||||
queryFn: () => client.fetch.fetchPackageChanges(packageBase, repository),
|
||||
queryKey: QueryKeys.changes(packageBase, repository),
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -30,39 +30,39 @@ import { useMemo } from "react";
|
||||
import { defaultInterval } from "utils";
|
||||
|
||||
export interface UsePackageDataResult {
|
||||
rows: PackageRow[];
|
||||
isLoading: boolean;
|
||||
isAuthorized: boolean;
|
||||
status: BuildStatus | undefined;
|
||||
autoRefresh: ReturnType<typeof useAutoRefresh>;
|
||||
isAuthorized: boolean;
|
||||
isLoading: boolean;
|
||||
rows: PackageRow[];
|
||||
status: BuildStatus | undefined;
|
||||
}
|
||||
|
||||
export function usePackageData(autoRefreshIntervals: AutoRefreshInterval[]): UsePackageDataResult {
|
||||
const client = useClient();
|
||||
const { current } = useRepository();
|
||||
const { currentRepository } = useRepository();
|
||||
const { isAuthorized } = useAuth();
|
||||
|
||||
const autoRefresh = useAutoRefresh("table-autoreload-button", defaultInterval(autoRefreshIntervals));
|
||||
|
||||
const { data: packages = [], isLoading } = useQuery({
|
||||
queryKey: current ? QueryKeys.packages(current) : ["packages"],
|
||||
queryFn: current ? () => client.fetch.fetchPackages(current) : skipToken,
|
||||
queryFn: currentRepository ? () => client.fetch.fetchPackages(currentRepository) : skipToken,
|
||||
queryKey: currentRepository ? QueryKeys.packages(currentRepository) : ["packages"],
|
||||
refetchInterval: autoRefresh.interval > 0 ? autoRefresh.interval : false,
|
||||
});
|
||||
|
||||
const { data: status } = useQuery({
|
||||
queryKey: current ? QueryKeys.status(current) : ["status"],
|
||||
queryFn: current ? () => client.fetch.fetchServerStatus(current) : skipToken,
|
||||
queryFn: currentRepository ? () => client.fetch.fetchServerStatus(currentRepository) : skipToken,
|
||||
queryKey: currentRepository ? QueryKeys.status(currentRepository) : ["status"],
|
||||
refetchInterval: autoRefresh.interval > 0 ? autoRefresh.interval : false,
|
||||
});
|
||||
|
||||
const rows = useMemo(() => packages.map(descriptor => new PackageRow(descriptor)), [packages]);
|
||||
|
||||
return {
|
||||
rows,
|
||||
autoRefresh,
|
||||
isLoading,
|
||||
isAuthorized,
|
||||
rows,
|
||||
status: status?.status.status,
|
||||
autoRefresh,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,35 +27,30 @@ import type { PackageRow } from "models/PackageRow";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export interface UsePackageTableResult {
|
||||
rows: PackageRow[];
|
||||
isLoading: boolean;
|
||||
isAuthorized: boolean;
|
||||
status: BuildStatus | undefined;
|
||||
|
||||
selectionModel: string[];
|
||||
setSelectionModel: (model: string[]) => void;
|
||||
|
||||
dialogOpen: "dashboard" | "add" | "rebuild" | "keyImport" | null;
|
||||
setDialogOpen: (dialog: "dashboard" | "add" | "rebuild" | "keyImport" | null) => void;
|
||||
selectedPackage: string | null;
|
||||
setSelectedPackage: (base: string | null) => void;
|
||||
|
||||
paginationModel: { pageSize: number; page: number };
|
||||
setPaginationModel: (model: { pageSize: number; page: number }) => void;
|
||||
columnVisibility: Record<string, boolean>;
|
||||
setColumnVisibility: (model: Record<string, boolean>) => void;
|
||||
filterModel: GridFilterModel;
|
||||
setFilterModel: (model: GridFilterModel) => void;
|
||||
searchText: string;
|
||||
setSearchText: (text: string) => void;
|
||||
|
||||
autoRefreshInterval: number;
|
||||
onAutoRefreshIntervalChange: (interval: number) => void;
|
||||
|
||||
handleReload: () => void;
|
||||
handleUpdate: () => Promise<void>;
|
||||
columnVisibility: Record<string, boolean>;
|
||||
dialogOpen: "dashboard" | "add" | "rebuild" | "keyImport" | null;
|
||||
filterModel: GridFilterModel;
|
||||
handleRefreshDatabase: () => Promise<void>;
|
||||
handleReload: () => void;
|
||||
handleRemove: () => Promise<void>;
|
||||
handleUpdate: () => Promise<void>;
|
||||
isAuthorized: boolean;
|
||||
isLoading: boolean;
|
||||
onAutoRefreshIntervalChange: (interval: number) => void;
|
||||
paginationModel: { page: number; pageSize: number };
|
||||
rows: PackageRow[];
|
||||
searchText: string;
|
||||
selectedPackage: string | null;
|
||||
selectionModel: string[];
|
||||
setColumnVisibility: (model: Record<string, boolean>) => void;
|
||||
setDialogOpen: (dialog: "dashboard" | "add" | "rebuild" | "keyImport" | null) => void;
|
||||
setFilterModel: (model: GridFilterModel) => void;
|
||||
setPaginationModel: (model: { page: number; pageSize: number }) => void;
|
||||
setSearchText: (text: string) => void;
|
||||
setSelectedPackage: (base: string | null) => void;
|
||||
setSelectionModel: (model: string[]) => void;
|
||||
status: BuildStatus | undefined;
|
||||
}
|
||||
|
||||
export function usePackageTable(autoRefreshIntervals: AutoRefreshInterval[]): UsePackageTableResult {
|
||||
@@ -71,16 +66,13 @@ export function usePackageTable(autoRefreshIntervals: AutoRefreshInterval[]): Us
|
||||
}, [isDialogOpen, setPaused]);
|
||||
|
||||
return {
|
||||
rows,
|
||||
autoRefreshInterval: autoRefresh.interval,
|
||||
isLoading,
|
||||
isAuthorized,
|
||||
status,
|
||||
|
||||
...tableState,
|
||||
|
||||
autoRefreshInterval: autoRefresh.interval,
|
||||
onAutoRefreshIntervalChange: autoRefresh.setInterval,
|
||||
|
||||
rows,
|
||||
status,
|
||||
...actions,
|
||||
...tableState,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,17 +22,17 @@ import type { RepositoryId } from "models/RepositoryId";
|
||||
import { useState } from "react";
|
||||
|
||||
export interface SelectedRepositoryResult {
|
||||
selectedKey: string;
|
||||
setSelectedKey: (key: string) => void;
|
||||
selectedRepository: RepositoryId | null;
|
||||
reset: () => void;
|
||||
selectedKey: string;
|
||||
selectedRepository: RepositoryId | null;
|
||||
setSelectedKey: (key: string) => void;
|
||||
}
|
||||
|
||||
export function useSelectedRepository(): SelectedRepositoryResult {
|
||||
const { repositories, current } = useRepository();
|
||||
const { repositories, currentRepository } = useRepository();
|
||||
const [selectedKey, setSelectedKey] = useState("");
|
||||
|
||||
let selectedRepository: RepositoryId | null = current;
|
||||
let selectedRepository: RepositoryId | null = currentRepository;
|
||||
if (selectedKey) {
|
||||
const repository = repositories.find(repository => repository.key === selectedKey);
|
||||
if (repository) {
|
||||
@@ -40,9 +40,9 @@ export function useSelectedRepository(): SelectedRepositoryResult {
|
||||
}
|
||||
}
|
||||
|
||||
const reset: () => void = () => {
|
||||
const reset = (): void => {
|
||||
setSelectedKey("");
|
||||
};
|
||||
|
||||
return { selectedKey, setSelectedKey, selectedRepository, reset };
|
||||
return { reset, selectedKey, selectedRepository, setSelectedKey };
|
||||
}
|
||||
|
||||
@@ -24,22 +24,20 @@ import { useState } from "react";
|
||||
export type DialogType = "dashboard" | "add" | "rebuild" | "keyImport";
|
||||
|
||||
export interface UseTableStateResult {
|
||||
selectionModel: string[];
|
||||
setSelectionModel: (model: string[]) => void;
|
||||
|
||||
dialogOpen: DialogType | null;
|
||||
setDialogOpen: (dialog: DialogType | null) => void;
|
||||
selectedPackage: string | null;
|
||||
setSelectedPackage: (base: string | null) => void;
|
||||
|
||||
paginationModel: { pageSize: number; page: number };
|
||||
setPaginationModel: (model: { pageSize: number; page: number }) => void;
|
||||
columnVisibility: Record<string, boolean>;
|
||||
setColumnVisibility: (model: Record<string, boolean>) => void;
|
||||
dialogOpen: DialogType | null;
|
||||
filterModel: GridFilterModel;
|
||||
setFilterModel: (model: GridFilterModel) => void;
|
||||
paginationModel: { pageSize: number; page: number };
|
||||
searchText: string;
|
||||
selectedPackage: string | null;
|
||||
selectionModel: string[];
|
||||
setColumnVisibility: (model: Record<string, boolean>) => void;
|
||||
setDialogOpen: (dialog: DialogType | null) => void;
|
||||
setFilterModel: (model: GridFilterModel) => void;
|
||||
setPaginationModel: (model: { pageSize: number; page: number }) => void;
|
||||
setSearchText: (text: string) => void;
|
||||
setSelectedPackage: (base: string | null) => void;
|
||||
setSelectionModel: (model: string[]) => void;
|
||||
}
|
||||
|
||||
export function useTableState(): UseTableStateResult {
|
||||
@@ -49,8 +47,8 @@ export function useTableState(): UseTableStateResult {
|
||||
const [searchText, setSearchText] = useState("");
|
||||
|
||||
const [paginationModel, setPaginationModel] = useLocalStorage("ahriman-packages-pagination", {
|
||||
pageSize: 10,
|
||||
page: 0,
|
||||
pageSize: 25,
|
||||
});
|
||||
const [columnVisibility, setColumnVisibility] = useLocalStorage<Record<string, boolean>>(
|
||||
"ahriman-packages-columns",
|
||||
@@ -62,21 +60,19 @@ export function useTableState(): UseTableStateResult {
|
||||
);
|
||||
|
||||
return {
|
||||
selectionModel,
|
||||
setSelectionModel,
|
||||
|
||||
dialogOpen,
|
||||
setDialogOpen,
|
||||
selectedPackage,
|
||||
setSelectedPackage,
|
||||
|
||||
paginationModel,
|
||||
setPaginationModel,
|
||||
columnVisibility,
|
||||
setColumnVisibility,
|
||||
dialogOpen,
|
||||
filterModel,
|
||||
setFilterModel,
|
||||
paginationModel,
|
||||
searchText,
|
||||
selectedPackage,
|
||||
selectionModel,
|
||||
setColumnVisibility,
|
||||
setDialogOpen,
|
||||
setFilterModel,
|
||||
setPaginationModel,
|
||||
setSearchText,
|
||||
setSelectedPackage,
|
||||
setSelectionModel,
|
||||
};
|
||||
}
|
||||
|
||||
25
frontend/src/hooks/useThemeMode.ts
Normal file
25
frontend/src/hooks/useThemeMode.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { ThemeContext, type ThemeContextValue } from "contexts/ThemeContext";
|
||||
import { useContextNotNull } from "hooks/useContextNotNull";
|
||||
|
||||
export function useThemeMode(): ThemeContextValue {
|
||||
return useContextNotNull(ThemeContext);
|
||||
}
|
||||
@@ -21,11 +21,18 @@ import "chartSetup";
|
||||
import "utils";
|
||||
|
||||
import App from "App";
|
||||
import ErrorFallback from "components/common/ErrorBoundary";
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
<StrictMode>
|
||||
<ErrorBoundary
|
||||
FallbackComponent={ErrorFallback}
|
||||
onError={(error, info) => console.error("Uncaught error:", error, info.componentStack)}
|
||||
>
|
||||
<App />
|
||||
</ErrorBoundary>
|
||||
</StrictMode>,
|
||||
);
|
||||
|
||||
@@ -18,6 +18,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
export interface AURPackage {
|
||||
package: string;
|
||||
description: string;
|
||||
package: string;
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
export type BuildStatus = "unknown" | "pending" | "building" | "failed" | "success";
|
||||
export type BuildStatus = "building" | "failed" | "pending" | "success" | "unknown";
|
||||
|
||||
@@ -20,4 +20,5 @@
|
||||
export interface Changes {
|
||||
changes?: string;
|
||||
last_commit_sha?: string;
|
||||
pkgbuild?: string;
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ import type { RepositoryId } from "models/RepositoryId";
|
||||
|
||||
export interface InfoResponse {
|
||||
auth: AuthInfo;
|
||||
repositories: RepositoryId[];
|
||||
version: string;
|
||||
autorefresh_intervals: AutoRefreshInterval[];
|
||||
docs_enabled: boolean;
|
||||
index_url?: string;
|
||||
repositories: RepositoryId[];
|
||||
version: string;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ import type { Status } from "models/Status";
|
||||
|
||||
export interface InternalStatus {
|
||||
architecture: string;
|
||||
repository: string;
|
||||
packages: Counters;
|
||||
repository: string;
|
||||
stats: RepositoryStats;
|
||||
status: Status;
|
||||
version: string;
|
||||
|
||||
@@ -18,6 +18,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
export interface LoginRequest {
|
||||
username: string;
|
||||
password: string;
|
||||
username: string;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import type { AlertColor } from "@mui/material";
|
||||
|
||||
export interface Notification {
|
||||
id: string;
|
||||
title: string;
|
||||
message: string;
|
||||
severity: AlertColor;
|
||||
title: string;
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
import type { Patch } from "models/Patch";
|
||||
|
||||
export interface PackageActionRequest {
|
||||
packages: string[];
|
||||
patches?: Patch[];
|
||||
refresh?: boolean;
|
||||
aur?: boolean;
|
||||
local?: boolean;
|
||||
manual?: boolean;
|
||||
packages: string[];
|
||||
patches?: Patch[];
|
||||
refresh?: boolean;
|
||||
}
|
||||
|
||||
@@ -21,30 +21,31 @@ import type { BuildStatus } from "models/BuildStatus";
|
||||
import type { PackageStatus } from "models/PackageStatus";
|
||||
|
||||
export class PackageRow {
|
||||
id: string;
|
||||
|
||||
base: string;
|
||||
webUrl?: string;
|
||||
version: string;
|
||||
packages: string[];
|
||||
groups: string[];
|
||||
id: string;
|
||||
isHeld: boolean;
|
||||
licenses: string[];
|
||||
packager: string;
|
||||
timestamp: string;
|
||||
timestampValue: number;
|
||||
packages: string[];
|
||||
status: BuildStatus;
|
||||
timestamp: string;
|
||||
version: string;
|
||||
webUrl?: string;
|
||||
|
||||
constructor(descriptor: PackageStatus) {
|
||||
this.id = descriptor.package.base;
|
||||
this.base = descriptor.package.base;
|
||||
this.webUrl = descriptor.package.remote.web_url ?? undefined;
|
||||
this.version = descriptor.package.version;
|
||||
this.packages = Object.keys(descriptor.package.packages).sort();
|
||||
this.groups = PackageRow.extractListProperties(descriptor.package, "groups");
|
||||
this.id = descriptor.package.base;
|
||||
this.isHeld = descriptor.status.is_held ?? false;
|
||||
this.licenses = PackageRow.extractListProperties(descriptor.package, "licenses");
|
||||
this.packager = descriptor.package.packager ?? "";
|
||||
this.timestamp = new Date(descriptor.status.timestamp * 1000).toISOStringShort();
|
||||
this.timestampValue = descriptor.status.timestamp;
|
||||
this.packages = Object.keys(descriptor.package.packages).sort();
|
||||
this.status = descriptor.status.status;
|
||||
this.timestamp = new Date(descriptor.status.timestamp * 1000).toISOStringShort();
|
||||
this.version = descriptor.package.version;
|
||||
this.webUrl = descriptor.package.remote.web_url ?? undefined;
|
||||
}
|
||||
|
||||
private static extractListProperties(pkg: PackageStatus["package"], property: "groups" | "licenses"): string[] {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
export class RepositoryId {
|
||||
|
||||
readonly architecture: string;
|
||||
readonly repository: string;
|
||||
|
||||
|
||||
23
frontend/src/models/RollbackRequest.ts
Normal file
23
frontend/src/models/RollbackRequest.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2026 ahriman team.
|
||||
*
|
||||
* This file is part of ahriman
|
||||
* (see https://github.com/arcan1s/ahriman).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
export interface RollbackRequest {
|
||||
package: string;
|
||||
version: string;
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
import type { BuildStatus } from "models/BuildStatus";
|
||||
|
||||
export interface Status {
|
||||
is_held?: boolean;
|
||||
status: BuildStatus;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
@@ -21,19 +21,19 @@ import { amber, green, grey, orange, red } from "@mui/material/colors";
|
||||
import type { BuildStatus } from "models/BuildStatus";
|
||||
|
||||
const base: Record<BuildStatus, string> = {
|
||||
unknown: grey[800],
|
||||
pending: amber[900],
|
||||
building: orange[900],
|
||||
failed: red[900],
|
||||
success: green[800],
|
||||
building: orange[800],
|
||||
failed: red[700],
|
||||
pending: amber[700],
|
||||
success: green[700],
|
||||
unknown: grey[600],
|
||||
};
|
||||
|
||||
const headerBase: Record<BuildStatus, string> = {
|
||||
unknown: grey[800],
|
||||
pending: amber[700],
|
||||
building: orange[600],
|
||||
failed: red[500],
|
||||
pending: amber[700],
|
||||
success: green[600],
|
||||
unknown: grey[600],
|
||||
};
|
||||
|
||||
export const StatusColors = base;
|
||||
|
||||
@@ -17,17 +17,28 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { createTheme } from "@mui/material/styles";
|
||||
import { createTheme, type Theme } from "@mui/material/styles";
|
||||
|
||||
const Theme = createTheme({
|
||||
export function createAppTheme(mode: "light" | "dark"): Theme {
|
||||
return createTheme({
|
||||
components: {
|
||||
MuiButton: {
|
||||
styleOverrides: {
|
||||
startIcon: {
|
||||
alignItems: "center",
|
||||
display: "flex",
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiDialog: {
|
||||
defaultProps: {
|
||||
maxWidth: "lg",
|
||||
fullWidth: true,
|
||||
maxWidth: "lg",
|
||||
},
|
||||
},
|
||||
},
|
||||
palette: {
|
||||
mode,
|
||||
},
|
||||
});
|
||||
|
||||
export default Theme;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,14 @@
|
||||
*/
|
||||
import type { AutoRefreshInterval } from "models/AutoRefreshInterval";
|
||||
|
||||
export const DETAIL_TABLE_PROPS = {
|
||||
density: "compact" as const,
|
||||
disableColumnSorting: true,
|
||||
disableRowSelectionOnClick: true,
|
||||
paginationModel: { page: 0, pageSize: 25 },
|
||||
sx: { height: 400, mt: 1 },
|
||||
};
|
||||
|
||||
export function defaultInterval(intervals: AutoRefreshInterval[]): number {
|
||||
return intervals.find(interval => interval.is_active)?.interval ?? 0;
|
||||
}
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
"baseUrl": "src",
|
||||
"isolatedModules": true,
|
||||
"jsx": "react-jsx",
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"noEmit": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"target": "ES2020",
|
||||
"target": "ESNext",
|
||||
"useDefineForClassFields": true
|
||||
},
|
||||
"include": ["src"]
|
||||
|
||||
@@ -1,35 +1,37 @@
|
||||
import { defineConfig, type Plugin } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import tsconfigPaths from "vite-tsconfig-paths";
|
||||
import path from "path";
|
||||
import { defineConfig, type Plugin } from "vite";
|
||||
|
||||
function renameHtml(newName: string): Plugin {
|
||||
function rename(oldName: string, newName: string): Plugin {
|
||||
return {
|
||||
name: "rename-html",
|
||||
enforce: "post",
|
||||
generateBundle(_, bundle) {
|
||||
if (bundle["index.html"]) {
|
||||
bundle["index.html"].fileName = newName;
|
||||
if (bundle[oldName]) {
|
||||
bundle[oldName].fileName = newName;
|
||||
}
|
||||
},
|
||||
name: "rename",
|
||||
};
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react(), tsconfigPaths(), renameHtml("build-status.jinja2")],
|
||||
base: "/",
|
||||
build: {
|
||||
chunkSizeWarningLimit: 10000,
|
||||
emptyOutDir: false,
|
||||
outDir: path.resolve(__dirname, "../package/share/ahriman/templates"),
|
||||
rollupOptions: {
|
||||
rolldownOptions: {
|
||||
output: {
|
||||
entryFileNames: "static/[name].js",
|
||||
chunkFileNames: "static/[name].js",
|
||||
assetFileNames: "static/[name].[ext]",
|
||||
chunkFileNames: "static/[name].js",
|
||||
entryFileNames: "static/[name].js",
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [react(), rename("index.html", "build-status.jinja2")],
|
||||
resolve: {
|
||||
tsconfigPaths: true,
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
"/api": "http://localhost:8080",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
pkgbase='ahriman'
|
||||
pkgname=('ahriman' 'ahriman-core' 'ahriman-triggers' 'ahriman-web')
|
||||
pkgver=2.20.0rc5
|
||||
pkgver=2.20.0
|
||||
pkgrel=1
|
||||
pkgdesc="ArcH linux ReposItory MANager"
|
||||
arch=('any')
|
||||
@@ -17,11 +17,10 @@ source=("https://github.com/arcan1s/ahriman/releases/download/$pkgver/$pkgbase-$
|
||||
build() {
|
||||
cd "$pkgbase-$pkgver"
|
||||
|
||||
python -m build --wheel --no-isolation
|
||||
npm --prefix "frontend" install --cache "$srcdir/npm-cache"
|
||||
npm --prefix "frontend" run build
|
||||
|
||||
cd "frontend"
|
||||
npm install --cache "$srcdir/npm-cache"
|
||||
npm run build
|
||||
python -m build --wheel --no-isolation
|
||||
}
|
||||
|
||||
package_ahriman() {
|
||||
|
||||
@@ -30,6 +30,14 @@ allow_read_only = yes
|
||||
; If no intervals set, auto refresh will be disabled. 0 can only be the first element and will disable auto refresh
|
||||
; by default.
|
||||
autorefresh_intervals = 5 1 10 30 60
|
||||
; Allowed CORS headers. By default everything is allowed.
|
||||
;cors_allow_headers =
|
||||
; Allowed CORS methods. By default everything is allowed.
|
||||
;cors_allow_methods =
|
||||
; Allowed CORS origins.
|
||||
;cors_allow_origins = *
|
||||
; Exposed CORS headers. By default everything is exposed.
|
||||
;cors_expose_headers =
|
||||
; Enable file upload endpoint used by some triggers.
|
||||
;enable_archive_upload = no
|
||||
; Address to bind the server.
|
||||
|
||||
@@ -26,10 +26,12 @@ formatter = syslog_format
|
||||
args = ("/dev/log",)
|
||||
|
||||
[formatter_generic_format]
|
||||
format = [%(levelname)s %(asctime)s] [%(name)s]: %(message)s
|
||||
format = [{levelname} {asctime}] [{name}]: {message}
|
||||
style = {
|
||||
|
||||
[formatter_syslog_format]
|
||||
format = [%(levelname)s] [%(name)s]: %(message)s
|
||||
format = [{levelname}] [{name}]: {message}
|
||||
style = {
|
||||
|
||||
[logger_root]
|
||||
level = DEBUG
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH AHRIMAN "1" "2026\-03\-06" "ahriman 2.20.0rc5" "ArcH linux ReposItory MANager"
|
||||
.TH AHRIMAN "1" "2026\-03\-08" "ahriman 2.20.0" "ArcH linux ReposItory MANager"
|
||||
.SH NAME
|
||||
ahriman \- ArcH linux ReposItory MANager
|
||||
.SH SYNOPSIS
|
||||
|
||||
@@ -58,6 +58,7 @@ web = [
|
||||
"aiohttp",
|
||||
"aiohttp_cors",
|
||||
"aiohttp_jinja2",
|
||||
"aiohttp_sse",
|
||||
]
|
||||
web-auth = [
|
||||
"ahriman[web]",
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
__version__ = "2.20.0rc5"
|
||||
__version__ = "2.20.0"
|
||||
|
||||
@@ -154,13 +154,13 @@ class Application(ApplicationPackages, ApplicationRepository):
|
||||
for package_name, packager in missing.items():
|
||||
if (source_dir := self.repository.paths.cache_for(package_name)).is_dir():
|
||||
# there is local cache, load package from it
|
||||
leaf = Package.from_build(source_dir, self.repository.architecture, packager)
|
||||
leaf = Package.from_build(source_dir, self.repository.repository_id.architecture, packager)
|
||||
else:
|
||||
leaf = Package.from_aur(package_name, packager, include_provides=True)
|
||||
portion[leaf.base] = leaf
|
||||
|
||||
# register package in the database
|
||||
self.repository.reporter.set_unknown(leaf)
|
||||
self.reporter.set_unknown(leaf)
|
||||
|
||||
return portion
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ class ApplicationRepository(ApplicationProperties):
|
||||
if last_commit_sha is None:
|
||||
continue # skip check in case if we can't calculate diff
|
||||
|
||||
changes = self.repository.package_changes(package, last_commit_sha)
|
||||
self.repository.reporter.package_changes_update(package.base, changes)
|
||||
if (changes := self.repository.package_changes(package, last_commit_sha)) is not None:
|
||||
self.reporter.package_changes_update(package.base, changes)
|
||||
|
||||
def clean(self, *, cache: bool, chroot: bool, manual: bool, packages: bool, pacman: bool) -> None:
|
||||
"""
|
||||
@@ -156,12 +156,15 @@ class ApplicationRepository(ApplicationProperties):
|
||||
result = Result()
|
||||
|
||||
# process already built packages if any
|
||||
built_packages = self.repository.packages_built()
|
||||
if built_packages: # speedup a bit
|
||||
if built_packages := self.repository.packages_built(): # speedup a bit
|
||||
build_result = self.repository.process_update(built_packages, packagers)
|
||||
self.on_result(build_result)
|
||||
result.merge(build_result)
|
||||
|
||||
# filter packages which were prebuilt
|
||||
succeeded = {package.base for package in build_result.success}
|
||||
updates = [package for package in updates if package.base not in succeeded]
|
||||
|
||||
builder = Updater.load(self.repository_id, self.configuration, self.repository)
|
||||
|
||||
# ok so for now we split all packages into chunks and process each chunk accordingly
|
||||
|
||||
@@ -21,10 +21,10 @@ import argparse
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||
from ahriman.application.handlers.update import Update
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.utils import enum_values, extract_user
|
||||
from ahriman.models.package_source import PackageSource
|
||||
from ahriman.models.packagers import Packagers
|
||||
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
|
||||
@@ -48,26 +48,7 @@ class Add(Handler):
|
||||
"""
|
||||
application = Application(repository_id, configuration, report=report, refresh_pacman_database=args.refresh)
|
||||
application.on_start()
|
||||
|
||||
application.add(args.package, args.source, args.username)
|
||||
patches = [PkgbuildPatch.from_env(patch) for patch in args.variable] if args.variable is not None else []
|
||||
for package in args.package: # for each requested package insert patch
|
||||
for patch in patches:
|
||||
application.reporter.package_patches_update(package, patch)
|
||||
|
||||
if not args.now:
|
||||
return
|
||||
|
||||
packages = application.updates(args.package, aur=False, local=False, manual=True, vcs=False, check_files=False)
|
||||
if args.changes: # generate changes if requested
|
||||
application.changes(packages)
|
||||
|
||||
packages = application.with_dependencies(packages, process_dependencies=args.dependencies)
|
||||
packagers = Packagers(args.username, {package.base: package.packager for package in packages})
|
||||
|
||||
application.print_updates(packages, log_fn=application.logger.info)
|
||||
result = application.update(packages, packagers, bump_pkgrel=args.increment)
|
||||
Add.check_status(args.exit_code, not result.is_empty)
|
||||
Add.perform_action(application, args)
|
||||
|
||||
@staticmethod
|
||||
def _set_package_add_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
@@ -103,14 +84,34 @@ class Add(Handler):
|
||||
parser.add_argument("--increment", help="increment package release (pkgrel) version on duplicate",
|
||||
action=argparse.BooleanOptionalAction, default=True)
|
||||
parser.add_argument("-n", "--now", help="run update function after", action="store_true")
|
||||
parser.add_argument("-y", "--refresh", help="download fresh package databases from the mirror before actions, "
|
||||
"-yy to force refresh even if up to date",
|
||||
action="count", default=False)
|
||||
parser.add_argument("-s", "--source", help="explicitly specify the package source for this command",
|
||||
type=PackageSource, choices=enum_values(PackageSource), default=PackageSource.Auto)
|
||||
parser.add_argument("-u", "--username", help="build as user", default=extract_user())
|
||||
parser.add_argument("-v", "--variable", help="apply specified makepkg variables to the next build",
|
||||
action="append")
|
||||
parser.add_argument("-y", "--refresh", help="download fresh package databases from the mirror before actions, "
|
||||
"-yy to force refresh even if up to date",
|
||||
action="count", default=False)
|
||||
parser.set_defaults(aur=False, check_files=False, dry_run=False, local=False, manual=True, vcs=False)
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
def perform_action(application: Application, args: argparse.Namespace) -> None:
|
||||
"""
|
||||
perform add action
|
||||
|
||||
Args:
|
||||
application(Application): application instance
|
||||
args(argparse.Namespace): command line args
|
||||
"""
|
||||
application.add(args.package, args.source, args.username)
|
||||
patches = [PkgbuildPatch.from_env(patch) for patch in args.variable] if args.variable is not None else []
|
||||
for package in args.package: # for each requested package insert patch
|
||||
for patch in patches:
|
||||
application.reporter.package_patches_update(package, patch)
|
||||
|
||||
if not args.now:
|
||||
return
|
||||
Update.perform_action(application, args)
|
||||
|
||||
arguments = [_set_package_add_parser]
|
||||
|
||||
81
src/ahriman/application/handlers/archives.py
Normal file
81
src/ahriman/application/handlers/archives.py
Normal file
@@ -0,0 +1,81 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import argparse
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.formatters import PackagePrinter
|
||||
from ahriman.models.action import Action
|
||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
|
||||
|
||||
class Archives(Handler):
|
||||
"""
|
||||
package archives handler
|
||||
"""
|
||||
|
||||
ALLOW_MULTI_ARCHITECTURE_RUN = False # conflicting io
|
||||
|
||||
@classmethod
|
||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||
report: bool) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
|
||||
Args:
|
||||
args(argparse.Namespace): command line args
|
||||
repository_id(RepositoryId): repository unique identifier
|
||||
configuration(Configuration): configuration instance
|
||||
report(bool): force enable or disable reporting
|
||||
"""
|
||||
application = Application(repository_id, configuration, report=True)
|
||||
|
||||
match args.action:
|
||||
case Action.List:
|
||||
archives = application.repository.package_archives(args.package)
|
||||
for package in archives:
|
||||
PackagePrinter(package, BuildStatus(BuildStatusEnum.Success))(verbose=args.info)
|
||||
|
||||
Archives.check_status(args.exit_code, bool(archives))
|
||||
|
||||
@staticmethod
|
||||
def _set_package_archives_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
"""
|
||||
add parser for package archives subcommand
|
||||
|
||||
Args:
|
||||
root(SubParserAction): subparsers for the commands
|
||||
|
||||
Returns:
|
||||
argparse.ArgumentParser: created argument parser
|
||||
"""
|
||||
parser = root.add_parser("package-archives", help="list package archive versions",
|
||||
description="list available archive versions for the package")
|
||||
parser.add_argument("package", help="package base")
|
||||
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||
action="store_true")
|
||||
parser.add_argument("--info", help="show additional package information",
|
||||
action=argparse.BooleanOptionalAction, default=False)
|
||||
parser.set_defaults(action=Action.List, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
arguments = [_set_package_archives_parser]
|
||||
@@ -47,14 +47,13 @@ class Change(Handler):
|
||||
configuration(Configuration): configuration instance
|
||||
report(bool): force enable or disable reporting
|
||||
"""
|
||||
application = Application(repository_id, configuration, report=True)
|
||||
client = application.repository.reporter
|
||||
client = Application(repository_id, configuration, report=True).reporter
|
||||
|
||||
match args.action:
|
||||
case Action.List:
|
||||
changes = client.package_changes_get(args.package)
|
||||
ChangesPrinter(changes)(verbose=True, separator="")
|
||||
Change.check_status(args.exit_code, not changes.is_empty)
|
||||
Change.check_status(args.exit_code, changes.changes is not None)
|
||||
case Action.Remove:
|
||||
client.package_changes_update(args.package, Changes())
|
||||
|
||||
|
||||
93
src/ahriman/application/handlers/hold.py
Normal file
93
src/ahriman/application/handlers/hold.py
Normal file
@@ -0,0 +1,93 @@
|
||||
#
|
||||
# Copyright (c) 2021-2026 ahriman team.
|
||||
#
|
||||
# This file is part of ahriman
|
||||
# (see https://github.com/arcan1s/ahriman).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
import argparse
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.models.action import Action
|
||||
from ahriman.models.repository_id import RepositoryId
|
||||
|
||||
|
||||
class Hold(Handler):
|
||||
"""
|
||||
package hold handler
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def run(cls, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration, *,
|
||||
report: bool) -> None:
|
||||
"""
|
||||
callback for command line
|
||||
|
||||
Args:
|
||||
args(argparse.Namespace): command line args
|
||||
repository_id(RepositoryId): repository unique identifier
|
||||
configuration(Configuration): configuration instance
|
||||
report(bool): force enable or disable reporting
|
||||
"""
|
||||
client = Application(repository_id, configuration, report=True).reporter
|
||||
|
||||
match args.action:
|
||||
case Action.Remove:
|
||||
for package in args.package:
|
||||
client.package_hold_update(package, enabled=False)
|
||||
case Action.Update:
|
||||
for package in args.package:
|
||||
client.package_hold_update(package, enabled=True)
|
||||
|
||||
@staticmethod
|
||||
def _set_package_hold_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
"""
|
||||
add parser for hold package subcommand
|
||||
|
||||
Args:
|
||||
root(SubParserAction): subparsers for the commands
|
||||
|
||||
Returns:
|
||||
argparse.ArgumentParser: created argument parser
|
||||
"""
|
||||
parser = root.add_parser("package-hold", help="hold package",
|
||||
description="hold package from automatic updates")
|
||||
parser.add_argument("package", help="package base", nargs="+")
|
||||
parser.set_defaults(action=Action.Update, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
def _set_package_unhold_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
"""
|
||||
add parser for unhold package subcommand
|
||||
|
||||
Args:
|
||||
root(SubParserAction): subparsers for the commands
|
||||
|
||||
Returns:
|
||||
argparse.ArgumentParser: created argument parser
|
||||
"""
|
||||
parser = root.add_parser("package-unhold", help="unhold package",
|
||||
description="remove package hold, allowing automatic updates")
|
||||
parser.add_argument("package", help="package base", nargs="+")
|
||||
parser.set_defaults(action=Action.Remove, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
arguments = [
|
||||
_set_package_hold_parser,
|
||||
_set_package_unhold_parser,
|
||||
]
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user