@backstage-community/plugin-bazaar 0.4.0 → 0.5.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,17 @@
1
1
  # @backstage-community/plugin-bazaar
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 56ae2fe: Backstage version bump to v1.32.2
8
+
9
+ ## 0.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - fe0d104: Added a new UserSelector component that allows users to select a responsible user from the catalog, with the option to manually enter still being there"
14
+
3
15
  ## 0.4.0
4
16
 
5
17
  ### Minor Changes
@@ -7,7 +7,7 @@ import makeStyles from '@material-ui/core/styles/makeStyles';
7
7
  import { parseEntityRef } from '@backstage/catalog-model';
8
8
  import { Avatar, Link } from '@backstage/core-components';
9
9
  import { useRouteRef } from '@backstage/core-plugin-api';
10
- import { entityRouteRef } from '@backstage/plugin-catalog-react';
10
+ import { entityRouteRef, EntityRefLink } from '@backstage/plugin-catalog-react';
11
11
  import { AboutField } from './AboutField.esm.js';
12
12
  import { StatusTag } from '../StatusTag/StatusTag.esm.js';
13
13
 
@@ -83,7 +83,14 @@ const CardContentFields = ({
83
83
  )
84
84
  );
85
85
  }) : /* @__PURE__ */ React.createElement("div", null))
86
- ), !isEntityPage && isMember && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(AboutField, { label: "I've joined the project, what's next?" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2", paragraph: true }, 'To learn more about this project, click the "Entity Page" link, where you can view more information about the effort and navigate to the source code itself to begin collaborating.'))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 2 }, /* @__PURE__ */ React.createElement(AboutField, { label: "Status" }, /* @__PURE__ */ React.createElement(StatusTag, { status: bazaarProject.status }))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 2 }, /* @__PURE__ */ React.createElement(AboutField, { label: "size" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, bazaarProject.size))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 2 }, /* @__PURE__ */ React.createElement(AboutField, { label: "Start date" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, bazaarProject.startDate?.substring(0, 10) || ""))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 2 }, /* @__PURE__ */ React.createElement(AboutField, { label: "End date" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, bazaarProject.endDate?.substring(0, 10) || ""))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 4 }, /* @__PURE__ */ React.createElement(AboutField, { label: "Responsible" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, bazaarProject.responsible || "")))))));
86
+ ), !isEntityPage && isMember && /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(AboutField, { label: "I've joined the project, what's next?" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2", paragraph: true }, 'To learn more about this project, click the "Entity Page" link, where you can view more information about the effort and navigate to the source code itself to begin collaborating.'))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 2 }, /* @__PURE__ */ React.createElement(AboutField, { label: "Status" }, /* @__PURE__ */ React.createElement(StatusTag, { status: bazaarProject.status }))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 2 }, /* @__PURE__ */ React.createElement(AboutField, { label: "size" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, bazaarProject.size))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 2 }, /* @__PURE__ */ React.createElement(AboutField, { label: "Start date" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, bazaarProject.startDate?.substring(0, 10) || ""))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 2 }, /* @__PURE__ */ React.createElement(AboutField, { label: "End date" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, bazaarProject.endDate?.substring(0, 10) || ""))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 4 }, /* @__PURE__ */ React.createElement(AboutField, { label: "Responsible" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, (() => {
87
+ try {
88
+ parseEntityRef(bazaarProject.responsible);
89
+ return /* @__PURE__ */ React.createElement(EntityRefLink, { entityRef: bazaarProject.responsible });
90
+ } catch {
91
+ return bazaarProject.responsible || "";
92
+ }
93
+ })(), " ")))))));
87
94
  };
88
95
 
89
96
  export { CardContentFields };
