@backstage/plugin-search 0.5.1 → 0.5.5
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 +60 -0
- package/dist/esm/{index-bfe6f2c6.esm.js → index-0938232c.esm.js} +11 -6
- package/dist/esm/index-0938232c.esm.js.map +1 -0
- package/dist/esm/{index-3cbe4558.esm.js → index-6640d668.esm.js} +11 -6
- package/dist/esm/index-6640d668.esm.js.map +1 -0
- package/dist/esm/{index-893ec2f5.esm.js → index-8bb5f525.esm.js} +409 -245
- package/dist/esm/index-8bb5f525.esm.js.map +1 -0
- package/dist/esm/{index-e9bf7392.esm.js → index-a1aff68f.esm.js} +11 -6
- package/dist/esm/index-a1aff68f.esm.js.map +1 -0
- package/dist/esm/{index-ca07a7cd.esm.js → index-c5ac9263.esm.js} +16 -10
- package/dist/esm/index-c5ac9263.esm.js.map +1 -0
- package/dist/esm/{index-04d32ed0.esm.js → index-c93144ea.esm.js} +11 -6
- package/dist/esm/index-c93144ea.esm.js.map +1 -0
- package/dist/esm/{index-bc274d46.esm.js → index-e8d39ffc.esm.js} +24 -15
- package/dist/esm/index-e8d39ffc.esm.js.map +1 -0
- package/dist/index.d.ts +92 -19
- package/dist/index.esm.js +12 -7
- package/dist/index.esm.js.map +1 -1
- package/package.json +12 -12
- package/dist/esm/index-04d32ed0.esm.js.map +0 -1
- package/dist/esm/index-3cbe4558.esm.js.map +0 -1
- package/dist/esm/index-893ec2f5.esm.js.map +0 -1
- package/dist/esm/index-bc274d46.esm.js.map +0 -1
- package/dist/esm/index-bfe6f2c6.esm.js.map +0 -1
- package/dist/esm/index-ca07a7cd.esm.js.map +0 -1
- package/dist/esm/index-e9bf7392.esm.js.map +0 -1
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import { createApiRef, useApi, configApiRef, createRouteRef, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, createRoutableExtension, createComponentExtension, useRouteRef } from '@backstage/core-plugin-api';
|
|
1
|
+
import { createApiRef, useApi, AnalyticsContext, useAnalytics, configApiRef, createRouteRef, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, createRoutableExtension, createComponentExtension, useRouteRef } from '@backstage/core-plugin-api';
|
|
2
2
|
import { ResponseError } from '@backstage/errors';
|
|
3
3
|
import qs from 'qs';
|
|
4
|
-
import
|
|
5
|
-
import React__default, { createContext, useState, useCallback, useEffect, useContext } from 'react';
|
|
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
|
-
import { Link, Progress, ResponseErrorPanel, EmptyState, Table, useQueryParamState, Page, Header, Content, SidebarSearchField } from '@backstage/core-components';
|
|
4
|
+
import React, { createContext, useState, useCallback, useEffect, useContext, Fragment, cloneElement } from 'react';
|
|
8
5
|
import FilterListIcon from '@material-ui/icons/FilterList';
|
|
9
|
-
import {
|
|
6
|
+
import { makeStyles, IconButton, Typography, Card, CardHeader, Button, Divider, CardContent, Select, MenuItem, List, ListItem, Checkbox, ListItemText, InputBase, InputAdornment, FormControl, FormLabel, FormControlLabel, InputLabel, ListItemIcon, Box, Dialog, DialogTitle, Paper, DialogContent, Grid, DialogActions, Accordion, AccordionSummary, AccordionDetails, Tabs, Tab, Chip } from '@material-ui/core';
|
|
7
|
+
import useDebounce from 'react-use/lib/useDebounce';
|
|
10
8
|
import SearchIcon from '@material-ui/icons/Search';
|
|
11
9
|
import ClearButton from '@material-ui/icons/Clear';
|
|
10
|
+
import useAsync from 'react-use/lib/useAsync';
|
|
11
|
+
import usePrevious from 'react-use/lib/usePrevious';
|
|
12
|
+
import LaunchIcon from '@material-ui/icons/Launch';
|
|
12
13
|
import { makeStyles as makeStyles$1 } from '@material-ui/core/styles';
|
|
14
|
+
import { Link, Progress, ResponseErrorPanel, EmptyState, Table, useQueryParamState, Page, Header, Content, SidebarSearchField } from '@backstage/core-components';
|
|
13
15
|
import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
|
|
14
16
|
import ArrowForwardIosIcon from '@material-ui/icons/ArrowForwardIos';
|
|
15
|
-
import { createSvgIcon } from '@material-ui/core/utils';
|
|
16
17
|
import { useOutlet, useLocation } from 'react-router';
|
|
17
18
|
import InputBase$1 from '@material-ui/core/InputBase';
|
|
18
19
|
import IconButton$1 from '@material-ui/core/IconButton';
|
|
19
20
|
import { Alert } from '@material-ui/lab';
|
|
20
21
|
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
|
21
22
|
import { ENTITY_DEFAULT_NAMESPACE } from '@backstage/catalog-model';
|
|
23
|
+
import useEffectOnce from 'react-use/lib/useEffectOnce';
|
|
24
|
+
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
25
|
+
import AllIcon from '@material-ui/icons/FontDownload';
|
|
22
26
|
import { useNavigate } from 'react-router-dom';
|
|
23
27
|
|
|
24
28
|
const searchApiRef = createApiRef({
|
|
25
|
-
id: "plugin.search.queryservice"
|
|
26
|
-
description: "Used to make requests against the search API"
|
|
29
|
+
id: "plugin.search.queryservice"
|
|
27
30
|
});
|
|
28
31
|
class SearchClient {
|
|
29
32
|
constructor(options) {
|
|
@@ -44,25 +47,7 @@ class SearchClient {
|
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
const
|
|
48
|
-
result,
|
|
49
|
-
icon,
|
|
50
|
-
secondaryAction
|
|
51
|
-
}) => {
|
|
52
|
-
return /* @__PURE__ */ React__default.createElement(Link, {
|
|
53
|
-
to: result.location
|
|
54
|
-
}, /* @__PURE__ */ React__default.createElement(ListItem, {
|
|
55
|
-
alignItems: "center"
|
|
56
|
-
}, icon && /* @__PURE__ */ React__default.createElement(ListItemIcon, null, icon), /* @__PURE__ */ React__default.createElement(ListItemText, {
|
|
57
|
-
primaryTypographyProps: { variant: "h6" },
|
|
58
|
-
primary: result.title,
|
|
59
|
-
secondary: result.text
|
|
60
|
-
}), secondaryAction && /* @__PURE__ */ React__default.createElement(Box, {
|
|
61
|
-
alignItems: "flex-end"
|
|
62
|
-
}, secondaryAction)), /* @__PURE__ */ React__default.createElement(Divider, null));
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const useStyles$9 = makeStyles((theme) => ({
|
|
50
|
+
const useStyles$b = makeStyles((theme) => ({
|
|
66
51
|
filters: {
|
|
67
52
|
width: "250px",
|
|
68
53
|
display: "flex"
|
|
@@ -75,19 +60,19 @@ const FiltersButton$1 = ({
|
|
|
75
60
|
numberOfSelectedFilters,
|
|
76
61
|
handleToggleFilters
|
|
77
62
|
}) => {
|
|
78
|
-
const classes = useStyles$
|
|
79
|
-
return /* @__PURE__ */
|
|
63
|
+
const classes = useStyles$b();
|
|
64
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
80
65
|
className: classes.filters
|
|
81
|
-
}, /* @__PURE__ */
|
|
66
|
+
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
82
67
|
className: classes.icon,
|
|
83
68
|
"aria-label": "settings",
|
|
84
69
|
onClick: handleToggleFilters
|
|
85
|
-
}, /* @__PURE__ */
|
|
70
|
+
}, /* @__PURE__ */ React.createElement(FilterListIcon, null)), /* @__PURE__ */ React.createElement(Typography, {
|
|
86
71
|
variant: "h6"
|
|
87
72
|
}, "Filters (", numberOfSelectedFilters ? numberOfSelectedFilters : 0, ")"));
|
|
88
73
|
};
|
|
89
74
|
|
|
90
|
-
const useStyles$
|
|
75
|
+
const useStyles$a = makeStyles((theme) => ({
|
|
91
76
|
filters: {
|
|
92
77
|
background: "transparent",
|
|
93
78
|
boxShadow: "0px 0px 0px 0px"
|
|
@@ -106,22 +91,22 @@ const Filters$1 = ({
|
|
|
106
91
|
updateSelected,
|
|
107
92
|
updateChecked
|
|
108
93
|
}) => {
|
|
109
|
-
const classes = useStyles$
|
|
110
|
-
return /* @__PURE__ */
|
|
94
|
+
const classes = useStyles$a();
|
|
95
|
+
return /* @__PURE__ */ React.createElement(Card, {
|
|
111
96
|
className: classes.filters
|
|
112
|
-
}, /* @__PURE__ */
|
|
113
|
-
title: /* @__PURE__ */
|
|
97
|
+
}, /* @__PURE__ */ React.createElement(CardHeader, {
|
|
98
|
+
title: /* @__PURE__ */ React.createElement(Typography, {
|
|
114
99
|
variant: "h6"
|
|
115
100
|
}, "Filters"),
|
|
116
|
-
action: /* @__PURE__ */
|
|
101
|
+
action: /* @__PURE__ */ React.createElement(Button, {
|
|
117
102
|
color: "primary",
|
|
118
103
|
onClick: () => resetFilters()
|
|
119
104
|
}, "CLEAR ALL")
|
|
120
|
-
}), /* @__PURE__ */
|
|
105
|
+
}), /* @__PURE__ */ React.createElement(Divider, null), filterOptions.kind.length === 0 && filterOptions.lifecycle.length === 0 && /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(Typography, {
|
|
121
106
|
variant: "subtitle2"
|
|
122
|
-
}, "Filters cannot be applied to available results")), filterOptions.kind.length > 0 && /* @__PURE__ */
|
|
107
|
+
}, "Filters cannot be applied to available results")), filterOptions.kind.length > 0 && /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(Typography, {
|
|
123
108
|
variant: "subtitle2"
|
|
124
|
-
}, "Kind"), /* @__PURE__ */
|
|
109
|
+
}, "Kind"), /* @__PURE__ */ React.createElement(Select, {
|
|
125
110
|
id: "outlined-select",
|
|
126
111
|
onChange: (e) => {
|
|
127
112
|
var _a;
|
|
@@ -130,22 +115,22 @@ const Filters$1 = ({
|
|
|
130
115
|
variant: "outlined",
|
|
131
116
|
className: classes.dropdown,
|
|
132
117
|
value: filters.selected
|
|
133
|
-
}, filterOptions.kind.map((filter) => /* @__PURE__ */
|
|
118
|
+
}, filterOptions.kind.map((filter) => /* @__PURE__ */ React.createElement(MenuItem, {
|
|
134
119
|
selected: filter === "",
|
|
135
120
|
dense: true,
|
|
136
121
|
key: filter,
|
|
137
122
|
value: filter
|
|
138
|
-
}, filter)))), filterOptions.lifecycle.length > 0 && /* @__PURE__ */
|
|
123
|
+
}, filter)))), filterOptions.lifecycle.length > 0 && /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(Typography, {
|
|
139
124
|
variant: "subtitle2"
|
|
140
|
-
}, "Lifecycle"), /* @__PURE__ */
|
|
125
|
+
}, "Lifecycle"), /* @__PURE__ */ React.createElement(List, {
|
|
141
126
|
disablePadding: true,
|
|
142
127
|
dense: true
|
|
143
|
-
}, filterOptions.lifecycle.map((filter) => /* @__PURE__ */
|
|
128
|
+
}, filterOptions.lifecycle.map((filter) => /* @__PURE__ */ React.createElement(ListItem, {
|
|
144
129
|
key: filter,
|
|
145
130
|
dense: true,
|
|
146
131
|
button: true,
|
|
147
132
|
onClick: () => updateChecked(filter)
|
|
148
|
-
}, /* @__PURE__ */
|
|
133
|
+
}, /* @__PURE__ */ React.createElement(Checkbox, {
|
|
149
134
|
edge: "start",
|
|
150
135
|
disableRipple: true,
|
|
151
136
|
className: classes.checkbox,
|
|
@@ -154,7 +139,7 @@ const Filters$1 = ({
|
|
|
154
139
|
tabIndex: -1,
|
|
155
140
|
value: filter,
|
|
156
141
|
name: filter
|
|
157
|
-
}), /* @__PURE__ */
|
|
142
|
+
}), /* @__PURE__ */ React.createElement(ListItemText, {
|
|
158
143
|
id: filter,
|
|
159
144
|
primary: filter
|
|
160
145
|
}))))));
|
|
@@ -215,10 +200,12 @@ const SearchContextProvider = ({
|
|
|
215
200
|
fetchNextPage: hasNextPage ? fetchNextPage : void 0,
|
|
216
201
|
fetchPreviousPage: hasPreviousPage ? fetchPreviousPage : void 0
|
|
217
202
|
};
|
|
218
|
-
return /* @__PURE__ */
|
|
203
|
+
return /* @__PURE__ */ React.createElement(AnalyticsContext, {
|
|
204
|
+
attributes: { searchTypes: types.sort().join(",") }
|
|
205
|
+
}, /* @__PURE__ */ React.createElement(SearchContext.Provider, {
|
|
219
206
|
value,
|
|
220
207
|
children
|
|
221
|
-
});
|
|
208
|
+
}));
|
|
222
209
|
};
|
|
223
210
|
const useSearch = () => {
|
|
224
211
|
const context = useContext(SearchContext);
|
|
@@ -228,78 +215,97 @@ const useSearch = () => {
|
|
|
228
215
|
return context;
|
|
229
216
|
};
|
|
230
217
|
|
|
218
|
+
const TrackSearch = ({ children }) => {
|
|
219
|
+
const analytics = useAnalytics();
|
|
220
|
+
const { term } = useSearch();
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
if (term) {
|
|
223
|
+
analytics.captureEvent("search", term);
|
|
224
|
+
}
|
|
225
|
+
}, [analytics, term]);
|
|
226
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const useSearchContextCheck = () => {
|
|
230
|
+
const context = useContext(SearchContext);
|
|
231
|
+
return context !== void 0;
|
|
232
|
+
};
|
|
231
233
|
const SearchBarBase = ({
|
|
232
|
-
autoFocus,
|
|
233
|
-
value,
|
|
234
234
|
onChange,
|
|
235
|
+
onKeyDown,
|
|
235
236
|
onSubmit,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
debounceTime = 200,
|
|
238
|
+
clearButton = true,
|
|
239
|
+
fullWidth = true,
|
|
240
|
+
value: defaultValue,
|
|
241
|
+
inputProps: defaultInputProps = {},
|
|
242
|
+
endAdornment: defaultEndAdornment,
|
|
243
|
+
...props
|
|
239
244
|
}) => {
|
|
240
245
|
const configApi = useApi(configApiRef);
|
|
241
|
-
const
|
|
246
|
+
const [value, setValue] = useState(defaultValue);
|
|
247
|
+
const hasSearchContext = useSearchContextCheck();
|
|
248
|
+
useEffect(() => {
|
|
249
|
+
setValue((prevValue) => prevValue !== defaultValue ? defaultValue : prevValue);
|
|
250
|
+
}, [defaultValue]);
|
|
251
|
+
useDebounce(() => onChange(value), debounceTime, [value]);
|
|
252
|
+
const handleChange = useCallback((e) => {
|
|
253
|
+
setValue(e.target.value);
|
|
254
|
+
}, [setValue]);
|
|
255
|
+
const handleKeyDown = useCallback((e) => {
|
|
256
|
+
if (onKeyDown)
|
|
257
|
+
onKeyDown(e);
|
|
242
258
|
if (onSubmit && e.key === "Enter") {
|
|
243
259
|
onSubmit();
|
|
244
260
|
}
|
|
245
|
-
}, [onSubmit]);
|
|
246
|
-
const handleClear =
|
|
261
|
+
}, [onKeyDown, onSubmit]);
|
|
262
|
+
const handleClear = useCallback(() => {
|
|
247
263
|
onChange("");
|
|
248
264
|
}, [onChange]);
|
|
249
|
-
const placeholder =
|
|
250
|
-
|
|
251
|
-
|
|
265
|
+
const placeholder = `Search in ${configApi.getOptionalString("app.title") || "Backstage"}`;
|
|
266
|
+
const startAdornment = /* @__PURE__ */ React.createElement(InputAdornment, {
|
|
267
|
+
position: "start"
|
|
268
|
+
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
269
|
+
"aria-label": "Query",
|
|
270
|
+
disabled: true
|
|
271
|
+
}, /* @__PURE__ */ React.createElement(SearchIcon, null)));
|
|
272
|
+
const endAdornment = /* @__PURE__ */ React.createElement(InputAdornment, {
|
|
273
|
+
position: "end"
|
|
274
|
+
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
275
|
+
"aria-label": "Clear",
|
|
276
|
+
onClick: handleClear
|
|
277
|
+
}, /* @__PURE__ */ React.createElement(ClearButton, null)));
|
|
278
|
+
const searchBar = /* @__PURE__ */ React.createElement(TrackSearch, null, /* @__PURE__ */ React.createElement(InputBase, {
|
|
252
279
|
"data-testid": "search-bar-next",
|
|
253
|
-
fullWidth: true,
|
|
254
|
-
placeholder,
|
|
255
280
|
value,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}, /* @__PURE__ */ React__default.createElement(IconButton, {
|
|
267
|
-
"aria-label": "Clear",
|
|
268
|
-
onClick: handleClear
|
|
269
|
-
}, /* @__PURE__ */ React__default.createElement(ClearButton, null))),
|
|
270
|
-
...className && { className },
|
|
271
|
-
...onSubmit && { onKeyDown }
|
|
272
|
-
});
|
|
281
|
+
placeholder,
|
|
282
|
+
startAdornment,
|
|
283
|
+
endAdornment: clearButton ? endAdornment : defaultEndAdornment,
|
|
284
|
+
inputProps: { "aria-label": "Search", ...defaultInputProps },
|
|
285
|
+
fullWidth,
|
|
286
|
+
onChange: handleChange,
|
|
287
|
+
onKeyDown: handleKeyDown,
|
|
288
|
+
...props
|
|
289
|
+
}));
|
|
290
|
+
return hasSearchContext ? searchBar : /* @__PURE__ */ React.createElement(SearchContextProvider, null, searchBar);
|
|
273
291
|
};
|
|
274
|
-
const SearchBar$1 = ({
|
|
275
|
-
autoFocus,
|
|
276
|
-
className,
|
|
277
|
-
debounceTime = 0,
|
|
278
|
-
placeholder,
|
|
279
|
-
clearButton = true
|
|
280
|
-
}) => {
|
|
292
|
+
const SearchBar$1 = ({ onChange, ...props }) => {
|
|
281
293
|
const { term, setTerm } = useSearch();
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
setValue(newValue);
|
|
294
|
+
const handleChange = (newValue) => {
|
|
295
|
+
if (onChange) {
|
|
296
|
+
onChange(newValue);
|
|
297
|
+
} else {
|
|
298
|
+
setTerm(newValue);
|
|
299
|
+
}
|
|
289
300
|
};
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
value,
|
|
295
|
-
onChange: handleQuery,
|
|
296
|
-
onClear: handleClear,
|
|
297
|
-
placeholder,
|
|
298
|
-
clearButton
|
|
301
|
+
return /* @__PURE__ */ React.createElement(SearchBarBase, {
|
|
302
|
+
value: term,
|
|
303
|
+
onChange: handleChange,
|
|
304
|
+
...props
|
|
299
305
|
});
|
|
300
306
|
};
|
|
301
307
|
|
|
302
|
-
const useStyles$
|
|
308
|
+
const useStyles$9 = makeStyles({
|
|
303
309
|
label: {
|
|
304
310
|
textTransform: "capitalize"
|
|
305
311
|
}
|
|
@@ -310,7 +316,7 @@ const CheckboxFilter = ({
|
|
|
310
316
|
defaultValue,
|
|
311
317
|
values = []
|
|
312
318
|
}) => {
|
|
313
|
-
const classes = useStyles$
|
|
319
|
+
const classes = useStyles$9();
|
|
314
320
|
const { filters, setFilters } = useSearch();
|
|
315
321
|
useEffect(() => {
|
|
316
322
|
if (Array.isArray(defaultValue)) {
|
|
@@ -331,17 +337,17 @@ const CheckboxFilter = ({
|
|
|
331
337
|
return items.length ? { ...others, [name]: items } : others;
|
|
332
338
|
});
|
|
333
339
|
};
|
|
334
|
-
return /* @__PURE__ */
|
|
340
|
+
return /* @__PURE__ */ React.createElement(FormControl, {
|
|
335
341
|
className,
|
|
336
342
|
fullWidth: true,
|
|
337
343
|
"data-testid": "search-checkboxfilter-next"
|
|
338
|
-
}, /* @__PURE__ */
|
|
344
|
+
}, /* @__PURE__ */ React.createElement(FormLabel, {
|
|
339
345
|
className: classes.label
|
|
340
346
|
}, name), values.map((value) => {
|
|
341
347
|
var _a;
|
|
342
|
-
return /* @__PURE__ */
|
|
348
|
+
return /* @__PURE__ */ React.createElement(FormControlLabel, {
|
|
343
349
|
key: value,
|
|
344
|
-
control: /* @__PURE__ */
|
|
350
|
+
control: /* @__PURE__ */ React.createElement(Checkbox, {
|
|
345
351
|
color: "primary",
|
|
346
352
|
tabIndex: -1,
|
|
347
353
|
inputProps: { "aria-labelledby": value },
|
|
@@ -360,7 +366,7 @@ const SelectFilter = ({
|
|
|
360
366
|
defaultValue,
|
|
361
367
|
values = []
|
|
362
368
|
}) => {
|
|
363
|
-
const classes = useStyles$
|
|
369
|
+
const classes = useStyles$9();
|
|
364
370
|
const { filters, setFilters } = useSearch();
|
|
365
371
|
useEffect(() => {
|
|
366
372
|
if (typeof defaultValue === "string") {
|
|
@@ -379,65 +385,79 @@ const SelectFilter = ({
|
|
|
379
385
|
return value ? { ...others, [name]: value } : others;
|
|
380
386
|
});
|
|
381
387
|
};
|
|
382
|
-
return /* @__PURE__ */
|
|
388
|
+
return /* @__PURE__ */ React.createElement(FormControl, {
|
|
383
389
|
className,
|
|
384
390
|
variant: "filled",
|
|
385
391
|
fullWidth: true,
|
|
386
392
|
"data-testid": "search-selectfilter-next"
|
|
387
|
-
}, /* @__PURE__ */
|
|
393
|
+
}, /* @__PURE__ */ React.createElement(InputLabel, {
|
|
388
394
|
className: classes.label,
|
|
389
395
|
margin: "dense"
|
|
390
|
-
}, name), /* @__PURE__ */
|
|
396
|
+
}, name), /* @__PURE__ */ React.createElement(Select, {
|
|
391
397
|
variant: "outlined",
|
|
392
398
|
value: filters[name] || "",
|
|
393
399
|
onChange: handleChange
|
|
394
|
-
}, /* @__PURE__ */
|
|
400
|
+
}, /* @__PURE__ */ React.createElement(MenuItem, {
|
|
395
401
|
value: ""
|
|
396
|
-
}, /* @__PURE__ */
|
|
402
|
+
}, /* @__PURE__ */ React.createElement("em", null, "All")), values.map((value) => /* @__PURE__ */ React.createElement(MenuItem, {
|
|
397
403
|
key: value,
|
|
398
404
|
value
|
|
399
405
|
}, value))));
|
|
400
406
|
};
|
|
401
|
-
const SearchFilter = ({ component: Element, ...props }) => /* @__PURE__ */
|
|
407
|
+
const SearchFilter = ({ component: Element, ...props }) => /* @__PURE__ */ React.createElement(Element, {
|
|
402
408
|
...props
|
|
403
409
|
});
|
|
404
|
-
SearchFilter.Checkbox = (props) => /* @__PURE__ */
|
|
410
|
+
SearchFilter.Checkbox = (props) => /* @__PURE__ */ React.createElement(SearchFilter, {
|
|
405
411
|
...props,
|
|
406
412
|
component: CheckboxFilter
|
|
407
413
|
});
|
|
408
|
-
SearchFilter.Select = (props) => /* @__PURE__ */
|
|
414
|
+
SearchFilter.Select = (props) => /* @__PURE__ */ React.createElement(SearchFilter, {
|
|
409
415
|
...props,
|
|
410
416
|
component: SelectFilter
|
|
411
417
|
});
|
|
412
418
|
const SearchFilterNext = SearchFilter;
|
|
413
419
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
420
|
+
const DefaultResultListItem$1 = ({
|
|
421
|
+
result,
|
|
422
|
+
icon,
|
|
423
|
+
secondaryAction
|
|
424
|
+
}) => {
|
|
425
|
+
return /* @__PURE__ */ React.createElement(Link, {
|
|
426
|
+
to: result.location
|
|
427
|
+
}, /* @__PURE__ */ React.createElement(ListItem, {
|
|
428
|
+
alignItems: "center"
|
|
429
|
+
}, icon && /* @__PURE__ */ React.createElement(ListItemIcon, null, icon), /* @__PURE__ */ React.createElement(ListItemText, {
|
|
430
|
+
primaryTypographyProps: { variant: "h6" },
|
|
431
|
+
primary: result.title,
|
|
432
|
+
secondary: result.text
|
|
433
|
+
}), secondaryAction && /* @__PURE__ */ React.createElement(Box, {
|
|
434
|
+
alignItems: "flex-end"
|
|
435
|
+
}, secondaryAction)), /* @__PURE__ */ React.createElement(Divider, null));
|
|
436
|
+
};
|
|
417
437
|
|
|
418
438
|
const SearchResultComponent = ({ children }) => {
|
|
419
439
|
const {
|
|
420
440
|
result: { loading, error, value }
|
|
421
441
|
} = useSearch();
|
|
422
442
|
if (loading) {
|
|
423
|
-
return /* @__PURE__ */
|
|
443
|
+
return /* @__PURE__ */ React.createElement(Progress, null);
|
|
424
444
|
}
|
|
425
445
|
if (error) {
|
|
426
|
-
return /* @__PURE__ */
|
|
446
|
+
return /* @__PURE__ */ React.createElement(ResponseErrorPanel, {
|
|
427
447
|
title: "Error encountered while fetching search results",
|
|
428
448
|
error
|
|
429
449
|
});
|
|
430
450
|
}
|
|
431
451
|
if (!(value == null ? void 0 : value.results.length)) {
|
|
432
|
-
return /* @__PURE__ */
|
|
452
|
+
return /* @__PURE__ */ React.createElement(EmptyState, {
|
|
433
453
|
missing: "data",
|
|
434
454
|
title: "Sorry, no results were found"
|
|
435
455
|
});
|
|
436
456
|
}
|
|
437
|
-
return /* @__PURE__ */
|
|
457
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children({ results: value.results }));
|
|
438
458
|
};
|
|
439
459
|
|
|
440
|
-
const useStyles$
|
|
460
|
+
const useStyles$8 = makeStyles((theme) => ({
|
|
441
461
|
root: {
|
|
442
462
|
display: "flex",
|
|
443
463
|
justifyContent: "space-between",
|
|
@@ -447,23 +467,23 @@ const useStyles$6 = makeStyles((theme) => ({
|
|
|
447
467
|
}));
|
|
448
468
|
const SearchResultPager = () => {
|
|
449
469
|
const { fetchNextPage, fetchPreviousPage } = useSearch();
|
|
450
|
-
const classes = useStyles$
|
|
470
|
+
const classes = useStyles$8();
|
|
451
471
|
if (!fetchNextPage && !fetchPreviousPage) {
|
|
452
|
-
return /* @__PURE__ */
|
|
472
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null);
|
|
453
473
|
}
|
|
454
|
-
return /* @__PURE__ */
|
|
474
|
+
return /* @__PURE__ */ React.createElement("nav", {
|
|
455
475
|
"arial-label": "pagination navigation",
|
|
456
476
|
className: classes.root
|
|
457
|
-
}, /* @__PURE__ */
|
|
477
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
458
478
|
"aria-label": "previous page",
|
|
459
479
|
disabled: !fetchPreviousPage,
|
|
460
480
|
onClick: fetchPreviousPage,
|
|
461
|
-
startIcon: /* @__PURE__ */
|
|
462
|
-
}, "Previous"), /* @__PURE__ */
|
|
481
|
+
startIcon: /* @__PURE__ */ React.createElement(ArrowBackIosIcon, null)
|
|
482
|
+
}, "Previous"), /* @__PURE__ */ React.createElement(Button, {
|
|
463
483
|
"aria-label": "next page",
|
|
464
484
|
disabled: !fetchNextPage,
|
|
465
485
|
onClick: fetchNextPage,
|
|
466
|
-
endIcon: /* @__PURE__ */
|
|
486
|
+
endIcon: /* @__PURE__ */ React.createElement(ArrowForwardIosIcon, null)
|
|
467
487
|
}, "Next"));
|
|
468
488
|
};
|
|
469
489
|
|
|
@@ -491,58 +511,58 @@ const searchPlugin = createPlugin({
|
|
|
491
511
|
});
|
|
492
512
|
const SearchPage$1 = searchPlugin.provide(createRoutableExtension({
|
|
493
513
|
name: "SearchPage",
|
|
494
|
-
component: () => import('./index-
|
|
514
|
+
component: () => import('./index-c93144ea.esm.js').then((m) => m.SearchPage),
|
|
495
515
|
mountPoint: rootRouteRef
|
|
496
516
|
}));
|
|
497
517
|
const SearchPageNext = searchPlugin.provide(createRoutableExtension({
|
|
498
518
|
name: "SearchPageNext",
|
|
499
|
-
component: () => import('./index-
|
|
519
|
+
component: () => import('./index-c93144ea.esm.js').then((m) => m.SearchPage),
|
|
500
520
|
mountPoint: rootNextRouteRef
|
|
501
521
|
}));
|
|
502
522
|
searchPlugin.provide(createComponentExtension({
|
|
503
523
|
name: "SearchBar",
|
|
504
524
|
component: {
|
|
505
|
-
lazy: () => import('./index-
|
|
525
|
+
lazy: () => import('./index-0938232c.esm.js').then((m) => m.SearchBar)
|
|
506
526
|
}
|
|
507
527
|
}));
|
|
508
528
|
const SearchBarNext = searchPlugin.provide(createComponentExtension({
|
|
509
529
|
name: "SearchBarNext",
|
|
510
530
|
component: {
|
|
511
|
-
lazy: () => import('./index-
|
|
531
|
+
lazy: () => import('./index-0938232c.esm.js').then((m) => m.SearchBar)
|
|
512
532
|
}
|
|
513
533
|
}));
|
|
514
534
|
const SearchResult$1 = searchPlugin.provide(createComponentExtension({
|
|
515
535
|
name: "SearchResult",
|
|
516
536
|
component: {
|
|
517
|
-
lazy: () => import('./index-
|
|
537
|
+
lazy: () => import('./index-6640d668.esm.js').then((m) => m.SearchResult)
|
|
518
538
|
}
|
|
519
539
|
}));
|
|
520
540
|
searchPlugin.provide(createComponentExtension({
|
|
521
541
|
name: "SearchResultNext",
|
|
522
542
|
component: {
|
|
523
|
-
lazy: () => import('./index-
|
|
543
|
+
lazy: () => import('./index-6640d668.esm.js').then((m) => m.SearchResult)
|
|
524
544
|
}
|
|
525
545
|
}));
|
|
526
546
|
const SidebarSearchModal = searchPlugin.provide(createComponentExtension({
|
|
527
547
|
name: "SidebarSearchModal",
|
|
528
548
|
component: {
|
|
529
|
-
lazy: () => import('./index-
|
|
549
|
+
lazy: () => import('./index-c5ac9263.esm.js').then((m) => m.SidebarSearchModal)
|
|
530
550
|
}
|
|
531
551
|
}));
|
|
532
552
|
const DefaultResultListItem = searchPlugin.provide(createComponentExtension({
|
|
533
553
|
name: "DefaultResultListItem",
|
|
534
554
|
component: {
|
|
535
|
-
lazy: () => import('./index-
|
|
555
|
+
lazy: () => import('./index-a1aff68f.esm.js').then((m) => m.DefaultResultListItem)
|
|
536
556
|
}
|
|
537
557
|
}));
|
|
538
558
|
const HomePageSearchBar = searchPlugin.provide(createComponentExtension({
|
|
539
559
|
name: "HomePageSearchBar",
|
|
540
560
|
component: {
|
|
541
|
-
lazy: () => import('./index-
|
|
561
|
+
lazy: () => import('./index-e8d39ffc.esm.js').then((m) => m.HomePageSearchBar)
|
|
542
562
|
}
|
|
543
563
|
}));
|
|
544
564
|
|
|
545
|
-
const useStyles$
|
|
565
|
+
const useStyles$7 = makeStyles$1((theme) => ({
|
|
546
566
|
container: {
|
|
547
567
|
borderRadius: 30,
|
|
548
568
|
display: "flex",
|
|
@@ -557,25 +577,15 @@ const useStyles$5 = makeStyles$1((theme) => ({
|
|
|
557
577
|
}));
|
|
558
578
|
const Modal = ({ open = true, toggleModal }) => {
|
|
559
579
|
const getSearchLink = useRouteRef(rootRouteRef);
|
|
560
|
-
const classes = useStyles$
|
|
561
|
-
const { term
|
|
562
|
-
const [value, setValue] = useState(term);
|
|
563
|
-
useEffect(() => {
|
|
564
|
-
setValue((prevValue) => prevValue !== term ? term : prevValue);
|
|
565
|
-
}, [term]);
|
|
566
|
-
useDebounce(() => setTerm(value), 500, [value]);
|
|
567
|
-
const handleQuery = (newValue) => {
|
|
568
|
-
setValue(newValue);
|
|
569
|
-
};
|
|
570
|
-
const handleClear = () => setValue("");
|
|
580
|
+
const classes = useStyles$7();
|
|
581
|
+
const { term } = useSearch();
|
|
571
582
|
const handleResultClick = () => {
|
|
572
583
|
toggleModal();
|
|
573
|
-
handleClear();
|
|
574
584
|
};
|
|
575
585
|
const handleKeyPress = () => {
|
|
576
586
|
handleResultClick();
|
|
577
587
|
};
|
|
578
|
-
return /* @__PURE__ */
|
|
588
|
+
return /* @__PURE__ */ React.createElement(Dialog, {
|
|
579
589
|
classes: {
|
|
580
590
|
paperFullWidth: classes.paperFullWidth
|
|
581
591
|
},
|
|
@@ -584,54 +594,51 @@ const Modal = ({ open = true, toggleModal }) => {
|
|
|
584
594
|
open,
|
|
585
595
|
fullWidth: true,
|
|
586
596
|
maxWidth: "lg"
|
|
587
|
-
}, /* @__PURE__ */
|
|
597
|
+
}, /* @__PURE__ */ React.createElement(DialogTitle, null, /* @__PURE__ */ React.createElement(Paper, {
|
|
588
598
|
className: classes.container
|
|
589
|
-
}, /* @__PURE__ */
|
|
590
|
-
className: classes.input
|
|
591
|
-
|
|
592
|
-
onChange: handleQuery,
|
|
593
|
-
onClear: handleClear
|
|
594
|
-
}))), /* @__PURE__ */ React__default.createElement(DialogContent, null, /* @__PURE__ */ React__default.createElement(Grid, {
|
|
599
|
+
}, /* @__PURE__ */ React.createElement(SearchBar$1, {
|
|
600
|
+
className: classes.input
|
|
601
|
+
}))), /* @__PURE__ */ React.createElement(DialogContent, null, /* @__PURE__ */ React.createElement(Grid, {
|
|
595
602
|
container: true,
|
|
596
603
|
direction: "row-reverse",
|
|
597
604
|
justifyContent: "flex-start",
|
|
598
605
|
alignItems: "center"
|
|
599
|
-
}, /* @__PURE__ */
|
|
606
|
+
}, /* @__PURE__ */ React.createElement(Grid, {
|
|
600
607
|
item: true
|
|
601
|
-
}, /* @__PURE__ */
|
|
608
|
+
}, /* @__PURE__ */ React.createElement(Link, {
|
|
602
609
|
onClick: toggleModal,
|
|
603
|
-
to: `${getSearchLink()}?query=${
|
|
604
|
-
}, /* @__PURE__ */
|
|
610
|
+
to: `${getSearchLink()}?query=${term}`
|
|
611
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
605
612
|
className: classes.viewResultsLink
|
|
606
|
-
}, "View Full Results"), /* @__PURE__ */
|
|
613
|
+
}, "View Full Results"), /* @__PURE__ */ React.createElement(LaunchIcon, {
|
|
607
614
|
color: "primary"
|
|
608
|
-
})))), /* @__PURE__ */
|
|
615
|
+
})))), /* @__PURE__ */ React.createElement(Divider, null), /* @__PURE__ */ React.createElement(SearchResultComponent, null, ({ results }) => /* @__PURE__ */ React.createElement(List, null, results.map(({ document }) => /* @__PURE__ */ React.createElement("div", {
|
|
609
616
|
role: "button",
|
|
610
617
|
tabIndex: 0,
|
|
611
618
|
key: `${document.location}-btn`,
|
|
612
619
|
onClick: handleResultClick,
|
|
613
620
|
onKeyPress: handleKeyPress
|
|
614
|
-
}, /* @__PURE__ */
|
|
621
|
+
}, /* @__PURE__ */ React.createElement(DefaultResultListItem$1, {
|
|
615
622
|
key: document.location,
|
|
616
623
|
result: document
|
|
617
|
-
})))))), /* @__PURE__ */
|
|
624
|
+
})))))), /* @__PURE__ */ React.createElement(DialogActions, {
|
|
618
625
|
className: classes.dialogActionsContainer
|
|
619
|
-
}, /* @__PURE__ */
|
|
626
|
+
}, /* @__PURE__ */ React.createElement(Grid, {
|
|
620
627
|
container: true,
|
|
621
628
|
direction: "row"
|
|
622
|
-
}, /* @__PURE__ */
|
|
629
|
+
}, /* @__PURE__ */ React.createElement(Grid, {
|
|
623
630
|
item: true,
|
|
624
631
|
xs: 12
|
|
625
|
-
}, /* @__PURE__ */
|
|
632
|
+
}, /* @__PURE__ */ React.createElement(SearchResultPager, null)))));
|
|
626
633
|
};
|
|
627
634
|
const SearchModal = ({ open = true, toggleModal }) => {
|
|
628
|
-
return /* @__PURE__ */
|
|
635
|
+
return /* @__PURE__ */ React.createElement(SearchContextProvider, null, /* @__PURE__ */ React.createElement(Modal, {
|
|
629
636
|
open,
|
|
630
637
|
toggleModal
|
|
631
638
|
}));
|
|
632
639
|
};
|
|
633
640
|
|
|
634
|
-
const useStyles$
|
|
641
|
+
const useStyles$6 = makeStyles$1(() => ({
|
|
635
642
|
root: {
|
|
636
643
|
display: "flex",
|
|
637
644
|
alignItems: "center"
|
|
@@ -645,28 +652,28 @@ const SearchBar = ({
|
|
|
645
652
|
handleSearch,
|
|
646
653
|
handleClearSearchBar
|
|
647
654
|
}) => {
|
|
648
|
-
const classes = useStyles$
|
|
649
|
-
return /* @__PURE__ */
|
|
655
|
+
const classes = useStyles$6();
|
|
656
|
+
return /* @__PURE__ */ React.createElement(Paper, {
|
|
650
657
|
component: "form",
|
|
651
658
|
onSubmit: (e) => handleSearch(e),
|
|
652
659
|
className: classes.root
|
|
653
|
-
}, /* @__PURE__ */
|
|
660
|
+
}, /* @__PURE__ */ React.createElement(IconButton$1, {
|
|
654
661
|
disabled: true,
|
|
655
662
|
type: "submit",
|
|
656
663
|
"aria-label": "search"
|
|
657
|
-
}, /* @__PURE__ */
|
|
664
|
+
}, /* @__PURE__ */ React.createElement(SearchIcon, null)), /* @__PURE__ */ React.createElement(InputBase$1, {
|
|
658
665
|
className: classes.input,
|
|
659
666
|
placeholder: "Search in Backstage",
|
|
660
667
|
value: searchQuery,
|
|
661
668
|
onChange: (e) => handleSearch(e),
|
|
662
669
|
inputProps: { "aria-label": "search backstage" }
|
|
663
|
-
}), /* @__PURE__ */
|
|
670
|
+
}), /* @__PURE__ */ React.createElement(IconButton$1, {
|
|
664
671
|
"aria-label": "search",
|
|
665
672
|
onClick: () => handleClearSearchBar()
|
|
666
|
-
}, /* @__PURE__ */
|
|
673
|
+
}, /* @__PURE__ */ React.createElement(ClearButton, null)));
|
|
667
674
|
};
|
|
668
675
|
|
|
669
|
-
const useStyles$
|
|
676
|
+
const useStyles$5 = makeStyles((theme) => ({
|
|
670
677
|
filters: {
|
|
671
678
|
width: "250px",
|
|
672
679
|
display: "flex"
|
|
@@ -679,19 +686,19 @@ const FiltersButton = ({
|
|
|
679
686
|
numberOfSelectedFilters,
|
|
680
687
|
handleToggleFilters
|
|
681
688
|
}) => {
|
|
682
|
-
const classes = useStyles$
|
|
683
|
-
return /* @__PURE__ */
|
|
689
|
+
const classes = useStyles$5();
|
|
690
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
684
691
|
className: classes.filters
|
|
685
|
-
}, /* @__PURE__ */
|
|
692
|
+
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
686
693
|
className: classes.icon,
|
|
687
694
|
"aria-label": "settings",
|
|
688
695
|
onClick: handleToggleFilters
|
|
689
|
-
}, /* @__PURE__ */
|
|
696
|
+
}, /* @__PURE__ */ React.createElement(FilterListIcon, null)), /* @__PURE__ */ React.createElement(Typography, {
|
|
690
697
|
variant: "h6"
|
|
691
698
|
}, "Filters (", numberOfSelectedFilters ? numberOfSelectedFilters : 0, ")"));
|
|
692
699
|
};
|
|
693
700
|
|
|
694
|
-
const useStyles$
|
|
701
|
+
const useStyles$4 = makeStyles((theme) => ({
|
|
695
702
|
filters: {
|
|
696
703
|
background: "transparent",
|
|
697
704
|
boxShadow: "0px 0px 0px 0px"
|
|
@@ -710,22 +717,22 @@ const Filters = ({
|
|
|
710
717
|
updateSelected,
|
|
711
718
|
updateChecked
|
|
712
719
|
}) => {
|
|
713
|
-
const classes = useStyles$
|
|
714
|
-
return /* @__PURE__ */
|
|
720
|
+
const classes = useStyles$4();
|
|
721
|
+
return /* @__PURE__ */ React.createElement(Card, {
|
|
715
722
|
className: classes.filters
|
|
716
|
-
}, /* @__PURE__ */
|
|
717
|
-
title: /* @__PURE__ */
|
|
723
|
+
}, /* @__PURE__ */ React.createElement(CardHeader, {
|
|
724
|
+
title: /* @__PURE__ */ React.createElement(Typography, {
|
|
718
725
|
variant: "h6"
|
|
719
726
|
}, "Filters"),
|
|
720
|
-
action: /* @__PURE__ */
|
|
727
|
+
action: /* @__PURE__ */ React.createElement(Button, {
|
|
721
728
|
color: "primary",
|
|
722
729
|
onClick: () => resetFilters()
|
|
723
730
|
}, "CLEAR ALL")
|
|
724
|
-
}), /* @__PURE__ */
|
|
731
|
+
}), /* @__PURE__ */ React.createElement(Divider, null), filterOptions.kind.length === 0 && filterOptions.lifecycle.length === 0 && /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(Typography, {
|
|
725
732
|
variant: "subtitle2"
|
|
726
|
-
}, "Filters cannot be applied to available results")), filterOptions.kind.length > 0 && /* @__PURE__ */
|
|
733
|
+
}, "Filters cannot be applied to available results")), filterOptions.kind.length > 0 && /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(Typography, {
|
|
727
734
|
variant: "subtitle2"
|
|
728
|
-
}, "Kind"), /* @__PURE__ */
|
|
735
|
+
}, "Kind"), /* @__PURE__ */ React.createElement(Select, {
|
|
729
736
|
id: "outlined-select",
|
|
730
737
|
onChange: (e) => {
|
|
731
738
|
var _a;
|
|
@@ -734,22 +741,22 @@ const Filters = ({
|
|
|
734
741
|
variant: "outlined",
|
|
735
742
|
className: classes.dropdown,
|
|
736
743
|
value: filters.selected
|
|
737
|
-
}, filterOptions.kind.map((filter) => /* @__PURE__ */
|
|
744
|
+
}, filterOptions.kind.map((filter) => /* @__PURE__ */ React.createElement(MenuItem, {
|
|
738
745
|
selected: filter === "",
|
|
739
746
|
dense: true,
|
|
740
747
|
key: filter,
|
|
741
748
|
value: filter
|
|
742
|
-
}, filter)))), filterOptions.lifecycle.length > 0 && /* @__PURE__ */
|
|
749
|
+
}, filter)))), filterOptions.lifecycle.length > 0 && /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(Typography, {
|
|
743
750
|
variant: "subtitle2"
|
|
744
|
-
}, "Lifecycle"), /* @__PURE__ */
|
|
751
|
+
}, "Lifecycle"), /* @__PURE__ */ React.createElement(List, {
|
|
745
752
|
disablePadding: true,
|
|
746
753
|
dense: true
|
|
747
|
-
}, filterOptions.lifecycle.map((filter) => /* @__PURE__ */
|
|
754
|
+
}, filterOptions.lifecycle.map((filter) => /* @__PURE__ */ React.createElement(ListItem, {
|
|
748
755
|
key: filter,
|
|
749
756
|
dense: true,
|
|
750
757
|
button: true,
|
|
751
758
|
onClick: () => updateChecked(filter)
|
|
752
|
-
}, /* @__PURE__ */
|
|
759
|
+
}, /* @__PURE__ */ React.createElement(Checkbox, {
|
|
753
760
|
edge: "start",
|
|
754
761
|
disableRipple: true,
|
|
755
762
|
className: classes.checkbox,
|
|
@@ -758,13 +765,13 @@ const Filters = ({
|
|
|
758
765
|
tabIndex: -1,
|
|
759
766
|
value: filter,
|
|
760
767
|
name: filter
|
|
761
|
-
}), /* @__PURE__ */
|
|
768
|
+
}), /* @__PURE__ */ React.createElement(ListItemText, {
|
|
762
769
|
id: filter,
|
|
763
770
|
primary: filter
|
|
764
771
|
}))))));
|
|
765
772
|
};
|
|
766
773
|
|
|
767
|
-
const useStyles$
|
|
774
|
+
const useStyles$3 = makeStyles((theme) => ({
|
|
768
775
|
searchQuery: {
|
|
769
776
|
color: theme.palette.text.primary,
|
|
770
777
|
background: theme.palette.background.default,
|
|
@@ -785,7 +792,7 @@ const columns = [
|
|
|
785
792
|
title: "Name",
|
|
786
793
|
field: "name",
|
|
787
794
|
highlight: true,
|
|
788
|
-
render: (result) => /* @__PURE__ */
|
|
795
|
+
render: (result) => /* @__PURE__ */ React.createElement(Link, {
|
|
789
796
|
to: result.url || ""
|
|
790
797
|
}, result.name)
|
|
791
798
|
},
|
|
@@ -812,23 +819,23 @@ const TableHeader = ({
|
|
|
812
819
|
numberOfResults,
|
|
813
820
|
handleToggleFilters
|
|
814
821
|
}) => {
|
|
815
|
-
const classes = useStyles$
|
|
816
|
-
return /* @__PURE__ */
|
|
822
|
+
const classes = useStyles$3();
|
|
823
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
817
824
|
className: classes.tableHeader
|
|
818
|
-
}, /* @__PURE__ */
|
|
825
|
+
}, /* @__PURE__ */ React.createElement(FiltersButton, {
|
|
819
826
|
numberOfSelectedFilters,
|
|
820
827
|
handleToggleFilters
|
|
821
|
-
}), /* @__PURE__ */
|
|
828
|
+
}), /* @__PURE__ */ React.createElement(Divider, {
|
|
822
829
|
className: classes.divider,
|
|
823
830
|
orientation: "vertical"
|
|
824
|
-
}), /* @__PURE__ */
|
|
831
|
+
}), /* @__PURE__ */ React.createElement(Grid, {
|
|
825
832
|
item: true,
|
|
826
833
|
xs: 12
|
|
827
|
-
}, searchQuery ? /* @__PURE__ */
|
|
834
|
+
}, searchQuery ? /* @__PURE__ */ React.createElement(Typography, {
|
|
828
835
|
variant: "h6"
|
|
829
|
-
}, `${numberOfResults} `, numberOfResults > 1 ? `results for ` : `result for `, /* @__PURE__ */
|
|
836
|
+
}, `${numberOfResults} `, numberOfResults > 1 ? `results for ` : `result for `, /* @__PURE__ */ React.createElement("span", {
|
|
830
837
|
className: classes.searchQuery
|
|
831
|
-
}, '"', searchQuery, '"'), " ") : /* @__PURE__ */
|
|
838
|
+
}, '"', searchQuery, '"'), " ") : /* @__PURE__ */ React.createElement(Typography, {
|
|
832
839
|
variant: "h6"
|
|
833
840
|
}, `${numberOfResults} results`)));
|
|
834
841
|
};
|
|
@@ -877,15 +884,15 @@ const SearchResult = ({ searchQuery }) => {
|
|
|
877
884
|
}
|
|
878
885
|
}, [selectedFilters, searchQuery, results]);
|
|
879
886
|
if (loading) {
|
|
880
|
-
return /* @__PURE__ */
|
|
887
|
+
return /* @__PURE__ */ React.createElement(Progress, null);
|
|
881
888
|
}
|
|
882
889
|
if (error) {
|
|
883
|
-
return /* @__PURE__ */
|
|
890
|
+
return /* @__PURE__ */ React.createElement(Alert, {
|
|
884
891
|
severity: "error"
|
|
885
892
|
}, "Error encountered while fetching search results. ", error.toString());
|
|
886
893
|
}
|
|
887
894
|
if (!results || results.length === 0) {
|
|
888
|
-
return /* @__PURE__ */
|
|
895
|
+
return /* @__PURE__ */ React.createElement(EmptyState, {
|
|
889
896
|
missing: "data",
|
|
890
897
|
title: "Sorry, no results were found"
|
|
891
898
|
});
|
|
@@ -927,25 +934,25 @@ const SearchResult = ({ searchQuery }) => {
|
|
|
927
934
|
kind: [],
|
|
928
935
|
lifecycle: []
|
|
929
936
|
});
|
|
930
|
-
return /* @__PURE__ */
|
|
937
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Grid, {
|
|
931
938
|
container: true
|
|
932
|
-
}, showFilters && /* @__PURE__ */
|
|
939
|
+
}, showFilters && /* @__PURE__ */ React.createElement(Grid, {
|
|
933
940
|
item: true,
|
|
934
941
|
xs: 3
|
|
935
|
-
}, /* @__PURE__ */
|
|
942
|
+
}, /* @__PURE__ */ React.createElement(Filters, {
|
|
936
943
|
filters: selectedFilters,
|
|
937
944
|
filterOptions,
|
|
938
945
|
resetFilters,
|
|
939
946
|
updateSelected,
|
|
940
947
|
updateChecked
|
|
941
|
-
})), /* @__PURE__ */
|
|
948
|
+
})), /* @__PURE__ */ React.createElement(Grid, {
|
|
942
949
|
item: true,
|
|
943
950
|
xs: showFilters ? 9 : 12
|
|
944
|
-
}, /* @__PURE__ */
|
|
951
|
+
}, /* @__PURE__ */ React.createElement(Table, {
|
|
945
952
|
options: { paging: true, pageSize: 20, search: false },
|
|
946
953
|
data: filteredResults,
|
|
947
954
|
columns,
|
|
948
|
-
title: /* @__PURE__ */
|
|
955
|
+
title: /* @__PURE__ */ React.createElement(TableHeader, {
|
|
949
956
|
searchQuery,
|
|
950
957
|
numberOfResults: filteredResults.length,
|
|
951
958
|
numberOfSelectedFilters: (selectedFilters.selected !== "" ? 1 : 0) + selectedFilters.checked.length,
|
|
@@ -968,24 +975,24 @@ const LegacySearchPage = () => {
|
|
|
968
975
|
const handleClearSearchBar = () => {
|
|
969
976
|
setSearchQuery("");
|
|
970
977
|
};
|
|
971
|
-
return /* @__PURE__ */
|
|
978
|
+
return /* @__PURE__ */ React.createElement(Page, {
|
|
972
979
|
themeId: "home"
|
|
973
|
-
}, /* @__PURE__ */
|
|
980
|
+
}, /* @__PURE__ */ React.createElement(Header, {
|
|
974
981
|
title: "Search"
|
|
975
|
-
}), /* @__PURE__ */
|
|
982
|
+
}), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(Grid, {
|
|
976
983
|
container: true,
|
|
977
984
|
direction: "row"
|
|
978
|
-
}, /* @__PURE__ */
|
|
985
|
+
}, /* @__PURE__ */ React.createElement(Grid, {
|
|
979
986
|
item: true,
|
|
980
987
|
xs: 12
|
|
981
|
-
}, /* @__PURE__ */
|
|
988
|
+
}, /* @__PURE__ */ React.createElement(SearchBar, {
|
|
982
989
|
handleSearch,
|
|
983
990
|
handleClearSearchBar,
|
|
984
991
|
searchQuery
|
|
985
|
-
})), /* @__PURE__ */
|
|
992
|
+
})), /* @__PURE__ */ React.createElement(Grid, {
|
|
986
993
|
item: true,
|
|
987
994
|
xs: 12
|
|
988
|
-
}, /* @__PURE__ */
|
|
995
|
+
}, /* @__PURE__ */ React.createElement(SearchResult, {
|
|
989
996
|
searchQuery: (queryString != null ? queryString : "").toLocaleLowerCase("en-US")
|
|
990
997
|
})))));
|
|
991
998
|
};
|
|
@@ -1035,7 +1042,157 @@ const UrlUpdater = () => {
|
|
|
1035
1042
|
};
|
|
1036
1043
|
const SearchPage = () => {
|
|
1037
1044
|
const outlet = useOutlet();
|
|
1038
|
-
return /* @__PURE__ */
|
|
1045
|
+
return /* @__PURE__ */ React.createElement(SearchContextProvider, null, /* @__PURE__ */ React.createElement(UrlUpdater, null), outlet || /* @__PURE__ */ React.createElement(LegacySearchPage, null));
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
const useStyles$2 = makeStyles((theme) => ({
|
|
1049
|
+
card: {
|
|
1050
|
+
backgroundColor: "rgba(0, 0, 0, .11)"
|
|
1051
|
+
},
|
|
1052
|
+
cardContent: {
|
|
1053
|
+
paddingTop: theme.spacing(1)
|
|
1054
|
+
},
|
|
1055
|
+
icon: {
|
|
1056
|
+
color: theme.palette.common.black
|
|
1057
|
+
},
|
|
1058
|
+
list: {
|
|
1059
|
+
width: "100%"
|
|
1060
|
+
},
|
|
1061
|
+
listItemIcon: {
|
|
1062
|
+
width: "24px",
|
|
1063
|
+
height: "24px"
|
|
1064
|
+
},
|
|
1065
|
+
accordion: {
|
|
1066
|
+
backgroundColor: theme.palette.background.paper
|
|
1067
|
+
},
|
|
1068
|
+
accordionSummary: {
|
|
1069
|
+
minHeight: "auto",
|
|
1070
|
+
"&.Mui-expanded": {
|
|
1071
|
+
minHeight: "auto"
|
|
1072
|
+
}
|
|
1073
|
+
},
|
|
1074
|
+
accordionSummaryContent: {
|
|
1075
|
+
margin: theme.spacing(2, 0),
|
|
1076
|
+
"&.Mui-expanded": {
|
|
1077
|
+
margin: theme.spacing(2, 0)
|
|
1078
|
+
}
|
|
1079
|
+
},
|
|
1080
|
+
accordionDetails: {
|
|
1081
|
+
padding: theme.spacing(0, 0, 1)
|
|
1082
|
+
}
|
|
1083
|
+
}));
|
|
1084
|
+
const SearchTypeAccordion = (props) => {
|
|
1085
|
+
const classes = useStyles$2();
|
|
1086
|
+
const { setPageCursor, setTypes, types } = useSearch();
|
|
1087
|
+
const [expanded, setExpanded] = useState(true);
|
|
1088
|
+
const { defaultValue, name, types: givenTypes } = props;
|
|
1089
|
+
const toggleExpanded = () => setExpanded((prevState) => !prevState);
|
|
1090
|
+
const handleClick = (type) => {
|
|
1091
|
+
return () => {
|
|
1092
|
+
setTypes(type !== "" ? [type] : []);
|
|
1093
|
+
setPageCursor(void 0);
|
|
1094
|
+
setExpanded(false);
|
|
1095
|
+
};
|
|
1096
|
+
};
|
|
1097
|
+
useEffect(() => {
|
|
1098
|
+
if (defaultValue) {
|
|
1099
|
+
setTypes([defaultValue]);
|
|
1100
|
+
}
|
|
1101
|
+
}, []);
|
|
1102
|
+
const definedTypes = [
|
|
1103
|
+
{
|
|
1104
|
+
value: "",
|
|
1105
|
+
name: "All",
|
|
1106
|
+
icon: /* @__PURE__ */ React.createElement(AllIcon, null)
|
|
1107
|
+
},
|
|
1108
|
+
...givenTypes
|
|
1109
|
+
];
|
|
1110
|
+
const selected = types[0] || "";
|
|
1111
|
+
return /* @__PURE__ */ React.createElement(Card, {
|
|
1112
|
+
className: classes.card
|
|
1113
|
+
}, /* @__PURE__ */ React.createElement(CardHeader, {
|
|
1114
|
+
title: name,
|
|
1115
|
+
titleTypographyProps: { variant: "overline" }
|
|
1116
|
+
}), /* @__PURE__ */ React.createElement(CardContent, {
|
|
1117
|
+
className: classes.cardContent
|
|
1118
|
+
}, /* @__PURE__ */ React.createElement(Accordion, {
|
|
1119
|
+
className: classes.accordion,
|
|
1120
|
+
expanded,
|
|
1121
|
+
onChange: toggleExpanded
|
|
1122
|
+
}, /* @__PURE__ */ React.createElement(AccordionSummary, {
|
|
1123
|
+
classes: {
|
|
1124
|
+
root: classes.accordionSummary,
|
|
1125
|
+
content: classes.accordionSummaryContent
|
|
1126
|
+
},
|
|
1127
|
+
expandIcon: /* @__PURE__ */ React.createElement(ExpandMoreIcon, {
|
|
1128
|
+
className: classes.icon
|
|
1129
|
+
}),
|
|
1130
|
+
IconButtonProps: { size: "small" }
|
|
1131
|
+
}, expanded ? "Collapse" : definedTypes.filter((t) => t.value === selected)[0].name), /* @__PURE__ */ React.createElement(AccordionDetails, {
|
|
1132
|
+
classes: { root: classes.accordionDetails }
|
|
1133
|
+
}, /* @__PURE__ */ React.createElement(List, {
|
|
1134
|
+
className: classes.list,
|
|
1135
|
+
component: "nav",
|
|
1136
|
+
"aria-label": "filter by type",
|
|
1137
|
+
disablePadding: true,
|
|
1138
|
+
dense: true
|
|
1139
|
+
}, definedTypes.map((type) => /* @__PURE__ */ React.createElement(Fragment, {
|
|
1140
|
+
key: type.value
|
|
1141
|
+
}, /* @__PURE__ */ React.createElement(Divider, null), /* @__PURE__ */ React.createElement(ListItem, {
|
|
1142
|
+
selected: types[0] === type.value || types.length === 0 && type.value === "",
|
|
1143
|
+
onClick: handleClick(type.value),
|
|
1144
|
+
button: true
|
|
1145
|
+
}, /* @__PURE__ */ React.createElement(ListItemIcon, null, cloneElement(type.icon, {
|
|
1146
|
+
className: classes.listItemIcon
|
|
1147
|
+
})), /* @__PURE__ */ React.createElement(ListItemText, {
|
|
1148
|
+
primary: type.name
|
|
1149
|
+
})))))))));
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
const useStyles$1 = makeStyles((theme) => ({
|
|
1153
|
+
tabs: {
|
|
1154
|
+
borderBottom: `1px solid ${theme.palette.textVerySubtle}`,
|
|
1155
|
+
padding: theme.spacing(0, 4)
|
|
1156
|
+
},
|
|
1157
|
+
tab: {
|
|
1158
|
+
height: "50px",
|
|
1159
|
+
fontWeight: theme.typography.fontWeightBold,
|
|
1160
|
+
fontSize: theme.typography.pxToRem(13),
|
|
1161
|
+
color: theme.palette.textSubtle,
|
|
1162
|
+
minWidth: "130px"
|
|
1163
|
+
}
|
|
1164
|
+
}));
|
|
1165
|
+
const SearchTypeTabs = (props) => {
|
|
1166
|
+
const classes = useStyles$1();
|
|
1167
|
+
const { setPageCursor, setTypes, types } = useSearch();
|
|
1168
|
+
const { defaultValue, types: givenTypes } = props;
|
|
1169
|
+
const changeTab = (_, newType) => {
|
|
1170
|
+
setTypes(newType !== "" ? [newType] : []);
|
|
1171
|
+
setPageCursor(void 0);
|
|
1172
|
+
};
|
|
1173
|
+
useEffect(() => {
|
|
1174
|
+
if (defaultValue) {
|
|
1175
|
+
setTypes([defaultValue]);
|
|
1176
|
+
}
|
|
1177
|
+
}, []);
|
|
1178
|
+
const definedTypes = [
|
|
1179
|
+
{
|
|
1180
|
+
value: "",
|
|
1181
|
+
name: "All"
|
|
1182
|
+
},
|
|
1183
|
+
...givenTypes
|
|
1184
|
+
];
|
|
1185
|
+
return /* @__PURE__ */ React.createElement(Tabs, {
|
|
1186
|
+
className: classes.tabs,
|
|
1187
|
+
indicatorColor: "primary",
|
|
1188
|
+
value: types.length === 0 ? "" : types[0],
|
|
1189
|
+
onChange: changeTab
|
|
1190
|
+
}, definedTypes.map((type) => /* @__PURE__ */ React.createElement(Tab, {
|
|
1191
|
+
className: classes.tab,
|
|
1192
|
+
disableRipple: true,
|
|
1193
|
+
label: type.name,
|
|
1194
|
+
value: type.value
|
|
1195
|
+
})));
|
|
1039
1196
|
};
|
|
1040
1197
|
|
|
1041
1198
|
const useStyles = makeStyles((theme) => ({
|
|
@@ -1051,12 +1208,8 @@ const useStyles = makeStyles((theme) => ({
|
|
|
1051
1208
|
margin: 2
|
|
1052
1209
|
}
|
|
1053
1210
|
}));
|
|
1054
|
-
const SearchType = ({
|
|
1055
|
-
values = []
|
|
1056
|
-
className,
|
|
1057
|
-
name,
|
|
1058
|
-
defaultValue
|
|
1059
|
-
}) => {
|
|
1211
|
+
const SearchType = (props) => {
|
|
1212
|
+
const { className, defaultValue, name, values = [] } = props;
|
|
1060
1213
|
const classes = useStyles();
|
|
1061
1214
|
const { types, setTypes } = useSearch();
|
|
1062
1215
|
useEffectOnce(() => {
|
|
@@ -1072,50 +1225,61 @@ const SearchType = ({
|
|
|
1072
1225
|
const value = e.target.value;
|
|
1073
1226
|
setTypes(value);
|
|
1074
1227
|
};
|
|
1075
|
-
return /* @__PURE__ */
|
|
1228
|
+
return /* @__PURE__ */ React.createElement(FormControl, {
|
|
1076
1229
|
className,
|
|
1077
1230
|
variant: "filled",
|
|
1078
1231
|
fullWidth: true,
|
|
1079
1232
|
"data-testid": "search-typefilter-next"
|
|
1080
|
-
}, /* @__PURE__ */
|
|
1233
|
+
}, /* @__PURE__ */ React.createElement(InputLabel, {
|
|
1081
1234
|
className: classes.label,
|
|
1082
1235
|
margin: "dense"
|
|
1083
|
-
}, name), /* @__PURE__ */
|
|
1236
|
+
}, name), /* @__PURE__ */ React.createElement(Select, {
|
|
1084
1237
|
multiple: true,
|
|
1085
1238
|
variant: "outlined",
|
|
1086
1239
|
value: types,
|
|
1087
1240
|
onChange: handleChange,
|
|
1088
1241
|
placeholder: "All Results",
|
|
1089
|
-
renderValue: (selected) => /* @__PURE__ */
|
|
1242
|
+
renderValue: (selected) => /* @__PURE__ */ React.createElement("div", {
|
|
1090
1243
|
className: classes.chips
|
|
1091
|
-
}, selected.map((value) => /* @__PURE__ */
|
|
1244
|
+
}, selected.map((value) => /* @__PURE__ */ React.createElement(Chip, {
|
|
1092
1245
|
key: value,
|
|
1093
1246
|
label: value,
|
|
1094
1247
|
className: classes.chip,
|
|
1095
1248
|
size: "small"
|
|
1096
1249
|
})))
|
|
1097
|
-
}, values.map((value) => /* @__PURE__ */
|
|
1250
|
+
}, values.map((value) => /* @__PURE__ */ React.createElement(MenuItem, {
|
|
1098
1251
|
key: value,
|
|
1099
1252
|
value
|
|
1100
|
-
}, /* @__PURE__ */
|
|
1253
|
+
}, /* @__PURE__ */ React.createElement(Checkbox, {
|
|
1101
1254
|
checked: types.indexOf(value) > -1
|
|
1102
|
-
}), /* @__PURE__ */
|
|
1255
|
+
}), /* @__PURE__ */ React.createElement(ListItemText, {
|
|
1103
1256
|
primary: value
|
|
1104
1257
|
})))));
|
|
1105
1258
|
};
|
|
1259
|
+
SearchType.Accordion = (props) => {
|
|
1260
|
+
return /* @__PURE__ */ React.createElement(SearchTypeAccordion, {
|
|
1261
|
+
...props
|
|
1262
|
+
});
|
|
1263
|
+
};
|
|
1264
|
+
SearchType.Tabs = (props) => {
|
|
1265
|
+
return /* @__PURE__ */ React.createElement(SearchTypeTabs, {
|
|
1266
|
+
...props
|
|
1267
|
+
});
|
|
1268
|
+
};
|
|
1106
1269
|
|
|
1107
|
-
const SidebarSearch = () => {
|
|
1270
|
+
const SidebarSearch = (props) => {
|
|
1108
1271
|
const searchRoute = useRouteRef(rootRouteRef);
|
|
1109
1272
|
const navigate = useNavigate();
|
|
1110
1273
|
const handleSearch = useCallback((query) => {
|
|
1111
1274
|
const queryString = qs.stringify({ query }, { addQueryPrefix: true });
|
|
1112
1275
|
navigate(`${searchRoute()}${queryString}`);
|
|
1113
1276
|
}, [navigate, searchRoute]);
|
|
1114
|
-
return /* @__PURE__ */
|
|
1277
|
+
return /* @__PURE__ */ React.createElement(SidebarSearchField, {
|
|
1278
|
+
icon: props.icon,
|
|
1115
1279
|
onSearch: handleSearch,
|
|
1116
1280
|
to: "/search"
|
|
1117
1281
|
});
|
|
1118
1282
|
};
|
|
1119
1283
|
|
|
1120
1284
|
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, SearchBarNext as m, SearchPage$1 as n, SearchPageNext as o, searchPlugin as p, SearchResult$1 as q, rootRouteRef as r, searchApiRef as s, SidebarSearchModal as t, useSearch as u };
|
|
1121
|
-
//# sourceMappingURL=index-
|
|
1285
|
+
//# sourceMappingURL=index-8bb5f525.esm.js.map
|