@backstage/plugin-search 0.4.17 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/dist/esm/{index-3b720a86.esm.js → index-0a2fab21.esm.js} +2 -2
- package/dist/esm/index-0a2fab21.esm.js.map +1 -0
- package/dist/esm/{index-12477c15.esm.js → index-18219c65.esm.js} +2 -2
- package/dist/esm/index-18219c65.esm.js.map +1 -0
- package/dist/esm/{index-022e0330.esm.js → index-2a318193.esm.js} +2 -2
- package/dist/esm/index-2a318193.esm.js.map +1 -0
- package/dist/esm/{index-17c9e868.esm.js → index-655809db.esm.js} +184 -144
- package/dist/esm/index-655809db.esm.js.map +1 -0
- package/dist/esm/{index-597d3990.esm.js → index-a71e930d.esm.js} +2 -2
- package/dist/esm/index-a71e930d.esm.js.map +1 -0
- package/dist/esm/{index-226c47ca.esm.js → index-af05ea86.esm.js} +7 -7
- package/dist/esm/index-af05ea86.esm.js.map +1 -0
- package/dist/esm/index-d5ddea91.esm.js +23 -0
- package/dist/esm/index-d5ddea91.esm.js.map +1 -0
- package/dist/index.d.ts +66 -25
- package/dist/index.esm.js +1 -1
- package/package.json +15 -14
- package/dist/esm/index-022e0330.esm.js.map +0 -1
- package/dist/esm/index-12477c15.esm.js.map +0 -1
- package/dist/esm/index-17c9e868.esm.js.map +0 -1
- package/dist/esm/index-226c47ca.esm.js.map +0 -1
- package/dist/esm/index-3b720a86.esm.js.map +0 -1
- package/dist/esm/index-597d3990.esm.js.map +0 -1
- package/dist/esm/index-b3bf028c.esm.js +0 -60
- package/dist/esm/index-b3bf028c.esm.js.map +0 -1
|
@@ -3,7 +3,7 @@ import { ResponseError } from '@backstage/errors';
|
|
|
3
3
|
import qs from 'qs';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import React__default, { createContext, useState, useCallback, useEffect, useContext } from 'react';
|
|
6
|
-
import { ListItem, ListItemText, Divider, makeStyles, IconButton, Typography, Card, CardHeader, Button, CardContent, Select, MenuItem, List, Checkbox, InputBase, InputAdornment, FormControl, FormLabel, FormControlLabel, InputLabel, Dialog, DialogTitle, Paper, DialogContent, Grid, DialogActions, Chip } from '@material-ui/core';
|
|
6
|
+
import { ListItem, ListItemIcon, ListItemText, Box, Divider, makeStyles, IconButton, Typography, Card, CardHeader, Button, CardContent, Select, MenuItem, List, Checkbox, InputBase, InputAdornment, FormControl, FormLabel, FormControlLabel, InputLabel, Dialog, DialogTitle, Paper, DialogContent, Grid, DialogActions, Chip } from '@material-ui/core';
|
|
7
7
|
import { Link, Progress, ResponseErrorPanel, EmptyState, Table, useQueryParamState, Page, Header, Content, SidebarSearchField } from '@backstage/core-components';
|
|
8
8
|
import FilterListIcon from '@material-ui/icons/FilterList';
|
|
9
9
|
import { usePrevious, useAsync, useDebounce, useEffectOnce } from 'react-use';
|
|
@@ -22,8 +22,7 @@ import { ENTITY_DEFAULT_NAMESPACE } from '@backstage/catalog-model';
|
|
|
22
22
|
import { useNavigate } from 'react-router-dom';
|
|
23
23
|
|
|
24
24
|
const searchApiRef = createApiRef({
|
|
25
|
-
id: "plugin.search.queryservice"
|
|
26
|
-
description: "Used to make requests against the search API"
|
|
25
|
+
id: "plugin.search.queryservice"
|
|
27
26
|
});
|
|
28
27
|
class SearchClient {
|
|
29
28
|
constructor(options) {
|
|
@@ -35,7 +34,7 @@ class SearchClient {
|
|
|
35
34
|
const queryString = qs.stringify(query);
|
|
36
35
|
const url = `${await this.discoveryApi.getBaseUrl("search/query")}?${queryString}`;
|
|
37
36
|
const response = await fetch(url, {
|
|
38
|
-
headers: token ? {Authorization: `Bearer ${token}`} : {}
|
|
37
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {}
|
|
39
38
|
});
|
|
40
39
|
if (!response.ok) {
|
|
41
40
|
throw await ResponseError.fromResponse(response);
|
|
@@ -44,19 +43,25 @@ class SearchClient {
|
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
const DefaultResultListItem$1 = ({
|
|
46
|
+
const DefaultResultListItem$1 = ({
|
|
47
|
+
result,
|
|
48
|
+
icon,
|
|
49
|
+
secondaryAction
|
|
50
|
+
}) => {
|
|
48
51
|
return /* @__PURE__ */ React__default.createElement(Link, {
|
|
49
52
|
to: result.location
|
|
50
53
|
}, /* @__PURE__ */ React__default.createElement(ListItem, {
|
|
51
|
-
alignItems: "
|
|
52
|
-
}, /* @__PURE__ */ React__default.createElement(ListItemText, {
|
|
53
|
-
primaryTypographyProps: {variant: "h6"},
|
|
54
|
+
alignItems: "center"
|
|
55
|
+
}, icon && /* @__PURE__ */ React__default.createElement(ListItemIcon, null, icon), /* @__PURE__ */ React__default.createElement(ListItemText, {
|
|
56
|
+
primaryTypographyProps: { variant: "h6" },
|
|
54
57
|
primary: result.title,
|
|
55
58
|
secondary: result.text
|
|
56
|
-
})
|
|
59
|
+
}), secondaryAction && /* @__PURE__ */ React__default.createElement(Box, {
|
|
60
|
+
alignItems: "flex-end"
|
|
61
|
+
}, secondaryAction)), /* @__PURE__ */ React__default.createElement(Divider, null));
|
|
57
62
|
};
|
|
58
63
|
|
|
59
|
-
const useStyles$
|
|
64
|
+
const useStyles$a = makeStyles((theme) => ({
|
|
60
65
|
filters: {
|
|
61
66
|
width: "250px",
|
|
62
67
|
display: "flex"
|
|
@@ -69,7 +74,7 @@ const FiltersButton$1 = ({
|
|
|
69
74
|
numberOfSelectedFilters,
|
|
70
75
|
handleToggleFilters
|
|
71
76
|
}) => {
|
|
72
|
-
const classes = useStyles$
|
|
77
|
+
const classes = useStyles$a();
|
|
73
78
|
return /* @__PURE__ */ React__default.createElement("div", {
|
|
74
79
|
className: classes.filters
|
|
75
80
|
}, /* @__PURE__ */ React__default.createElement(IconButton, {
|
|
@@ -81,7 +86,7 @@ const FiltersButton$1 = ({
|
|
|
81
86
|
}, "Filters (", numberOfSelectedFilters ? numberOfSelectedFilters : 0, ")"));
|
|
82
87
|
};
|
|
83
88
|
|
|
84
|
-
const useStyles$
|
|
89
|
+
const useStyles$9 = makeStyles((theme) => ({
|
|
85
90
|
filters: {
|
|
86
91
|
background: "transparent",
|
|
87
92
|
boxShadow: "0px 0px 0px 0px"
|
|
@@ -100,7 +105,7 @@ const Filters$1 = ({
|
|
|
100
105
|
updateSelected,
|
|
101
106
|
updateChecked
|
|
102
107
|
}) => {
|
|
103
|
-
const classes = useStyles$
|
|
108
|
+
const classes = useStyles$9();
|
|
104
109
|
return /* @__PURE__ */ React__default.createElement(Card, {
|
|
105
110
|
className: classes.filters
|
|
106
111
|
}, /* @__PURE__ */ React__default.createElement(CardHeader, {
|
|
@@ -170,6 +175,8 @@ const SearchContextProvider = ({
|
|
|
170
175
|
const [filters, setFilters] = useState(initialState.filters);
|
|
171
176
|
const [term, setTerm] = useState(initialState.term);
|
|
172
177
|
const [types, setTypes] = useState(initialState.types);
|
|
178
|
+
const [open, setOpen] = useState(false);
|
|
179
|
+
const toggleModal = useCallback(() => setOpen((prevState) => !prevState), []);
|
|
173
180
|
const prevTerm = usePrevious(term);
|
|
174
181
|
const result = useAsync(() => searchApi.query({
|
|
175
182
|
term,
|
|
@@ -196,6 +203,8 @@ const SearchContextProvider = ({
|
|
|
196
203
|
result,
|
|
197
204
|
filters,
|
|
198
205
|
setFilters,
|
|
206
|
+
open,
|
|
207
|
+
toggleModal,
|
|
199
208
|
term,
|
|
200
209
|
setTerm,
|
|
201
210
|
types,
|
|
@@ -219,70 +228,77 @@ const useSearch = () => {
|
|
|
219
228
|
};
|
|
220
229
|
|
|
221
230
|
const SearchBarBase = ({
|
|
222
|
-
value,
|
|
223
231
|
onChange,
|
|
232
|
+
onKeyDown,
|
|
224
233
|
onSubmit,
|
|
225
|
-
|
|
226
|
-
|
|
234
|
+
debounceTime = 200,
|
|
235
|
+
clearButton = true,
|
|
236
|
+
fullWidth = true,
|
|
237
|
+
value: defaultValue,
|
|
238
|
+
inputProps: defaultInputProps = {},
|
|
239
|
+
endAdornment: defaultEndAdornment,
|
|
240
|
+
...props
|
|
227
241
|
}) => {
|
|
228
242
|
const configApi = useApi(configApiRef);
|
|
229
|
-
const
|
|
243
|
+
const [value, setValue] = useState(defaultValue);
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
setValue((prevValue) => prevValue !== defaultValue ? defaultValue : prevValue);
|
|
246
|
+
}, [defaultValue]);
|
|
247
|
+
useDebounce(() => onChange(value), debounceTime, [value]);
|
|
248
|
+
const handleChange = useCallback((e) => {
|
|
249
|
+
setValue(e.target.value);
|
|
250
|
+
}, [setValue]);
|
|
251
|
+
const handleKeyDown = useCallback((e) => {
|
|
252
|
+
if (onKeyDown)
|
|
253
|
+
onKeyDown(e);
|
|
230
254
|
if (onSubmit && e.key === "Enter") {
|
|
231
255
|
onSubmit();
|
|
232
256
|
}
|
|
233
|
-
}, [onSubmit]);
|
|
234
|
-
const handleClear =
|
|
257
|
+
}, [onKeyDown, onSubmit]);
|
|
258
|
+
const handleClear = useCallback(() => {
|
|
235
259
|
onChange("");
|
|
236
260
|
}, [onChange]);
|
|
237
|
-
const placeholder =
|
|
261
|
+
const placeholder = `Search in ${configApi.getOptionalString("app.title") || "Backstage"}`;
|
|
262
|
+
const startAdornment = /* @__PURE__ */ React__default.createElement(InputAdornment, {
|
|
263
|
+
position: "start"
|
|
264
|
+
}, /* @__PURE__ */ React__default.createElement(IconButton, {
|
|
265
|
+
"aria-label": "Query",
|
|
266
|
+
disabled: true
|
|
267
|
+
}, /* @__PURE__ */ React__default.createElement(SearchIcon, null)));
|
|
268
|
+
const endAdornment = /* @__PURE__ */ React__default.createElement(InputAdornment, {
|
|
269
|
+
position: "end"
|
|
270
|
+
}, /* @__PURE__ */ React__default.createElement(IconButton, {
|
|
271
|
+
"aria-label": "Clear",
|
|
272
|
+
onClick: handleClear
|
|
273
|
+
}, /* @__PURE__ */ React__default.createElement(ClearButton, null)));
|
|
238
274
|
return /* @__PURE__ */ React__default.createElement(InputBase, {
|
|
239
275
|
"data-testid": "search-bar-next",
|
|
240
|
-
fullWidth: true,
|
|
241
|
-
placeholder,
|
|
242
276
|
value,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
endAdornment: /* @__PURE__ */ React__default.createElement(InputAdornment, {
|
|
252
|
-
position: "end"
|
|
253
|
-
}, /* @__PURE__ */ React__default.createElement(IconButton, {
|
|
254
|
-
"aria-label": "Clear",
|
|
255
|
-
onClick: handleClear
|
|
256
|
-
}, /* @__PURE__ */ React__default.createElement(ClearButton, null))),
|
|
257
|
-
...className && {className},
|
|
258
|
-
...onSubmit && {onKeyDown}
|
|
277
|
+
placeholder,
|
|
278
|
+
startAdornment,
|
|
279
|
+
endAdornment: clearButton ? endAdornment : defaultEndAdornment,
|
|
280
|
+
inputProps: { "aria-label": "Search", ...defaultInputProps },
|
|
281
|
+
fullWidth,
|
|
282
|
+
onChange: handleChange,
|
|
283
|
+
onKeyDown: handleKeyDown,
|
|
284
|
+
...props
|
|
259
285
|
});
|
|
260
286
|
};
|
|
261
|
-
const SearchBar$1 = ({
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
const [value, setValue] = useState(term);
|
|
268
|
-
useEffect(() => {
|
|
269
|
-
setValue((prevValue) => prevValue !== term ? term : prevValue);
|
|
270
|
-
}, [term]);
|
|
271
|
-
useDebounce(() => setTerm(value), debounceTime, [value]);
|
|
272
|
-
const handleQuery = (newValue) => {
|
|
273
|
-
setValue(newValue);
|
|
287
|
+
const SearchBar$1 = ({ onChange, ...props }) => {
|
|
288
|
+
const { term, setTerm } = useSearch();
|
|
289
|
+
const handleChange = (newValue) => {
|
|
290
|
+
setTerm(newValue);
|
|
291
|
+
if (onChange)
|
|
292
|
+
onChange(newValue);
|
|
274
293
|
};
|
|
275
|
-
const handleClear = () => setValue("");
|
|
276
294
|
return /* @__PURE__ */ React__default.createElement(SearchBarBase, {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
onClear: handleClear,
|
|
281
|
-
placeholder
|
|
295
|
+
value: term,
|
|
296
|
+
onChange: handleChange,
|
|
297
|
+
...props
|
|
282
298
|
});
|
|
283
299
|
};
|
|
284
300
|
|
|
285
|
-
const useStyles$
|
|
301
|
+
const useStyles$8 = makeStyles({
|
|
286
302
|
label: {
|
|
287
303
|
textTransform: "capitalize"
|
|
288
304
|
}
|
|
@@ -293,8 +309,8 @@ const CheckboxFilter = ({
|
|
|
293
309
|
defaultValue,
|
|
294
310
|
values = []
|
|
295
311
|
}) => {
|
|
296
|
-
const classes = useStyles$
|
|
297
|
-
const {filters, setFilters} = useSearch();
|
|
312
|
+
const classes = useStyles$8();
|
|
313
|
+
const { filters, setFilters } = useSearch();
|
|
298
314
|
useEffect(() => {
|
|
299
315
|
if (Array.isArray(defaultValue)) {
|
|
300
316
|
setFilters((prevFilters) => ({
|
|
@@ -305,13 +321,13 @@ const CheckboxFilter = ({
|
|
|
305
321
|
}, []);
|
|
306
322
|
const handleChange = (e) => {
|
|
307
323
|
const {
|
|
308
|
-
target: {value, checked}
|
|
324
|
+
target: { value, checked }
|
|
309
325
|
} = e;
|
|
310
326
|
setFilters((prevFilters) => {
|
|
311
|
-
const {[name]: filter, ...others} = prevFilters;
|
|
327
|
+
const { [name]: filter, ...others } = prevFilters;
|
|
312
328
|
const rest = (filter || []).filter((i) => i !== value);
|
|
313
329
|
const items = checked ? [...rest, value] : rest;
|
|
314
|
-
return items.length ? {...others, [name]: items} : others;
|
|
330
|
+
return items.length ? { ...others, [name]: items } : others;
|
|
315
331
|
});
|
|
316
332
|
};
|
|
317
333
|
return /* @__PURE__ */ React__default.createElement(FormControl, {
|
|
@@ -327,7 +343,7 @@ const CheckboxFilter = ({
|
|
|
327
343
|
control: /* @__PURE__ */ React__default.createElement(Checkbox, {
|
|
328
344
|
color: "primary",
|
|
329
345
|
tabIndex: -1,
|
|
330
|
-
inputProps: {"aria-labelledby": value},
|
|
346
|
+
inputProps: { "aria-labelledby": value },
|
|
331
347
|
value,
|
|
332
348
|
name: value,
|
|
333
349
|
onChange: handleChange,
|
|
@@ -343,8 +359,8 @@ const SelectFilter = ({
|
|
|
343
359
|
defaultValue,
|
|
344
360
|
values = []
|
|
345
361
|
}) => {
|
|
346
|
-
const classes = useStyles$
|
|
347
|
-
const {filters, setFilters} = useSearch();
|
|
362
|
+
const classes = useStyles$8();
|
|
363
|
+
const { filters, setFilters } = useSearch();
|
|
348
364
|
useEffect(() => {
|
|
349
365
|
if (typeof defaultValue === "string") {
|
|
350
366
|
setFilters((prevFilters) => ({
|
|
@@ -355,11 +371,11 @@ const SelectFilter = ({
|
|
|
355
371
|
}, []);
|
|
356
372
|
const handleChange = (e) => {
|
|
357
373
|
const {
|
|
358
|
-
target: {value}
|
|
374
|
+
target: { value }
|
|
359
375
|
} = e;
|
|
360
376
|
setFilters((prevFilters) => {
|
|
361
|
-
const {[name]: filter, ...others} = prevFilters;
|
|
362
|
-
return value ? {...others, [name]: value} : others;
|
|
377
|
+
const { [name]: filter, ...others } = prevFilters;
|
|
378
|
+
return value ? { ...others, [name]: value } : others;
|
|
363
379
|
});
|
|
364
380
|
};
|
|
365
381
|
return /* @__PURE__ */ React__default.createElement(FormControl, {
|
|
@@ -381,7 +397,7 @@ const SelectFilter = ({
|
|
|
381
397
|
value
|
|
382
398
|
}, value))));
|
|
383
399
|
};
|
|
384
|
-
const SearchFilter = ({component: Element, ...props}) => /* @__PURE__ */ React__default.createElement(Element, {
|
|
400
|
+
const SearchFilter = ({ component: Element, ...props }) => /* @__PURE__ */ React__default.createElement(Element, {
|
|
385
401
|
...props
|
|
386
402
|
});
|
|
387
403
|
SearchFilter.Checkbox = (props) => /* @__PURE__ */ React__default.createElement(SearchFilter, {
|
|
@@ -398,9 +414,9 @@ var Launch = createSvgIcon( /*#__PURE__*/React.createElement("path", {
|
|
|
398
414
|
d: "M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"
|
|
399
415
|
}), 'Launch');
|
|
400
416
|
|
|
401
|
-
const SearchResultComponent = ({children}) => {
|
|
417
|
+
const SearchResultComponent = ({ children }) => {
|
|
402
418
|
const {
|
|
403
|
-
result: {loading, error, value}
|
|
419
|
+
result: { loading, error, value }
|
|
404
420
|
} = useSearch();
|
|
405
421
|
if (loading) {
|
|
406
422
|
return /* @__PURE__ */ React__default.createElement(Progress, null);
|
|
@@ -417,20 +433,20 @@ const SearchResultComponent = ({children}) => {
|
|
|
417
433
|
title: "Sorry, no results were found"
|
|
418
434
|
});
|
|
419
435
|
}
|
|
420
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children({results: value.results}));
|
|
436
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children({ results: value.results }));
|
|
421
437
|
};
|
|
422
438
|
|
|
423
|
-
const useStyles$
|
|
439
|
+
const useStyles$7 = makeStyles((theme) => ({
|
|
424
440
|
root: {
|
|
425
441
|
display: "flex",
|
|
426
442
|
justifyContent: "space-between",
|
|
427
443
|
gap: theme.spacing(2),
|
|
428
|
-
margin: theme.spacing(
|
|
444
|
+
margin: theme.spacing(2, 0)
|
|
429
445
|
}
|
|
430
446
|
}));
|
|
431
447
|
const SearchResultPager = () => {
|
|
432
|
-
const {fetchNextPage, fetchPreviousPage} = useSearch();
|
|
433
|
-
const classes = useStyles$
|
|
448
|
+
const { fetchNextPage, fetchPreviousPage } = useSearch();
|
|
449
|
+
const classes = useStyles$7();
|
|
434
450
|
if (!fetchNextPage && !fetchPreviousPage) {
|
|
435
451
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
|
|
436
452
|
}
|
|
@@ -441,33 +457,29 @@ const SearchResultPager = () => {
|
|
|
441
457
|
"aria-label": "previous page",
|
|
442
458
|
disabled: !fetchPreviousPage,
|
|
443
459
|
onClick: fetchPreviousPage,
|
|
444
|
-
startIcon: /* @__PURE__ */ React__default.createElement(ArrowBackIosIcon, null)
|
|
445
|
-
|
|
446
|
-
}, "Back"), /* @__PURE__ */ React__default.createElement(Button, {
|
|
460
|
+
startIcon: /* @__PURE__ */ React__default.createElement(ArrowBackIosIcon, null)
|
|
461
|
+
}, "Previous"), /* @__PURE__ */ React__default.createElement(Button, {
|
|
447
462
|
"aria-label": "next page",
|
|
448
463
|
disabled: !fetchNextPage,
|
|
449
464
|
onClick: fetchNextPage,
|
|
450
|
-
endIcon: /* @__PURE__ */ React__default.createElement(ArrowForwardIosIcon, null)
|
|
451
|
-
size: "small"
|
|
465
|
+
endIcon: /* @__PURE__ */ React__default.createElement(ArrowForwardIosIcon, null)
|
|
452
466
|
}, "Next"));
|
|
453
467
|
};
|
|
454
468
|
|
|
455
469
|
const rootRouteRef = createRouteRef({
|
|
456
|
-
|
|
457
|
-
title: "search"
|
|
470
|
+
id: "search"
|
|
458
471
|
});
|
|
459
472
|
const rootNextRouteRef = createRouteRef({
|
|
460
|
-
|
|
461
|
-
title: "search"
|
|
473
|
+
id: "search:next"
|
|
462
474
|
});
|
|
463
475
|
const searchPlugin = createPlugin({
|
|
464
476
|
id: "search",
|
|
465
477
|
apis: [
|
|
466
478
|
createApiFactory({
|
|
467
479
|
api: searchApiRef,
|
|
468
|
-
deps: {discoveryApi: discoveryApiRef, identityApi: identityApiRef},
|
|
469
|
-
factory: ({discoveryApi, identityApi}) => {
|
|
470
|
-
return new SearchClient({discoveryApi, identityApi});
|
|
480
|
+
deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef },
|
|
481
|
+
factory: ({ discoveryApi, identityApi }) => {
|
|
482
|
+
return new SearchClient({ discoveryApi, identityApi });
|
|
471
483
|
}
|
|
472
484
|
})
|
|
473
485
|
],
|
|
@@ -478,58 +490,58 @@ const searchPlugin = createPlugin({
|
|
|
478
490
|
});
|
|
479
491
|
const SearchPage$1 = searchPlugin.provide(createRoutableExtension({
|
|
480
492
|
name: "SearchPage",
|
|
481
|
-
component: () => import('./index-
|
|
493
|
+
component: () => import('./index-0a2fab21.esm.js').then((m) => m.SearchPage),
|
|
482
494
|
mountPoint: rootRouteRef
|
|
483
495
|
}));
|
|
484
496
|
const SearchPageNext = searchPlugin.provide(createRoutableExtension({
|
|
485
497
|
name: "SearchPageNext",
|
|
486
|
-
component: () => import('./index-
|
|
498
|
+
component: () => import('./index-0a2fab21.esm.js').then((m) => m.SearchPage),
|
|
487
499
|
mountPoint: rootNextRouteRef
|
|
488
500
|
}));
|
|
489
501
|
searchPlugin.provide(createComponentExtension({
|
|
490
502
|
name: "SearchBar",
|
|
491
503
|
component: {
|
|
492
|
-
lazy: () => import('./index-
|
|
504
|
+
lazy: () => import('./index-d5ddea91.esm.js').then((m) => m.SearchBar)
|
|
493
505
|
}
|
|
494
506
|
}));
|
|
495
507
|
const SearchBarNext = searchPlugin.provide(createComponentExtension({
|
|
496
508
|
name: "SearchBarNext",
|
|
497
509
|
component: {
|
|
498
|
-
lazy: () => import('./index-
|
|
510
|
+
lazy: () => import('./index-d5ddea91.esm.js').then((m) => m.SearchBar)
|
|
499
511
|
}
|
|
500
512
|
}));
|
|
501
513
|
const SearchResult$1 = searchPlugin.provide(createComponentExtension({
|
|
502
514
|
name: "SearchResult",
|
|
503
515
|
component: {
|
|
504
|
-
lazy: () => import('./index-
|
|
516
|
+
lazy: () => import('./index-2a318193.esm.js').then((m) => m.SearchResult)
|
|
505
517
|
}
|
|
506
518
|
}));
|
|
507
519
|
searchPlugin.provide(createComponentExtension({
|
|
508
520
|
name: "SearchResultNext",
|
|
509
521
|
component: {
|
|
510
|
-
lazy: () => import('./index-
|
|
522
|
+
lazy: () => import('./index-2a318193.esm.js').then((m) => m.SearchResult)
|
|
511
523
|
}
|
|
512
524
|
}));
|
|
513
525
|
const SidebarSearchModal = searchPlugin.provide(createComponentExtension({
|
|
514
526
|
name: "SidebarSearchModal",
|
|
515
527
|
component: {
|
|
516
|
-
lazy: () => import('./index-
|
|
528
|
+
lazy: () => import('./index-af05ea86.esm.js').then((m) => m.SidebarSearchModal)
|
|
517
529
|
}
|
|
518
530
|
}));
|
|
519
531
|
const DefaultResultListItem = searchPlugin.provide(createComponentExtension({
|
|
520
532
|
name: "DefaultResultListItem",
|
|
521
533
|
component: {
|
|
522
|
-
lazy: () => import('./index-
|
|
534
|
+
lazy: () => import('./index-18219c65.esm.js').then((m) => m.DefaultResultListItem)
|
|
523
535
|
}
|
|
524
536
|
}));
|
|
525
|
-
const HomePageSearchBar = searchPlugin.provide(createComponentExtension({
|
|
537
|
+
const HomePageSearchBar$1 = searchPlugin.provide(createComponentExtension({
|
|
526
538
|
name: "HomePageSearchBar",
|
|
527
539
|
component: {
|
|
528
|
-
lazy: () => import('./index-
|
|
540
|
+
lazy: () => import('./index-a71e930d.esm.js').then((m) => m.HomePageSearchBar)
|
|
529
541
|
}
|
|
530
542
|
}));
|
|
531
543
|
|
|
532
|
-
const useStyles$
|
|
544
|
+
const useStyles$6 = makeStyles$1((theme) => ({
|
|
533
545
|
container: {
|
|
534
546
|
borderRadius: 30,
|
|
535
547
|
display: "flex",
|
|
@@ -538,26 +550,16 @@ const useStyles$5 = makeStyles$1((theme) => ({
|
|
|
538
550
|
input: {
|
|
539
551
|
flex: 1
|
|
540
552
|
},
|
|
541
|
-
paperFullWidth: {height: "calc(100% - 128px)"},
|
|
542
|
-
dialogActionsContainer: {padding: theme.spacing(1, 3)},
|
|
543
|
-
viewResultsLink: {verticalAlign: "0.5em"}
|
|
553
|
+
paperFullWidth: { height: "calc(100% - 128px)" },
|
|
554
|
+
dialogActionsContainer: { padding: theme.spacing(1, 3) },
|
|
555
|
+
viewResultsLink: { verticalAlign: "0.5em" }
|
|
544
556
|
}));
|
|
545
|
-
const Modal = ({open = true, toggleModal}) => {
|
|
557
|
+
const Modal = ({ open = true, toggleModal }) => {
|
|
546
558
|
const getSearchLink = useRouteRef(rootRouteRef);
|
|
547
|
-
const classes = useStyles$
|
|
548
|
-
const {term
|
|
549
|
-
const [value, setValue] = useState(term);
|
|
550
|
-
useEffect(() => {
|
|
551
|
-
setValue((prevValue) => prevValue !== term ? term : prevValue);
|
|
552
|
-
}, [term]);
|
|
553
|
-
useDebounce(() => setTerm(value), 1e3, [value]);
|
|
554
|
-
const handleQuery = (newValue) => {
|
|
555
|
-
setValue(newValue);
|
|
556
|
-
};
|
|
557
|
-
const handleClear = () => setValue("");
|
|
559
|
+
const classes = useStyles$6();
|
|
560
|
+
const { term } = useSearch();
|
|
558
561
|
const handleResultClick = () => {
|
|
559
562
|
toggleModal();
|
|
560
|
-
handleClear();
|
|
561
563
|
};
|
|
562
564
|
const handleKeyPress = () => {
|
|
563
565
|
handleResultClick();
|
|
@@ -573,11 +575,8 @@ const Modal = ({open = true, toggleModal}) => {
|
|
|
573
575
|
maxWidth: "lg"
|
|
574
576
|
}, /* @__PURE__ */ React__default.createElement(DialogTitle, null, /* @__PURE__ */ React__default.createElement(Paper, {
|
|
575
577
|
className: classes.container
|
|
576
|
-
}, /* @__PURE__ */ React__default.createElement(
|
|
577
|
-
className: classes.input
|
|
578
|
-
value,
|
|
579
|
-
onChange: handleQuery,
|
|
580
|
-
onClear: handleClear
|
|
578
|
+
}, /* @__PURE__ */ React__default.createElement(SearchBar$1, {
|
|
579
|
+
className: classes.input
|
|
581
580
|
}))), /* @__PURE__ */ React__default.createElement(DialogContent, null, /* @__PURE__ */ React__default.createElement(Grid, {
|
|
582
581
|
container: true,
|
|
583
582
|
direction: "row-reverse",
|
|
@@ -586,12 +585,13 @@ const Modal = ({open = true, toggleModal}) => {
|
|
|
586
585
|
}, /* @__PURE__ */ React__default.createElement(Grid, {
|
|
587
586
|
item: true
|
|
588
587
|
}, /* @__PURE__ */ React__default.createElement(Link, {
|
|
589
|
-
|
|
588
|
+
onClick: toggleModal,
|
|
589
|
+
to: `${getSearchLink()}?query=${term}`
|
|
590
590
|
}, /* @__PURE__ */ React__default.createElement("span", {
|
|
591
591
|
className: classes.viewResultsLink
|
|
592
592
|
}, "View Full Results"), /* @__PURE__ */ React__default.createElement(Launch, {
|
|
593
593
|
color: "primary"
|
|
594
|
-
})))), /* @__PURE__ */ React__default.createElement(Divider, null), /* @__PURE__ */ React__default.createElement(SearchResultComponent, null, ({results}) => /* @__PURE__ */ React__default.createElement(List, null, results.map(({document}) => /* @__PURE__ */ React__default.createElement("div", {
|
|
594
|
+
})))), /* @__PURE__ */ React__default.createElement(Divider, null), /* @__PURE__ */ React__default.createElement(SearchResultComponent, null, ({ results }) => /* @__PURE__ */ React__default.createElement(List, null, results.map(({ document }) => /* @__PURE__ */ React__default.createElement("div", {
|
|
595
595
|
role: "button",
|
|
596
596
|
tabIndex: 0,
|
|
597
597
|
key: `${document.location}-btn`,
|
|
@@ -610,14 +610,14 @@ const Modal = ({open = true, toggleModal}) => {
|
|
|
610
610
|
xs: 12
|
|
611
611
|
}, /* @__PURE__ */ React__default.createElement(SearchResultPager, null)))));
|
|
612
612
|
};
|
|
613
|
-
const SearchModal = ({open = true, toggleModal}) => {
|
|
613
|
+
const SearchModal = ({ open = true, toggleModal }) => {
|
|
614
614
|
return /* @__PURE__ */ React__default.createElement(SearchContextProvider, null, /* @__PURE__ */ React__default.createElement(Modal, {
|
|
615
615
|
open,
|
|
616
616
|
toggleModal
|
|
617
617
|
}));
|
|
618
618
|
};
|
|
619
619
|
|
|
620
|
-
const useStyles$
|
|
620
|
+
const useStyles$5 = makeStyles$1(() => ({
|
|
621
621
|
root: {
|
|
622
622
|
display: "flex",
|
|
623
623
|
alignItems: "center"
|
|
@@ -631,7 +631,7 @@ const SearchBar = ({
|
|
|
631
631
|
handleSearch,
|
|
632
632
|
handleClearSearchBar
|
|
633
633
|
}) => {
|
|
634
|
-
const classes = useStyles$
|
|
634
|
+
const classes = useStyles$5();
|
|
635
635
|
return /* @__PURE__ */ React__default.createElement(Paper, {
|
|
636
636
|
component: "form",
|
|
637
637
|
onSubmit: (e) => handleSearch(e),
|
|
@@ -645,14 +645,14 @@ const SearchBar = ({
|
|
|
645
645
|
placeholder: "Search in Backstage",
|
|
646
646
|
value: searchQuery,
|
|
647
647
|
onChange: (e) => handleSearch(e),
|
|
648
|
-
inputProps: {"aria-label": "search backstage"}
|
|
648
|
+
inputProps: { "aria-label": "search backstage" }
|
|
649
649
|
}), /* @__PURE__ */ React__default.createElement(IconButton$1, {
|
|
650
650
|
"aria-label": "search",
|
|
651
651
|
onClick: () => handleClearSearchBar()
|
|
652
652
|
}, /* @__PURE__ */ React__default.createElement(ClearButton, null)));
|
|
653
653
|
};
|
|
654
654
|
|
|
655
|
-
const useStyles$
|
|
655
|
+
const useStyles$4 = makeStyles((theme) => ({
|
|
656
656
|
filters: {
|
|
657
657
|
width: "250px",
|
|
658
658
|
display: "flex"
|
|
@@ -665,7 +665,7 @@ const FiltersButton = ({
|
|
|
665
665
|
numberOfSelectedFilters,
|
|
666
666
|
handleToggleFilters
|
|
667
667
|
}) => {
|
|
668
|
-
const classes = useStyles$
|
|
668
|
+
const classes = useStyles$4();
|
|
669
669
|
return /* @__PURE__ */ React__default.createElement("div", {
|
|
670
670
|
className: classes.filters
|
|
671
671
|
}, /* @__PURE__ */ React__default.createElement(IconButton, {
|
|
@@ -677,7 +677,7 @@ const FiltersButton = ({
|
|
|
677
677
|
}, "Filters (", numberOfSelectedFilters ? numberOfSelectedFilters : 0, ")"));
|
|
678
678
|
};
|
|
679
679
|
|
|
680
|
-
const useStyles$
|
|
680
|
+
const useStyles$3 = makeStyles((theme) => ({
|
|
681
681
|
filters: {
|
|
682
682
|
background: "transparent",
|
|
683
683
|
boxShadow: "0px 0px 0px 0px"
|
|
@@ -696,7 +696,7 @@ const Filters = ({
|
|
|
696
696
|
updateSelected,
|
|
697
697
|
updateChecked
|
|
698
698
|
}) => {
|
|
699
|
-
const classes = useStyles$
|
|
699
|
+
const classes = useStyles$3();
|
|
700
700
|
return /* @__PURE__ */ React__default.createElement(Card, {
|
|
701
701
|
className: classes.filters
|
|
702
702
|
}, /* @__PURE__ */ React__default.createElement(CardHeader, {
|
|
@@ -750,7 +750,7 @@ const Filters = ({
|
|
|
750
750
|
}))))));
|
|
751
751
|
};
|
|
752
752
|
|
|
753
|
-
const useStyles$
|
|
753
|
+
const useStyles$2 = makeStyles((theme) => ({
|
|
754
754
|
searchQuery: {
|
|
755
755
|
color: theme.palette.text.primary,
|
|
756
756
|
background: theme.palette.background.default,
|
|
@@ -798,7 +798,7 @@ const TableHeader = ({
|
|
|
798
798
|
numberOfResults,
|
|
799
799
|
handleToggleFilters
|
|
800
800
|
}) => {
|
|
801
|
-
const classes = useStyles$
|
|
801
|
+
const classes = useStyles$2();
|
|
802
802
|
return /* @__PURE__ */ React__default.createElement("div", {
|
|
803
803
|
className: classes.tableHeader
|
|
804
804
|
}, /* @__PURE__ */ React__default.createElement(FiltersButton, {
|
|
@@ -818,7 +818,7 @@ const TableHeader = ({
|
|
|
818
818
|
variant: "h6"
|
|
819
819
|
}, `${numberOfResults} results`)));
|
|
820
820
|
};
|
|
821
|
-
const SearchResult = ({searchQuery}) => {
|
|
821
|
+
const SearchResult = ({ searchQuery }) => {
|
|
822
822
|
const catalogApi = useApi(catalogApiRef);
|
|
823
823
|
const [showFilters, toggleFilters] = useState(false);
|
|
824
824
|
const [selectedFilters, setSelectedFilters] = useState({
|
|
@@ -928,7 +928,7 @@ const SearchResult = ({searchQuery}) => {
|
|
|
928
928
|
item: true,
|
|
929
929
|
xs: showFilters ? 9 : 12
|
|
930
930
|
}, /* @__PURE__ */ React__default.createElement(Table, {
|
|
931
|
-
options: {paging: true, pageSize: 20, search: false},
|
|
931
|
+
options: { paging: true, pageSize: 20, search: false },
|
|
932
932
|
data: filteredResults,
|
|
933
933
|
columns,
|
|
934
934
|
title: /* @__PURE__ */ React__default.createElement(TableHeader, {
|
|
@@ -993,7 +993,7 @@ const UrlUpdater = () => {
|
|
|
993
993
|
if (location.search === prevQueryParams) {
|
|
994
994
|
return;
|
|
995
995
|
}
|
|
996
|
-
const query = qs.parse(location.search.substring(1), {arrayLimit: 0}) || {};
|
|
996
|
+
const query = qs.parse(location.search.substring(1), { arrayLimit: 0 }) || {};
|
|
997
997
|
if (query.filters) {
|
|
998
998
|
setFilters(query.filters);
|
|
999
999
|
}
|
|
@@ -1013,7 +1013,7 @@ const UrlUpdater = () => {
|
|
|
1013
1013
|
types,
|
|
1014
1014
|
pageCursor,
|
|
1015
1015
|
filters
|
|
1016
|
-
}, {arrayFormat: "brackets"});
|
|
1016
|
+
}, { arrayFormat: "brackets" });
|
|
1017
1017
|
const newUrl = `${window.location.pathname}?${newParams}`;
|
|
1018
1018
|
window.history.replaceState(null, document.title, newUrl);
|
|
1019
1019
|
}, [term, types, pageCursor, filters]);
|
|
@@ -1024,7 +1024,7 @@ const SearchPage = () => {
|
|
|
1024
1024
|
return /* @__PURE__ */ React__default.createElement(SearchContextProvider, null, /* @__PURE__ */ React__default.createElement(UrlUpdater, null), outlet || /* @__PURE__ */ React__default.createElement(LegacySearchPage, null));
|
|
1025
1025
|
};
|
|
1026
1026
|
|
|
1027
|
-
const useStyles = makeStyles((theme) => ({
|
|
1027
|
+
const useStyles$1 = makeStyles((theme) => ({
|
|
1028
1028
|
label: {
|
|
1029
1029
|
textTransform: "capitalize"
|
|
1030
1030
|
},
|
|
@@ -1043,8 +1043,8 @@ const SearchType = ({
|
|
|
1043
1043
|
name,
|
|
1044
1044
|
defaultValue
|
|
1045
1045
|
}) => {
|
|
1046
|
-
const classes = useStyles();
|
|
1047
|
-
const {types, setTypes} = useSearch();
|
|
1046
|
+
const classes = useStyles$1();
|
|
1047
|
+
const { types, setTypes } = useSearch();
|
|
1048
1048
|
useEffectOnce(() => {
|
|
1049
1049
|
if (!types.length) {
|
|
1050
1050
|
if (defaultValue && Array.isArray(defaultValue)) {
|
|
@@ -1090,18 +1090,58 @@ const SearchType = ({
|
|
|
1090
1090
|
})))));
|
|
1091
1091
|
};
|
|
1092
1092
|
|
|
1093
|
-
const SidebarSearch = () => {
|
|
1093
|
+
const SidebarSearch = (props) => {
|
|
1094
1094
|
const searchRoute = useRouteRef(rootRouteRef);
|
|
1095
1095
|
const navigate = useNavigate();
|
|
1096
1096
|
const handleSearch = useCallback((query) => {
|
|
1097
|
-
const queryString = qs.stringify({query}, {addQueryPrefix: true});
|
|
1097
|
+
const queryString = qs.stringify({ query }, { addQueryPrefix: true });
|
|
1098
1098
|
navigate(`${searchRoute()}${queryString}`);
|
|
1099
1099
|
}, [navigate, searchRoute]);
|
|
1100
1100
|
return /* @__PURE__ */ React__default.createElement(SidebarSearchField, {
|
|
1101
|
+
icon: props.icon,
|
|
1101
1102
|
onSearch: handleSearch,
|
|
1102
1103
|
to: "/search"
|
|
1103
1104
|
});
|
|
1104
1105
|
};
|
|
1105
1106
|
|
|
1106
|
-
|
|
1107
|
-
|
|
1107
|
+
const useNavigateToQuery = () => {
|
|
1108
|
+
const searchRoute = useRouteRef(rootRouteRef);
|
|
1109
|
+
const navigate = useNavigate();
|
|
1110
|
+
return useCallback(({ query }) => {
|
|
1111
|
+
const queryString = qs.stringify({ query }, { addQueryPrefix: true });
|
|
1112
|
+
navigate(`${searchRoute()}${queryString}`);
|
|
1113
|
+
}, [navigate, searchRoute]);
|
|
1114
|
+
};
|
|
1115
|
+
|
|
1116
|
+
const useStyles = makeStyles$1({
|
|
1117
|
+
searchBar: {
|
|
1118
|
+
border: "1px solid #555",
|
|
1119
|
+
borderRadius: "6px",
|
|
1120
|
+
fontSize: "1.5em"
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1123
|
+
const HomePageSearchBar = ({
|
|
1124
|
+
className: defaultClassName,
|
|
1125
|
+
...props
|
|
1126
|
+
}) => {
|
|
1127
|
+
const classes = useStyles();
|
|
1128
|
+
const [query, setQuery] = useState("");
|
|
1129
|
+
const handleSearch = useNavigateToQuery();
|
|
1130
|
+
const className = defaultClassName ? `${classes.searchBar} ${defaultClassName}` : classes.searchBar;
|
|
1131
|
+
const handleSubmit = () => {
|
|
1132
|
+
handleSearch({ query });
|
|
1133
|
+
};
|
|
1134
|
+
const handleChange = useCallback((value) => {
|
|
1135
|
+
setQuery(value);
|
|
1136
|
+
}, [setQuery]);
|
|
1137
|
+
return /* @__PURE__ */ React__default.createElement(SearchBarBase, {
|
|
1138
|
+
className,
|
|
1139
|
+
value: query,
|
|
1140
|
+
onSubmit: handleSubmit,
|
|
1141
|
+
onChange: handleChange,
|
|
1142
|
+
...props
|
|
1143
|
+
});
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
export { DefaultResultListItem$1 as D, Filters$1 as F, HomePageSearchBar as H, SearchPage as S, SearchBar$1 as a, SearchBarBase as b, SearchResultComponent as c, SearchModal as d, FiltersButton$1 as e, SearchContextProvider as f, SearchFilter as g, SearchFilterNext as h, SearchResultPager as i, SearchType as j, SidebarSearch as k, DefaultResultListItem as l, HomePageSearchBar$1 as m, SearchBarNext as n, SearchPage$1 as o, SearchPageNext as p, searchPlugin as q, SearchResult$1 as r, searchApiRef as s, SidebarSearchModal as t, useSearch as u };
|
|
1147
|
+
//# sourceMappingURL=index-655809db.esm.js.map
|