@@ -1 +1 @@
1
- {"version":3,"file":"CardContentFields.esm.js","sources":["../../../src/components/CardContentFields/CardContentFields.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 React from 'react';\nimport Grid from '@material-ui/core/Grid';\nimport Card from '@material-ui/core/Card';\nimport CardContent from '@material-ui/core/CardContent';\nimport Typography from '@material-ui/core/Typography';\nimport makeStyles from '@material-ui/core/styles/makeStyles';\n\nimport { GridSize } from '@material-ui/core/Grid';\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { Avatar, Link } from '@backstage/core-components';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { entityRouteRef } from '@backstage/plugin-catalog-react';\nimport { AboutField } from './AboutField';\nimport { StatusTag } from '../StatusTag';\nimport { Member, BazaarProject } from '../../types';\n\ntype Props = {\n bazaarProject: BazaarProject;\n members: Member[];\n descriptionSize: GridSize;\n membersSize: GridSize;\n isMember: boolean;\n};\n\nconst useStyles = makeStyles(\n {\n avatar: {\n width: '19px',\n height: '19px',\n float: 'left',\n marginRight: '0.3rem',\n marginTop: '0rem',\n marginBottom: '0rem',\n alignItems: 'left',\n },\n avatarText: {\n fontSize: '8px',\n textAlign: 'left',\n },\n },\n { name: 'CardContentFields' },\n);\n\nexport const CardContentFields = ({\n bazaarProject,\n members,\n descriptionSize,\n membersSize,\n isMember,\n}: Props) => {\n const catalogEntityRoute = useRouteRef(entityRouteRef);\n const currentPage = window.location.pathname;\n const isEntityPage = currentPage.includes('/catalog/');\n const classes = useStyles();\n return (\n <div>\n <Card>\n <CardContent>\n <Grid container>\n <Grid item xs={descriptionSize}>\n <AboutField label=\"Description\">\n {bazaarProject.description\n .split('\\n')\n .map((str: string, i: number) => (\n <Typography key={i} variant=\"body2\" paragraph>\n {str}\n </Typography>\n ))}\n </AboutField>\n </Grid>\n\n <Grid\n style={{\n display: 'flex',\n justifyContent: 'flex-end',\n }}\n item\n xs={membersSize}\n >\n <AboutField label=\"Latest members\">\n {members.length ? (\n members.slice(0, 7).map((member: Member) => {\n return (\n <div\n style={{\n textAlign: 'left',\n backgroundColor: '',\n marginBottom: '0.3rem',\n marginTop: '0.3rem',\n display: 'block',\n }}\n key={member.userId}\n >\n <Avatar\n displayName={member.userId}\n classes={classes}\n picture={member.picture}\n />\n <Link\n target=\"_blank\"\n to={\n member.userRef\n ? `${catalogEntityRoute(\n parseEntityRef(member.userRef),\n )}`\n : `http://github.com/${member.userId}`\n }\n >\n {member?.userId}\n </Link>\n </div>\n );\n })\n ) : (\n <div />\n )}\n </AboutField>\n </Grid>\n\n {!isEntityPage && isMember && (\n <Grid item xs={12}>\n <AboutField label=\"I've joined the project, what's next?\">\n <Typography variant=\"body2\" paragraph>\n To learn more about this project, click the \"Entity Page\"\n link, where you can view more information about the effort\n and navigate to the source code itself to begin\n collaborating.\n </Typography>\n </AboutField>\n </Grid>\n )}\n\n <Grid item xs={2}>\n <AboutField label=\"Status\">\n <StatusTag status={bazaarProject.status} />\n </AboutField>\n </Grid>\n\n <Grid item xs={2}>\n <AboutField label=\"size\">\n <Typography variant=\"body2\">{bazaarProject.size}</Typography>\n </AboutField>\n </Grid>\n\n <Grid item xs={2}>\n <AboutField label=\"Start date\">\n <Typography variant=\"body2\">\n {bazaarProject.startDate?.substring(0, 10) || ''}\n </Typography>\n </AboutField>\n </Grid>\n\n <Grid item xs={2}>\n <AboutField label=\"End date\">\n <Typography variant=\"body2\">\n {bazaarProject.endDate?.substring(0, 10) || ''}\n </Typography>\n </AboutField>\n </Grid>\n\n <Grid item xs={4}>\n <AboutField label=\"Responsible\">\n <Typography variant=\"body2\">\n {bazaarProject.responsible || ''}\n </Typography>\n </AboutField>\n </Grid>\n </Grid>\n </CardContent>\n </Card>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAwCA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB;AAAA,IACE,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA,MAAA;AAAA,MACP,MAAQ,EAAA,MAAA;AAAA,MACR,KAAO,EAAA,MAAA;AAAA,MACP,WAAa,EAAA,QAAA;AAAA,MACb,SAAW,EAAA,MAAA;AAAA,MACX,YAAc,EAAA,MAAA;AAAA,MACd,UAAY,EAAA,MAAA;AAAA,KACd;AAAA,IACA,UAAY,EAAA;AAAA,MACV,QAAU,EAAA,KAAA;AAAA,MACV,SAAW,EAAA,MAAA;AAAA,KACb;AAAA,GACF;AAAA,EACA,EAAE,MAAM,mBAAoB,EAAA;AAC9B,CAAA,CAAA;AAEO,MAAM,oBAAoB,CAAC;AAAA,EAChC,aAAA;AAAA,EACA,OAAA;AAAA,EACA,eAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AACF,CAAa,KAAA;AACX,EAAM,MAAA,kBAAA,GAAqB,YAAY,cAAc,CAAA,CAAA;AACrD,EAAM,MAAA,WAAA,GAAc,OAAO,QAAS,CAAA,QAAA,CAAA;AACpC,EAAM,MAAA,YAAA,GAAe,WAAY,CAAA,QAAA,CAAS,WAAW,CAAA,CAAA;AACrD,EAAA,MAAM,U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F,CACF,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"CardContentFields.esm.js","sources":["../../../src/components/CardContentFields/CardContentFields.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 React from 'react';\nimport Grid from '@material-ui/core/Grid';\nimport Card from '@material-ui/core/Card';\nimport CardContent from '@material-ui/core/CardContent';\nimport Typography from '@material-ui/core/Typography';\nimport makeStyles from '@material-ui/core/styles/makeStyles';\n\nimport { GridSize } from '@material-ui/core/Grid';\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { Avatar, Link } from '@backstage/core-components';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { entityRouteRef } from '@backstage/plugin-catalog-react';\nimport { AboutField } from './AboutField';\nimport { StatusTag } from '../StatusTag';\nimport { Member, BazaarProject } from '../../types';\nimport { EntityRefLink } from '@backstage/plugin-catalog-react';\n\ntype Props = {\n bazaarProject: BazaarProject;\n members: Member[];\n descriptionSize: GridSize;\n membersSize: GridSize;\n isMember: boolean;\n};\n\nconst useStyles = makeStyles(\n {\n avatar: {\n width: '19px',\n height: '19px',\n float: 'left',\n marginRight: '0.3rem',\n marginTop: '0rem',\n marginBottom: '0rem',\n alignItems: 'left',\n },\n avatarText: {\n fontSize: '8px',\n textAlign: 'left',\n },\n },\n { name: 'CardContentFields' },\n);\n\nexport const CardContentFields = ({\n bazaarProject,\n members,\n descriptionSize,\n membersSize,\n isMember,\n}: Props) => {\n const catalogEntityRoute = useRouteRef(entityRouteRef);\n const currentPage = window.location.pathname;\n const isEntityPage = currentPage.includes('/catalog/');\n const classes = useStyles();\n return (\n <div>\n <Card>\n <CardContent>\n <Grid container>\n <Grid item xs={descriptionSize}>\n <AboutField label=\"Description\">\n {bazaarProject.description\n .split('\\n')\n .map((str: string, i: number) => (\n <Typography key={i} variant=\"body2\" paragraph>\n {str}\n </Typography>\n ))}\n </AboutField>\n </Grid>\n\n <Grid\n style={{\n display: 'flex',\n justifyContent: 'flex-end',\n }}\n item\n xs={membersSize}\n >\n <AboutField label=\"Latest members\">\n {members.length ? (\n members.slice(0, 7).map((member: Member) => {\n return (\n <div\n style={{\n textAlign: 'left',\n backgroundColor: '',\n marginBottom: '0.3rem',\n marginTop: '0.3rem',\n display: 'block',\n }}\n key={member.userId}\n >\n <Avatar\n displayName={member.userId}\n classes={classes}\n picture={member.picture}\n />\n <Link\n target=\"_blank\"\n to={\n member.userRef\n ? `${catalogEntityRoute(\n parseEntityRef(member.userRef),\n )}`\n : `http://github.com/${member.userId}`\n }\n >\n {member?.userId}\n </Link>\n </div>\n );\n })\n ) : (\n <div />\n )}\n </AboutField>\n </Grid>\n\n {!isEntityPage && isMember && (\n <Grid item xs={12}>\n <AboutField label=\"I've joined the project, what's next?\">\n <Typography variant=\"body2\" paragraph>\n To learn more about this project, click the \"Entity Page\"\n link, where you can view more information about the effort\n and navigate to the source code itself to begin\n collaborating.\n </Typography>\n </AboutField>\n </Grid>\n )}\n\n <Grid item xs={2}>\n <AboutField label=\"Status\">\n <StatusTag status={bazaarProject.status} />\n </AboutField>\n </Grid>\n\n <Grid item xs={2}>\n <AboutField label=\"size\">\n <Typography variant=\"body2\">{bazaarProject.size}</Typography>\n </AboutField>\n </Grid>\n\n <Grid item xs={2}>\n <AboutField label=\"Start date\">\n <Typography variant=\"body2\">\n {bazaarProject.startDate?.substring(0, 10) || ''}\n </Typography>\n </AboutField>\n </Grid>\n\n <Grid item xs={2}>\n <AboutField label=\"End date\">\n <Typography variant=\"body2\">\n {bazaarProject.endDate?.substring(0, 10) || ''}\n </Typography>\n </AboutField>\n </Grid>\n\n <Grid item xs={4}>\n <AboutField label=\"Responsible\">\n <Typography variant=\"body2\">\n {(() => {\n try {\n parseEntityRef(bazaarProject.responsible);\n return (\n <EntityRefLink entityRef={bazaarProject.responsible} />\n );\n } catch {\n return bazaarProject.responsible || '';\n }\n })()}{' '}\n </Typography>\n </AboutField>\n </Grid>\n </Grid>\n </CardContent>\n </Card>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAyCA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB;AAAA,IACE,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA,MAAA;AAAA,MACP,MAAQ,EAAA,MAAA;AAAA,MACR,KAAO,EAAA,MAAA;AAAA,MACP,WAAa,EAAA,QAAA;AAAA,MACb,SAAW,EAAA,MAAA;AAAA,MACX,YAAc,EAAA,MAAA;AAAA,MACd,UAAY,EAAA,MAAA;AAAA,KACd;AAAA,IACA,UAAY,EAAA;AAAA,MACV,QAAU,EAAA,KAAA;AAAA,MACV,SAAW,EAAA,MAAA;AAAA,KACb;AAAA,GACF;AAAA,EACA,EAAE,MAAM,mBAAoB,EAAA;AAC9B,CAAA,CAAA;AAEO,MAAM,oBAAoB,CAAC;AAAA,EAChC,aAAA;AAAA,EACA,OAAA;AAAA,EACA,eAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AACF,CAAa,KAAA;AACX,EAAM,MAAA,kBAAA,GAAqB,YAAY,cAAc,CAAA,CAAA;AACrD,EAAM,MAAA,WAAA,GAAc,OAAO,QAAS,CAAA,QAAA,CAAA;AACpC,EAAM,MAAA,YAAA,GAAe,WAAY,CAAA,QAAA,CAAS,WAAW,CAAA,CAAA;AACrD,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,2CACG,KACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,4BACE,KAAA,CAAA,aAAA,CAAA,WAAA,EAAA,IAAA,sCACE,IAAK,EAAA,EAAA,SAAA,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CAAA;AAAA,KAEjD,CAAA,MAAA;AACN,MAAA,OAAO,cAAc,WAAe,IAAA,EAAA,CAAA;AAAA,KACtC;AAAA,GACF,KAAM,GACR,CACF,CACF,CACF,CACF,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import Button from '@material-ui/core/Button';
3
3
  import Dialog from '@material-ui/core/Dialog';
4
4
  import { useForm } from 'react-hook-form';
@@ -6,6 +6,10 @@ import { InputField } from '../InputField/InputField.esm.js';
6
6
  import { InputSelector } from '../InputSelector/InputSelector.esm.js';
7
7
  import { DoubleDateSelector } from '../DoubleDateSelector/DoubleDateSelector.esm.js';
8
8
  import { CustomDialogTitle, DialogContent, DialogActions } from '../CustomDialogTitle/CustomDialogTitle.esm.js';
9
+ import { fetchUsers } from '../../util/fetchMethods.esm.js';
10
+ import { UserSelector } from '../UserSelector/UserSelector.esm.js';
11
+ import { useApi } from '@backstage/core-plugin-api';
12
+ import { catalogApiRef } from '@backstage/plugin-catalog-react';
9
13
 
10
14
  const ProjectDialog = ({
11
15
  handleSave,
@@ -17,6 +21,8 @@ const ProjectDialog = ({
17
21
  deleteButton,
18
22
  handleClose
19
23
  }) => {
24
+ const catalogApi = useApi(catalogApiRef);
25
+ const [users, setUsers] = useState([]);
20
26
  const {
21
27
  handleSubmit,
22
28
  reset,
@@ -35,6 +41,9 @@ const ProjectDialog = ({
35
41
  handleClose();
36
42
  reset(defaultValues);
37
43
  };
44
+ useEffect(() => {
45
+ fetchUsers(catalogApi).then(setUsers);
46
+ }, [catalogApi]);
38
47
  return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
39
48
  Dialog,
40
49
  {
@@ -89,16 +98,15 @@ const ProjectDialog = ({
89
98
  options: ["small", "medium", "large"]
90
99
  }
91
100
  ), /* @__PURE__ */ React.createElement(
92
- InputField,
101
+ UserSelector,
93
102
  {
94
- error: errors.responsible,
103
+ users,
104
+ disableClearable: false,
105
+ defaultValue: defaultValues.responsible,
106
+ label: "Select or enter responsible user",
107
+ name: "responsible",
95
108
  control,
96
- rules: {
97
- required: true
98
- },
99
- inputType: "responsible",
100
- helperText: "Please enter a contact person",
101
- placeholder: "Contact person of the project"
109
+ rules: { required: "Please select or enter a responsible user" }
102
110
  }
103
111
  ), isAddForm && projectSelector, /* @__PURE__ */ React.createElement(
104
112
  InputField,
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectDialog.esm.js","sources":["../../../src/components/ProjectDialog/ProjectDialog.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 React from 'react';\nimport Button from '@material-ui/core/Button';\nimport Dialog from '@material-ui/core/Dialog';\nimport { useForm, UseFormReset, UseFormGetValues } from 'react-hook-form';\nimport { InputField } from '../InputField/InputField';\nimport { InputSelector } from '../InputSelector/InputSelector';\nimport { FormValues } from '../../types';\nimport { DoubleDateSelector } from '../DoubleDateSelector/DoubleDateSelector';\nimport {\n CustomDialogTitle,\n DialogActions,\n DialogContent,\n} from '../CustomDialogTitle';\n\ntype Props = {\n handleSave: (\n getValues: UseFormGetValues<FormValues>,\n reset: UseFormReset<FormValues>,\n ) => Promise<void>;\n isAddForm: boolean;\n title: string;\n defaultValues: FormValues;\n open: boolean;\n projectSelector?: JSX.Element;\n deleteButton?: JSX.Element;\n handleClose: () => void;\n};\n\nexport const ProjectDialog = ({\n handleSave,\n isAddForm,\n title,\n defaultValues,\n open,\n projectSelector,\n deleteButton,\n handleClose,\n}: Props) => {\n const {\n handleSubmit,\n reset,\n control,\n getValues,\n formState: { errors },\n setValue,\n } = useForm<FormValues>({\n mode: 'onChange',\n defaultValues,\n });\n\n const handleSaveForm = () => {\n handleSave(getValues, reset);\n };\n\n const handleCloseDialog = () => {\n handleClose();\n reset(defaultValues);\n };\n\n return (\n <div>\n <Dialog\n fullWidth\n maxWidth=\"xs\"\n onClose={handleCloseDialog}\n aria-labelledby=\"customized-dialog-title\"\n open={open}\n >\n <CustomDialogTitle\n id=\"customized-dialog-title\"\n onClose={handleCloseDialog}\n >\n {title}\n </CustomDialogTitle>\n <DialogContent style={{ padding: '1rem', paddingTop: '0rem' }} dividers>\n <InputField\n error={errors.title}\n control={control}\n rules={{\n required: true,\n }}\n inputType=\"title\"\n helperText=\"Please enter a title for your project\"\n />\n <InputField\n error={errors.description}\n control={control}\n rules={{\n required: true,\n }}\n inputType=\"description\"\n helperText=\"Please enter a description\"\n />\n\n <InputSelector\n control={control}\n name=\"status\"\n options={['proposed', 'ongoing', 'completed']}\n />\n\n <InputSelector\n control={control}\n name=\"size\"\n options={['small', 'medium', 'large']}\n />\n\n <InputField\n error={errors.responsible}\n control={control}\n rules={{\n required: true,\n }}\n inputType=\"responsible\"\n helperText=\"Please enter a contact person\"\n placeholder=\"Contact person of the project\"\n />\n\n {isAddForm && projectSelector}\n\n <InputField\n error={errors.community}\n control={control}\n rules={{\n required: false,\n pattern: RegExp('^(https?)://'),\n }}\n inputType=\"community\"\n helperText=\"Please enter a link starting with http/https\"\n placeholder=\"Community link to e.g. Teams or Discord\"\n />\n\n <InputField\n error={errors.docs}\n control={control}\n rules={{\n required: false,\n pattern: RegExp('^(https?)://'),\n }}\n inputType=\"docs\"\n helperText=\"Please enter a link starting with http/https\"\n placeholder=\"Project docs link\"\n />\n\n <DoubleDateSelector setValue={setValue} control={control} />\n </DialogContent>\n\n <DialogActions>\n {!isAddForm && deleteButton}\n <Button\n onClick={handleSubmit(handleSaveForm)}\n color=\"primary\"\n type=\"submit\"\n >\n Submit\n </Button>\n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AAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,OAAO,MAAO,CAAA,SAAA;AAAA,QACd,OAAA;AAAA,QACA,KAAO,EAAA;AAAA,UACL,QAAU,EAAA,KAAA;AAAA,UACV,OAAA,EAAS,OAAO,cAAc,CAAA;AAAA,SAChC;AAAA,QACA,SAAU,EAAA,WAAA;AAAA,QACV,UAAW,EAAA,8CAAA;AAAA,QACX,WAAY,EAAA,yCAAA;AAAA,OAAA;AAAA,KAGd,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,OAAO,MAAO,CAAA,IAAA;AAAA,QACd,OAAA;AAAA,QACA,KAAO,EAAA;AAAA,UACL,QAAU,EAAA,KAAA;AAAA,UACV,OAAA,EAAS,OAAO,cAAc,CAAA;AAAA,SAChC;AAAA,QACA,SAAU,EAAA,MAAA;AAAA,QACV,UAAW,EAAA,8CAAA;AAAA,QACX,WAAY,EAAA,mBAAA;AAAA,OAAA;AAAA,KAGd,kBAAA,KAAA,CAAA,aAAA,CAAC,kBAAmB,EAAA,EAAA,QAAA,EAAoB,SAAkB,CAC5D,CAAA;AAAA,oBAEC,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA,IAAA,EACE,CAAC,SAAA,IAAa,YACf,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAA,EAAS,aAAa,cAAc,CAAA;AAAA,QACpC,KAAM,EAAA,SAAA;AAAA,QACN,IAAK,EAAA,QAAA;AAAA,OAAA;AAAA,MACN,QAAA;AAAA,KAGH,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"ProjectDialog.esm.js","sources":["../../../src/components/ProjectDialog/ProjectDialog.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 React, { useEffect, useState } from 'react';\nimport Button from '@material-ui/core/Button';\nimport Dialog from '@material-ui/core/Dialog';\nimport { useForm, UseFormReset, UseFormGetValues } from 'react-hook-form';\nimport { InputField } from '../InputField/InputField';\nimport { InputSelector } from '../InputSelector/InputSelector';\nimport { FormValues } from '../../types';\nimport { DoubleDateSelector } from '../DoubleDateSelector/DoubleDateSelector';\nimport {\n CustomDialogTitle,\n DialogActions,\n DialogContent,\n} from '../CustomDialogTitle';\nimport { fetchUsers } from '../../util/fetchMethods';\nimport { UserSelector } from '../UserSelector';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { Entity } from '@backstage/catalog-model';\n\ntype Props = {\n handleSave: (\n getValues: UseFormGetValues<FormValues>,\n reset: UseFormReset<FormValues>,\n ) => Promise<void>;\n isAddForm: boolean;\n title: string;\n defaultValues: FormValues;\n open: boolean;\n projectSelector?: JSX.Element;\n deleteButton?: JSX.Element;\n handleClose: () => void;\n};\n\nexport const ProjectDialog = ({\n handleSave,\n isAddForm,\n title,\n defaultValues,\n open,\n projectSelector,\n deleteButton,\n handleClose,\n}: Props) => {\n const catalogApi = useApi(catalogApiRef);\n const [users, setUsers] = useState<Entity[]>([]);\n\n const {\n handleSubmit,\n reset,\n control,\n getValues,\n formState: { errors },\n setValue,\n } = useForm<FormValues>({\n mode: 'onChange',\n defaultValues,\n });\n\n const handleSaveForm = () => {\n handleSave(getValues, reset);\n };\n\n const handleCloseDialog = () => {\n handleClose();\n reset(defaultValues);\n };\n\n useEffect(() => {\n fetchUsers(catalogApi).then(setUsers);\n }, [catalogApi]);\n\n return (\n <div>\n <Dialog\n fullWidth\n maxWidth=\"xs\"\n onClose={handleCloseDialog}\n aria-labelledby=\"customized-dialog-title\"\n open={open}\n >\n <CustomDialogTitle\n id=\"customized-dialog-title\"\n onClose={handleCloseDialog}\n >\n {title}\n </CustomDialogTitle>\n <DialogContent style={{ padding: '1rem', paddingTop: '0rem' }} dividers>\n <InputField\n error={errors.title}\n control={control}\n rules={{\n required: true,\n }}\n inputType=\"title\"\n helperText=\"Please enter a title for your project\"\n />\n <InputField\n error={errors.description}\n control={control}\n rules={{\n required: true,\n }}\n inputType=\"description\"\n helperText=\"Please enter a description\"\n />\n\n <InputSelector\n control={control}\n name=\"status\"\n options={['proposed', 'ongoing', 'completed']}\n />\n\n <InputSelector\n control={control}\n name=\"size\"\n options={['small', 'medium', 'large']}\n />\n\n <UserSelector\n users={users}\n disableClearable={false}\n defaultValue={defaultValues.responsible}\n label=\"Select or enter responsible user\"\n name=\"responsible\"\n control={control}\n rules={{ required: 'Please select or enter a responsible user' }}\n />\n\n {isAddForm && projectSelector}\n\n <InputField\n error={errors.community}\n control={control}\n rules={{\n required: false,\n pattern: RegExp('^(https?)://'),\n }}\n inputType=\"community\"\n helperText=\"Please enter a link starting with http/https\"\n placeholder=\"Community link to e.g. Teams or Discord\"\n />\n\n <InputField\n error={errors.docs}\n control={control}\n rules={{\n required: false,\n pattern: RegExp('^(https?)://'),\n }}\n inputType=\"docs\"\n helperText=\"Please enter a link starting with http/https\"\n placeholder=\"Project docs link\"\n />\n\n <DoubleDateSelector setValue={setValue} control={control} />\n </DialogContent>\n\n <DialogActions>\n {!isAddForm && deleteButton}\n <Button\n onClick={handleSubmit(handleSaveForm)}\n color=\"primary\"\n type=\"submit\"\n >\n Submit\n </Button>\n </DialogActions>\n </Dialog>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAiDO,MAAM,gBAAgB,CAAC;AAAA,EAC5B,UAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,aAAA;AAAA,EACA,IAAA;AAAA,EACA,eA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/catalog-model';
3
+ import Autocomplete, { createFilterOptions } from '@material-ui/lab/Autocomplete';
4
+ import TextField from '@material-ui/core/TextField';
5
+ import { makeStyles } from '@material-ui/core/styles';
6
+ import { Controller } from 'react-hook-form';
7
+ import { useApi } from '@backstage/core-plugin-api';
8
+ import { entityPresentationApiRef, EntityDisplayName } from '@backstage/plugin-catalog-react';
9
+
10
+ const useStyles = makeStyles({
11
+ container: { width: "100%", minWidth: "22rem" },
12
+ autocomplete: { overflow: "hidden" }
13
+ });
14
+ const UserSelector = ({
15
+ users,
16
+ disableClearable,
17
+ defaultValue,
18
+ label,
19
+ name,
20
+ control,
21
+ rules
22
+ }) => {
23
+ const classes = useStyles();
24
+ const entityPresentationApi = useApi(entityPresentationApiRef);
25
+ const [entityPresentations, setEntityPresentations] = useState(/* @__PURE__ */ new Map());
26
+ useEffect(() => {
27
+ const fetchPresentations = async () => {
28
+ const presentations = /* @__PURE__ */ new Map();
29
+ await Promise.all(
30
+ users.map(async (user) => {
31
+ const presentation = await entityPresentationApi.forEntity(user).promise;
32
+ presentations.set(stringifyEntityRef(user), presentation);
33
+ })
34
+ );
35
+ setEntityPresentations(presentations);
36
+ };
37
+ fetchPresentations();
38
+ }, [users, entityPresentationApi]);
39
+ const getOptionLabel = (option) => {
40
+ if (typeof option === "string") return option;
41
+ const entityRef = stringifyEntityRef(option);
42
+ return entityPresentations.get(entityRef)?.primaryTitle ?? option.metadata.name;
43
+ };
44
+ const filterOptions = createFilterOptions({
45
+ stringify: (option) => {
46
+ if (typeof option === "string") return option;
47
+ const entityRef = stringifyEntityRef(option);
48
+ return entityPresentations.get(entityRef)?.primaryTitle ?? option.metadata.name;
49
+ }
50
+ });
51
+ return /* @__PURE__ */ React.createElement("div", { className: classes.container }, /* @__PURE__ */ React.createElement(
52
+ Controller,
53
+ {
54
+ name,
55
+ control,
56
+ rules,
57
+ defaultValue: defaultValue ?? "",
58
+ render: ({ field: { onChange, value }, fieldState: { error } }) => /* @__PURE__ */ React.createElement(
59
+ Autocomplete,
60
+ {
61
+ className: classes.autocomplete,
62
+ fullWidth: true,
63
+ freeSolo: true,
64
+ disableClearable,
65
+ value,
66
+ options: users,
67
+ getOptionLabel,
68
+ renderOption: (option) => typeof option === "string" ? option : /* @__PURE__ */ React.createElement(EntityDisplayName, { entityRef: option }),
69
+ renderInput: (params) => /* @__PURE__ */ React.createElement(
70
+ TextField,
71
+ {
72
+ ...params,
73
+ label,
74
+ required: !!rules?.required,
75
+ error: !!error,
76
+ helperText: error?.message
77
+ }
78
+ ),
79
+ onChange: (_, data) => {
80
+ if (typeof data === "string") {
81
+ onChange(data);
82
+ } else if (data) {
83
+ onChange(stringifyEntityRef(data));
84
+ } else {
85
+ onChange("");
86
+ }
87
+ },
88
+ filterOptions: (options, params) => {
89
+ const filtered = filterOptions(options, params);
90
+ if (params.inputValue !== "" && !options.some(
91
+ (option) => getOptionLabel(option) === params.inputValue
92
+ )) {
93
+ filtered.push(params.inputValue);
94
+ }
95
+ return filtered;
96
+ }
97
+ }
98
+ )
99
+ }
100
+ ));
101
+ };
102
+
103
+ export { UserSelector };
104
+ //# sourceMappingURL=UserSelector.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserSelector.esm.js","sources":["../../../src/components/UserSelector/UserSelector.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 */\nimport React, { useState, useEffect } from 'react';\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\nimport Autocomplete, {\n createFilterOptions,\n} from '@material-ui/lab/Autocomplete';\nimport TextField from '@material-ui/core/TextField';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { Controller, Control } from 'react-hook-form';\nimport { FormValues } from '../../types';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n entityPresentationApiRef,\n EntityDisplayName,\n EntityRefPresentationSnapshot,\n} from '@backstage/plugin-catalog-react';\n\ntype Props = {\n users: Entity[];\n disableClearable: boolean;\n defaultValue: string | null;\n label: string;\n name: 'responsible';\n control: Control<FormValues, object>;\n rules?: Record<string, any>;\n};\n\nconst useStyles = makeStyles({\n container: { width: '100%', minWidth: '22rem' },\n autocomplete: { overflow: 'hidden' },\n});\n\nexport const UserSelector = ({\n users,\n disableClearable,\n defaultValue,\n label,\n name,\n control,\n rules,\n}: Props) => {\n const classes = useStyles();\n const entityPresentationApi = useApi(entityPresentationApiRef);\n const [entityPresentations, setEntityPresentations] = useState<\n Map<string, EntityRefPresentationSnapshot>\n >(new Map());\n\n useEffect(() => {\n const fetchPresentations = async () => {\n const presentations = new Map<string, EntityRefPresentationSnapshot>();\n await Promise.all(\n users.map(async user => {\n const presentation = await entityPresentationApi.forEntity(user)\n .promise;\n presentations.set(stringifyEntityRef(user), presentation);\n }),\n );\n setEntityPresentations(presentations);\n };\n\n fetchPresentations();\n }, [users, entityPresentationApi]);\n\n const getOptionLabel = (option: Entity | string) => {\n // option can be a string due to freeSolo.\n if (typeof option === 'string') return option;\n const entityRef = stringifyEntityRef(option);\n\n return (\n entityPresentations.get(entityRef)?.primaryTitle ?? option.metadata.name\n );\n };\n\n const filterOptions = createFilterOptions<Entity | string>({\n stringify: option => {\n if (typeof option === 'string') return option;\n const entityRef = stringifyEntityRef(option);\n return (\n entityPresentations.get(entityRef)?.primaryTitle ?? option.metadata.name\n );\n },\n });\n\n return (\n <div className={classes.container}>\n <Controller\n name={name}\n control={control}\n rules={rules}\n defaultValue={defaultValue ?? ''}\n render={({ field: { onChange, value }, fieldState: { error } }) => (\n <Autocomplete\n className={classes.autocomplete}\n fullWidth\n freeSolo\n disableClearable={disableClearable}\n value={value}\n options={users}\n getOptionLabel={getOptionLabel}\n renderOption={option =>\n typeof option === 'string' ? (\n option\n ) : (\n <EntityDisplayName entityRef={option} />\n )\n }\n renderInput={params => (\n <TextField\n {...params}\n label={label}\n required={!!rules?.required}\n error={!!error}\n helperText={error?.message}\n />\n )}\n onChange={(_, data) => {\n if (typeof data === 'string') {\n onChange(data);\n } else if (data) {\n onChange(stringifyEntityRef(data));\n } else {\n onChange('');\n }\n }}\n filterOptions={(options, params) => {\n const filtered = filterOptions(options, params);\n if (\n params.inputValue !== '' &&\n !options.some(\n option => getOptionLabel(option) === params.inputValue,\n )\n ) {\n filtered.push(params.inputValue);\n }\n return filtered;\n }}\n />\n )}\n />\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAyCA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,SAAW,EAAA,EAAE,KAAO,EAAA,MAAA,EAAQ,UAAU,OAAQ,EAAA;AAAA,EAC9C,YAAA,EAAc,EAAE,QAAA,EAAU,QAAS,EAAA;AACrC,CAAC,CAAA,CAAA;AAEM,MAAM,eAAe,CAAC;AAAA,EAC3B,KAAA;AAAA,EACA,gBAAA;AAAA,EACA,YAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AACF,CAAa,KAAA;AACX,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAM,MAAA,qBAAA,GAAwB,OAAO,wBAAwB,CAAA,CAAA;AAC7D,EAAA,MAAM,CAAC,mBAAqB,EAAA,sBAAsB,IAAI,QAEpD,iBAAA,IAAI,KAAK,CAAA,CAAA;AAEX,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,qBAAqB,YAAY;AACrC,MAAM,MAAA,aAAA,uBAAoB,GAA2C,EAAA,CAAA;AACrE,MAAA,MAAM,OAAQ,CAAA,GAAA;AAAA,QACZ,KAAA,CAAM,GAAI,CAAA,OAAM,IAAQ,KAAA;AACtB,UAAA,MA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UAAA,KAAe,EACtB,IAAA,CAAC,OAAQ,CAAA,IAAA;AAAA,cACP,CAAU,MAAA,KAAA,cAAA,CAAe,MAAM,CAAA,KAAM,MAAO,CAAA,UAAA;AAAA,aAE9C,EAAA;AACA,cAAS,QAAA,CAAA,IAAA,CAAK,OAAO,UAAU,CAAA,CAAA;AAAA,aACjC;AACA,YAAO,OAAA,QAAA,CAAA;AAAA,WACT;AAAA,SAAA;AAAA,OACF;AAAA,KAAA;AAAA,GAGN,CAAA,CAAA;AAEJ;;;;"}
@@ -21,6 +21,15 @@ const fetchCatalogItems = async (catalogApi) => {
21
21
  });
22
22
  return entities.items;
23
23
  };
24
+ const fetchUsers = async (catalogApi) => {
25
+ const entities = await catalogApi.getEntities({
26
+ filter: {
27
+ kind: ["User"]
28
+ },
29
+ fields: ["kind", "metadata.name", "metadata.namespace"]
30
+ });
31
+ return entities.items;
32
+ };
24
33
 
25
- export { fetchCatalogItems, fetchProjectMembers };
34
+ export { fetchCatalogItems, fetchProjectMembers, fetchUsers };
26
35
  //# sourceMappingURL=fetchMethods.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchMethods.esm.js","sources":["../../src/util/fetchMethods.ts"],"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 { sortMembers } from './sortMethods';\nimport { parseMember } from './parseMethods';\nimport { BazaarProject, Member } from '../types';\nimport { BazaarApi } from '../api';\nimport { Entity } from '@backstage/catalog-model';\nimport { CatalogApi } from '@backstage/plugin-catalog-react';\n\nexport const fetchProjectMembers = async (\n bazaarApi: BazaarApi,\n project: BazaarProject,\n): Promise<Member[]> => {\n const response = await bazaarApi.getMembers(project.id);\n\n if (response.data.length > 0) {\n const dbMembers = response.data.map((member: any) => {\n return parseMember(member);\n });\n\n dbMembers.sort(sortMembers);\n return dbMembers;\n }\n return [];\n};\n\nexport const fetchCatalogItems = async (\n catalogApi: CatalogApi,\n): Promise<Entity[]> => {\n const entities = await catalogApi.getEntities({\n filter: {\n kind: ['Component', 'Resource'],\n },\n fields: ['kind', 'metadata.name', 'metadata.namespace'],\n });\n\n return entities.items;\n};\n"],"names":[],"mappings":";;;AAuBa,MAAA,mBAAA,GAAsB,OACjC,SAAA,EACA,OACsB,KAAA;AACtB,EAAA,MAAM,QAAW,GAAA,MAAM,SAAU,CAAA,UAAA,CAAW,QAAQ,EAAE,CAAA,CAAA;AAEtD,EAAI,IAAA,QAAA,CAAS,IAAK,CAAA,MAAA,GAAS,CAAG,EAAA;AAC5B,IAAA,MAAM,SAAY,GAAA,QAAA,CAAS,IAAK,CAAA,GAAA,CAAI,CAAC,MAAgB,KAAA;AACnD,MAAA,OAAO,YAAY,MAAM,CAAA,CAAA;AAAA,KAC1B,CAAA,CAAA;AAED,IAAA,SAAA,CAAU,KAAK,WAAW,CAAA,CAAA;AAC1B,IAAO,OAAA,SAAA,CAAA;AAAA,GACT;AACA,EAAA,OAAO,EAAC,CAAA;AACV,EAAA;AAEa,MAAA,iBAAA,GAAoB,OAC/B,UACsB,KAAA;AACtB,EAAM,MAAA,QAAA,GAAW,MAAM,UAAA,CAAW,WAAY,CAAA;AAAA,IAC5C,MAAQ,EAAA;AAAA,MACN,IAAA,EAAM,CAAC,WAAA,EAAa,UAAU,CAAA;AAAA,KAChC;AAAA,IACA,MAAQ,EAAA,CAAC,MAAQ,EAAA,eAAA,EAAiB,oBAAoB,CAAA;AAAA,GACvD,CAAA,CAAA;AAED,EAAA,OAAO,QAAS,CAAA,KAAA,CAAA;AAClB;;;;"}
1
+ {"version":3,"file":"fetchMethods.esm.js","sources":["../../src/util/fetchMethods.ts"],"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 { sortMembers } from './sortMethods';\nimport { parseMember } from './parseMethods';\nimport { BazaarProject, Member } from '../types';\nimport { BazaarApi } from '../api';\nimport { Entity } from '@backstage/catalog-model';\nimport { CatalogApi } from '@backstage/plugin-catalog-react';\n\nexport const fetchProjectMembers = async (\n bazaarApi: BazaarApi,\n project: BazaarProject,\n): Promise<Member[]> => {\n const response = await bazaarApi.getMembers(project.id);\n\n if (response.data.length > 0) {\n const dbMembers = response.data.map((member: any) => {\n return parseMember(member);\n });\n\n dbMembers.sort(sortMembers);\n return dbMembers;\n }\n return [];\n};\n\nexport const fetchCatalogItems = async (\n catalogApi: CatalogApi,\n): Promise<Entity[]> => {\n const entities = await catalogApi.getEntities({\n filter: {\n kind: ['Component', 'Resource'],\n },\n fields: ['kind', 'metadata.name', 'metadata.namespace'],\n });\n\n return entities.items;\n};\n\nexport const fetchUsers = async (catalogApi: CatalogApi): Promise<Entity[]> => {\n const entities = await catalogApi.getEntities({\n filter: {\n kind: ['User'],\n },\n fields: ['kind', 'metadata.name', 'metadata.namespace'],\n });\n\n return entities.items;\n};\n"],"names":[],"mappings":";;;AAuBa,MAAA,mBAAA,GAAsB,OACjC,SAAA,EACA,OACsB,KAAA;AACtB,EAAA,MAAM,QAAW,GAAA,MAAM,SAAU,CAAA,UAAA,CAAW,QAAQ,EAAE,CAAA,CAAA;AAEtD,EAAI,IAAA,QAAA,CAAS,IAAK,CAAA,MAAA,GAAS,CAAG,EAAA;AAC5B,IAAA,MAAM,SAAY,GAAA,QAAA,CAAS,IAAK,CAAA,GAAA,CAAI,CAAC,MAAgB,KAAA;AACnD,MAAA,OAAO,YAAY,MAAM,CAAA,CAAA;AAAA,KAC1B,CAAA,CAAA;AAED,IAAA,SAAA,CAAU,KAAK,WAAW,CAAA,CAAA;AAC1B,IAAO,OAAA,SAAA,CAAA;AAAA,GACT;AACA,EAAA,OAAO,EAAC,CAAA;AACV,EAAA;AAEa,MAAA,iBAAA,GAAoB,OAC/B,UACsB,KAAA;AACtB,EAAM,MAAA,QAAA,GAAW,MAAM,UAAA,CAAW,WAAY,CAAA;AAAA,IAC5C,MAAQ,EAAA;AAAA,MACN,IAAA,EAAM,CAAC,WAAA,EAAa,UAAU,CAAA;AAAA,KAChC;AAAA,IACA,MAAQ,EAAA,CAAC,MAAQ,EAAA,eAAA,EAAiB,oBAAoB,CAAA;AAAA,GACvD,CAAA,CAAA;AAED,EAAA,OAAO,QAAS,CAAA,KAAA,CAAA;AAClB,EAAA;AAEa,MAAA,UAAA,GAAa,OAAO,UAA8C,KAAA;AAC7E,EAAM,MAAA,QAAA,GAAW,MAAM,UAAA,CAAW,WAAY,CAAA;AAAA,IAC5C,MAAQ,EAAA;AAAA,MACN,IAAA,EAAM,CAAC,MAAM,CAAA;AAAA,KACf;AAAA,IACA,MAAQ,EAAA,CAAC,MAAQ,EAAA,eAAA,EAAiB,oBAAoB,CAAA;AAAA,GACvD,CAAA,CAAA;AAED,EAAA,OAAO,QAAS,CAAA,KAAA,CAAA;AAClB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-bazaar",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "backstage": {
5
5
  "role": "frontend-plugin",
6
6
  "pluginId": "bazaar",
@@ -37,12 +37,12 @@
37
37
  "test": "backstage-cli package test"
38
38
  },
39
39
  "dependencies": {
40
- "@backstage/catalog-client": "^1.7.0",
40
+ "@backstage/catalog-client": "^1.7.1",
41
41
  "@backstage/catalog-model": "^1.7.0",
42
- "@backstage/core-components": "^0.15.0",
43
- "@backstage/core-plugin-api": "^1.9.4",
42
+ "@backstage/core-components": "^0.15.1",
43
+ "@backstage/core-plugin-api": "^1.10.0",
44
44
  "@backstage/errors": "^1.2.4",
45
- "@backstage/plugin-catalog-react": "^1.13.0",
45
+ "@backstage/plugin-catalog-react": "^1.14.0",
46
46
  "@date-io/luxon": "1.x",
47
47
  "@material-ui/core": "^4.12.2",
48
48
  "@material-ui/icons": "^4.9.1",
@@ -56,8 +56,8 @@
56
56
  "react-use": "^17.2.4"
57
57
  },
58
58
  "devDependencies": {
59
- "@backstage/cli": "^0.27.1",
60
- "@backstage/dev-utils": "^1.1.0",
59
+ "@backstage/cli": "^0.28.0",
60
+ "@backstage/dev-utils": "^1.1.2",
61
61
  "@testing-library/dom": "^10.0.0",
62
62
  "@testing-library/jest-dom": "^6.0.0",
63
63
  "@testing-library/react": "^15.0.0",