@backstage/plugin-catalog-react 1.15.1-next.1 → 1.15.1

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @backstage/plugin-catalog-react
2
2
 
3
+ ## 1.15.1
4
+
5
+ ### Patch Changes
6
+
7
+ - aaf6508: Creates new CatalogAutocomplete component in catalog-react that aligns with Select component UI for consistent a dropdown UI for all catalog filters.
8
+ - cbfc0a4: Fixed an issue where the `<EntityListProvider />` in `offset` mode would unnecessarily re-fetch data when the filter didn't change, causing a flicker effect.
9
+ - Updated dependencies
10
+ - @backstage/frontend-plugin-api@0.9.4
11
+ - @backstage/core-plugin-api@1.10.3
12
+ - @backstage/types@1.2.1
13
+ - @backstage/core-components@0.16.3
14
+ - @backstage/catalog-client@1.9.1
15
+ - @backstage/catalog-model@1.7.3
16
+ - @backstage/core-compat-api@0.3.5
17
+ - @backstage/errors@1.2.7
18
+ - @backstage/frontend-test-utils@0.2.5
19
+ - @backstage/integration-react@1.2.3
20
+ - @backstage/version-bridge@1.0.10
21
+ - @backstage/plugin-catalog-common@1.1.3
22
+ - @backstage/plugin-permission-common@0.8.4
23
+ - @backstage/plugin-permission-react@0.4.30
24
+
3
25
  ## 1.15.1-next.1
4
26
 
5
27
  ### Patch Changes
@@ -0,0 +1,119 @@
1
+ import Box from '@material-ui/core/Box';
2
+ import Typography from '@material-ui/core/Typography';
3
+ import Paper from '@material-ui/core/Paper';
4
+ import Popper from '@material-ui/core/Popper';
5
+ import TextField from '@material-ui/core/TextField';
6
+ import Grow from '@material-ui/core/Grow';
7
+ import { makeStyles, withStyles, createStyles } from '@material-ui/core/styles';
8
+ import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
9
+ import Autocomplete from '@material-ui/lab/Autocomplete';
10
+ import React, { useCallback } from 'react';
11
+ import { merge } from 'lodash';
12
+ import classNames from 'classnames';
13
+
14
+ const useStyles = makeStyles(
15
+ (theme) => ({
16
+ root: {
17
+ margin: theme.spacing(1, 0)
18
+ },
19
+ label: {
20
+ position: "relative",
21
+ fontWeight: "bold",
22
+ fontSize: theme.typography.body2.fontSize,
23
+ fontFamily: theme.typography.fontFamily,
24
+ color: theme.palette.text.primary,
25
+ "& > span": {
26
+ top: 0,
27
+ left: 0,
28
+ position: "absolute"
29
+ }
30
+ }
31
+ }),
32
+ { name: "BackstageAutocomplete" }
33
+ );
34
+ const BootstrapAutocomplete = withStyles(
35
+ (theme) => createStyles({
36
+ root: {},
37
+ paper: {
38
+ margin: 0
39
+ },
40
+ hasClearIcon: {},
41
+ hasPopupIcon: {},
42
+ focused: {},
43
+ inputRoot: {
44
+ marginTop: 24,
45
+ backgroundColor: theme.palette.background.paper,
46
+ "$root$hasClearIcon$hasPopupIcon &": {
47
+ paddingBlock: theme.spacing(0.75),
48
+ paddingInlineStart: theme.spacing(0.75)
49
+ },
50
+ "$root$focused &": {
51
+ outline: "none"
52
+ },
53
+ "$root &:hover > fieldset": {
54
+ borderColor: "#ced4da"
55
+ },
56
+ "$root$focused & > fieldset": {
57
+ borderWidth: 1,
58
+ borderColor: theme.palette.primary.main
59
+ }
60
+ },
61
+ popupIndicator: {
62
+ padding: 0,
63
+ margin: 0,
64
+ color: "#616161",
65
+ "&:hover": {
66
+ backgroundColor: "unset"
67
+ },
68
+ '& [class*="MuiTouchRipple-root"]': {
69
+ display: "none"
70
+ }
71
+ },
72
+ endAdornment: {
73
+ "$root$hasClearIcon$hasPopupIcon &": {
74
+ right: 4
75
+ }
76
+ },
77
+ input: {
78
+ "$root$hasClearIcon$hasPopupIcon &": {
79
+ fontSize: theme.typography.body1.fontSize,
80
+ paddingBlock: theme.spacing(0.8125)
81
+ }
82
+ }
83
+ }),
84
+ { name: "BackstageAutocompleteBase" }
85
+ )(Autocomplete);
86
+ const PopperComponent = (props) => /* @__PURE__ */ React.createElement(Popper, { ...props, transition: true, placement: "bottom-start" }, ({ TransitionProps }) => /* @__PURE__ */ React.createElement(Grow, { ...TransitionProps, style: { transformOrigin: "0 0 0" } }, /* @__PURE__ */ React.createElement(Box, null, props.children)));
87
+ const PaperComponent = (props) => /* @__PURE__ */ React.createElement(Paper, { ...props, elevation: 8 });
88
+ function CatalogAutocomplete(props) {
89
+ const { label, name, LabelProps, TextFieldProps, ...rest } = props;
90
+ const classes = useStyles();
91
+ const renderInput = useCallback(
92
+ (params) => /* @__PURE__ */ React.createElement(TextField, { ...merge(params, TextFieldProps), variant: "outlined" }),
93
+ [TextFieldProps]
94
+ );
95
+ const autocomplete = /* @__PURE__ */ React.createElement(
96
+ BootstrapAutocomplete,
97
+ {
98
+ size: "small",
99
+ ...rest,
100
+ renderInput: rest.renderInput ?? renderInput,
101
+ popupIcon: /* @__PURE__ */ React.createElement(ExpandMoreIcon, { "data-testid": `${name}-expand` }),
102
+ PaperComponent,
103
+ PopperComponent
104
+ }
105
+ );
106
+ return /* @__PURE__ */ React.createElement(Box, { className: classes.root }, label ? /* @__PURE__ */ React.createElement(
107
+ Typography,
108
+ {
109
+ ...LabelProps,
110
+ className: classNames(classes.label, LabelProps?.className),
111
+ component: "label"
112
+ },
113
+ /* @__PURE__ */ React.createElement(Box, { component: "span" }, label),
114
+ autocomplete
115
+ ) : autocomplete);
116
+ }
117
+
118
+ export { CatalogAutocomplete };
119
+ //# sourceMappingURL=CatalogAutocomplete.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CatalogAutocomplete.esm.js","sources":["../../../src/components/CatalogAutocomplete/CatalogAutocomplete.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Box from '@material-ui/core/Box';\nimport Typography, { TypographyProps } from '@material-ui/core/Typography';\nimport Paper, { PaperProps } from '@material-ui/core/Paper';\nimport Popper, { PopperProps } from '@material-ui/core/Popper';\nimport TextField, { OutlinedTextFieldProps } from '@material-ui/core/TextField';\nimport Grow from '@material-ui/core/Grow';\nimport {\n createStyles,\n makeStyles,\n Theme,\n withStyles,\n} from '@material-ui/core/styles';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport Autocomplete, {\n AutocompleteProps,\n AutocompleteRenderInputParams,\n} from '@material-ui/lab/Autocomplete';\nimport React, { ReactNode, useCallback } from 'react';\nimport { merge } from 'lodash';\nimport classNames from 'classnames';\n\nconst useStyles = makeStyles(\n theme => ({\n root: {\n margin: theme.spacing(1, 0),\n },\n label: {\n position: 'relative',\n fontWeight: 'bold',\n fontSize: theme.typography.body2.fontSize,\n fontFamily: theme.typography.fontFamily,\n color: theme.palette.text.primary,\n '& > span': {\n top: 0,\n left: 0,\n position: 'absolute',\n },\n },\n }),\n { name: 'BackstageAutocomplete' },\n);\n\nconst BootstrapAutocomplete = withStyles(\n (theme: Theme) =>\n createStyles({\n root: {},\n paper: {\n margin: 0,\n },\n hasClearIcon: {},\n hasPopupIcon: {},\n focused: {},\n inputRoot: {\n marginTop: 24,\n backgroundColor: theme.palette.background.paper,\n '$root$hasClearIcon$hasPopupIcon &': {\n paddingBlock: theme.spacing(0.75),\n paddingInlineStart: theme.spacing(0.75),\n },\n '$root$focused &': {\n outline: 'none',\n },\n '$root &:hover > fieldset': {\n borderColor: '#ced4da',\n },\n '$root$focused & > fieldset': {\n borderWidth: 1,\n borderColor: theme.palette.primary.main,\n },\n },\n popupIndicator: {\n padding: 0,\n margin: 0,\n color: '#616161',\n '&:hover': {\n backgroundColor: 'unset',\n },\n '& [class*=\"MuiTouchRipple-root\"]': {\n display: 'none',\n },\n },\n endAdornment: {\n '$root$hasClearIcon$hasPopupIcon &': {\n right: 4,\n },\n },\n input: {\n '$root$hasClearIcon$hasPopupIcon &': {\n fontSize: theme.typography.body1.fontSize,\n paddingBlock: theme.spacing(0.8125),\n },\n },\n }),\n { name: 'BackstageAutocompleteBase' },\n)(Autocomplete) as typeof Autocomplete;\n\nconst PopperComponent = (props: PopperProps) => (\n <Popper {...props} transition placement=\"bottom-start\">\n {({ TransitionProps }) => (\n <Grow {...TransitionProps} style={{ transformOrigin: '0 0 0' }}>\n <Box>{props.children as ReactNode}</Box>\n </Grow>\n )}\n </Popper>\n);\n\nconst PaperComponent = (props: PaperProps) => (\n <Paper {...props} elevation={8} />\n);\n\nexport type CatalogAutocompleteProps<\n T,\n Multiple extends boolean | undefined = undefined,\n DisableClearable extends boolean | undefined = undefined,\n FreeSolo extends boolean | undefined = undefined,\n> = Omit<\n AutocompleteProps<T, Multiple, DisableClearable, FreeSolo>,\n 'PopperComponent' | 'PaperComponent' | 'popupIcon' | 'renderInput'\n> & {\n name: string;\n label?: string;\n LabelProps?: TypographyProps<'label'>;\n TextFieldProps?: Omit<OutlinedTextFieldProps, 'variant'>;\n renderInput?: AutocompleteProps<\n T,\n Multiple,\n DisableClearable,\n FreeSolo\n >['renderInput'];\n};\n\nexport function CatalogAutocomplete<\n T,\n Multiple extends boolean | undefined = undefined,\n DisableClearable extends boolean | undefined = undefined,\n FreeSolo extends boolean | undefined = undefined,\n>(props: CatalogAutocompleteProps<T, Multiple, DisableClearable, FreeSolo>) {\n const { label, name, LabelProps, TextFieldProps, ...rest } = props;\n const classes = useStyles();\n const renderInput = useCallback(\n (params: AutocompleteRenderInputParams) => (\n <TextField {...merge(params, TextFieldProps)} variant=\"outlined\" />\n ),\n [TextFieldProps],\n );\n const autocomplete = (\n <BootstrapAutocomplete\n size=\"small\"\n {...rest}\n renderInput={rest.renderInput ?? renderInput}\n popupIcon={<ExpandMoreIcon data-testid={`${name}-expand`} />}\n PaperComponent={PaperComponent}\n PopperComponent={PopperComponent}\n />\n );\n\n return (\n <Box className={classes.root}>\n {label ? (\n <Typography\n {...LabelProps}\n className={classNames(classes.label, LabelProps?.className)}\n component=\"label\"\n >\n <Box component=\"span\">{label}</Box>\n {autocomplete}\n </Typography>\n ) : (\n autocomplete\n )}\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAqCA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB,CAAU,KAAA,MAAA;AAAA,IACR,IAAM,EAAA;AAAA,MACJ,MAAQ,EAAA,KAAA,CAAM,OAAQ,CAAA,CAAA,EAAG,CAAC;AAAA,KAC5B;AAAA,IACA,KAAO,EAAA;AAAA,MACL,QAAU,EAAA,UAAA;AAAA,MACV,UAAY,EAAA,MAAA;AAAA,MACZ,QAAA,EAAU,KAAM,CAAA,UAAA,CAAW,KAAM,CAAA,QAAA;AAAA,MACjC,UAAA,EAAY,MAAM,UAAW,CAAA,UAAA;AAAA,MAC7B,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,OAAA;AAAA,MAC1B,UAAY,EAAA;AAAA,QACV,GAAK,EAAA,CAAA;AAAA,QACL,IAAM,EAAA,CAAA;AAAA,QACN,QAAU,EAAA;AAAA;AACZ;AACF,GACF,CAAA;AAAA,EACA,EAAE,MAAM,uBAAwB;AAClC,CAAA;AAEA,MAAM,qBAAwB,GAAA,UAAA;AAAA,EAC5B,CAAC,UACC,YAAa,CAAA;AAAA,IACX,MAAM,EAAC;AAAA,IACP,KAAO,EAAA;AAAA,MACL,MAAQ,EAAA;AAAA,KACV;AAAA,IACA,cAAc,EAAC;AAAA,IACf,cAAc,EAAC;AAAA,IACf,SAAS,EAAC;AAAA,IACV,SAAW,EAAA;AAAA,MACT,SAAW,EAAA,EAAA;AAAA,MACX,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,UAAW,CAAA,KAAA;AAAA,MAC1C,mCAAqC,EAAA;AAAA,QACnC,YAAA,EAAc,KAAM,CAAA,OAAA,CAAQ,IAAI,CAAA;AAAA,QAChC,kB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,CAAA,GAAA,EAAA,EAAI,SAAU,EAAA,MAAA,EAAA,EAAQ,KAAM,CAAA;AAAA,IAC5B;AAAA,MAGH,YAEJ,CAAA;AAEJ;;;;"}
@@ -1,16 +1,13 @@
1
1
  import Box from '@material-ui/core/Box';
