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:
@@ -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;
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user