Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hive/clive
1 result
Show changes
Commits on Source (6)
Showing
with 147 additions and 88 deletions
......@@ -20,7 +20,7 @@ CartBasedScreen CartOverview CartItemsAmount {
background: $secondary-lighten-1;
padding: 1;
width: 1fr;
height: 1fr;
height: 3;
color: $text;
}
......
......@@ -9,6 +9,7 @@ from textual.css.query import NoMatches
from textual.widgets import Label, Static
from clive.__private.abstract_class import AbstractClassMessagePump
from clive.__private.ui.get_css import get_css_from_relative_path
from clive.__private.ui.widgets.can_focus_with_scrollbars_only import CanFocusWithScrollbarsOnly
if TYPE_CHECKING:
......@@ -18,6 +19,8 @@ if TYPE_CHECKING:
class GovernanceActionRow(Horizontal, AbstractClassMessagePump):
"""Class that displays either the name of the witness or the ID of the proposal - chosen generically based on the action to be performed."""
DEFAULT_CSS = get_css_from_relative_path(__file__)
def __init__(self, identifier: str, vote: bool, pending: bool = False):
"""
Initialize the GovernanceActionRow.
......@@ -58,6 +61,7 @@ class GovernanceActionRow(Horizontal, AbstractClassMessagePump):
class GovernanceActions(VerticalScroll, CanFocusWithScrollbarsOnly):
"""Contains a table of actions to be performed after confirmation."""
DEFAULT_CSS = get_css_from_relative_path(__file__)
NAME_OF_ACTION: ClassVar[str] = "Action"
def __init__(self) -> None:
......
$governance-green-color: $success-darken-3;
$governance-red-color: $error;
$table-info-headline: $accent-lighten-1;
$table-header-contrast-column: $warning-darken-2;
GovernanceActions {
margin-left: 1;
width: 3fr;
}
GovernanceActionRow {
height: auto;
}
GovernanceActionRow .action-vote {
background: $governance-green-color;
}
GovernanceActionRow .action-unvote {
background: $governance-red-color;
}
GovernanceActionRow .action-pending {
background: $panel-lighten-3;
}
GovernanceActions #name-and-action {
height: auto;
}
GovernanceActions #action-row {
background: $table-header-contrast-column;
width: 1fr;
}
GovernanceActions #actions-header {
background: $table-info-headline;
}
......@@ -4,6 +4,7 @@ from textual import on
from textual.containers import ScrollableContainer
from textual.widgets import TabPane
from clive.__private.ui.get_css import get_css_from_relative_path
from clive.__private.ui.operations.bindings import OperationActionBindings
from clive.__private.ui.operations.governance_operations.common_governance.governance_actions import (
GovernanceActions,
......@@ -20,6 +21,8 @@ class ScrollablePart(ScrollableContainer, can_focus=False):
class GovernanceTabPane(TabPane, OperationActionBindings):
"""TabPane with operation bindings and mechanism to handle with message to mount/unmount action."""
DEFAULT_CSS = get_css_from_relative_path(__file__)
@on(GovernanceTableRow.ChangeActionStatus)
async def change_action_status(self, event: GovernanceTableRow.ChangeActionStatus) -> None:
actions = self.query_one(GovernanceActions) # type: ignore[type-abstract]
......
GovernanceTabPane Static {
text-style: bold;
text-align: center;
}
GovernanceTabPane Button:focus {
text-style: bold reverse;
}
......@@ -17,6 +17,7 @@ from clive.__private.abstract_class import AbstractClassMessagePump
from clive.__private.core.commands.data_retrieval.proposals_data import Proposal as ProposalData
from clive.__private.core.commands.data_retrieval.witnesses_data import WitnessData
from clive.__private.ui.data_providers.abc.data_provider import DataProvider
from clive.__private.ui.get_css import get_css_from_relative_path
from clive.__private.ui.operations.governance_operations.governance_checkbox import GovernanceCheckbox
from clive.__private.ui.widgets.clive_widget import CliveWidget
......@@ -211,7 +212,7 @@ class GovernanceTableRow(Grid, CliveWidget, Generic[GovernanceDataT], AbstractCl
def is_already_in_actions_container(self) -> bool:
"""Should check if operation is already in the action container."""
try:
self.app.query_one(self.get_action_row_id())
self.app.get_widget_by_id(self.get_action_row_id())
except NoMatches:
return False
else:
......@@ -232,6 +233,7 @@ class GovernanceTable(
):
MAX_ELEMENTS_ON_PAGE: ClassVar[int] = 10
DEFAULT_CSS = get_css_from_relative_path(__file__)
BINDINGS = [
Binding("pageup", "previous_page", "PgDn"),
Binding("pagedown", "next_page", "PgUp"),
......
GovernanceTableRow:focus {
background: rgba(0, 0, 0, 1);
}
GovernanceTableRow.dimmed {
opacity: 0.7;
}
GovernanceListWidget {
height: auto;
}
$governance-green-color: $success-darken-3;
$governance-red-color: $error;
$table-info-headline: $accent-lighten-1;
$table-header-contrast-column: $warning-darken-2;
Governance Tab {
width: 1fr;
}
Governance CliveTabbedContent Static {
text-style: bold;
text-align: center;
}
Governance Button:focus {
text-style: bold reverse;
}
Governance GovernanceTableRow:focus {
background: rgba(0, 0, 0, 1);
}
Governance GovernanceTableRow.dimmed {
opacity: 0.7;
}
Governance GovernanceListWidget {
height: auto;
}
Governance GovernanceActions {
margin-left: 1;
width: 3fr;
}
Governance GovernanceActionRow {
height: auto;
}
Governance GovernanceActionRow .action-vote {
background: $governance-green-color;
}
Governance GovernanceActionRow .action-unvote {
background: $governance-red-color;
}
Governance GovernanceActionRow .action-pending {
background: $panel-lighten-3;
}
Governance #name-and-action {
height: auto;
}
Governance .vote-actions {
width: 1fr;
height: auto;
max-height: 32;
}
Governance #action-row {
background: $table-header-contrast-column;
width: 1fr;
}
Governance #actions-header {
background: $table-info-headline;
}
DetailsScreen {
align: center middle;
height: auto;
......
......@@ -3,10 +3,11 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from textual import on
from textual.containers import Container, Horizontal, ScrollableContainer
from textual.containers import Container, Horizontal
from textual.widgets import Button, Static, TabPane
from clive.__private.ui.get_css import get_css_from_relative_path
from clive.__private.ui.operations.governance_operations.common_governance.governance_tab_pane import ScrollablePart
from clive.__private.ui.operations.raw.account_witness_proxy.account_witness_proxy import AccountWitnessProxy
from clive.__private.ui.widgets.clive_button import CliveButton
from clive.__private.ui.widgets.clive_widget import CliveWidget
......@@ -17,32 +18,18 @@ if TYPE_CHECKING:
from textual.app import ComposeResult
class ScrollablePart(ScrollableContainer, can_focus=False):
pass
class Proxy(TabPane, CliveWidget):
"""TabPane with all content about proxy."""
class ProxyBaseContainer(Container):
"""Base widget for the ProxyNotSet and ProxySet container to properly catch both by the query_one."""
DEFAULT_CSS = get_css_from_relative_path(__file__)
def __init__(self, title: TextType):
super().__init__(title=title)
self.__proxy_input = AccountNameInput()
self.__current_proxy = self.app.world.profile_data.working_account.data.proxy
class ProxyInput(AccountNameInput):
pass
@property
def new_proxy(self) -> str | None:
return self.__proxy_input.value
class ProxyNotSet(ProxyBaseContainer):
def compose(self) -> ComposeResult:
content = self.__compose_proxy_set if self.__current_proxy else self.__compose_proxy_not_set
with ScrollablePart():
yield from content()
def __compose_proxy_not_set(self) -> ComposeResult:
yield AccountNameInput(label="current proxy", value="Not set", disabled=True)
yield self.__proxy_input
yield ProxyInput()
with Container(id="set-button-container"):
yield CliveButton("Set proxy", id_="set-proxy-button")
yield Static(
......@@ -50,20 +37,72 @@ class Proxy(TabPane, CliveWidget):
id="proxy-set-information",
)
def __compose_proxy_set(self) -> ComposeResult:
yield AccountNameInput(label="current proxy", value=self.__current_proxy, disabled=True)
yield self.__proxy_input
class ProxySet(ProxyBaseContainer):
def __init__(self, current_proxy: str) -> None:
"""
Initialize the ProxySet Container.
Args:
----
current_proxy: Proxy that is currently assigned to the account.
"""
super().__init__()
self._current_proxy = current_proxy
def compose(self) -> ComposeResult:
yield AccountNameInput(label="current proxy", value=self._current_proxy, disabled=True)
yield ProxyInput()
with Horizontal(id="modify-proxy-buttons"):
yield CliveButton("Change proxy", id_="set-proxy-button")
yield CliveButton("Remove proxy", id_="remove-proxy-button")
class Proxy(TabPane, CliveWidget):
"""TabPane with all content about proxy."""
DEFAULT_CSS = get_css_from_relative_path(__file__)
def __init__(self, title: TextType):
super().__init__(title=title)
self._current_proxy = self.app.world.profile_data.working_account.data.proxy
def on_mount(self) -> None:
self.watch(self.app.world, "profile_data", self.sync_when_proxy_changed)
@property
def new_proxy(self) -> str | None:
return self.query_one(ProxyInput).value
def compose(self) -> ComposeResult:
content = ProxySet(self._current_proxy) if self._current_proxy else ProxyNotSet()
with ScrollablePart():
yield content
@on(Button.Pressed, "#set-proxy-button")
def set_new_proxy(self) -> None:
if not self.new_proxy:
return
working_account_name = self.app.world.profile_data.working_account.name
if self.new_proxy == working_account_name:
self.notify("You cannot set the proxy on yourself!", severity="error")
return
self.app.push_screen(AccountWitnessProxy(is_raw=False, new_proxy=self.new_proxy))
@on(Button.Pressed, "#remove-proxy-button")
def remove_proxy(self) -> None:
self.app.push_screen(AccountWitnessProxy(is_raw=False))
def sync_when_proxy_changed(self) -> None:
proxy_profile_data = self.app.world.profile_data.working_account.data.proxy
if self._current_proxy != proxy_profile_data:
self._current_proxy = proxy_profile_data
content = ProxySet(self._current_proxy) if self._current_proxy else ProxyNotSet()
with self.app.batch_update():
self.query_one(ProxyBaseContainer).remove()
self.query_one(ScrollablePart).mount(content)
$governance-green-color: $success-darken-3;
$governance-red-color: $error;
Proxy {
height: auto;
}
Proxy .current-proxy-static {
background: $accent-lighten-1;
width: 1fr;
......@@ -10,7 +14,7 @@ Proxy .current-proxy-static {
Proxy AccountNameInput {
margin-top: 1;
margin-bottom: 1;
height: 3;
height: auto;
}
Proxy #set-button-container {
......@@ -23,7 +27,9 @@ Proxy #set-proxy-button {
}
Proxy #proxy-set-information {
text-style: bold;
background: $accent-lighten-2;
text-align: center;
}
Proxy #modify-proxy-buttons {
......@@ -40,3 +46,11 @@ Proxy #remove-proxy-button {
margin-left: 3;
background: $governance-red-color;
}
ProxyNotSet {
height: auto;
}
ProxySet {
height: auto;
}