2
- import Typography from '@material-ui/core/Typography';
3
2
  import { makeStyles } from '@material-ui/core/styles';
4
- import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
5
- import Autocomplete from '@material-ui/lab/Autocomplete';
6
3
  import React, { useMemo, useState, useEffect } from 'react';
7
4
  import { useApi } from '@backstage/core-plugin-api';
8
5
  import useAsync from 'react-use/esm/useAsync';
9
6
  import { catalogApiRef } from '../../api.esm.js';
10
7
  import { EntityAutocompletePickerOption } from './EntityAutocompletePickerOption.esm.js';
11
- import { EntityAutocompletePickerInput } from './EntityAutocompletePickerInput.esm.js';
12
8
  import { useEntityList } from '../../hooks/useEntityListProvider.esm.js';
13
9
  import { reduceBackendCatalogFilters } from '../../utils/filters.esm.js';
10
+ import { CatalogAutocomplete } from '../CatalogAutocomplete/CatalogAutocomplete.esm.js';
14
11
 
15
12
  const useStyles = makeStyles(
16
13
  {
@@ -78,14 +75,16 @@ function EntityAutocompletePicker(props) {
78
75
  if (filter && typeof filter === "object" && !("values" in filter) || !availableOptions.length) {
79
76
  return null;
80
77
  }
81
- return /* @__PURE__ */ React.createElement(Box, { className: classes.root, pb: 1, pt: 1 }, /* @__PURE__ */ React.createElement(Typography, { className: classes.label, variant: "button", component: "label" }, label, /* @__PURE__ */ React.createElement(
82
- Autocomplete,
78
+ return /* @__PURE__ */ React.createElement(Box, { className: classes.root, pb: 1, pt: 1 }, /* @__PURE__ */ React.createElement(
79
+ CatalogAutocomplete,
83
80
  {
84
- PopperComponent: (popperProps) => /* @__PURE__ */ React.createElement("div", { ...popperProps }, popperProps.children),
85
81
  multiple: true,
86
82
  disableCloseOnSelect: true,
83
+ label,
84
+ name: `${String(name)}-picker`,
87
85
  options: availableOptions,
88
86
  value: selectedOptions,
87
+ TextFieldProps: InputProps,
89
88
  onChange: (_event, options) => setSelectedOptions(options),
90
89
  renderOption: (option, { selected }) => /* @__PURE__ */ React.createElement(
91
90
  EntityAutocompletePickerOption,
@@ -95,12 +94,9 @@ function EntityAutocompletePicker(props) {
95
94
  availableOptions: availableValues,
96
95
  showCounts: !!showCounts
97
96
  }
98
- ),
99
- size: "small",
100
- popupIcon: /* @__PURE__ */ React.createElement(ExpandMoreIcon, { "data-testid": `${String(name)}-picker-expand` }),
101
- renderInput: (params) => /* @__PURE__ */ React.createElement(EntityAutocompletePickerInput, { ...params, ...InputProps })
97
+ )
102
98
  }
103
- )));
99
+ ));
104
100
  }
105
101
 
106
102
  export { EntityAutocompletePicker };
@@ -1 +1 @@
1
- {"version":3,"file":"EntityAutocompletePicker.esm.js","sources":["../../../src/components/EntityAutocompletePicker/EntityAutocompletePicker.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Box from '@material-ui/core/Box';\nimport { TextFieldProps } from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport React, { useEffect, useMemo, useState, ReactNode } from 'react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsync from 'react-use/esm/useAsync';\nimport { catalogApiRef } from '../../api';\nimport { EntityAutocompletePickerOption } from './EntityAutocompletePickerOption';\nimport { EntityAutocompletePickerInput } from './EntityAutocompletePickerInput';\nimport {\n DefaultEntityFilters,\n useEntityList,\n} from '../../hooks/useEntityListProvider';\nimport { EntityFilter } from '../../types';\nimport { reduceBackendCatalogFilters } from '../../utils/filters';\n\n/** @public */\nexport type AllowedEntityFilters<T extends DefaultEntityFilters> = {\n [K in keyof T]-?: NonNullable<T[K]> extends EntityFilter & {\n values: string[];\n }\n ? K\n : never;\n}[keyof T];\n\n/** @public */\nexport type EntityAutocompletePickerProps<\n T extends DefaultEntityFilters = DefaultEntityFilters,\n Name extends AllowedEntityFilters<T> = AllowedEntityFilters<T>,\n> = {\n label: string;\n name: Name;\n path: string;\n showCounts?: boolean;\n Filter: { new (values: string[]): NonNullable<T[Name]> };\n InputProps?: TextFieldProps;\n initialSelectedOptions?: string[];\n filtersForAvailableValues?: Array<keyof T>;\n};\n\n/** @public */\nexport type CatalogReactEntityAutocompletePickerClassKey = 'root' | 'label';\n\nconst useStyles = makeStyles(\n {\n root: {},\n label: {\n textTransform: 'none',\n fontWeight: 'bold',\n },\n },\n { name: 'CatalogReactEntityAutocompletePicker' },\n);\n\n/** @public */\nexport function EntityAutocompletePicker<\n T extends DefaultEntityFilters = DefaultEntityFilters,\n Name extends AllowedEntityFilters<T> = AllowedEntityFilters<T>,\n>(props: EntityAutocompletePickerProps<T, Name>) {\n const {\n label,\n name,\n path,\n showCounts,\n Filter,\n InputProps,\n initialSelectedOptions = [],\n filtersForAvailableValues = ['kind'],\n } = props;\n\n const classes = useStyles();\n\n const {\n updateFilters,\n filters,\n queryParameters: { [name]: queryParameter },\n } = useEntityList<T>();\n\n const catalogApi = useApi(catalogApiRef);\n const availableValuesFilters = filtersForAvailableValues.map(\n f => filters[f] as EntityFilter | undefined,\n );\n const { value: availableValues } = useAsync(async () => {\n const facet = path;\n const { facets } = await catalogApi.getEntityFacets({\n facets: [facet],\n filter: reduceBackendCatalogFilters(\n availableValuesFilters.filter(Boolean) as EntityFilter[],\n ),\n });\n\n return Object.fromEntries(\n facets[facet].map(({ value, count }) => [value, count]),\n );\n }, [...availableValuesFilters]);\n\n const queryParameters = useMemo(\n () => [queryParameter].flat().filter(Boolean) as string[],\n [queryParameter],\n );\n\n const [selectedOptions, setSelectedOptions] = useState(\n queryParameters.length\n ? queryParameters\n : (filters[name] as unknown as { values: string[] })?.values ??\n initialSelectedOptions,\n );\n\n // Set selected options on query parameter updates; this happens at initial page load and from\n // external updates to the page location\n useEffect(() => {\n if (queryParameters.length) {\n setSelectedOptions(queryParameters);\n }\n }, [queryParameters]);\n\n const availableOptions = Object.keys(availableValues ?? {});\n const shouldAddFilter = selectedOptions.length && availableOptions.length;\n\n useEffect(() => {\n updateFilters({\n [name]: shouldAddFilter ? new Filter(selectedOptions) : undefined,\n } as Partial<T>);\n }, [name, shouldAddFilter, selectedOptions, Filter, updateFilters]);\n\n const filter = filters[name];\n if (\n (filter && typeof filter === 'object' && !('values' in filter)) ||\n !availableOptions.length\n ) {\n return null;\n }\n\n return (\n <Box className={classes.root} pb={1} pt={1}>\n <Typography className={classes.label} variant=\"button\" component=\"label\">\n {label}\n <Autocomplete<string, true>\n PopperComponent={popperProps => (\n <div {...popperProps}>{popperProps.children as ReactNode}</div>\n )}\n multiple\n disableCloseOnSelect\n options={availableOptions}\n value={selectedOptions}\n onChange={(_event: object, options: string[]) =>\n setSelectedOptions(options)\n }\n renderOption={(option, { selected }) => (\n <EntityAutocompletePickerOption\n selected={selected}\n value={option}\n availableOptions={availableValues}\n showCounts={!!showCounts}\n />\n )}\n size=\"small\"\n popupIcon={\n <ExpandMoreIcon data-testid={`${String(name)}-picker-expand`} />\n }\n renderInput={params => (\n <EntityAutocompletePickerInput {...params} {...InputProps} />\n )}\n />\n </Typography>\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA8DA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB;AAAA,IACE,MAAM,EAAC;AAAA,IACP,KAAO,EAAA;AAAA,MACL,aAAe,EAAA,MAAA;AAAA,MACf,UAAY,EAAA;AAAA;AACd,GACF;AAAA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,YAAA;AAAA,IAAA;AAAA,MACC,iBAAiB,CACf,WAAA,qBAAA,KAAA,CAAA,aAAA,CAAC,SAAK,GAAG,WAAA,EAAA,EAAc,YAAY,QAAsB,CAAA;AAAA,MAE3D,QAAQ,EAAA,IAAA;AAAA,MACR,oBAAoB,EAAA,IAAA;AAAA,MACpB,OAAS,EAAA,gBAAA;AAAA,MACT,KAAO,EAAA,eAAA;AAAA,MACP,QAAU,EAAA,CAAC,MAAgB,EAAA,OAAA,KACzB,mBAAmB,OAAO,CAAA;AAAA,MAE5B,YAAc,EAAA,CAAC,MAAQ,EAAA,EAAE,UACvB,qBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,8BAAA;AAAA,QAAA;AAAA,UACC,QAAA;AAAA,UACA,KAAO,EAAA,MAAA;AAAA,UACP,gBAAkB,EAAA,eAAA;AAAA,UAClB,UAAA,EAAY,CAAC,CAAC;AAAA;AAAA,OAChB;AAAA,MAEF,IAAK,EAAA,OAAA;AAAA,MACL,SAAA,sCACG,cAAe,EAAA,EAAA,aAAA,EAAa,GAAG,MAAO,CAAA,IAAI,CAAC,CAAkB,cAAA,CAAA,EAAA,CAAA;AAAA,MAEhE,aAAa,CACX,MAAA,qBAAA,KAAA,CAAA,aAAA,CAAC,iCAA+B,GAAG,MAAA,EAAS,GAAG,UAAY,EAAA;AAAA;AAAA,GAGjE,CACF,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"EntityAutocompletePicker.esm.js","sources":["../../../src/components/EntityAutocompletePicker/EntityAutocompletePicker.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Box from '@material-ui/core/Box';\nimport { TextFieldProps } from '@material-ui/core/TextField';\nimport { makeStyles } from '@material-ui/core/styles';\nimport React, { useEffect, useMemo, useState } from 'react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport useAsync from 'react-use/esm/useAsync';\nimport { catalogApiRef } from '../../api';\nimport { EntityAutocompletePickerOption } from './EntityAutocompletePickerOption';\nimport {\n DefaultEntityFilters,\n useEntityList,\n} from '../../hooks/useEntityListProvider';\nimport { EntityFilter } from '../../types';\nimport { reduceBackendCatalogFilters } from '../../utils/filters';\nimport { CatalogAutocomplete } from '../CatalogAutocomplete';\n\n/** @public */\nexport type AllowedEntityFilters<T extends DefaultEntityFilters> = {\n [K in keyof T]-?: NonNullable<T[K]> extends EntityFilter & {\n values: string[];\n }\n ? K\n : never;\n}[keyof T];\n\n/** @public */\nexport type EntityAutocompletePickerProps<\n T extends DefaultEntityFilters = DefaultEntityFilters,\n Name extends AllowedEntityFilters<T> = AllowedEntityFilters<T>,\n> = {\n label: string;\n name: Name;\n path: string;\n showCounts?: boolean;\n Filter: { new (values: string[]): NonNullable<T[Name]> };\n InputProps?: TextFieldProps;\n initialSelectedOptions?: string[];\n filtersForAvailableValues?: Array<keyof T>;\n};\n\n/** @public */\nexport type CatalogReactEntityAutocompletePickerClassKey = 'root' | 'label';\n\nconst useStyles = makeStyles(\n {\n root: {},\n label: {\n textTransform: 'none',\n fontWeight: 'bold',\n },\n },\n { name: 'CatalogReactEntityAutocompletePicker' },\n);\n\n/** @public */\nexport function EntityAutocompletePicker<\n T extends DefaultEntityFilters = DefaultEntityFilters,\n Name extends AllowedEntityFilters<T> = AllowedEntityFilters<T>,\n>(props: EntityAutocompletePickerProps<T, Name>) {\n const {\n label,\n name,\n path,\n showCounts,\n Filter,\n InputProps,\n initialSelectedOptions = [],\n filtersForAvailableValues = ['kind'],\n } = props;\n const classes = useStyles();\n\n const {\n updateFilters,\n filters,\n queryParameters: { [name]: queryParameter },\n } = useEntityList<T>();\n\n const catalogApi = useApi(catalogApiRef);\n const availableValuesFilters = filtersForAvailableValues.map(\n f => filters[f] as EntityFilter | undefined,\n );\n const { value: availableValues } = useAsync(async () => {\n const facet = path;\n const { facets } = await catalogApi.getEntityFacets({\n facets: [facet],\n filter: reduceBackendCatalogFilters(\n availableValuesFilters.filter(Boolean) as EntityFilter[],\n ),\n });\n\n return Object.fromEntries(\n facets[facet].map(({ value, count }) => [value, count]),\n );\n }, [...availableValuesFilters]);\n\n const queryParameters = useMemo(\n () => [queryParameter].flat().filter(Boolean) as string[],\n [queryParameter],\n );\n\n const [selectedOptions, setSelectedOptions] = useState(\n queryParameters.length\n ? queryParameters\n : (filters[name] as unknown as { values: string[] })?.values ??\n initialSelectedOptions,\n );\n\n // Set selected options on query parameter updates; this happens at initial page load and from\n // external updates to the page location\n useEffect(() => {\n if (queryParameters.length) {\n setSelectedOptions(queryParameters);\n }\n }, [queryParameters]);\n\n const availableOptions = Object.keys(availableValues ?? {});\n const shouldAddFilter = selectedOptions.length && availableOptions.length;\n\n useEffect(() => {\n updateFilters({\n [name]: shouldAddFilter ? new Filter(selectedOptions) : undefined,\n } as Partial<T>);\n }, [name, shouldAddFilter, selectedOptions, Filter, updateFilters]);\n\n const filter = filters[name];\n if (\n (filter && typeof filter === 'object' && !('values' in filter)) ||\n !availableOptions.length\n ) {\n return null;\n }\n\n return (\n <Box className={classes.root} pb={1} pt={1}>\n <CatalogAutocomplete<string, true>\n multiple\n disableCloseOnSelect\n label={label}\n name={`${String(name)}-picker`}\n options={availableOptions}\n value={selectedOptions}\n TextFieldProps={InputProps}\n onChange={(_event: object, options: string[]) =>\n setSelectedOptions(options)\n }\n renderOption={(option, { selected }) => (\n <EntityAutocompletePickerOption\n selected={selected}\n value={option}\n availableOptions={availableValues}\n showCounts={!!showCounts}\n />\n )}\n />\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA2DA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB;A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AAC,mBAAA;AAAA,IAAA;AAAA,MACC,QAAQ,EAAA,IAAA;AAAA,MACR,oBAAoB,EAAA,IAAA;AAAA,MACpB,KAAA;AAAA,MACA,IAAM,EAAA,CAAA,EAAG,MAAO,CAAA,IAAI,CAAC,CAAA,OAAA,CAAA;AAAA,MACrB,OAAS,EAAA,gBAAA;AAAA,MACT,KAAO,EAAA,eAAA;AAAA,MACP,cAAgB,EAAA,UAAA;AAAA,MAChB,QAAU,EAAA,CAAC,MAAgB,EAAA,OAAA,KACzB,mBAAmB,OAAO,CAAA;AAAA,MAE5B,YAAc,EAAA,CAAC,MAAQ,EAAA,EAAE,UACvB,qBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,8BAAA;AAAA,QAAA;AAAA,UACC,QAAA;AAAA,UACA,KAAO,EAAA,MAAA;AAAA,UACP,gBAAkB,EAAA,eAAA;AAAA,UAClB,UAAA,EAAY,CAAC,CAAC;AAAA;AAAA;AAChB;AAAA,GAGN,CAAA;AAEJ;;;;"}
@@ -2,14 +2,11 @@ import { stringifyEntityRef, parseEntityRef } from '@backstage/catalog-model';
2
2
  import Box from '@material-ui/core/Box';
3
3
  import Checkbox from '@material-ui/core/Checkbox';
4
4
  import FormControlLabel from '@material-ui/core/FormControlLabel';
5
- import TextField from '@material-ui/core/TextField';
6
5
  import Typography from '@material-ui/core/Typography';
7
6
  import Tooltip from '@material-ui/core/Tooltip';
8
- import { makeStyles, createStyles, withStyles } from '@material-ui/core/styles';
7
+ import { makeStyles, withStyles } from '@material-ui/core/styles';
9
8
  import CheckBoxIcon from '@material-ui/icons/CheckBox';
10
9
  import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';
11
- import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
12
- import Autocomplete from '@material-ui/lab/Autocomplete';
13
10
  import React, { useState, useMemo, useEffect } from 'react';
14
11
  import { useEntityList } from '../../hooks/useEntityListProvider.esm.js';
15
12
  import { EntityOwnerFilter } from '../../filters.esm.js';
@@ -25,24 +22,20 @@ import '../../apis/StarredEntitiesApi/StarredEntitiesApi.esm.js';
25
22
  import 'zen-observable';
26
23
  import { catalogReactTranslationRef } from '../../translation.esm.js';
27
24
  import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
25
+ import { CatalogAutocomplete } from '../CatalogAutocomplete/CatalogAutocomplete.esm.js';
28
26
 
29
27
  const useStyles = makeStyles(
30
- (theme) => createStyles({
28
+ {
31
29
  root: {},
32
- label: {
33
- textTransform: "none",
34
- fontWeight: "bold"
35
- },
36
- input: {
37
- backgroundColor: theme.palette.background.paper
38
- },
30
+ label: {},
31
+ input: {},
39
32
  fullWidth: { width: "100%" },
40
33
  boxLabel: {
41
34
  width: "100%",
42
35
  textOverflow: "ellipsis",
43
36
  overflow: "hidden"
44
37
  }
45
- }),
38
+ },
46
39
  { name: "CatalogReactEntityOwnerPicker" }
47
40
  );
48
41
  const FixedWidthFormControlLabel = withStyles(
@@ -118,10 +111,10 @@ const EntityOwnerPicker = (props) => {
118
111
  )) {
119
112
  return null;
120
113
  }
121
- return /* @__PURE__ */ React.createElement(Box, { className: classes.root, pb: 1, pt: 1 }, /* @__PURE__ */ React.createElement(Typography, { className: classes.label, variant: "button", component: "label" }, t("entityOwnerPicker.title"), /* @__PURE__ */ React.createElement(
122
- Autocomplete,
114
+ return /* @__PURE__ */ React.createElement(Box, { className: classes.root, pb: 1, pt: 1 }, /* @__PURE__ */ React.createElement(
115
+ CatalogAutocomplete,
123
116
  {
124
- PopperComponent: Popper,
117
+ label: t("entityOwnerPicker.title"),
125
118
  multiple: true,
126
119
  disableCloseOnSelect: true,
127
120
  loading,
@@ -156,19 +149,10 @@ const EntityOwnerPicker = (props) => {
156
149
  renderOption: (entity, { selected }) => {
157
150
  return /* @__PURE__ */ React.createElement(RenderOptionLabel, { entity, isSelected: selected });
158
151
  },
159
- size: "small",
160
- popupIcon: /* @__PURE__ */ React.createElement(ExpandMoreIcon, { "data-testid": "owner-picker-expand" }),
161
- renderInput: (params) => /* @__PURE__ */ React.createElement(
162
- TextField,
163
- {
164
- ...params,
165
- className: classes.input,
166
- onChange: (e) => {
167
- setText(e.currentTarget.value);
168
- },
169
- variant: "outlined"
170
- }
171
- ),
152
+ name: "owner-picker",
153
+ onInputChange: (_e, inputValue) => {
154
+ setText(inputValue);
155
+ },
172
156
  ListboxProps: {
173
157
  onScroll: (e) => {
174
158
  const element = e.currentTarget;
@@ -180,13 +164,12 @@ const EntityOwnerPicker = (props) => {
180
164
  }
181
165
  },
182
166
  "data-testid": "owner-picker-listbox"
183
- }
167
+ },
168
+ LabelProps: { className: classes.label },
169
+ TextFieldProps: { className: classes.input }
184
170
  }
185
- )));
171
+ ));
186
172
  };
187
- function Popper({ children }) {
188
- return /* @__PURE__ */ React.createElement("div", null, children);
189
- }
190
173
 
191
174
  export { EntityOwnerPicker };
192
175
  //# sourceMappingURL=EntityOwnerPicker.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityOwnerPicker.esm.js","sources":["../../../src/components/EntityOwnerPicker/EntityOwnerPicker.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Entity,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport Box from '@material-ui/core/Box';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport CheckBoxIcon from '@material-ui/icons/CheckBox';\nimport CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport React, { useEffect, useMemo, useState, ReactNode } from 'react';\nimport { useEntityList } from '../../hooks/useEntityListProvider';\nimport { EntityOwnerFilter } from '../../filters';\nimport { useDebouncedEffect } from '@react-hookz/web';\nimport PersonIcon from '@material-ui/icons/Person';\nimport GroupIcon from '@material-ui/icons/Group';\nimport { humanizeEntity, humanizeEntityRef } from '../EntityRefLink/humanize';\nimport { useFetchEntities } from './useFetchEntities';\nimport { withStyles } from '@material-ui/core/styles';\nimport { useEntityPresentation } from '../../apis';\nimport { catalogReactTranslationRef } from '../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { PopperProps } from '@material-ui/core/Popper';\n\n/** @public */\nexport type CatalogReactEntityOwnerPickerClassKey = 'input';\n\nconst useStyles = makeStyles(\n (theme: Theme) =>\n createStyles({\n root: {},\n label: {\n textTransform: 'none',\n fontWeight: 'bold',\n },\n input: {\n backgroundColor: theme.palette.background.paper,\n },\n fullWidth: { width: '100%' },\n boxLabel: {\n width: '100%',\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n },\n }),\n { name: 'CatalogReactEntityOwnerPicker' },\n);\n\n/** @public */\nexport type FixedWidthFormControlLabelClassKey = 'label' | 'root';\n\nconst FixedWidthFormControlLabel = withStyles(\n _theme => ({\n label: {\n width: '100%',\n },\n root: {\n width: '90%',\n },\n }),\n { name: 'FixedWidthFormControlLabel' },\n)(FormControlLabel);\n\nconst icon = <CheckBoxOutlineBlankIcon fontSize=\"small\" />;\nconst checkedIcon = <CheckBoxIcon fontSize=\"small\" />;\n\n/**\n * @public\n */\nexport type EntityOwnerPickerProps = {\n mode?: 'owners-only' | 'all';\n};\n\nfunction RenderOptionLabel(props: { entity: Entity; isSelected: boolean }) {\n const classes = useStyles();\n const isGroup = props.entity.kind.toLocaleLowerCase('en-US') === 'group';\n const { primaryTitle: title } = useEntityPresentation(props.entity);\n return (\n <Box className={classes.fullWidth}>\n <FixedWidthFormControlLabel\n className={classes.fullWidth}\n control={\n <Checkbox\n icon={icon}\n checkedIcon={checkedIcon}\n checked={props.isSelected}\n />\n }\n onClick={event => event.preventDefault()}\n label={\n <Tooltip title={title}>\n <Box display=\"flex\" alignItems=\"center\">\n {isGroup ? (\n <GroupIcon fontSize=\"small\" />\n ) : (\n <PersonIcon fontSize=\"small\" />\n )}\n &nbsp;\n <Box className={classes.boxLabel}>\n <Typography noWrap>{title}</Typography>\n </Box>\n </Box>\n </Tooltip>\n }\n />\n </Box>\n );\n}\n\n/** @public */\nexport const EntityOwnerPicker = (props?: EntityOwnerPickerProps) => {\n const classes = useStyles();\n const { mode = 'owners-only' } = props || {};\n const {\n updateFilters,\n filters,\n queryParameters: { owners: ownersParameter },\n } = useEntityList();\n\n const [text, setText] = useState('');\n const { t } = useTranslationRef(catalogReactTranslationRef);\n\n const queryParamOwners = useMemo(\n () => [ownersParameter].flat().filter(Boolean) as string[],\n [ownersParameter],\n );\n\n const [selectedOwners, setSelectedOwners] = useState(\n queryParamOwners.length ? queryParamOwners : filters.owners?.values ?? [],\n );\n\n const [{ value, loading }, handleFetch, cache] = useFetchEntities({\n mode,\n initialSelectedOwnersRefs: selectedOwners,\n });\n useDebouncedEffect(() => handleFetch({ text }), [text, handleFetch], 250);\n\n const availableOwners = value?.items || [];\n\n // Set selected owners on query parameter updates; this happens at initial page load and from\n // external updates to the page location.\n useEffect(() => {\n if (queryParamOwners.length) {\n const filter = new EntityOwnerFilter(queryParamOwners);\n setSelectedOwners(filter.values);\n }\n }, [queryParamOwners]);\n\n useEffect(() => {\n updateFilters({\n owners: selectedOwners.length\n ? new EntityOwnerFilter(selectedOwners)\n : undefined,\n });\n }, [selectedOwners, updateFilters]);\n\n if (\n ['user', 'group'].includes(\n filters.kind?.value.toLocaleLowerCase('en-US') || '',\n )\n ) {\n return null;\n }\n\n return (\n <Box className={classes.root} pb={1} pt={1}>\n <Typography className={classes.label} variant=\"button\" component=\"label\">\n {t('entityOwnerPicker.title')}\n <Autocomplete\n PopperComponent={Popper}\n multiple\n disableCloseOnSelect\n loading={loading}\n options={availableOwners}\n value={selectedOwners as unknown as Entity[]}\n getOptionSelected={(o, v) => {\n if (typeof v === 'string') {\n return stringifyEntityRef(o) === v;\n }\n return o === v;\n }}\n getOptionLabel={o => {\n const entity =\n typeof o === 'string'\n ? cache.getEntity(o) ||\n parseEntityRef(o, {\n defaultKind: 'group',\n defaultNamespace: 'default',\n })\n : o;\n return humanizeEntity(entity, humanizeEntityRef(entity));\n }}\n onChange={(_: object, owners) => {\n setText('');\n setSelectedOwners(\n owners.map(e => {\n const entityRef =\n typeof e === 'string' ? e : stringifyEntityRef(e);\n\n if (typeof e !== 'string') {\n cache.setEntity(e);\n }\n return entityRef;\n }),\n );\n }}\n filterOptions={x => x}\n renderOption={(entity, { selected }) => {\n return <RenderOptionLabel entity={entity} isSelected={selected} />;\n }}\n size=\"small\"\n popupIcon={<ExpandMoreIcon data-testid=\"owner-picker-expand\" />}\n renderInput={params => (\n <TextField\n {...params}\n className={classes.input}\n onChange={e => {\n setText(e.currentTarget.value);\n }}\n variant=\"outlined\"\n />\n )}\n ListboxProps={{\n onScroll: (e: React.MouseEvent) => {\n const element = e.currentTarget;\n const hasReachedEnd =\n Math.abs(\n element.scrollHeight -\n element.clientHeight -\n element.scrollTop,\n ) < 1;\n\n if (hasReachedEnd && value?.cursor) {\n handleFetch({ items: value.items, cursor: value.cursor });\n }\n },\n 'data-testid': 'owner-picker-listbox',\n }}\n />\n </Typography>\n </Box>\n );\n};\n\nfunction Popper({ children }: PopperProps) {\n return <div>{children as ReactNode}</div>;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB,CAAC,UACC,YAAa,CAAA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AAA,CAAM,OAAO,MAAQ,EAAA,KAAA,CAAM,QAAQ,CAAA;AAAA;AAC1D,SACF;AAAA,QACA,aAAe,EAAA;AAAA;AACjB;AAAA,GAEJ,CACF,CAAA;AAEJ;AAEA,SAAS,MAAA,CAAO,EAAE,QAAA,EAAyB,EAAA;AACzC,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,aAAK,QAAsB,CAAA;AACrC;;;;"}
1
+ {"version":3,"file":"EntityOwnerPicker.esm.js","sources":["../../../src/components/EntityOwnerPicker/EntityOwnerPicker.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Entity,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport Box from '@material-ui/core/Box';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport Typography from '@material-ui/core/Typography';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { makeStyles } from '@material-ui/core/styles';\nimport CheckBoxIcon from '@material-ui/icons/CheckBox';\nimport CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';\nimport React, { useEffect, useMemo, useState } from 'react';\nimport { useEntityList } from '../../hooks/useEntityListProvider';\nimport { EntityOwnerFilter } from '../../filters';\nimport { useDebouncedEffect } from '@react-hookz/web';\nimport PersonIcon from '@material-ui/icons/Person';\nimport GroupIcon from '@material-ui/icons/Group';\nimport { humanizeEntity, humanizeEntityRef } from '../EntityRefLink/humanize';\nimport { useFetchEntities } from './useFetchEntities';\nimport { withStyles } from '@material-ui/core/styles';\nimport { useEntityPresentation } from '../../apis';\nimport { catalogReactTranslationRef } from '../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { CatalogAutocomplete } from '../CatalogAutocomplete';\n\n/** @public */\nexport type CatalogReactEntityOwnerPickerClassKey = 'input';\n\nconst useStyles = makeStyles(\n {\n root: {},\n label: {},\n input: {},\n fullWidth: { width: '100%' },\n boxLabel: {\n width: '100%',\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n },\n },\n { name: 'CatalogReactEntityOwnerPicker' },\n);\n\n/** @public */\nexport type FixedWidthFormControlLabelClassKey = 'label' | 'root';\n\nconst FixedWidthFormControlLabel = withStyles(\n _theme => ({\n label: {\n width: '100%',\n },\n root: {\n width: '90%',\n },\n }),\n { name: 'FixedWidthFormControlLabel' },\n)(FormControlLabel);\n\nconst icon = <CheckBoxOutlineBlankIcon fontSize=\"small\" />;\nconst checkedIcon = <CheckBoxIcon fontSize=\"small\" />;\n\n/**\n * @public\n */\nexport type EntityOwnerPickerProps = {\n mode?: 'owners-only' | 'all';\n};\n\nfunction RenderOptionLabel(props: { entity: Entity; isSelected: boolean }) {\n const classes = useStyles();\n const isGroup = props.entity.kind.toLocaleLowerCase('en-US') === 'group';\n const { primaryTitle: title } = useEntityPresentation(props.entity);\n return (\n <Box className={classes.fullWidth}>\n <FixedWidthFormControlLabel\n className={classes.fullWidth}\n control={\n <Checkbox\n icon={icon}\n checkedIcon={checkedIcon}\n checked={props.isSelected}\n />\n }\n onClick={event => event.preventDefault()}\n label={\n <Tooltip title={title}>\n <Box display=\"flex\" alignItems=\"center\">\n {isGroup ? (\n <GroupIcon fontSize=\"small\" />\n ) : (\n <PersonIcon fontSize=\"small\" />\n )}\n &nbsp;\n <Box className={classes.boxLabel}>\n <Typography noWrap>{title}</Typography>\n </Box>\n </Box>\n </Tooltip>\n }\n />\n </Box>\n );\n}\n\n/** @public */\nexport const EntityOwnerPicker = (props?: EntityOwnerPickerProps) => {\n const classes = useStyles();\n const { mode = 'owners-only' } = props || {};\n const {\n updateFilters,\n filters,\n queryParameters: { owners: ownersParameter },\n } = useEntityList();\n\n const [text, setText] = useState('');\n const { t } = useTranslationRef(catalogReactTranslationRef);\n\n const queryParamOwners = useMemo(\n () => [ownersParameter].flat().filter(Boolean) as string[],\n [ownersParameter],\n );\n\n const [selectedOwners, setSelectedOwners] = useState<string[]>(\n queryParamOwners.length ? queryParamOwners : filters.owners?.values ?? [],\n );\n\n const [{ value, loading }, handleFetch, cache] = useFetchEntities({\n mode,\n initialSelectedOwnersRefs: selectedOwners,\n });\n useDebouncedEffect(() => handleFetch({ text }), [text, handleFetch], 250);\n\n const availableOwners = value?.items || [];\n\n // Set selected owners on query parameter updates; this happens at initial page load and from\n // external updates to the page location.\n useEffect(() => {\n if (queryParamOwners.length) {\n const filter = new EntityOwnerFilter(queryParamOwners);\n setSelectedOwners(filter.values);\n }\n }, [queryParamOwners]);\n\n useEffect(() => {\n updateFilters({\n owners: selectedOwners.length\n ? new EntityOwnerFilter(selectedOwners)\n : undefined,\n });\n }, [selectedOwners, updateFilters]);\n\n if (\n ['user', 'group'].includes(\n filters.kind?.value.toLocaleLowerCase('en-US') || '',\n )\n ) {\n return null;\n }\n\n return (\n <Box className={classes.root} pb={1} pt={1}>\n <CatalogAutocomplete<Entity, true>\n label={t('entityOwnerPicker.title')}\n multiple\n disableCloseOnSelect\n loading={loading}\n options={availableOwners}\n value={selectedOwners as unknown as Entity[]}\n getOptionSelected={(o, v) => {\n if (typeof v === 'string') {\n return stringifyEntityRef(o) === v;\n }\n return o === v;\n }}\n getOptionLabel={o => {\n const entity =\n typeof o === 'string'\n ? cache.getEntity(o) ||\n parseEntityRef(o, {\n defaultKind: 'group',\n defaultNamespace: 'default',\n })\n : o;\n return humanizeEntity(entity, humanizeEntityRef(entity));\n }}\n onChange={(_: object, owners) => {\n setText('');\n setSelectedOwners(\n owners.map(e => {\n const entityRef =\n typeof e === 'string' ? e : stringifyEntityRef(e);\n\n if (typeof e !== 'string') {\n cache.setEntity(e);\n }\n return entityRef;\n }),\n );\n }}\n filterOptions={x => x}\n renderOption={(entity, { selected }) => {\n return <RenderOptionLabel entity={entity} isSelected={selected} />;\n }}\n name=\"owner-picker\"\n onInputChange={(_e, inputValue) => {\n setText(inputValue);\n }}\n ListboxProps={{\n onScroll: (e: React.MouseEvent) => {\n const element = e.currentTarget;\n const hasReachedEnd =\n Math.abs(\n element.scrollHeight - element.clientHeight - element.scrollTop,\n ) < 1;\n\n if (hasReachedEnd && value?.cursor) {\n handleFetch({ items: value.items, cursor: value.cursor });\n }\n },\n 'data-testid': 'owner-picker-listbox',\n }}\n LabelProps={{ className: classes.label }}\n TextFieldProps={{ className: classes.input }}\n />\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB;AAAA,IACE,MAAM,EAAC;AAAA,IACP,OAAO,EAAC;AAAA,IACR,OAAO,EAAC;AAAA,IACR,SAAA,EAAW,EAAE,KAAA,EAAO,MAAO,EAAA;AAAA,IAC3B,QAAU,EAAA;AAAA,MACR,KAAO,EAAA,MAAA;AAAA,MACP,YAAc,EAAA,UAAA;AAAA,MACd,QAAU,EAAA;AAAA;AACZ,GACF;AAAA,EACA,EAAE,MAAM,+BAAgC;AAC1C,CAAA;AAKA,MAAM,0BAA6B,GAAA,UAAA;AAAA,EACjC,CAAW,MAAA,MAAA;AAAA,IACT,KAAO,EAAA;AAAA,MACL,KAAO,EAAA;AAAA,KACT;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,KAAO,EAAA;AAAA;AACT,GACF,CAAA;AAAA,EACA,EAAE,MAAM,4BAA6B;AACvC,CAAA,CAAE,gBAAgB,CAAA;AAElB,MAAM,IAAO,mBAAA,KAAA,CAAA,aAAA,CAAC,wBAAyB,EAAA,EAAA,QAAA,EAAS,OAAQ,EAAA,CAAA;AACxD,MAAM,WAAc,mBAAA,KAAA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AAA,CAAM,OAAO,MAAQ,EAAA,KAAA,CAAM,QAAQ,CAAA;AAAA;AAC1D,SACF;AAAA,QACA,aAAe,EAAA;AAAA,OACjB;AAAA,MACA,UAAY,EAAA,EAAE,SAAW,EAAA,OAAA,CAAQ,KAAM,EAAA;AAAA,MACvC,cAAgB,EAAA,EAAE,SAAW,EAAA,OAAA,CAAQ,KAAM;AAAA;AAAA,GAE/C,CAAA;AAEJ;;;;"}
@@ -2,12 +2,9 @@ import { EntityOrphanFilter, EntityErrorFilter } from '../../filters.esm.js';
2
2
  import Box from '@material-ui/core/Box';
3
3
  import Checkbox from '@material-ui/core/Checkbox';
4
4
  import FormControlLabel from '@material-ui/core/FormControlLabel';
5
- import TextField from '@material-ui/core/TextField';
6
- import Typography from '@material-ui/core/Typography';
7
- import { makeStyles, createStyles } from '@material-ui/core/styles';
5
+ import { makeStyles } from '@material-ui/core/styles';
8
6
  import CheckBoxIcon from '@material-ui/icons/CheckBox';
9
7
  import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';
10
- import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
11
8
  import React, { useState } from 'react';
12
9
  import '../../hooks/useEntity.esm.js';
13
10
  import { useEntityList } from '../../hooks/useEntityListProvider.esm.js';
@@ -22,21 +19,16 @@ import '../../apis/EntityPresentationApi/EntityPresentationApi.esm.js';
22
19
  import 'lodash/get';
23
20
  import '../../apis/StarredEntitiesApi/StarredEntitiesApi.esm.js';
24
21
  import 'zen-observable';
25
- import Autocomplete from '@material-ui/lab/Autocomplete';
26
22
  import { catalogReactTranslationRef } from '../../translation.esm.js';
27
23
  import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
24
+ import { CatalogAutocomplete } from '../CatalogAutocomplete/CatalogAutocomplete.esm.js';
28
25
 
29
26
  const useStyles = makeStyles(
30
- (theme) => createStyles({
27
+ {
31
28
  root: {},
32
- input: {
33
- backgroundColor: theme.palette.background.paper
34
- },
35
- label: {
36
- textTransform: "none",
37
- fontWeight: "bold"
38
- }
39
- }),
29
+ input: {},
30
+ label: {}
31
+ },
40
32
  { name: "CatalogReactEntityProcessingStatusPickerPicker" }
41
33
  );
42
34
  const icon = /* @__PURE__ */ React.createElement(CheckBoxOutlineBlankIcon, { fontSize: "small" });
@@ -59,10 +51,10 @@ const EntityProcessingStatusPicker = () => {
59
51
  });
60
52
  }
61
53
  const availableAdvancedItems = ["Is Orphan", "Has Error"];
62
- return /* @__PURE__ */ React.createElement(Box, { className: classes.root, pb: 1, pt: 1 }, /* @__PURE__ */ React.createElement(Typography, { className: classes.label, variant: "button", component: "label" }, t("entityProcessingStatusPicker.title"), /* @__PURE__ */ React.createElement(
63
- Autocomplete,
54
+ return /* @__PURE__ */ React.createElement(Box, { className: classes.root, pb: 1, pt: 1 }, /* @__PURE__ */ React.createElement(
55
+ CatalogAutocomplete,
64
56
  {
65
- PopperComponent: (popperProps) => /* @__PURE__ */ React.createElement("div", { ...popperProps }, popperProps.children),
57
+ label: t("entityProcessingStatusPicker.title"),
66
58
  multiple: true,
67
59
  disableCloseOnSelect: true,
68
60
  options: availableAdvancedItems,
@@ -87,18 +79,11 @@ const EntityProcessingStatusPicker = () => {
87
79
  label: option
88
80
  }
89
81
  ),
90
- size: "small",
91
- popupIcon: /* @__PURE__ */ React.createElement(ExpandMoreIcon, { "data-testid": "processing-status-picker-expand" }),
92
- renderInput: (params) => /* @__PURE__ */ React.createElement(
93
- TextField,
94
- {
95
- ...params,
96
- className: classes.input,
97
- variant: "outlined"
98
- }
99
- )
82
+ name: "processing-status-picker",
83
+ LabelProps: { className: classes.label },
84
+ TextFieldProps: { className: classes.input }
100
85
  }
101
- )));
86
+ ));
102
87
  };
