mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[ui][aur] improved Required / Optional confirmation dialogs
This commit is contained in:
@@ -2,15 +2,28 @@ from typing import Set
|
||||
|
||||
from bauh.api.abstract.handler import ProcessWatcher
|
||||
from bauh.api.abstract.view import MultipleSelectComponent, InputOption
|
||||
from bauh.commons import resource
|
||||
from bauh.commons.html import bold
|
||||
from bauh.gems.arch import ROOT_DIR
|
||||
from bauh.view.util.translation import I18n
|
||||
|
||||
|
||||
def _get_mirror_icon(mirror: str):
|
||||
return resource.get_path('img/{}.png'.format('arch' if mirror == 'aur' else 'mirror'), ROOT_DIR)
|
||||
|
||||
|
||||
def request_optional_deps(pkgname: str, pkg_mirrors: dict, watcher: ProcessWatcher, i18n: I18n) -> Set[str]:
|
||||
opts = [InputOption('{}{} ( {} )'.format(p, ': ' + d['desc'] if d['desc'] else '', d['mirror'].upper()), p) for p, d in pkg_mirrors.items()]
|
||||
opts = []
|
||||
|
||||
for p, d in pkg_mirrors.items():
|
||||
op = InputOption('{}{} ( {} )'.format(p, ': ' + d['desc'] if d['desc'] else '', d['mirror'].upper()), p)
|
||||
op.icon_path = _get_mirror_icon(d['mirror'])
|
||||
opts.append(op)
|
||||
|
||||
view_opts = MultipleSelectComponent(label='',
|
||||
options=opts,
|
||||
default_options=None)
|
||||
|
||||
install = watcher.request_confirmation(title=i18n['arch.install.optdeps.request.title'],
|
||||
body='<p>{}</p>'.format(i18n['arch.install.optdeps.request.body'].format(bold(pkgname)) + ':'),
|
||||
components=[view_opts],
|
||||
@@ -22,8 +35,17 @@ def request_optional_deps(pkgname: str, pkg_mirrors: dict, watcher: ProcessWatch
|
||||
|
||||
|
||||
def request_install_missing_deps(pkgname: str, pkg_mirrors: dict, watcher: ProcessWatcher, i18n: I18n) -> bool:
|
||||
deps_str = ''.join(['<br/><span style="font-weight:bold"> - {} ( {} )</span>'.format(d, m.upper()) for d, m in pkg_mirrors.items()])
|
||||
msg = '<p>{}</p>'.format(i18n['arch.missing_deps.body'].format(bold(pkgname)) + ':<br/>' + deps_str)
|
||||
msg += i18n['ask.continue']
|
||||
msg = '<p>{}</p>'.format(i18n['arch.missing_deps.body'].format(bold(pkgname)) + ':')
|
||||
|
||||
return watcher.request_confirmation(i18n['arch.missing_deps.title'], msg)
|
||||
opts = []
|
||||
for p, m in pkg_mirrors.items():
|
||||
op = InputOption('{} ( {} )'.format(p, m), p)
|
||||
op.read_only = True
|
||||
op.icon_path = _get_mirror_icon(m)
|
||||
opts.append(op)
|
||||
|
||||
comps = [
|
||||
MultipleSelectComponent(label='', options=opts, default_options=set(opts))
|
||||
]
|
||||
|
||||
return watcher.request_confirmation(i18n['arch.missing_deps.title'], msg, comps, confirmation_label=i18n['continue'].capitalize())
|
||||
|
||||
Reference in New Issue
Block a user