@backstage-community/plugin-bazaar 0.2.27 → 0.2.29
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 +12 -0
- package/README.md +1 -1
- package/dist/api.esm.js +120 -0
- package/dist/api.esm.js.map +1 -0
- package/dist/{esm/index-CM8Pdxty.esm.js → components/About/About.esm.js} +3 -70
- package/dist/components/About/About.esm.js.map +1 -0
- package/dist/components/AddProjectDialog/AddProjectDialog.esm.js +76 -0
- package/dist/components/AddProjectDialog/AddProjectDialog.esm.js.map +1 -0
- package/dist/components/BazaarOverviewCard/BazaarOverviewCard.esm.js +107 -0
- package/dist/components/BazaarOverviewCard/BazaarOverviewCard.esm.js.map +1 -0
- package/dist/components/CardContentFields/AboutField.esm.js +33 -0
- package/dist/components/CardContentFields/AboutField.esm.js.map +1 -0
- package/dist/components/CardContentFields/CardContentFields.esm.js +87 -0
- package/dist/components/CardContentFields/CardContentFields.esm.js.map +1 -0
- package/dist/components/ConfirmationDialog/ConfirmationDialog.esm.js +29 -0
- package/dist/components/ConfirmationDialog/ConfirmationDialog.esm.js.map +1 -0
- package/dist/components/CustomDialogTitle/CustomDialogTitle.esm.js +49 -0
- package/dist/components/CustomDialogTitle/CustomDialogTitle.esm.js.map +1 -0
- package/dist/components/DateSelector/DateSelector.esm.js +40 -0
- package/dist/components/DateSelector/DateSelector.esm.js.map +1 -0
- package/dist/components/DoubleDateSelector/DoubleDateSelector.esm.js +34 -0
- package/dist/components/DoubleDateSelector/DoubleDateSelector.esm.js.map +1 -0
- package/dist/components/EditProjectDialog/EditProjectDialog.esm.js +115 -0
- package/dist/components/EditProjectDialog/EditProjectDialog.esm.js.map +1 -0
- package/dist/components/EntityBazaarInfoCard/EntityBazaarInfoCard.esm.js +41 -0
- package/dist/components/EntityBazaarInfoCard/EntityBazaarInfoCard.esm.js.map +1 -0
- package/dist/components/EntityBazaarInfoContent/EntityBazaarInfoContent.esm.js +177 -0
- package/dist/components/EntityBazaarInfoContent/EntityBazaarInfoContent.esm.js.map +1 -0
- package/dist/components/HomePage/HomePage.esm.js +30 -0
- package/dist/components/HomePage/HomePage.esm.js.map +1 -0
- package/dist/components/HomePage/index.esm.js +2 -0
- package/dist/components/HomePage/index.esm.js.map +1 -0
- package/dist/components/HomePageBazaarInfoCard/HomePageBazaarInfoCard.esm.js +218 -0
- package/dist/components/HomePageBazaarInfoCard/HomePageBazaarInfoCard.esm.js.map +1 -0
- package/dist/components/InputField/InputField.esm.js +41 -0
- package/dist/components/InputField/InputField.esm.js.map +1 -0
- package/dist/components/InputSelector/InputSelector.esm.js +47 -0
- package/dist/components/InputSelector/InputSelector.esm.js.map +1 -0
- package/dist/components/LinkProjectDialog/LinkProjectDialog.esm.js +68 -0
- package/dist/components/LinkProjectDialog/LinkProjectDialog.esm.js.map +1 -0
- package/dist/components/ProjectCard/ProjectCard.esm.js +70 -0
- package/dist/components/ProjectCard/ProjectCard.esm.js.map +1 -0
- package/dist/components/ProjectDialog/ProjectDialog.esm.js +143 -0
- package/dist/components/ProjectDialog/ProjectDialog.esm.js.map +1 -0
- package/dist/components/ProjectPreview/ProjectPreview.esm.js +79 -0
- package/dist/components/ProjectPreview/ProjectPreview.esm.js.map +1 -0
- package/dist/components/ProjectSelector/ProjectSelector.esm.js +38 -0
- package/dist/components/ProjectSelector/ProjectSelector.esm.js.map +1 -0
- package/dist/components/SortMethodSelector/SortMethodSelector.esm.js +35 -0
- package/dist/components/SortMethodSelector/SortMethodSelector.esm.js.map +1 -0
- package/dist/components/SortView/SortView.esm.js +176 -0
- package/dist/components/SortView/SortView.esm.js.map +1 -0
- package/dist/components/StatusTag/StatusTag.esm.js +13 -0
- package/dist/components/StatusTag/StatusTag.esm.js.map +1 -0
- package/dist/index.esm.js +5 -1749
- package/dist/index.esm.js.map +1 -1
- package/dist/plugin.esm.js +31 -0
- package/dist/plugin.esm.js.map +1 -0
- package/dist/routes.esm.js +8 -0
- package/dist/routes.esm.js.map +1 -0
- package/dist/util/fetchMethods.esm.js +26 -0
- package/dist/util/fetchMethods.esm.js.map +1 -0
- package/dist/util/parseMethods.esm.js +38 -0
- package/dist/util/parseMethods.esm.js.map +1 -0
- package/dist/util/sortMethods.esm.js +20 -0
- package/dist/util/sortMethods.esm.js.map +1 -0
- package/package.json +14 -9
- package/dist/esm/index-CM8Pdxty.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ The Bazaar allows engineers and teams to open up and announce their new and exci
|
|
|
14
14
|
|
|
15
15
|
# Note
|
|
16
16
|
|
|
17
|
-
You will **need** to also perform the installation instructions in [Bazaar Backend](https://github.com/backstage/
|
|
17
|
+
You will **need** to also perform the installation instructions in [Bazaar Backend](https://github.com/backstage/community-plugins/tree/main/workspaces/bazaar/plugins/bazaar-backend) in order for this plugin to work.
|
|
18
18
|
|
|
19
19
|
## Getting Started
|
|
20
20
|
|
package/dist/api.esm.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { stringifyEntityRef } from '@backstage/catalog-model';
|
|
2
|
+
import { createApiRef } from '@backstage/core-plugin-api';
|
|
3
|
+
import { ResponseError } from '@backstage/errors';
|
|
4
|
+
|
|
5
|
+
const bazaarApiRef = createApiRef({
|
|
6
|
+
id: "bazaar"
|
|
7
|
+
});
|
|
8
|
+
const isBazaarAvailable = async (entity, context) => {
|
|
9
|
+
const bazaarClient = context.apis.get(bazaarApiRef);
|
|
10
|
+
if (bazaarClient === void 0) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const entityRef = stringifyEntityRef({
|
|
14
|
+
kind: entity.kind,
|
|
15
|
+
name: entity.metadata.name,
|
|
16
|
+
namespace: entity.metadata.namespace
|
|
17
|
+
});
|
|
18
|
+
const response = await bazaarClient.getProjectByRef(entityRef);
|
|
19
|
+
const project = await response.json();
|
|
20
|
+
return project.data.length > 0;
|
|
21
|
+
};
|
|
22
|
+
class BazaarClient {
|
|
23
|
+
identityApi;
|
|
24
|
+
discoveryApi;
|
|
25
|
+
fetchApi;
|
|
26
|
+
constructor(options) {
|
|
27
|
+
this.identityApi = options.identityApi;
|
|
28
|
+
this.discoveryApi = options.discoveryApi;
|
|
29
|
+
this.fetchApi = options.fetchApi;
|
|
30
|
+
}
|
|
31
|
+
async updateProject(bazaarProject) {
|
|
32
|
+
const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
|
|
33
|
+
return await this.fetchApi.fetch(`${baseUrl}/projects`, {
|
|
34
|
+
method: "PUT",
|
|
35
|
+
headers: {
|
|
36
|
+
Accept: "application/json",
|
|
37
|
+
"Content-Type": "application/json"
|
|
38
|
+
},
|
|
39
|
+
body: JSON.stringify(bazaarProject)
|
|
40
|
+
}).then((resp) => resp.json());
|
|
41
|
+
}
|
|
42
|
+
async addProject(bazaarProject) {
|
|
43
|
+
const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
|
|
44
|
+
return await this.fetchApi.fetch(`${baseUrl}/projects`, {
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: {
|
|
47
|
+
Accept: "application/json",
|
|
48
|
+
"Content-Type": "application/json"
|
|
49
|
+
},
|
|
50
|
+
body: JSON.stringify(bazaarProject)
|
|
51
|
+
}).then((resp) => resp.json());
|
|
52
|
+
}
|
|
53
|
+
async getProjectById(id) {
|
|
54
|
+
const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
|
|
55
|
+
const response = await this.fetchApi.fetch(
|
|
56
|
+
`${baseUrl}/projects/${encodeURIComponent(id)}`
|
|
57
|
+
);
|
|
58
|
+
return response.ok ? response : null;
|
|
59
|
+
}
|
|
60
|
+
async getProjectByRef(entityRef) {
|
|
61
|
+
const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
|
|
62
|
+
const response = await this.fetchApi.fetch(
|
|
63
|
+
`${baseUrl}/projects/${encodeURIComponent(entityRef)}`
|
|
64
|
+
);
|
|
65
|
+
return response.ok ? response : null;
|
|
66
|
+
}
|
|
67
|
+
async getMembers(id) {
|
|
68
|
+
const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
|
|
69
|
+
return await this.fetchApi.fetch(`${baseUrl}/projects/${encodeURIComponent(id)}/members`).then((resp) => resp.json());
|
|
70
|
+
}
|
|
71
|
+
async addMember(id, userId) {
|
|
72
|
+
const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
|
|
73
|
+
const { picture } = await this.identityApi.getProfileInfo();
|
|
74
|
+
await this.fetchApi.fetch(
|
|
75
|
+
`${baseUrl}/projects/${encodeURIComponent(
|
|
76
|
+
id
|
|
77
|
+
)}/member/${encodeURIComponent(userId)}`,
|
|
78
|
+
{
|
|
79
|
+
method: "PUT",
|
|
80
|
+
headers: {
|
|
81
|
+
Accept: "application/json",
|
|
82
|
+
"Content-Type": "application/json"
|
|
83
|
+
},
|
|
84
|
+
body: JSON.stringify({ picture })
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
async deleteMember(id, userId) {
|
|
89
|
+
const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
|
|
90
|
+
await this.fetchApi.fetch(
|
|
91
|
+
`${baseUrl}/projects/${encodeURIComponent(
|
|
92
|
+
id
|
|
93
|
+
)}/member/${encodeURIComponent(userId)}`,
|
|
94
|
+
{ method: "DELETE" }
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
async getProjects(limit, order) {
|
|
98
|
+
const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
|
|
99
|
+
const params = {
|
|
100
|
+
...limit ? { limit: limit.toString() } : {},
|
|
101
|
+
...order ? { order } : {}
|
|
102
|
+
};
|
|
103
|
+
const query = new URLSearchParams(params);
|
|
104
|
+
const url = `projects?${query.toString()}`;
|
|
105
|
+
const data = await this.fetchApi.fetch(`${baseUrl}/${url}`);
|
|
106
|
+
if (!data.ok) {
|
|
107
|
+
throw await ResponseError.fromResponse(data);
|
|
108
|
+
}
|
|
109
|
+
return data.json();
|
|
110
|
+
}
|
|
111
|
+
async deleteProject(id) {
|
|
112
|
+
const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
|
|
113
|
+
await this.fetchApi.fetch(`${baseUrl}/projects/${encodeURIComponent(id)}`, {
|
|
114
|
+
method: "DELETE"
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { BazaarClient, bazaarApiRef, isBazaarAvailable };
|
|
120
|
+
//# sourceMappingURL=api.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.esm.js","sources":["../src/api.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 { Entity, stringifyEntityRef } from '@backstage/catalog-model';\nimport {\n ApiHolder,\n createApiRef,\n DiscoveryApi,\n FetchApi,\n IdentityApi,\n} from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\n\nexport const bazaarApiRef = createApiRef<BazaarApi>({\n id: 'bazaar',\n});\n\nexport interface BazaarApi {\n updateProject(bazaarProject: any): Promise<any>;\n\n addProject(bazaarProject: any): Promise<any>;\n\n getProjectById(id: number): Promise<any>;\n\n getProjectByRef(entityRef: string): Promise<any>;\n\n getMembers(id: number): Promise<any>;\n\n deleteMember(id: number, userId: string): Promise<void>;\n\n addMember(id: number, userId: string): Promise<void>;\n\n getProjects(limit?: number, order?: string): Promise<any>;\n\n deleteProject(id: number): Promise<void>;\n}\n\n/** @public */\nexport const isBazaarAvailable = async (\n entity: Entity,\n context: { apis: ApiHolder },\n): Promise<boolean> => {\n const bazaarClient = context.apis.get(bazaarApiRef);\n if (bazaarClient === undefined) {\n return false;\n }\n const entityRef = stringifyEntityRef({\n kind: entity.kind,\n name: entity.metadata.name,\n namespace: entity.metadata.namespace,\n });\n const response = await bazaarClient.getProjectByRef(entityRef);\n const project = await response.json();\n return project.data.length > 0;\n};\n\nexport class BazaarClient implements BazaarApi {\n private readonly identityApi: IdentityApi;\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n constructor(options: {\n identityApi: IdentityApi;\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n }) {\n this.identityApi = options.identityApi;\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi;\n }\n\n async updateProject(bazaarProject: any): Promise<any> {\n const baseUrl = await this.discoveryApi.getBaseUrl('bazaar');\n\n return await this.fetchApi\n .fetch(`${baseUrl}/projects`, {\n method: 'PUT',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(bazaarProject),\n })\n .then(resp => resp.json());\n }\n\n async addProject(bazaarProject: any): Promise<any> {\n const baseUrl = await this.discoveryApi.getBaseUrl('bazaar');\n\n return await this.fetchApi\n .fetch(`${baseUrl}/projects`, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(bazaarProject),\n })\n .then(resp => resp.json());\n }\n\n async getProjectById(id: number): Promise<any> {\n const baseUrl = await this.discoveryApi.getBaseUrl('bazaar');\n\n const response = await this.fetchApi.fetch(\n `${baseUrl}/projects/${encodeURIComponent(id)}`,\n );\n\n return response.ok ? response : null;\n }\n\n async getProjectByRef(entityRef: string): Promise<any> {\n const baseUrl = await this.discoveryApi.getBaseUrl('bazaar');\n\n const response = await this.fetchApi.fetch(\n `${baseUrl}/projects/${encodeURIComponent(entityRef)}`,\n );\n\n return response.ok ? response : null;\n }\n\n async getMembers(id: number): Promise<any> {\n const baseUrl = await this.discoveryApi.getBaseUrl('bazaar');\n\n return await this.fetchApi\n .fetch(`${baseUrl}/projects/${encodeURIComponent(id)}/members`)\n .then(resp => resp.json());\n }\n\n async addMember(id: number, userId: string): Promise<void> {\n const baseUrl = await this.discoveryApi.getBaseUrl('bazaar');\n const { picture } = await this.identityApi.getProfileInfo();\n\n await this.fetchApi.fetch(\n `${baseUrl}/projects/${encodeURIComponent(\n id,\n )}/member/${encodeURIComponent(userId)}`,\n {\n method: 'PUT',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ picture }),\n },\n );\n }\n\n async deleteMember(id: number, userId: string): Promise<void> {\n const baseUrl = await this.discoveryApi.getBaseUrl('bazaar');\n\n await this.fetchApi.fetch(\n `${baseUrl}/projects/${encodeURIComponent(\n id,\n )}/member/${encodeURIComponent(userId)}`,\n { method: 'DELETE' },\n );\n }\n\n async getProjects(limit?: number, order?: string): Promise<any> {\n const baseUrl = await this.discoveryApi.getBaseUrl('bazaar');\n const params = {\n ...(limit ? { limit: limit.toString() } : {}),\n ...(order ? { order } : {}),\n };\n const query = new URLSearchParams(params);\n const url = `projects?${query.toString()}`;\n\n const data = await this.fetchApi.fetch(`${baseUrl}/${url}`);\n if (!data.ok) {\n throw await ResponseError.fromResponse(data);\n }\n return data.json();\n }\n\n async deleteProject(id: number): Promise<void> {\n const baseUrl = await this.discoveryApi.getBaseUrl('bazaar');\n\n await this.fetchApi.fetch(`${baseUrl}/projects/${encodeURIComponent(id)}`, {\n method: 'DELETE',\n });\n }\n}\n"],"names":[],"mappings":";;;;AA0BO,MAAM,eAAe,YAAwB,CAAA;AAAA,EAClD,EAAI,EAAA,QAAA;AACN,CAAC,EAAA;AAuBY,MAAA,iBAAA,GAAoB,OAC/B,MAAA,EACA,OACqB,KAAA;AACrB,EAAA,MAAM,YAAe,GAAA,OAAA,CAAQ,IAAK,CAAA,GAAA,CAAI,YAAY,CAAA,CAAA;AAClD,EAAA,IAAI,iBAAiB,KAAW,CAAA,EAAA;AAC9B,IAAO,OAAA,K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EAAA;AAAA,MACzE,MAAQ,EAAA,QAAA;AAAA,KACT,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
|
|
@@ -1,52 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { InfoCard, Link, Header, RoutedTabs } from '@backstage/core-components';
|
|
3
|
-
import { SortView } from '../index.esm.js';
|
|
4
2
|
import Grid from '@material-ui/core/Grid';
|
|
5
3
|
import Typography from '@material-ui/core/Typography';
|
|
6
4
|
import { makeStyles } from '@material-ui/core/styles';
|
|
7
|
-
import '@backstage/core-
|
|
8
|
-
import '@backstage/catalog-model';
|
|
9
|
-
import '@backstage/errors';
|
|
10
|
-
import '@material-ui/core/Card';
|
|
11
|
-
import '@material-ui/core/CardActionArea';
|
|
12
|
-
import '@material-ui/core/CardContent';
|
|
13
|
-
import '@material-ui/core/Dialog';
|
|
14
|
-
import 'luxon';
|
|
15
|
-
import '@material-ui/core/CardHeader';
|
|
16
|
-
import '@material-ui/core/Divider';
|
|
17
|
-
import '@material-ui/core/IconButton';
|
|
18
|
-
import '@material-ui/icons/Edit';
|
|
19
|
-
import '@material-ui/icons/Chat';
|
|
20
|
-
import '@material-ui/icons/PersonAdd';
|
|
21
|
-
import '@material-ui/icons/InsertLink';
|
|
22
|
-
import '@material-ui/icons/Dashboard';
|
|
23
|
-
import '@material-ui/icons/Close';
|
|
24
|
-
import '@material-ui/icons/LinkOff';
|
|
25
|
-
import '@material-ui/icons/Description';
|
|
26
|
-
import '@material-ui/core/Button';
|
|
27
|
-
import 'react-hook-form';
|
|
28
|
-
import '@material-ui/core/TextField';
|
|
29
|
-
import '@material-ui/core/InputLabel';
|
|
30
|
-
import '@material-ui/core/MenuItem';
|
|
31
|
-
import '@material-ui/core/FormControl';
|
|
32
|
-
import '@material-ui/core/Select';
|
|
33
|
-
import '@material-ui/pickers/DatePicker';
|
|
34
|
-
import '@material-ui/pickers/MuiPickersUtilsProvider';
|
|
35
|
-
import '@date-io/luxon';
|
|
36
|
-
import '@material-ui/icons/Clear';
|
|
37
|
-
import '@material-ui/core/DialogTitle';
|
|
38
|
-
import '@material-ui/core/DialogContent';
|
|
39
|
-
import '@material-ui/core/DialogActions';
|
|
40
|
-
import '@material-ui/icons/ExitToApp';
|
|
41
|
-
import '@material-ui/lab/Alert';
|
|
42
|
-
import 'react-use/esm/useAsyncFn';
|
|
43
|
-
import '@backstage/plugin-catalog-react';
|
|
44
|
-
import '@material-ui/core/styles/makeStyles';
|
|
45
|
-
import '@material-ui/lab/Autocomplete';
|
|
46
|
-
import '@material-ui/core/Box';
|
|
47
|
-
import '@material-ui/core/TablePagination';
|
|
48
|
-
import '@material-ui/icons/Storefront';
|
|
49
|
-
import 'material-ui-search-bar';
|
|
5
|
+
import { InfoCard, Link } from '@backstage/core-components';
|
|
50
6
|
|
|
51
7
|
const useStyles = makeStyles({
|
|
52
8
|
subheader: {
|
|
@@ -65,28 +21,5 @@ const About = () => {
|
|
|
65
21
|
), '. With "Inner Sourcing", we mean projects that are developed internally within a company, but with Open Source best practices.'), /* @__PURE__ */ React.createElement(Typography, { className: classes.subheader, variant: "body1" }, "Why?"), /* @__PURE__ */ React.createElement(Typography, { paragraph: true }, "Many companies today are of high need to increase the ease of cross-team cooperation. In large organizations, engineers often have limited ways of discovering or announcing the projects which could benefit from a wider development effort in terms of different expertise, experiences, and teams spread across the organization. With no good way to find these existing internal projects to join, the possibility of working with Inner Sourcing practices suffers."), /* @__PURE__ */ React.createElement(Typography, { className: classes.subheader, variant: "body1" }, "How?"), /* @__PURE__ */ React.createElement(Typography, { paragraph: true }, "The Bazaar allows engineers and teams to open up and announce their new and exciting projects for transparent cooperation in other parts of larger organizations. The Bazaar ensures that new Inner Sourcing friendly projects gain visibility through Backstage and a way for interested engineers to show their interest and in the future contribute with their specific skill set. The Bazaar also provides an easy way to manage, catalog, and browse these Inner Sourcing friendly projects and components."))));
|
|
66
22
|
};
|
|
67
23
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const tabContent = [
|
|
71
|
-
{
|
|
72
|
-
path: "/",
|
|
73
|
-
title: "Home",
|
|
74
|
-
children: /* @__PURE__ */ React.createElement(SortView, { fullWidth, fullHeight })
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
path: "/about",
|
|
78
|
-
title: "About",
|
|
79
|
-
children: /* @__PURE__ */ React.createElement(About, null)
|
|
80
|
-
}
|
|
81
|
-
];
|
|
82
|
-
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
|
|
83
|
-
Header,
|
|
84
|
-
{
|
|
85
|
-
title: title || "Bazaar",
|
|
86
|
-
subtitle: subtitle || "Marketplace for inner source projects"
|
|
87
|
-
}
|
|
88
|
-
), /* @__PURE__ */ React.createElement(RoutedTabs, { routes: tabContent }));
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export { HomePage };
|
|
92
|
-
//# sourceMappingURL=index-CM8Pdxty.esm.js.map
|
|
24
|
+
export { About };
|
|
25
|
+
//# sourceMappingURL=About.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"About.esm.js","sources":["../../../src/components/About/About.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 Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { InfoCard, Link } from '@backstage/core-components';\n\nconst useStyles = makeStyles({\n subheader: {\n fontWeight: 'bold',\n },\n});\n\nexport const About = () => {\n const classes = useStyles();\n return (\n <Grid container spacing={4}>\n <Grid item xs={5}>\n <InfoCard title=\"About Bazaar\">\n <Typography className={classes.subheader} variant=\"body1\">\n What is the Bazaar?\n </Typography>\n <Typography paragraph>\n The Bazaar is a place where teams can propose projects for\n cross-functional team development. Essentially a marketplace for\n internal projects suitable for{' '}\n <Link\n target=\"_blank\"\n to=\"https://en.wikipedia.org/wiki/Inner_source\"\n >\n Inner Sourcing\n </Link>\n . With \"Inner Sourcing\", we mean projects that are developed\n internally within a company, but with Open Source best practices.\n </Typography>\n <Typography className={classes.subheader} variant=\"body1\">\n Why?\n </Typography>\n <Typography paragraph>\n Many companies today are of high need to increase the ease of\n cross-team cooperation. In large organizations, engineers often have\n limited ways of discovering or announcing the projects which could\n benefit from a wider development effort in terms of different\n expertise, experiences, and teams spread across the organization.\n With no good way to find these existing internal projects to join,\n the possibility of working with Inner Sourcing practices suffers.\n </Typography>\n <Typography className={classes.subheader} variant=\"body1\">\n How?\n </Typography>\n <Typography paragraph>\n The Bazaar allows engineers and teams to open up and announce their\n new and exciting projects for transparent cooperation in other parts\n of larger organizations. The Bazaar ensures that new Inner Sourcing\n friendly projects gain visibility through Backstage and a way for\n interested engineers to show their interest and in the future\n contribute with their specific skill set. The Bazaar also provides\n an easy way to manage, catalog, and browse these Inner Sourcing\n friendly projects and components.\n </Typography>\n </InfoCard>\n </Grid>\n </Grid>\n );\n};\n"],"names":[],"mappings":";;;;;;AAsBA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,SAAW,EAAA;AAAA,IACT,UAAY,EAAA,MAAA;AAAA,GACd;AACF,CAAC,CAAA,CAAA;AAEM,MAAM,QAAQ,MAAM;AACzB,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,SAAS,EAAA,IAAA,EAAC,OAAS,EAAA,CAAA,EAAA,kBACtB,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,IAAI,EAAA,IAAA,EAAC,EAAI,EAAA,CAAA,EAAA,sCACZ,QAAS,EAAA,EAAA,KAAA,EAAM,cACd,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,SAAA,EAAW,OAAQ,CAAA,SAAA,EAAW,OAAQ,EAAA,OAAA,EAAA,EAAQ,qBAE1D,CAAA,kBACC,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,SAAS,EAAA,IAAA,EAAA,EAAC,8JAGW,GAC/B,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,MAAO,EAAA,QAAA;AAAA,MACP,EAAG,EAAA,4CAAA;AAAA,KAAA;AAAA,IACJ,gBAAA;AAAA,GAEM,EAAA,gIAGT,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,SAAW,EAAA,OAAA,CAAQ,SAAW,EAAA,OAAA,EAAQ,WAAQ,MAE1D,CAAA,kBACC,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,WAAS,IAAC,EAAA,EAAA,4cAQtB,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,SAAA,EAAW,OAAQ,CAAA,SAAA,EAAW,SAAQ,OAAQ,EAAA,EAAA,MAE1D,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,SAAS,EAAA,IAAA,EAAA,EAAC,mfAStB,CACF,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { stringifyEntityRef } from '@backstage/catalog-model';
|
|
3
|
+
import { useApi, alertApiRef } from '@backstage/core-plugin-api';
|
|
4
|
+
import { ProjectDialog } from '../ProjectDialog/ProjectDialog.esm.js';
|
|
5
|
+
import { ProjectSelector } from '../ProjectSelector/ProjectSelector.esm.js';
|
|
6
|
+
import { bazaarApiRef } from '../../api.esm.js';
|
|
7
|
+
|
|
8
|
+
const AddProjectDialog = ({
|
|
9
|
+
catalogEntities,
|
|
10
|
+
open,
|
|
11
|
+
handleClose,
|
|
12
|
+
fetchBazaarProjects,
|
|
13
|
+
fetchCatalogEntities
|
|
14
|
+
}) => {
|
|
15
|
+
const bazaarApi = useApi(bazaarApiRef);
|
|
16
|
+
const alertApi = useApi(alertApiRef);
|
|
17
|
+
const [selectedEntity, setSelectedEntity] = useState(null);
|
|
18
|
+
const defaultValues = {
|
|
19
|
+
title: "",
|
|
20
|
+
community: "",
|
|
21
|
+
description: "",
|
|
22
|
+
docs: "",
|
|
23
|
+
status: "proposed",
|
|
24
|
+
size: "medium",
|
|
25
|
+
responsible: "",
|
|
26
|
+
startDate: null,
|
|
27
|
+
endDate: null
|
|
28
|
+
};
|
|
29
|
+
const handleEntityClick = (entity) => {
|
|
30
|
+
setSelectedEntity(entity);
|
|
31
|
+
};
|
|
32
|
+
const handleSubmit = async (getValues, reset) => {
|
|
33
|
+
const formValues = getValues();
|
|
34
|
+
const response = await bazaarApi.addProject({
|
|
35
|
+
...formValues,
|
|
36
|
+
entityRef: selectedEntity ? stringifyEntityRef(selectedEntity) : null,
|
|
37
|
+
startDate: formValues.startDate ?? null,
|
|
38
|
+
endDate: formValues.endDate ?? null
|
|
39
|
+
});
|
|
40
|
+
if (response.status === "ok") {
|
|
41
|
+
fetchBazaarProjects();
|
|
42
|
+
fetchCatalogEntities();
|
|
43
|
+
alertApi.post({
|
|
44
|
+
message: `Added project '${formValues.title}' to the Bazaar list`,
|
|
45
|
+
severity: "success",
|
|
46
|
+
display: "transient"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
handleClose();
|
|
50
|
+
reset(defaultValues);
|
|
51
|
+
};
|
|
52
|
+
return /* @__PURE__ */ React.createElement(
|
|
53
|
+
ProjectDialog,
|
|
54
|
+
{
|
|
55
|
+
handleSave: handleSubmit,
|
|
56
|
+
title: "Add project",
|
|
57
|
+
isAddForm: true,
|
|
58
|
+
defaultValues,
|
|
59
|
+
open,
|
|
60
|
+
projectSelector: /* @__PURE__ */ React.createElement(
|
|
61
|
+
ProjectSelector,
|
|
62
|
+
{
|
|
63
|
+
onChange: handleEntityClick,
|
|
64
|
+
catalogEntities: catalogEntities || [],
|
|
65
|
+
disableClearable: false,
|
|
66
|
+
defaultValue: null,
|
|
67
|
+
label: "Select a project"
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
handleClose
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export { AddProjectDialog };
|
|
76
|
+
//# sourceMappingURL=AddProjectDialog.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddProjectDialog.esm.js","sources":["../../../src/components/AddProjectDialog/AddProjectDialog.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, { useState } from 'react';\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\nimport { UseFormReset, UseFormGetValues } from 'react-hook-form';\nimport { useApi, alertApiRef } from '@backstage/core-plugin-api';\nimport { ProjectDialog } from '../ProjectDialog';\nimport { ProjectSelector } from '../ProjectSelector';\nimport { BazaarProject, FormValues, Size, Status } from '../../types';\nimport { bazaarApiRef } from '../../api';\n\ntype Props = {\n catalogEntities: Entity[];\n open: boolean;\n handleClose: () => void;\n fetchBazaarProjects: () => Promise<BazaarProject[]>;\n fetchCatalogEntities: () => Promise<Entity[]>;\n};\n\nexport const AddProjectDialog = ({\n catalogEntities,\n open,\n handleClose,\n fetchBazaarProjects,\n fetchCatalogEntities,\n}: Props) => {\n const bazaarApi = useApi(bazaarApiRef);\n const alertApi = useApi(alertApiRef);\n const [selectedEntity, setSelectedEntity] = useState<Entity | null>(null);\n\n const defaultValues = {\n title: '',\n community: '',\n description: '',\n docs: '',\n status: 'proposed' as Status,\n size: 'medium' as Size,\n responsible: '',\n startDate: null,\n endDate: null,\n };\n\n const handleEntityClick = (entity: Entity) => {\n setSelectedEntity(entity);\n };\n\n const handleSubmit: (\n getValues: UseFormGetValues<FormValues>,\n reset: UseFormReset<FormValues>,\n ) => Promise<void> = async (\n getValues: UseFormGetValues<FormValues>,\n reset: UseFormReset<FormValues>,\n ) => {\n const formValues = getValues();\n\n const response = await bazaarApi.addProject({\n ...formValues,\n entityRef: selectedEntity ? stringifyEntityRef(selectedEntity) : null,\n startDate: formValues.startDate ?? null,\n endDate: formValues.endDate ?? null,\n } as BazaarProject);\n\n if (response.status === 'ok') {\n fetchBazaarProjects();\n fetchCatalogEntities();\n alertApi.post({\n message: `Added project '${formValues.title}' to the Bazaar list`,\n severity: 'success',\n display: 'transient',\n });\n }\n\n handleClose();\n reset(defaultValues);\n };\n\n return (\n <ProjectDialog\n handleSave={handleSubmit}\n title=\"Add project\"\n isAddForm\n defaultValues={defaultValues}\n open={open}\n projectSelector={\n <ProjectSelector\n onChange={handleEntityClick}\n catalogEntities={catalogEntities || []}\n disableClearable={false}\n defaultValue={null}\n label=\"Select a project\"\n />\n }\n handleClose={handleClose}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;AAiCO,MAAM,mBAAmB,CAAC;AAAA,EAC/B,eAAA;AAAA,EACA,IAAA;AAAA,EACA,WAAA;AAAA,EACA,mBAAA;AAAA,EACA,oBAAA;AACF,CAAa,KAAA;AACX,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA,CAAA;AACrC,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAI,SAAwB,IAAI,CAAA,CAA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E,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,UAAY,EAAA,YAAA;AAAA,MACZ,KAAM,EAAA,aAAA;AAAA,MACN,SAAS,EAAA,IAAA;AAAA,MACT,aAAA;AAAA,MACA,IAAA;AAAA,MACA,eACE,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,eAAA;AAAA,QAAA;AAAA,UACC,QAAU,EAAA,iBAAA;AAAA,UACV,eAAA,EAAiB,mBAAmB,EAAC;AAAA,UACrC,gBAAkB,EAAA,KAAA;AAAA,UAClB,YAAc,EAAA,IAAA;AAAA,UACd,KAAM,EAAA,kBAAA;AAAA,SAAA;AAAA,OACR;AAAA,MAEF,WAAA;AAAA,KAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { ProjectPreview } from '../ProjectPreview/ProjectPreview.esm.js';
|
|
3
|
+
import useAsyncFn from 'react-use/esm/useAsyncFn';
|
|
4
|
+
import { stringifyEntityRef } from '@backstage/catalog-model';
|
|
5
|
+
import { useApi, useRouteRef } from '@backstage/core-plugin-api';
|
|
6
|
+
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
|
7
|
+
import { bazaarApiRef } from '../../api.esm.js';
|
|
8
|
+
import { fetchCatalogItems } from '../../util/fetchMethods.esm.js';
|
|
9
|
+
import { parseBazaarProject } from '../../util/parseMethods.esm.js';
|
|
10
|
+
import { ErrorPanel, InfoCard, Link } from '@backstage/core-components';
|
|
11
|
+
import { bazaarPlugin } from '../../plugin.esm.js';
|
|
12
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
13
|
+
import StorefrontIcon from '@material-ui/icons/Storefront';
|
|
14
|
+
|
|
15
|
+
const getUnlinkedCatalogEntities = (bazaarProjects, catalogEntities) => {
|
|
16
|
+
const bazaarProjectRefs = bazaarProjects.map(
|
|
17
|
+
(project) => project.entityRef
|
|
18
|
+
);
|
|
19
|
+
return catalogEntities.filter((entity) => {
|
|
20
|
+
return !bazaarProjectRefs?.includes(stringifyEntityRef(entity));
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const BazaarOverviewCard = (props) => {
|
|
24
|
+
const { title, order, fullWidth = false, fullHeight = false } = props;
|
|
25
|
+
const bazaarApi = useApi(bazaarApiRef);
|
|
26
|
+
const catalogApi = useApi(catalogApiRef);
|
|
27
|
+
const root = useRouteRef(bazaarPlugin.routes.root);
|
|
28
|
+
const defaultTitle = order === "latest" ? "Bazaar Latest Projects" : "Bazaar Random Projects";
|
|
29
|
+
const bazaarLink = {
|
|
30
|
+
title: "Go to Bazaar",
|
|
31
|
+
link: `${root()}`
|
|
32
|
+
};
|
|
33
|
+
const [unlinkedCatalogEntities, setUnlinkedCatalogEntities] = useState();
|
|
34
|
+
const [catalogEntities, fetchCatalogEntities] = useAsyncFn(async () => {
|
|
35
|
+
return await fetchCatalogItems(catalogApi);
|
|
36
|
+
});
|
|
37
|
+
const [bazaarProjects, fetchBazaarProjects] = useAsyncFn(async () => {
|
|
38
|
+
const limit = fullWidth ? 6 : 3;
|
|
39
|
+
const response = await bazaarApi.getProjects(limit, order);
|
|
40
|
+
return response.data.map(parseBazaarProject);
|
|
41
|
+
});
|
|
42
|
+
const catalogEntityRefs = catalogEntities.value?.map(
|
|
43
|
+
(project) => stringifyEntityRef(project)
|
|
44
|
+
);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const filterBrokenLinks = () => {
|
|
47
|
+
if (catalogEntityRefs) {
|
|
48
|
+
bazaarProjects.value?.forEach(async (project) => {
|
|
49
|
+
if (project.entityRef) {
|
|
50
|
+
if (!catalogEntityRefs?.includes(project.entityRef)) {
|
|
51
|
+
await bazaarApi.updateProject({
|
|
52
|
+
...project,
|
|
53
|
+
entityRef: null
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
filterBrokenLinks();
|
|
61
|
+
}, [
|
|
62
|
+
bazaarApi,
|
|
63
|
+
bazaarProjects.value,
|
|
64
|
+
catalogEntityRefs,
|
|
65
|
+
catalogEntities.value
|
|
66
|
+
]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
fetchCatalogEntities();
|
|
69
|
+
fetchBazaarProjects();
|
|
70
|
+
}, [fetchBazaarProjects, fetchCatalogEntities]);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
const unlinkedCEntities = getUnlinkedCatalogEntities(
|
|
73
|
+
bazaarProjects.value || [],
|
|
74
|
+
catalogEntities.value || []
|
|
75
|
+
);
|
|
76
|
+
if (unlinkedCEntities) {
|
|
77
|
+
setUnlinkedCatalogEntities(unlinkedCEntities);
|
|
78
|
+
}
|
|
79
|
+
}, [bazaarProjects, catalogEntities]);
|
|
80
|
+
if (catalogEntities.error) {
|
|
81
|
+
return /* @__PURE__ */ React.createElement(ErrorPanel, { error: catalogEntities.error });
|
|
82
|
+
}
|
|
83
|
+
if (bazaarProjects.error) {
|
|
84
|
+
return /* @__PURE__ */ React.createElement(ErrorPanel, { error: bazaarProjects.error });
|
|
85
|
+
}
|
|
86
|
+
return /* @__PURE__ */ React.createElement(
|
|
87
|
+
InfoCard,
|
|
88
|
+
{
|
|
89
|
+
title: title ?? defaultTitle,
|
|
90
|
+
action: /* @__PURE__ */ React.createElement(IconButton, null, /* @__PURE__ */ React.createElement(Link, { to: bazaarLink.link, title: bazaarLink.title }, /* @__PURE__ */ React.createElement(StorefrontIcon, null)))
|
|
91
|
+
},
|
|
92
|
+
/* @__PURE__ */ React.createElement(
|
|
93
|
+
ProjectPreview,
|
|
94
|
+
{
|
|
95
|
+
bazaarProjects: bazaarProjects.value || [],
|
|
96
|
+
fetchBazaarProjects,
|
|
97
|
+
catalogEntities: unlinkedCatalogEntities || [],
|
|
98
|
+
useTablePagination: false,
|
|
99
|
+
gridSize: fullWidth ? 2 : 4,
|
|
100
|
+
height: fullHeight ? "large" : "small"
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export { BazaarOverviewCard };
|
|
107
|
+
//# sourceMappingURL=BazaarOverviewCard.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BazaarOverviewCard.esm.js","sources":["../../../src/components/BazaarOverviewCard/BazaarOverviewCard.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 React, { useEffect, useState } from 'react';\nimport { ProjectPreview } from '../ProjectPreview/ProjectPreview';\nimport useAsyncFn from 'react-use/esm/useAsyncFn';\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\nimport { useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport type { BazaarProject } from '../../types';\nimport { bazaarApiRef } from '../../api';\nimport { fetchCatalogItems } from '../../util/fetchMethods';\nimport { parseBazaarProject } from '../../util/parseMethods';\nimport { ErrorPanel, InfoCard, Link } from '@backstage/core-components';\nimport { bazaarPlugin } from '../../plugin';\nimport IconButton from '@material-ui/core/IconButton';\nimport StorefrontIcon from '@material-ui/icons/Storefront';\n\n/** @public */\nexport type BazaarOverviewCardProps = {\n title?: string;\n order: 'latest' | 'random';\n fullWidth?: boolean;\n fullHeight?: boolean;\n};\n\nconst getUnlinkedCatalogEntities = (\n bazaarProjects: BazaarProject[],\n catalogEntities: Entity[],\n) => {\n const bazaarProjectRefs = bazaarProjects.map(\n (project: BazaarProject) => project.entityRef,\n );\n\n return catalogEntities.filter((entity: Entity) => {\n return !bazaarProjectRefs?.includes(stringifyEntityRef(entity));\n });\n};\n\n/** @public */\nexport const BazaarOverviewCard = (props: BazaarOverviewCardProps) => {\n const { title, order, fullWidth = false, fullHeight = false } = props;\n const bazaarApi = useApi(bazaarApiRef);\n const catalogApi = useApi(catalogApiRef);\n const root = useRouteRef(bazaarPlugin.routes.root);\n\n const defaultTitle =\n order === 'latest' ? 'Bazaar Latest Projects' : 'Bazaar Random Projects';\n\n const bazaarLink = {\n title: 'Go to Bazaar',\n link: `${root()}`,\n };\n\n const [unlinkedCatalogEntities, setUnlinkedCatalogEntities] =\n useState<Entity[]>();\n\n const [catalogEntities, fetchCatalogEntities] = useAsyncFn(async () => {\n return await fetchCatalogItems(catalogApi);\n });\n\n const [bazaarProjects, fetchBazaarProjects] = useAsyncFn(async () => {\n const limit = fullWidth ? 6 : 3;\n const response = await bazaarApi.getProjects(limit, order);\n return response.data.map(parseBazaarProject) as BazaarProject[];\n });\n\n const catalogEntityRefs = catalogEntities.value?.map((project: Entity) =>\n stringifyEntityRef(project),\n );\n\n useEffect(() => {\n const filterBrokenLinks = () => {\n if (catalogEntityRefs) {\n bazaarProjects.value?.forEach(async (project: BazaarProject) => {\n if (project.entityRef) {\n if (!catalogEntityRefs?.includes(project.entityRef)) {\n await bazaarApi.updateProject({\n ...project,\n entityRef: null,\n });\n }\n }\n });\n }\n };\n filterBrokenLinks();\n }, [\n bazaarApi,\n bazaarProjects.value,\n catalogEntityRefs,\n catalogEntities.value,\n ]);\n\n useEffect(() => {\n fetchCatalogEntities();\n fetchBazaarProjects();\n }, [fetchBazaarProjects, fetchCatalogEntities]);\n\n useEffect(() => {\n const unlinkedCEntities = getUnlinkedCatalogEntities(\n bazaarProjects.value || [],\n catalogEntities.value || [],\n );\n\n if (unlinkedCEntities) {\n setUnlinkedCatalogEntities(unlinkedCEntities);\n }\n }, [bazaarProjects, catalogEntities]);\n\n if (catalogEntities.error) {\n return <ErrorPanel error={catalogEntities.error} />;\n }\n\n if (bazaarProjects.error) {\n return <ErrorPanel error={bazaarProjects.error} />;\n }\n\n return (\n <InfoCard\n title={title ?? defaultTitle}\n action={\n <IconButton>\n <Link to={bazaarLink.link} title={bazaarLink.title}>\n <StorefrontIcon />\n </Link>\n </IconButton>\n }\n >\n <ProjectPreview\n bazaarProjects={bazaarProjects.value || []}\n fetchBazaarProjects={fetchBazaarProjects}\n catalogEntities={unlinkedCatalogEntities || []}\n useTablePagination={false}\n gridSize={fullWidth ? 2 : 4}\n height={fullHeight ? 'large' : 'small'}\n />\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAuCA,MAAM,0BAAA,GAA6B,CACjC,cAAA,EACA,eACG,KAAA;AACH,EAAA,MAAM,oBAAoB,cAAe,CAAA,GAAA;AAAA,IACvC,CAAC,YAA2B,OAAQ,CAAA,SAAA;AAAA,GACtC,CAAA;AAEA,EAAO,OAAA,eAAA,CAAgB,MAAO,CAAA,CAAC,MAAmB,KAAA;AAChD,IAAA,OAAO,CAAC,iBAAA,EAAmB,QAAS,CAAA,kBAAA,CAAmB,MAAM,CAAC,CAAA,CAAA;AAAA,GAC/D,CAAA,CAAA;AACH,CAAA,CAAA;AAGa,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AACpE,EAAA,MAAM,EAAE,KAAO,EAAA,KAAA,EAAO,YAAY,KAAO,EAAA,UAAA,GAAa,OAAU,GAAA,KAAA,CAAA;AAChE,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA,CAAA;AACrC,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AACvC,EAAA,MAAM,IAAO,GAAA,WAAA,CAAY,YAAa,CAAA,MAAA,CAAO,IAAI,CAAA,CAAA;AAEjD,EAAM,MAAA,YAAA,GACJ,KAAU,KAAA,QAAA,GAAW,wBAA2B,GAAA,wBAAA,CAAA;AAElD,EAAA,MAAM,UAAa,GAAA;AAAA,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W,CAAA,KAAA,EAAA,kBAC1C,KAAA,CAAA,aAAA,CAAA,cAAA,EAAA,IAAe,CAClB,CACF,CAAA;AAAA,KAAA;AAAA,oBAGF,KAAA,CAAA,aAAA;AAAA,MAAC,cAAA;AAAA,MAAA;AAAA,QACC,cAAA,EAAgB,cAAe,CAAA,KAAA,IAAS,EAAC;AAAA,QACzC,mBAAA;AAAA,QACA,eAAA,EAAiB,2BAA2B,EAAC;AAAA,QAC7C,kBAAoB,EAAA,KAAA;AAAA,QACpB,QAAA,EAAU,YAAY,CAAI,GAAA,CAAA;AAAA,QAC1B,MAAA,EAAQ,aAAa,OAAU,GAAA,OAAA;AAAA,OAAA;AAAA,KACjC;AAAA,GACF,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useElementFilter } from '@backstage/core-plugin-api';
|
|
2
|
+
import Grid from '@material-ui/core/Grid';
|
|
3
|
+
import Typography from '@material-ui/core/Typography';
|
|
4
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
const useStyles = makeStyles((theme) => ({
|
|
8
|
+
value: {
|
|
9
|
+
fontWeight: "bold",
|
|
10
|
+
overflow: "hidden",
|
|
11
|
+
lineHeight: "24px",
|
|
12
|
+
wordBreak: "break-word"
|
|
13
|
+
},
|
|
14
|
+
label: {
|
|
15
|
+
color: theme.palette.text.secondary,
|
|
16
|
+
textTransform: "uppercase",
|
|
17
|
+
fontSize: "10px",
|
|
18
|
+
fontWeight: "bold",
|
|
19
|
+
letterSpacing: 0.5,
|
|
20
|
+
overflow: "hidden",
|
|
21
|
+
whiteSpace: "nowrap"
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
function AboutField(props) {
|
|
25
|
+
const { label, value, gridSizes, children } = props;
|
|
26
|
+
const classes = useStyles();
|
|
27
|
+
const childElements = useElementFilter(children, (c) => c.getElements());
|
|
28
|
+
const content = childElements.length > 0 ? childElements : /* @__PURE__ */ React.createElement(Typography, { variant: "body2", className: classes.value }, value || `unknown`);
|
|
29
|
+
return /* @__PURE__ */ React.createElement(Grid, { item: true, ...gridSizes }, /* @__PURE__ */ React.createElement(Typography, { variant: "h2", className: classes.label }, label), content);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { AboutField };
|
|
33
|
+
//# sourceMappingURL=AboutField.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AboutField.esm.js","sources":["../../../src/components/CardContentFields/AboutField.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { useElementFilter } from '@backstage/core-plugin-api';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport React from 'react';\n\nconst useStyles = makeStyles(theme => ({\n value: {\n fontWeight: 'bold',\n overflow: 'hidden',\n lineHeight: '24px',\n wordBreak: 'break-word',\n },\n label: {\n color: theme.palette.text.secondary,\n textTransform: 'uppercase',\n fontSize: '10px',\n fontWeight: 'bold',\n letterSpacing: 0.5,\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n },\n}));\n\n/**\n * Props for {@link AboutField}.\n */\nexport interface AboutFieldProps {\n label: string;\n value?: string;\n gridSizes?: Record<string, number>;\n children?: React.ReactNode;\n}\n\nexport function AboutField(props: AboutFieldProps) {\n const { label, value, gridSizes, children } = props;\n const classes = useStyles();\n\n const childElements = useElementFilter(children, c => c.getElements());\n\n // Content is either children or a string prop `value`\n const content =\n childElements.length > 0 ? (\n childElements\n ) : (\n <Typography variant=\"body2\" className={classes.value}>\n {value || `unknown`}\n </Typography>\n );\n return (\n <Grid item {...gridSizes}>\n <Typography variant=\"h2\" className={classes.label}>\n {label}\n </Typography>\n {content}\n </Grid>\n );\n}\n"],"names":[],"mappings":";;;;;;AAsBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,KAAO,EAAA;AAAA,IACL,UAAY,EAAA,MAAA;AAAA,IACZ,QAAU,EAAA,QAAA;AAAA,IACV,UAAY,EAAA,MAAA;AAAA,IACZ,SAAW,EAAA,YAAA;AAAA,GACb;AAAA,EACA,KAAO,EAAA;AAAA,IACL,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,SAAA;AAAA,IAC1B,aAAe,EAAA,WAAA;AAAA,IACf,QAAU,EAAA,MAAA;AAAA,IACV,UAAY,EAAA,MAAA;AAAA,IACZ,aAAe,EAAA,GAAA;AAAA,IACf,QAAU,EAAA,QAAA;AAAA,IACV,UAAY,EAAA,QAAA;AAAA,GACd;AACF,CAAE,CAAA,CAAA,CAAA;AAYK,SAAS,WAAW,KAAwB,EAAA;AACjD,EAAA,MAAM,EAAE,KAAA,EAAO,KAAO,EAAA,SAAA,EAAW,UAAa,GAAA,KAAA,CAAA;AAC9C,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAE1B,EAAA,MAAM,gBAAgB,gBAAiB,CAAA,QAAA,EAAU,CAAK,CAAA,KAAA,CAAA,CAAE,aAAa,CAAA,CAAA;AAGrE,EAAA,MAAM,OACJ,GAAA,aAAA,CAAc,MAAS,GAAA,CAAA,GACrB,aAEA,mBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,OAAQ,EAAA,SAAA,EAAW,OAAQ,CAAA,KAAA,EAAA,EAC5C,SAAS,CACZ,OAAA,CAAA,CAAA,CAAA;AAEJ,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,IAAI,EAAA,IAAA,EAAE,GAAG,SACb,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,MAAK,SAAW,EAAA,OAAA,CAAQ,KACzC,EAAA,EAAA,KACH,GACC,OACH,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Grid from '@material-ui/core/Grid';
|
|
3
|
+
import Card from '@material-ui/core/Card';
|
|
4
|
+
import CardContent from '@material-ui/core/CardContent';
|
|
5
|
+
import Typography from '@material-ui/core/Typography';
|
|
6
|
+
import makeStyles from '@material-ui/core/styles/makeStyles';
|
|
7
|
+
import { parseEntityRef } from '@backstage/catalog-model';
|
|
8
|
+
import { Avatar, Link } from '@backstage/core-components';
|
|
9
|
+
import { useRouteRef } from '@backstage/core-plugin-api';
|
|
10
|
+
import { entityRouteRef } from '@backstage/plugin-catalog-react';
|
|
11
|
+
import { AboutField } from './AboutField.esm.js';
|
|
12
|
+
import { StatusTag } from '../StatusTag/StatusTag.esm.js';
|
|
13
|
+
|
|
14
|
+
const useStyles = makeStyles(
|
|
15
|
+
{
|
|
16
|
+
avatar: {
|
|
17
|
+
width: "19px",
|
|
18
|
+
height: "19px",
|
|
19
|
+
float: "left",
|
|
20
|
+
marginRight: "0.3rem",
|
|
21
|
+
marginTop: "0rem",
|
|
22
|
+
marginBottom: "0rem",
|
|
23
|
+
alignItems: "left"
|
|
24
|
+
},
|
|
25
|
+
avatarText: {
|
|
26
|
+
fontSize: "8px",
|
|
27
|
+
textAlign: "left"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{ name: "CardContentFields" }
|
|
31
|
+
);
|
|
32
|
+
const CardContentFields = ({
|
|
33
|
+
bazaarProject,
|
|
34
|
+
members,
|
|
35
|
+
descriptionSize,
|
|
36
|
+
membersSize
|
|
37
|
+
}) => {
|
|
38
|
+
const catalogEntityRoute = useRouteRef(entityRouteRef);
|
|
39
|
+
const classes = useStyles();
|
|
40
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(Grid, { container: true }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: descriptionSize }, /* @__PURE__ */ React.createElement(AboutField, { label: "Description" }, bazaarProject.description.split("\n").map((str, i) => /* @__PURE__ */ React.createElement(Typography, { key: i, variant: "body2", paragraph: true }, str)))), /* @__PURE__ */ React.createElement(
|
|
41
|
+
Grid,
|
|
42
|
+
{
|
|
43
|
+
style: {
|
|
44
|
+
display: "flex",
|
|
45
|
+
justifyContent: "flex-end"
|
|
46
|
+
},
|
|
47
|
+
item: true,
|
|
48
|
+
xs: membersSize
|
|
49
|
+
},
|
|
50
|
+
/* @__PURE__ */ React.createElement(AboutField, { label: "Latest members" }, members.length ? members.slice(0, 7).map((member) => {
|
|
51
|
+
return /* @__PURE__ */ React.createElement(
|
|
52
|
+
"div",
|
|
53
|
+
{
|
|
54
|
+
style: {
|
|
55
|
+
textAlign: "left",
|
|
56
|
+
backgroundColor: "",
|
|
57
|
+
marginBottom: "0.3rem",
|
|
58
|
+
marginTop: "0.3rem",
|
|
59
|
+
display: "block"
|
|
60
|
+
},
|
|
61
|
+
key: member.userId
|
|
62
|
+
},
|
|
63
|
+
/* @__PURE__ */ React.createElement(
|
|
64
|
+
Avatar,
|
|
65
|
+
{
|
|
66
|
+
displayName: member.userId,
|
|
67
|
+
classes,
|
|
68
|
+
picture: member.picture
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
/* @__PURE__ */ React.createElement(
|
|
72
|
+
Link,
|
|
73
|
+
{
|
|
74
|
+
target: "_blank",
|
|
75
|
+
to: member.userRef ? `${catalogEntityRoute(
|
|
76
|
+
parseEntityRef(member.userRef)
|
|
77
|
+
)}` : `http://github.com/${member.userId}`
|
|
78
|
+
},
|
|
79
|
+
member?.userId
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
}) : /* @__PURE__ */ React.createElement("div", null))
|
|
83
|
+
), /* @__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 || "")))))));
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { CardContentFields };
|
|
87
|
+
//# sourceMappingURL=CardContentFields.esm.js.map
|
|
@@ -0,0 +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};\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}: Props) => {\n const catalogEntityRoute = useRouteRef(entityRouteRef);\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 <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":";;;;;;;;;;;;;AAuCA,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,O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