103
88
 
104
89
  export { EntityProcessingStatusPicker };
@@ -1 +1 @@
1
- {"version":3,"file":"EntityProcessingStatusPicker.esm.js","sources":["../../../src/components/EntityProcessingStatusPicker/EntityProcessingStatusPicker.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { EntityErrorFilter, EntityOrphanFilter } from '../../filters';\nimport Box from '@material-ui/core/Box';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport CheckBoxIcon from '@material-ui/icons/CheckBox';\nimport CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport React, { useState, ReactNode } from 'react';\nimport { useEntityList } from '../../hooks';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport { catalogReactTranslationRef } from '../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\n\n/** @public */\nexport type CatalogReactEntityProcessingStatusPickerClassKey = 'input';\n\nconst useStyles = makeStyles(\n (theme: Theme) =>\n createStyles({\n root: {},\n input: {\n backgroundColor: theme.palette.background.paper,\n },\n label: {\n textTransform: 'none',\n fontWeight: 'bold',\n },\n }),\n { name: 'CatalogReactEntityProcessingStatusPickerPicker' },\n);\n\nconst icon = <CheckBoxOutlineBlankIcon fontSize=\"small\" />;\nconst checkedIcon = <CheckBoxIcon fontSize=\"small\" />;\n\n/** @public */\nexport const EntityProcessingStatusPicker = () => {\n const classes = useStyles();\n const { updateFilters } = useEntityList();\n const { t } = useTranslationRef(catalogReactTranslationRef);\n\n const [selectedAdvancedItems, setSelectedAdvancedItems] = useState<string[]>(\n [],\n );\n\n function orphanChange(value: boolean) {\n updateFilters({\n orphan: value ? new EntityOrphanFilter(value) : undefined,\n });\n }\n\n function errorChange(value: boolean) {\n updateFilters({\n error: value ? new EntityErrorFilter(value) : undefined,\n });\n }\n\n const availableAdvancedItems = ['Is Orphan', 'Has Error'];\n\n return (\n <Box className={classes.root} pb={1} pt={1}>\n <Typography className={classes.label} variant=\"button\" component=\"label\">\n {t('entityProcessingStatusPicker.title')}\n <Autocomplete<string, true>\n PopperComponent={popperProps => (\n <div {...popperProps}>{popperProps.children as ReactNode}</div>\n )}\n multiple\n disableCloseOnSelect\n options={availableAdvancedItems}\n value={selectedAdvancedItems}\n onChange={(_: object, value: string[]) => {\n setSelectedAdvancedItems(value);\n orphanChange(value.includes('Is Orphan'));\n errorChange(value.includes('Has Error'));\n }}\n renderOption={(option, { selected }) => (\n <FormControlLabel\n control={\n <Checkbox\n icon={icon}\n checkedIcon={checkedIcon}\n checked={selected}\n />\n }\n onClick={event => event.preventDefault()}\n label={option}\n />\n )}\n size=\"small\"\n popupIcon={\n <ExpandMoreIcon data-testid=\"processing-status-picker-expand\" />\n }\n renderInput={params => (\n <TextField\n {...params}\n className={classes.input}\n variant=\"outlined\"\n />\n )}\n />\n </Typography>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB,CAAC,UACC,YAAa,CAAA;AAAA,IACX,MAAM,EAAC;AAAA,IACP,KAAO,EAAA;AAAA,MACL,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,UAAW,CAAA;AAAA,KAC5C;AAAA,IACA,KAAO,EAAA;AAAA,MACL,aAAe,EAAA,MAAA;AAAA,MACf,UAAY,EAAA;AAAA;AACd,GACD,CAAA;AAAA,EACH,EAAE,MAAM,gDAAiD;AAC3D,CAAA;AAEA,MAAM,IAAO,mBAAA,KAAA,CAAA,aAAA,CAAC,wBAAyB,EAAA,EAAA,QAAA,EAAS,OAAQ,EAAA,CAA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,EAAA,IAAA;AAAA,MACR,oBAAoB,EAAA,IAAA;AAAA,MACpB,OAAS,EAAA,sBAAA;AAAA,MACT,KAAO,EAAA,qBAAA;AAAA,MACP,QAAA,EAAU,CAAC,CAAA,EAAW,KAAoB,KAAA;AACxC,QAAA,wBAAA,CAAyB,KAAK,CAAA;AAC9B,QAAa,YAAA,CAAA,KAAA,CAAM,QAAS,CAAA,WAAW,CAAC,CAAA;AACxC,QAAY,WAAA,CAAA,KAAA,CAAM,QAAS,CAAA,WAAW,CAAC,CAAA;AAAA,OACzC;AAAA,MACA,YAAc,EAAA,CAAC,MAAQ,EAAA,EAAE,UACvB,qBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,gBAAA;AAAA,QAAA;AAAA,UACC,OACE,kBAAA,KAAA,CAAA,aAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,IAAA;AAAA,cACA,WAAA;AAAA,cACA,OAAS,EAAA;AAAA;AAAA,WACX;AAAA,UAEF,OAAA,EAAS,CAAS,KAAA,KAAA,KAAA,CAAM,cAAe,EAAA;AAAA,UACvC,KAAO,EAAA;AAAA;AAAA,OACT;AAAA,MAEF,IAAK,EAAA,OAAA;AAAA,MACL,SACE,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAe,EAAA,EAAA,aAAA,EAAY,iCAAkC,EAAA,CAAA;AAAA,MAEhE,aAAa,CACX,MAAA,qBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,SAAA;AAAA,QAAA;AAAA,UACE,GAAG,MAAA;AAAA,UACJ,WAAW,OAAQ,CAAA,KAAA;AAAA,UACnB,OAAQ,EAAA;AAAA;AAAA;AACV;AAAA,GAGN,CACF,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"EntityProcessingStatusPicker.esm.js","sources":["../../../src/components/EntityProcessingStatusPicker/EntityProcessingStatusPicker.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { EntityErrorFilter, EntityOrphanFilter } from '../../filters';\nimport Box from '@material-ui/core/Box';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport { makeStyles } from '@material-ui/core/styles';\nimport CheckBoxIcon from '@material-ui/icons/CheckBox';\nimport CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';\nimport React, { useState } from 'react';\nimport { useEntityList } from '../../hooks';\nimport { catalogReactTranslationRef } from '../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { CatalogAutocomplete } from '../CatalogAutocomplete';\n\n/** @public */\nexport type CatalogReactEntityProcessingStatusPickerClassKey = 'input';\n\nconst useStyles = makeStyles(\n {\n root: {},\n input: {},\n label: {},\n },\n { name: 'CatalogReactEntityProcessingStatusPickerPicker' },\n);\n\nconst icon = <CheckBoxOutlineBlankIcon fontSize=\"small\" />;\nconst checkedIcon = <CheckBoxIcon fontSize=\"small\" />;\n\n/** @public */\nexport const EntityProcessingStatusPicker = () => {\n const classes = useStyles();\n const { updateFilters } = useEntityList();\n const { t } = useTranslationRef(catalogReactTranslationRef);\n\n const [selectedAdvancedItems, setSelectedAdvancedItems] = useState<string[]>(\n [],\n );\n\n function orphanChange(value: boolean) {\n updateFilters({\n orphan: value ? new EntityOrphanFilter(value) : undefined,\n });\n }\n\n function errorChange(value: boolean) {\n updateFilters({\n error: value ? new EntityErrorFilter(value) : undefined,\n });\n }\n\n const availableAdvancedItems = ['Is Orphan', 'Has Error'];\n\n return (\n <Box className={classes.root} pb={1} pt={1}>\n <CatalogAutocomplete<string, true>\n label={t('entityProcessingStatusPicker.title')}\n multiple\n disableCloseOnSelect\n options={availableAdvancedItems}\n value={selectedAdvancedItems}\n onChange={(_: object, value: string[]) => {\n setSelectedAdvancedItems(value);\n orphanChange(value.includes('Is Orphan'));\n errorChange(value.includes('Has Error'));\n }}\n renderOption={(option, { selected }) => (\n <FormControlLabel\n control={\n <Checkbox\n icon={icon}\n checkedIcon={checkedIcon}\n checked={selected}\n />\n }\n onClick={event => event.preventDefault()}\n label={option}\n />\n )}\n name=\"processing-status-picker\"\n LabelProps={{ className: classes.label }}\n TextFieldProps={{ className: classes.input }}\n />\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB;AAAA,IACE,MAAM,EAAC;AAAA,IACP,OAAO,EAAC;AAAA,IACR,OAAO;AAAC,GACV;AAAA,EACA,EAAE,MAAM,gDAAiD;AAC3D,CAAA;AAEA,MAAM,IAAO,mBAAA,KAAA,CAAA,aAAA,CAAC,wBAAyB,EAAA,EAAA,QAAA,EAAS,OAAQ,EAAA,CAAA;AACxD,MAAM,WAAc,mBAAA,KAAA,CAAA,aAAA,CAAC,YAAa,EAAA,EAAA,QAAA,EAAS,OAAQ,EAAA,CAAA;AAG5C,MAAM,+BAA+B,MAAM;AAChD,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAM,MAAA,EAAE,aAAc,EAAA,GAAI,aAAc,EAAA;AACxC,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA;AAE1D,EAAM,MAAA,CAAC,qBAAuB,EAAA,wBAAwB,CAAI,GAAA,QAAA;AAAA,IACxD;AAAC,GACH;AAEA,EAAA,SAAS,aAAa,KAAgB,EAAA;AACpC,IAAc,aAAA,CAAA;AAAA,MACZ,MAAQ,EAAA,KAAA,GAAQ,IAAI,kBAAA,CAAmB,KAAK,CAAI,GAAA,KAAA;AAAA,KACjD,CAAA;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EAAA,EAAE,SAAW,EAAA,OAAA,CAAQ,KAAM,EAAA;AAAA,MACvC,cAAgB,EAAA,EAAE,SAAW,EAAA,OAAA,CAAQ,KAAM;AAAA;AAAA,GAE/C,CAAA;AAEJ;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-react",
3
- "version": "1.15.1-next.1",
3
+ "version": "1.15.1",
4
4
  "description": "A frontend library that helps other Backstage plugins interact with the catalog",
5
5
  "backstage": {
6
6
  "role": "web-library",
@@ -73,20 +73,20 @@
73
73
  "test": "backstage-cli package test"
74
74
  },
75
75
  "dependencies": {
76
- "@backstage/catalog-client": "1.9.1-next.0",
77
- "@backstage/catalog-model": "1.7.3-next.0",
78
- "@backstage/core-compat-api": "0.3.5-next.0",
79
- "@backstage/core-components": "0.16.3-next.0",
80
- "@backstage/core-plugin-api": "1.10.3-next.0",
81
- "@backstage/errors": "1.2.7-next.0",
82
- "@backstage/frontend-plugin-api": "0.9.4-next.0",
83
- "@backstage/frontend-test-utils": "0.2.5-next.0",
84
- "@backstage/integration-react": "1.2.3-next.0",
85
- "@backstage/plugin-catalog-common": "1.1.3-next.0",
86
- "@backstage/plugin-permission-common": "0.8.4-next.0",
87
- "@backstage/plugin-permission-react": "0.4.30-next.0",
88
- "@backstage/types": "1.2.1-next.0",
89
- "@backstage/version-bridge": "1.0.10",
76
+ "@backstage/catalog-client": "^1.9.1",
77
+ "@backstage/catalog-model": "^1.7.3",
78
+ "@backstage/core-compat-api": "^0.3.5",
79
+ "@backstage/core-components": "^0.16.3",
80
+ "@backstage/core-plugin-api": "^1.10.3",
81
+ "@backstage/errors": "^1.2.7",
82
+ "@backstage/frontend-plugin-api": "^0.9.4",
83
+ "@backstage/frontend-test-utils": "^0.2.5",
84
+ "@backstage/integration-react": "^1.2.3",
85
+ "@backstage/plugin-catalog-common": "^1.1.3",
86
+ "@backstage/plugin-permission-common": "^0.8.4",
87
+ "@backstage/plugin-permission-react": "^0.4.30",
88
+ "@backstage/types": "^1.2.1",
89
+ "@backstage/version-bridge": "^1.0.10",
90
90
  "@material-ui/core": "^4.12.2",
91
91
  "@material-ui/icons": "^4.9.1",
92
92
  "@material-ui/lab": "4.0.0-alpha.61",
@@ -100,11 +100,11 @@
100
100
  "zen-observable": "^0.10.0"
101
101
  },
102
102
  "devDependencies": {
103
- "@backstage/cli": "0.29.5-next.1",
104
- "@backstage/core-app-api": "1.15.4-next.0",
105
- "@backstage/plugin-catalog-common": "1.1.3-next.0",
106
- "@backstage/plugin-scaffolder-common": "1.5.9-next.0",
107
- "@backstage/test-utils": "1.7.4-next.0",
103
+ "@backstage/cli": "^0.29.5",
104
+ "@backstage/core-app-api": "^1.15.4",
105
+ "@backstage/plugin-catalog-common": "^1.1.3",
106
+ "@backstage/plugin-scaffolder-common": "^1.5.9",
107
+ "@backstage/test-utils": "^1.7.4",
108
108
  "@testing-library/dom": "^10.0.0",
109
109
  "@testing-library/jest-dom": "^6.0.0",
110
110
  "@testing-library/react": "^16.0.0",
@@ -1,29 +0,0 @@
1
- import TextField from '@material-ui/core/TextField';
2
- import { makeStyles, createStyles } from '@material-ui/core/styles';
3
- import React from 'react';
4
- import classNames from 'classnames';
5
-
6
- const useStyles = makeStyles(
7
- (theme) => createStyles({
8
- input: {
9
- backgroundColor: theme.palette.background.paper
10
- }
11
- }),
12
- {
13
- name: "CatalogReactEntityAutocompletePickerInput"
14
- }
15
- );
16
- function EntityAutocompletePickerInput(params) {
17
- const classes = useStyles();
18
- return /* @__PURE__ */ React.createElement(
19
- TextField,
20
- {
21
- variant: "outlined",
22
- ...params,
23
- className: classNames(classes.input, params.className)
24
- }
25
- );
26
- }
27
-
28
- export { EntityAutocompletePickerInput };
29
- //# sourceMappingURL=EntityAutocompletePickerInput.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EntityAutocompletePickerInput.esm.js","sources":["../../../src/components/EntityAutocompletePicker/EntityAutocompletePickerInput.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport TextField, { TextFieldProps } from '@material-ui/core/TextField';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport React from 'react';\nimport classnames from 'classnames';\n\nconst useStyles = makeStyles(\n (theme: Theme) =>\n createStyles({\n input: {\n backgroundColor: theme.palette.background.paper,\n },\n }),\n {\n name: 'CatalogReactEntityAutocompletePickerInput',\n },\n);\n\nexport function EntityAutocompletePickerInput(params: TextFieldProps) {\n const classes = useStyles();\n\n return (\n <TextField\n variant=\"outlined\"\n {...params}\n className={classnames(classes.input, params.className)}\n />\n );\n}\n"],"names":["classnames"],"mappings":";;;;;AAoBA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB,CAAC,UACC,YAAa,CAAA;AAAA,IACX,KAAO,EAAA;AAAA,MACL,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,UAAW,CAAA;AAAA;AAC5C,GACD,CAAA;AAAA,EACH;AAAA,IACE,IAAM,EAAA;AAAA;AAEV,CAAA;AAEO,SAAS,8BAA8B,MAAwB,EAAA;AACpE,EAAA,MAAM,UAAU,SAAU,EAAA;AAE1B,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,OAAQ,EAAA,UAAA;AAAA,MACP,GAAG,MAAA;AAAA,MACJ,SAAW,EAAAA,UAAA,CAAW,OAAQ,CAAA,KAAA,EAAO,OAAO,SAAS;AAAA;AAAA,GACvD;AAEJ;;;;"}