Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/error when switching spaces #110

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions web/admin_docs.py

This file was deleted.

2 changes: 0 additions & 2 deletions web/admin_spaces.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Page: Admin / Manage Documents."""
import streamlit as st
from st_pages import add_page_title
from utils.layout import admin_docs_ui, auth_required, create_space_ui

Expand All @@ -8,7 +7,6 @@
add_page_title()

PARAM_NAME = "sid"
st.session_state["admin_docs_alert"] = st.empty()

## Create Space UI
create_space_ui()
Expand Down
15 changes: 2 additions & 13 deletions web/utils/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,7 @@ def create_space_ui(expanded: bool = False) -> None:
if ds:
_render_space_data_source_config_input_fields(ds, "create_space_")
if st.button("Create Space"):
space = handle_create_space()
alert: DeltaGenerator = st.session_state["admin_docs_alert"]
if isinstance(space, SpaceKey) and alert:
alert.success(f"Successfully created space with ID: {space.id_}")
st.session_state["admin_docs_active_space"] = space.id_
elif alert:
alert.error(f"Failed to create space. Error: {space}")
handle_create_space()


def _render_view_space_details_with_container(
Expand Down Expand Up @@ -843,9 +837,6 @@ def admin_docs_ui(q_param: str = None) -> None:
if spaces:
st.subheader("Select a space from below:")

def _on_change() -> None:
del st.session_state["admin_docs_active_space"]

try: # Get the space id from the query param with prefence to the newly created space.
_sid = (
int(st.experimental_get_query_params()[q_param][0])
Expand All @@ -854,14 +845,12 @@ def _on_change() -> None:
)
except ValueError:
_sid = None
new_space = st.session_state.get("admin_docs_active_space", _sid)
default_sid = next((i for i, s in enumerate(spaces) if s[0] == new_space), None)
default_sid = next((i for i, s in enumerate(spaces) if s[0] == _sid), None)

selected = st.selectbox(
"Spaces",
spaces,
format_func=lambda x: x[2],
on_change=_on_change,
label_visibility="collapsed",
index=default_sid if default_sid else 0,
)
Expand Down