76 lines
3.1 KiB
Python
76 lines
3.1 KiB
Python
from textual.screen import Screen
|
|
from textual.app import ComposeResult
|
|
from textual.widgets import Input, Select, Static, DataTable, ContentSwitcher, Tabs, Tab, Button
|
|
from textual.containers import VerticalGroup, Vertical, HorizontalGroup, Right
|
|
|
|
from widgets import Navbar
|
|
|
|
import requests
|
|
|
|
|
|
class RepoViewScreen(Screen):
|
|
CSS_PATH = "../assets/repo_view_screen.tcss"
|
|
|
|
def __init__(self, owner_name: str, repo_name: str):
|
|
super().__init__()
|
|
self.owner_name = owner_name
|
|
self.repo_name = repo_name
|
|
|
|
def compose(self) -> ComposeResult:
|
|
|
|
# get repo data via a request
|
|
response = requests.get(
|
|
url=self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}"
|
|
)
|
|
if not response.ok:
|
|
self.notify(response.text, title="Failed to get repo:", severity="error")
|
|
yield Navbar()
|
|
return
|
|
data = response.json()
|
|
|
|
|
|
yield Navbar()
|
|
|
|
with VerticalGroup(id="top"):
|
|
with HorizontalGroup():
|
|
yield Static(f" {self.owner_name}/[b]{self.repo_name}[/]", id="title")
|
|
with Right(id="buttons"):
|
|
yield Button("Star [d](0)", variant="warning", flat=True)
|
|
yield Button("Watch [d](0)", flat=True)
|
|
yield Tabs(
|
|
"\uf44f Code",
|
|
"\uebf8 Issues",
|
|
"\ue726 Pull Requests",
|
|
"\uf500 Actions",
|
|
"\ueb29 Packages",
|
|
"\uf502 Projects",
|
|
"\uf02b Releases",
|
|
"\ueaa4 Wiki",
|
|
"\uf21e Activity"
|
|
)
|
|
|
|
with ContentSwitcher(initial="Code"):
|
|
with HorizontalGroup(id="Code"):
|
|
with Vertical(id="commits"):
|
|
with HorizontalGroup(id="branch-info"):
|
|
yield Static("\uf4b6 1 Commits")
|
|
yield Static("\uf418 1 Branch")
|
|
yield Static("\uf02b 0 Tags")
|
|
|
|
with HorizontalGroup(id="branch-options"):
|
|
yield Select.from_values([
|
|
"main"
|
|
], allow_blank=False, id="branch")
|
|
yield Button("\ue726", flat=True, id="new-pull-request", tooltip="New Pull Request")
|
|
yield Button("Go to file", flat=True)
|
|
|
|
table = DataTable(id="files", show_cursor=False)
|
|
table.add_columns("SpookyDervish [r]9b32c417e9[/]", "switched from tabs to spaces", "51 minutes ago")
|
|
table.add_row("\ue5ff screens", "[d]switched from tabs to spaces", "[d]51 minutes ago")
|
|
yield table
|
|
with Vertical(id="repo-info"):
|
|
with HorizontalGroup():
|
|
yield Input("Search code...", id="search-query")
|
|
yield Button("\uf002", flat=True, id="search-btn")
|
|
yield Static("\n[b] Description")
|
|
yield Static("[d]" + data["description"], id="description") |