Skip to content

Commit

Permalink
Add config for collection browser position
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Aug 11, 2024
1 parent d877cbf commit 79a63a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ Dotenv files are separate from collections, although you may wish to include the
| `heading.show_host` (`POSTING_HEADING__SHOW_HOST`) | `true`, `false` (Default: `true`) | Show/hide the hostname in the app header. |
| `heading.show_version` (`POSTING_HEADING__SHOW_VERSION`) | `true`, `false` (Default: `true`) | Show/hide the version in the app header. |
| `url_bar.show_value_preview` (`POSTING_URL_BAR__SHOW_VALUE_PREVIEW`) | `true`, `false` (Default: `true`) | Show/hide the variable value preview below the URL bar. |
| `collection_browser.position` (`POSTING_COLLECTION_BROWSER__POSITION`) | `"left"`, `"right"` (Default: `"left"`) | The position of the collection browser on screen. |
| `pager` (`POSTING_PAGER`) | (Default: `$PAGER`) | Command to use for paging text. |
| `pager_json` (`POSTING_PAGER_JSON`) | (Default: `$PAGER`) | Command to use for paging JSON. |
| `editor` (`POSTING_EDITOR`) | (Default: `$EDITOR`) | Command to use for opening files in an external editor. |
Expand Down
12 changes: 12 additions & 0 deletions src/posting/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ class CommandPaletteSettings(BaseModel):
"""If enabled, the command palette will display a preview of the selected theme when the cursor is over it."""


class CollectionBrowserSettings(BaseModel):
"""Configuration for the collection browser."""

position: Literal["left", "right"] = Field(default="left")
"""The position of the collection browser on screen."""


class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_file=".env",
Expand Down Expand Up @@ -130,6 +137,11 @@ class Settings(BaseSettings):
url_bar: UrlBarSettings = Field(default_factory=UrlBarSettings)
"""Configuration for the URL bar."""

collection_browser: CollectionBrowserSettings = Field(
default_factory=CollectionBrowserSettings
)
"""Configuration for the collection browser."""

command_palette: CommandPaletteSettings = Field(
default_factory=CommandPaletteSettings
)
Expand Down
2 changes: 2 additions & 0 deletions src/posting/widgets/collection/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from textual.widgets.tree import TreeNode

from posting.collection import Collection, RequestModel
from posting.config import SETTINGS
from posting.help_screen import HelpData
from posting.widgets.collection.new_request_modal import (
NewRequestData,
Expand Down Expand Up @@ -435,6 +436,7 @@ def __init__(
self.collection = collection

def compose(self) -> ComposeResult:
self.styles.dock = SETTINGS.get().collection_browser.position
self.border_title = "Collection"
self.add_class("section")
collection = self.collection
Expand Down

0 comments on commit 79a63a2

Please sign in to comment.