Skip to content

Commit

Permalink
add search feature dynamically
Browse files Browse the repository at this point in the history
Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
  • Loading branch information
ytausch and jaimergp committed Nov 4, 2024
1 parent 276f8ee commit b056194
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
25 changes: 16 additions & 9 deletions conda_metadata_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import streamlit as st

from conda_metadata_app.app_config import AppConfig

"""
If deploying a streamlit app as a Python module, we cannot use
the automatic pages/ subpages. Instead, we need to define the
Expand All @@ -10,15 +12,20 @@

pages_dir = Path(__file__).parent / "pages"

main_page = st.Page(
pages_dir / "main_page.py",
title="app",
)
pages = [
st.Page(
pages_dir / "main_page.py",
title="app",
)
]

search_by_file_path_page = st.Page(
pages_dir / "search_by_file_path_page.py",
title="Search By File Path",
)
if AppConfig().enable_filepath_search:
pages.append(
st.Page(
pages_dir / "search_by_file_path_page.py",
title="Search By File Path",
)
)

pg = st.navigation([main_page, search_by_file_path_page])
pg = st.navigation(pages)
pg.run()
4 changes: 0 additions & 4 deletions conda_metadata_app/pages/search_by_file_path_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ def find_artifacts_by_path(path):
initial_sidebar_state="collapsed",
)

if not AppConfig().enable_filepath_search:
st.error("File path search is disabled in the app configuration.")
st.stop()

c1, c2 = st.columns([1, 0.25])
with c1:
path_to_search = st_searchbox(
Expand Down
Binary file removed docs/assets/filepath_search_disabled_dark.png
Binary file not shown.
Binary file removed docs/assets/filepath_search_disabled_light.png
Binary file not shown.
6 changes: 1 addition & 5 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ If enabled, the file path search looks like this:
![File Path Search](assets/filepath_search_enabled_dark.png#gh-dark-mode-only)
![File Path Search](assets/filepath_search_enabled_light.png#gh-light-mode-only)

Due to limitations of Streamlit, disabling this feature will not remove the search bar from the sidebar.
Instead, it will show a message that the feature is disabled:

![File Path Search Disabled](assets/filepath_search_disabled_dark.png#gh-dark-mode-only)
![File Path Search Disabled](assets/filepath_search_disabled_light.png#gh-light-mode-only)
Disabling the file path search feature will remove it from the sidebar.

## Configuring Channels

Expand Down

0 comments on commit b056194

Please sign in to comment.