Add support for providing values and labels to the search filters

Signed-off-by: Gustaf Räntilä <g.rantila@gmail.com>
This commit is contained in:
Gustaf Räntilä
2025-02-06 14:17:05 +01:00
parent 92013bfee9
commit 611c941d8e
10 changed files with 152 additions and 34 deletions
@@ -148,15 +148,18 @@ export const SearchModal = ({ toggleModal }: { toggleModal: () => void }) => {
values={async () => {
// Return a list of entities which are documented.
const { items } = await catalogApi.getEntities({
fields: ['metadata.name'],
fields: ['metadata.name', 'metadata.title'],
filter: {
'metadata.annotations.backstage.io/techdocs-ref':
CATALOG_FILTER_EXISTS,
},
});
const names = items.map(entity => entity.metadata.name);
names.sort();
const names = items.map(entity => ({
value: entity.metadata.name,
label: entity.metadata.title ?? entity.metadata.name,
}));
names.sort((a, b) => a.label.localeCompare(b.label));
return names;
}}
/>
@@ -97,15 +97,18 @@ const SearchPage = () => {
values={async () => {
// Return a list of entities which are documented.
const { items } = await catalogApi.getEntities({
fields: ['metadata.name'],
fields: ['metadata.name', 'metadata.title'],
filter: {
'metadata.annotations.backstage.io/techdocs-ref':
CATALOG_FILTER_EXISTS,
},
});
const names = items.map(entity => entity.metadata.name);
names.sort();
const names = items.map(entity => ({
value: entity.metadata.name,
label: entity.metadata.title ?? entity.metadata.name,
}));
names.sort((a, b) => a.label.localeCompare(b.label));
return names;
}}
/>