Skip to content

Commit

Permalink
app store manage action btn skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
Archmonger committed May 27, 2023
1 parent 994e5df commit cc5ba35
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 11 deletions.
49 changes: 42 additions & 7 deletions conreq/_core/app_store/components/manage_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

@component
def manage_apps():
"""Bootstrap table for managing apps.
Apps contain the following action buttons: logs, upgrade, reinstall, remove, and details
"""
"""Bootstrap table for managing apps."""

installed_packages = sorted(
set(get_env("INSTALLED_PACKAGES", [], return_type=list))
Expand All @@ -33,6 +31,7 @@ def manage_apps():
html.th("Name"),
html.th("Installed"),
html.th("Latest"),
html.th("Disabled"),
html.th({"style": {"text-align": "center"}}, "Actions"),
)
),
Expand Down Expand Up @@ -68,7 +67,7 @@ def thread_func():

# Check if output is broken
if not proc.stderr or not proc.stdout:
set_error_msg("Error. Check logs.")
set_error_msg("ERROR")
_logger.error(
"Broken stderr or stdout while getting pip index versions for %s",
pkg_name,
Expand All @@ -79,7 +78,7 @@ def thread_func():
stderr = proc.stderr.readlines()
for line in stderr:
if line.strip().startswith(b"ERROR:"):
set_error_msg("Error. Check logs.")
set_error_msg("ERROR")
_logger.error(
"'pip index versions' failed for %s: %s",
pkg_name,
Expand Down Expand Up @@ -109,7 +108,7 @@ def thread_func():

# Output wasn't parsed properly, or package isn't installed
if not installed:
set_error_msg("Error. Check logs.")
set_error_msg("ERROR")
_logger.error(
"Failed to obtain currently installed version from 'pip index versions' for %s: %s",
pkg_name,
Expand Down Expand Up @@ -146,7 +145,43 @@ def thread_func():
)
),
html.td(latest_version or ("N/A" if error_msg else "Checking...")),
html.td("No"),
html.td(
{"style": {"text-align": "center"}}, html.i({"class_name": "fas fa-cog"})
{"style": {"text-align": "center"}},
html.div(
{"class_name": "dropdown"},
html.button(
{
"class_name": "btn btn-sm btn-dark dropdown-toggle",
"type": "button",
"data-bs-toggle": "dropdown",
"aria-expanded": "false",
},
html.i({"class_name": "fas fa-cog"}),
),
html.ul(
{"class_name": "dropdown-menu"},
dropdown_item("Update")
if latest_version != current_version
else "",
dropdown_item("Uninstall"),
dropdown_item("Disable"),
dropdown_item("Change Version") if available_versions else "",
),
),
),
)


def dropdown_item(option: str):
return html.li(
{"key": option},
html.a(
{
"class_name": "dropdown-item",
"href": f"#{option}",
"on_click": lambda _: None,
},
f"{option}",
),
)
5 changes: 5 additions & 0 deletions conreq/_core/home/static/conreq/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions conreq/utils/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def validate_conreq_modules(module_names: list[str]) -> list[str]:

if not hasattr(module, "conreq_apps"):
_logger.warning(
"\033[93mPackage '%s' is not properly configured. "
"Please define `conreq_apps`.\033[0m",
"\033[93mApp package '%s' is not properly configured. "
"`conreq_apps` is undefined.\033[0m",
package,
)
continue
Expand Down
6 changes: 5 additions & 1 deletion conreq/utils/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ def _parse_records(package: str) -> list[str]:
install_paths = distribution.get_metadata("RECORD").splitlines()
names = set()
for path in install_paths:
folder = Path(path).parts[0]
path = path.split(",")[0]
testable_path = Path(path)
if len(testable_path.parts) <= 1:
continue
folder = testable_path.parts[0]
if "." in folder:
continue
names.add(folder)
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ warn_unused_configs = true
warn_redundant_casts = true
warn_unused_ignores = true
check_untyped_defs = true
incremental = false
plugins = ["mypy_django_plugin.main"]

[tool.django-stubs]
Expand Down

0 comments on commit cc5ba35

Please sign in to comment.