diff --git a/ragna/deploy/_ui/components/metadata_filters_builder.py b/ragna/deploy/_ui/components/metadata_filters_builder.py index 5307d32d..b1a11c5b 100644 --- a/ragna/deploy/_ui/components/metadata_filters_builder.py +++ b/ragna/deploy/_ui/components/metadata_filters_builder.py @@ -11,7 +11,7 @@ ] NO_CORPUS_KEY = "No corpuses available" -NO_FILTER_KEY = "Empty Filter" +NO_FILTER_KEY = "" class FilterRow(pn.viewable.Viewer): @@ -146,15 +146,11 @@ def __init__(self, corpus_metadata, **params): self.corpus_metadata = corpus_metadata - self.filter_rows = self.create_filter_row() - self.add_filter_row_button = pn.widgets.ButtonIcon( icon="circle-plus", width=25, height=25 ) self.add_filter_row_button.on_click(self.add_filter_row) - self.corpus_names_select.param.watch(self.reset_filter_rows, "value") - def create_filter_row(self): return [ FilterRow( @@ -167,17 +163,10 @@ def create_filter_row(self): ) ] - def reset_filter_rows(self, event=None): - self.filter_rows = self.create_filter_row() - def add_filter_row(self, event): self.filter_rows = self.filter_rows + self.create_filter_row() def delete_filter_row(self, event): - if len(self.filter_rows) == 1: - self.reset_filter_rows() - return - filter_row_to_remove = None for filter_row in self.filter_rows: if event.obj == filter_row.delete_button: @@ -207,6 +196,13 @@ def construct_metadata_filters(self): return MetadataFilter.and_(metadata_filters).to_primitive() def __panel__(self): + if len(self.corpus_names) == 0: + return pn.Column( + pn.pane.HTML("No corpus available for selected source storage"), + sizing_mode="stretch_both", + height_policy="max", + ) + return pn.Column( self.corpus_names_select, pn.pane.HTML("Metadata Filters"), diff --git a/ragna/deploy/_ui/modal_configuration.py b/ragna/deploy/_ui/modal_configuration.py index 160c50e4..6acf3a33 100644 --- a/ragna/deploy/_ui/modal_configuration.py +++ b/ragna/deploy/_ui/modal_configuration.py @@ -464,7 +464,12 @@ def corpus_or_upload_row(self): corpus_names=corpus_names, corpus_metadata=corpus_metadata ) - data = pn.Column(self.metadata_filter_rows_title, self.metadata_filter_rows) + if len(corpus_names) > 0: + data = pn.Column( + self.metadata_filter_rows_title, self.metadata_filter_rows + ) + else: + data = pn.Column(self.metadata_filter_rows) self.error = False return data