Skip to content

Commit 12ab60b

Browse files
author
Óscar Nájera
committed
Use standard site Autocompleter
1 parent 437d17c commit 12ab60b

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/components/site.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,15 @@ import { AsyncAutocomplete, vsAutocomplete } from './fields';
1616
import { get, update } from 'lodash';
1717

1818
export const SiteFilter = (props: EditorProps) => {
19-
const getSites = (inputValue: string) =>
20-
props.datasource
21-
.doRequest({ refId: 'siteQuery', params: { action: 'get_user_sites' }, context: {} })
22-
.then((response) =>
23-
response.data.result
24-
.filter(([_, text]: [string, string]) => text.toLowerCase().includes(inputValue.toLowerCase()))
25-
.map(([value, text]: [string, string]) => ({ label: text, value: value }))
26-
)
27-
.then((sites) => [{ label: 'All Sites', value: '' }, ...sites]);
19+
const sitesVS = { ident: 'sites', params: { strict: false, context: props.query.context } };
2820

2921
return (
3022
<InlineField labelWidth={14} label="Site">
31-
<AsyncAutocomplete autocompleter={getSites} contextPath="context.siteopt.site" {...props} />
23+
<AsyncAutocomplete
24+
autocompleter={vsAutocomplete(props.datasource, sitesVS)}
25+
contextPath="context.siteopt.site"
26+
{...props}
27+
/>
3228
</InlineField>
3329
);
3430
};

0 commit comments

Comments
 (0)