feat: check if there are labels

Aien Saidi created

Change summary

webui/src/pages/list/FilterToolbar.tsx | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)

Detailed changes

webui/src/pages/list/FilterToolbar.tsx 🔗

@@ -65,7 +65,7 @@ function FilterToolbar({ query, queryLocation }: Props) {
   const classes = useStyles();
   const params: Query = parse(query);
   const { data: identitiesData } = useListIdentitiesQuery();
-  const { data: labelsData } = useListLabelsQuery()
+  const { data: labelsData } = useListLabelsQuery();
 
   let identities: any = [];
   let labels: any = [];
@@ -153,13 +153,15 @@ function FilterToolbar({ query, queryLocation }: Props) {
       >
         Author
       </FilterDropdown>
-      <FilterDropdown
-        dropdown={labels}
-        itemActive={(key) => hasValue('label', key)}
-        to={(key) => pipe(replaceParam('label', key), loc)(params)}
-      >
-        Label
-      </FilterDropdown>
+      {labels.length ? (
+        <FilterDropdown
+          dropdown={labels}
+          itemActive={(key) => hasValue('label', key)}
+          to={(key) => pipe(replaceParam('label', key), loc)(params)}
+        >
+          Label
+        </FilterDropdown>
+      ) : null}
       <FilterDropdown
         dropdown={[
           ['id', 'ID'],