-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use basic project configuration file * Refactor TabbedContents * Upgrade Terminal Component * Update design * Add project custom command setup * Init Sidebar * Move composer customer script to sidebar and refactor composer action messages * Setup project custom action group
- Loading branch information
Showing
23 changed files
with
446 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .terminal_modal import TerminalModal | ||
from .terminal import Terminal | ||
from .terminal import Terminal, ShellCommand, NonShellCommand, CommandType | ||
from .sidebar import Sidebar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from textual import on | ||
from textual.widgets import OptionList | ||
from textual.widgets.option_list import Option | ||
|
||
from models import Project | ||
from models.project import ProjectAction | ||
from .terminal import ShellCommand, NonShellCommand, CommandType | ||
from .message import TerminalCommandRequested | ||
|
||
|
||
class ActionOptionList(OptionList): | ||
# BORDER_TITLE = "Commands" | ||
|
||
# def __init__(self, project: Project, **kwargs): | ||
def __init__( | ||
self, | ||
project: Project, | ||
actions: list[ProjectAction], | ||
group_name: str = "Commands", | ||
**kwargs | ||
): | ||
self._project: Project = project | ||
self._actions: list[ProjectAction] = actions | ||
super().__init__(*(Option(action.label) for action in self._actions), **kwargs) | ||
self.border_title = group_name | ||
|
||
@on(OptionList.OptionSelected) | ||
def on_script_selected(self, event: OptionList.OptionSelected) -> None: | ||
action = self._actions[event.option_index] | ||
command: CommandType = ( | ||
ShellCommand(path=self._project.path, command=action.command) | ||
if action.use_shell | ||
else NonShellCommand( | ||
path=self._project.path, command=action.command.split(" ") | ||
) | ||
) | ||
self.post_message(TerminalCommandRequested(command=command)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from textual.message import Message | ||
|
||
from .terminal import CommandType | ||
|
||
|
||
class TerminalCommandRequested(Message): | ||
def __init__( | ||
self, | ||
command: CommandType, | ||
allow_rerun: bool = True, | ||
): | ||
self.command = command | ||
self.allow_rerun = allow_rerun | ||
super().__init__() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from textual.app import ComposeResult | ||
from textual.containers import Container | ||
from textual.widgets import OptionList | ||
from textual.widgets.option_list import Option, Separator | ||
|
||
|
||
from models import Project | ||
from presentation.component.action_option_list import ActionOptionList | ||
from presentation.composer.composer_script_option_list import ComposerScriptOptionList | ||
from service_locator import ServiceContainer | ||
|
||
|
||
class Sidebar(Container): | ||
DEFAULT_CSS = """ | ||
Sidebar { | ||
width: 30; | ||
height: 100%; | ||
dock: left; | ||
background: $background; | ||
layer: sidebar; | ||
} | ||
Sidebar.-hidden { | ||
display: none; | ||
} | ||
""" | ||
|
||
def __init__(self, project: Project, **kwargs): | ||
self.project = project | ||
super().__init__(**kwargs) | ||
self.add_class("-hidden") | ||
|
||
def compose(self) -> ComposeResult: | ||
|
||
if len(ServiceContainer.composer_client().scripts(self.project)) > 0: | ||
yield ComposerScriptOptionList(self.project) | ||
if self.project.actions is None: | ||
return | ||
for action_group, actions in self.project.actions.items(): | ||
if len(actions) > 0: | ||
yield ActionOptionList( | ||
project=self.project, actions=actions, group_name=action_group | ||
) | ||
# yield ActionOptionList(project=self.project) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .composer_container import ComposerContainer | ||
from .composer_message import ComposerCommandRequested |
Oops, something went wrong.