Skip to content

Commit

Permalink
Add config for showing/hiding collection browser ons tartup
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Sep 8, 2024
1 parent e389048 commit 44dd509
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
Binary file modified .coverage
Binary file not shown.
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## 1.13.0 [8th September 2024]

### Added

- New `collection_browser.show_on_startup` config to control whether the collection browser is shown on startup.
- Watch for changes to loaded dotenv files and reload UI elements that depend on them when they change.

### Changed

- Upgraded all dependencies
Expand Down
1 change: 1 addition & 0 deletions docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ The table below lists all available configuration options and their environment
| `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. |
| `collection_browser.show_on_startup` (`POSTING_COLLECTION_BROWSER__SHOW_ON_STARTUP`) | `true`, `false` (Default: `true`) | Show/hide the collection browser on startup. Can always be toggled using the command palette. |
| `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
2 changes: 1 addition & 1 deletion docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This introduction will show you how to create a simple POST request to the [JSON

A *collection* is simply a directory which may contain requests saved by Posting.

If you launch Posting without specifying a collection, any requests you create will be saved in the "default" collection.
If you launch Posting without specifying a collection, any requests you create will be saved in the `"default"` collection.
This is a directory reserved by Posting on your filesystem, and unrelated to the directory you launched Posting from.

This is fine for quick throwaway requests, but you'll probably want to create a new collection for each project you work on so that you can check it into version control.
Expand Down
13 changes: 5 additions & 8 deletions src/posting/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ def compose(self) -> ComposeResult:
yield AppHeader()
yield UrlBar()
with AppBody():
yield CollectionBrowser(collection=self.collection)
collection_browser = CollectionBrowser(collection=self.collection)
collection_browser.display = (
self.settings.collection_browser.show_on_startup
)
yield collection_browser
yield RequestEditor()
yield ResponseArea()
yield Footer(show_command_palette=False)
Expand Down Expand Up @@ -677,13 +681,6 @@ def get_default_screen(self) -> MainScreen:
layout=self.settings.layout,
environment_files=self.environment_files,
)
if not self.collection_specified:
self.notify(
"Using the default collection directory.",
title="No collection specified",
severity="warning",
timeout=7,
)
return self.main_screen

def get_css_variables(self) -> dict[str, str]:
Expand Down
3 changes: 3 additions & 0 deletions src/posting/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ class CollectionBrowserSettings(BaseModel):
position: Literal["left", "right"] = Field(default="left")
"""The position of the collection browser on screen."""

show_on_startup: bool = Field(default=True)
"""If enabled, the collection browser will be shown on startup."""


class Settings(BaseSettings):
model_config = SettingsConfigDict(
Expand Down

0 comments on commit 44dd509

Please sign in to comment.