@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.
Files changed (68) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/api.esm.js +120 -0
  4. package/dist/api.esm.js.map +1 -0
  5. package/dist/{esm/index-CM8Pdxty.esm.js → components/About/About.esm.js} +3 -70
  6. package/dist/components/About/About.esm.js.map +1 -0
  7. package/dist/components/AddProjectDialog/AddProjectDialog.esm.js +76 -0
  8. package/dist/components/AddProjectDialog/AddProjectDialog.esm.js.map +1 -0
  9. package/dist/components/BazaarOverviewCard/BazaarOverviewCard.esm.js +107 -0
  10. package/dist/components/BazaarOverviewCard/BazaarOverviewCard.esm.js.map +1 -0
  11. package/dist/components/CardContentFields/AboutField.esm.js +33 -0
  12. package/dist/components/CardContentFields/AboutField.esm.js.map +1 -0
  13. package/dist/components/CardContentFields/CardContentFields.esm.js +87 -0
  14. package/dist/components/CardContentFields/CardContentFields.esm.js.map +1 -0
  15. package/dist/components/ConfirmationDialog/ConfirmationDialog.esm.js +29 -0
  16. package/dist/components/ConfirmationDialog/ConfirmationDialog.esm.js.map +1 -0
  17. package/dist/components/CustomDialogTitle/CustomDialogTitle.esm.js +49 -0
  18. package/dist/components/CustomDialogTitle/CustomDialogTitle.esm.js.map +1 -0
  19. package/dist/components/DateSelector/DateSelector.esm.js +40 -0
  20. package/dist/components/DateSelector/DateSelector.esm.js.map +1 -0
  21. package/dist/components/DoubleDateSelector/DoubleDateSelector.esm.js +34 -0
  22. package/dist/components/DoubleDateSelector/DoubleDateSelector.esm.js.map +1 -0
  23. package/dist/components/EditProjectDialog/EditProjectDialog.esm.js +115 -0
  24. package/dist/components/EditProjectDialog/EditProjectDialog.esm.js.map +1 -0
  25. package/dist/components/EntityBazaarInfoCard/EntityBazaarInfoCard.esm.js +41 -0
  26. package/dist/components/EntityBazaarInfoCard/EntityBazaarInfoCard.esm.js.map +1 -0
  27. package/dist/components/EntityBazaarInfoContent/EntityBazaarInfoContent.esm.js +177 -0
  28. package/dist/components/EntityBazaarInfoContent/EntityBazaarInfoContent.esm.js.map +1 -0
  29. package/dist/components/HomePage/HomePage.esm.js +30 -0
  30. package/dist/components/HomePage/HomePage.esm.js.map +1 -0
  31. package/dist/components/HomePage/index.esm.js +2 -0
  32. package/dist/components/HomePage/index.esm.js.map +1 -0
  33. package/dist/components/HomePageBazaarInfoCard/HomePageBazaarInfoCard.esm.js +218 -0
  34. package/dist/components/HomePageBazaarInfoCard/HomePageBazaarInfoCard.esm.js.map +1 -0
  35. package/dist/components/InputField/InputField.esm.js +41 -0
  36. package/dist/components/InputField/InputField.esm.js.map +1 -0
  37. package/dist/components/InputSelector/InputSelector.esm.js +47 -0
  38. package/dist/components/InputSelector/InputSelector.esm.js.map +1 -0
  39. package/dist/components/LinkProjectDialog/LinkProjectDialog.esm.js +68 -0
  40. package/dist/components/LinkProjectDialog/LinkProjectDialog.esm.js.map +1 -0
  41. package/dist/components/ProjectCard/ProjectCard.esm.js +70 -0
  42. package/dist/components/ProjectCard/ProjectCard.esm.js.map +1 -0
  43. package/dist/components/ProjectDialog/ProjectDialog.esm.js +143 -0
  44. package/dist/components/ProjectDialog/ProjectDialog.esm.js.map +1 -0
  45. package/dist/components/ProjectPreview/ProjectPreview.esm.js +79 -0
  46. package/dist/components/ProjectPreview/ProjectPreview.esm.js.map +1 -0
  47. package/dist/components/ProjectSelector/ProjectSelector.esm.js +38 -0
  48. package/dist/components/ProjectSelector/ProjectSelector.esm.js.map +1 -0
  49. package/dist/components/SortMethodSelector/SortMethodSelector.esm.js +35 -0
  50. package/dist/components/SortMethodSelector/SortMethodSelector.esm.js.map +1 -0
  51. package/dist/components/SortView/SortView.esm.js +176 -0
  52. package/dist/components/SortView/SortView.esm.js.map +1 -0
  53. package/dist/components/StatusTag/StatusTag.esm.js +13 -0
  54. package/dist/components/StatusTag/StatusTag.esm.js.map +1 -0
  55. package/dist/index.esm.js +5 -1749
  56. package/dist/index.esm.js.map +1 -1
  57. package/dist/plugin.esm.js +31 -0
  58. package/dist/plugin.esm.js.map +1 -0
  59. package/dist/routes.esm.js +8 -0
  60. package/dist/routes.esm.js.map +1 -0
  61. package/dist/util/fetchMethods.esm.js +26 -0
  62. package/dist/util/fetchMethods.esm.js.map +1 -0
  63. package/dist/util/parseMethods.esm.js +38 -0
  64. package/dist/util/parseMethods.esm.js.map +1 -0
  65. package/dist/util/sortMethods.esm.js +20 -0
  66. package/dist/util/sortMethods.esm.js.map +1 -0
  67. package/package.json +14 -9
  68. package/dist/esm/index-CM8Pdxty.esm.js.map +0 -1
package/dist/index.esm.js CHANGED
@@ -1,1750 +1,6 @@
1
- import { createRouteRef, createApiRef, createPlugin, createApiFactory, identityApiRef, discoveryApiRef, fetchApiRef, createRoutableExtension, useApi, alertApiRef, useElementFilter, useRouteRef } from '@backstage/core-plugin-api';
2
- import { stringifyEntityRef, parseEntityRef } from '@backstage/catalog-model';
3
- import { ResponseError } from '@backstage/errors';
4
- import React, { useState, useEffect } from 'react';
5
- import { StatusWarning, StatusOK, Avatar, Link, HeaderIconLinkRow, ItemCardHeader, ErrorPanel, InfoCard, Content, SupportButton } from '@backstage/core-components';
6
- import Card from '@material-ui/core/Card';
7
- import CardActionArea from '@material-ui/core/CardActionArea';
8
- import CardContent from '@material-ui/core/CardContent';
9
- import Dialog from '@material-ui/core/Dialog';
10
- import Typography from '@material-ui/core/Typography';
11
- import { makeStyles, withStyles, createStyles } from '@material-ui/core/styles';
12
- import { DateTime } from 'luxon';
13
- import CardHeader from '@material-ui/core/CardHeader';
14
- import Divider from '@material-ui/core/Divider';
15
- import IconButton from '@material-ui/core/IconButton';
16
- import EditIcon from '@material-ui/icons/Edit';
17
- import ChatIcon from '@material-ui/icons/Chat';
18
- import PersonAddIcon from '@material-ui/icons/PersonAdd';
19
- import InsertLinkIcon from '@material-ui/icons/InsertLink';
20
- import DashboardIcon from '@material-ui/icons/Dashboard';
21
- import CloseIcon from '@material-ui/icons/Close';
22
- import LinkOffIcon from '@material-ui/icons/LinkOff';
23
- import Description from '@material-ui/icons/Description';
24
- import Button from '@material-ui/core/Button';
25
- import { Controller, useForm } from 'react-hook-form';
26
- import TextField from '@material-ui/core/TextField';
27
- import InputLabel from '@material-ui/core/InputLabel';
28
- import MenuItem from '@material-ui/core/MenuItem';
29
- import FormControl from '@material-ui/core/FormControl';
30
- import Select from '@material-ui/core/Select';
31
- import { KeyboardDatePicker } from '@material-ui/pickers/DatePicker';
32
- import MuiPickersUtilsProvider from '@material-ui/pickers/MuiPickersUtilsProvider';
33
- import LuxonUtils from '@date-io/luxon';
34
- import ClearIcon from '@material-ui/icons/Clear';
35
- import MuiDialogTitle from '@material-ui/core/DialogTitle';
36
- import MuiDialogContent from '@material-ui/core/DialogContent';
37
- import MuiDialogActions from '@material-ui/core/DialogActions';
38
- import ExitToAppIcon from '@material-ui/icons/ExitToApp';
39
- import Alert from '@material-ui/lab/Alert';
40
- import useAsyncFn from 'react-use/esm/useAsyncFn';
41
- import { entityRouteRef, catalogApiRef, useEntity } from '@backstage/plugin-catalog-react';
42
- import Grid from '@material-ui/core/Grid';
43
- import makeStyles$1 from '@material-ui/core/styles/makeStyles';
44
- import Autocomplete from '@material-ui/lab/Autocomplete';
45
- import Box from '@material-ui/core/Box';
46
- import TablePagination from '@material-ui/core/TablePagination';
47
- import StorefrontIcon from '@material-ui/icons/Storefront';
48
- import SearchBar from 'material-ui-search-bar';
49
-
50
- const rootRouteRef = createRouteRef({
51
- id: "bazaar"
52
- });
53
-
54
- var __defProp = Object.defineProperty;
55
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
56
- var __publicField = (obj, key, value) => {
57
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
58
- return value;
59
- };
60
- const bazaarApiRef = createApiRef({
61
- id: "bazaar"
62
- });
63
- const isBazaarAvailable = async (entity, context) => {
64
- const bazaarClient = context.apis.get(bazaarApiRef);
65
- if (bazaarClient === void 0) {
66
- return false;
67
- }
68
- const entityRef = stringifyEntityRef({
69
- kind: entity.kind,
70
- name: entity.metadata.name,
71
- namespace: entity.metadata.namespace
72
- });
73
- const response = await bazaarClient.getProjectByRef(entityRef);
74
- const project = await response.json();
75
- return project.data.length > 0;
76
- };
77
- class BazaarClient {
78
- constructor(options) {
79
- __publicField(this, "identityApi");
80
- __publicField(this, "discoveryApi");
81
- __publicField(this, "fetchApi");
82
- this.identityApi = options.identityApi;
83
- this.discoveryApi = options.discoveryApi;
84
- this.fetchApi = options.fetchApi;
85
- }
86
- async updateProject(bazaarProject) {
87
- const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
88
- return await this.fetchApi.fetch(`${baseUrl}/projects`, {
89
- method: "PUT",
90
- headers: {
91
- Accept: "application/json",
92
- "Content-Type": "application/json"
93
- },
94
- body: JSON.stringify(bazaarProject)
95
- }).then((resp) => resp.json());
96
- }
97
- async addProject(bazaarProject) {
98
- const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
99
- return await this.fetchApi.fetch(`${baseUrl}/projects`, {
100
- method: "POST",
101
- headers: {
102
- Accept: "application/json",
103
- "Content-Type": "application/json"
104
- },
105
- body: JSON.stringify(bazaarProject)
106
- }).then((resp) => resp.json());
107
- }
108
- async getProjectById(id) {
109
- const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
110
- const response = await this.fetchApi.fetch(
111
- `${baseUrl}/projects/${encodeURIComponent(id)}`
112
- );
113
- return response.ok ? response : null;
114
- }
115
- async getProjectByRef(entityRef) {
116
- const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
117
- const response = await this.fetchApi.fetch(
118
- `${baseUrl}/projects/${encodeURIComponent(entityRef)}`
119
- );
120
- return response.ok ? response : null;
121
- }
122
- async getMembers(id) {
123
- const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
124
- return await this.fetchApi.fetch(`${baseUrl}/projects/${encodeURIComponent(id)}/members`).then((resp) => resp.json());
125
- }
126
- async addMember(id, userId) {
127
- const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
128
- const { picture } = await this.identityApi.getProfileInfo();
129
- await this.fetchApi.fetch(
130
- `${baseUrl}/projects/${encodeURIComponent(
131
- id
132
- )}/member/${encodeURIComponent(userId)}`,
133
- {
134
- method: "PUT",
135
- headers: {
136
- Accept: "application/json",
137
- "Content-Type": "application/json"
138
- },
139
- body: JSON.stringify({ picture })
140
- }
141
- );
142
- }
143
- async deleteMember(id, userId) {
144
- const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
145
- await this.fetchApi.fetch(
146
- `${baseUrl}/projects/${encodeURIComponent(
147
- id
148
- )}/member/${encodeURIComponent(userId)}`,
149
- { method: "DELETE" }
150
- );
151
- }
152
- async getProjects(limit, order) {
153
- const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
154
- const params = {
155
- ...limit ? { limit: limit.toString() } : {},
156
- ...order ? { order } : {}
157
- };
158
- const query = new URLSearchParams(params);
159
- const url = `projects?${query.toString()}`;
160
- const data = await this.fetchApi.fetch(`${baseUrl}/${url}`);
161
- if (!data.ok) {
162
- throw await ResponseError.fromResponse(data);
163
- }
164
- return data.json();
165
- }
166
- async deleteProject(id) {
167
- const baseUrl = await this.discoveryApi.getBaseUrl("bazaar");
168
- await this.fetchApi.fetch(`${baseUrl}/projects/${encodeURIComponent(id)}`, {
169
- method: "DELETE"
170
- });
171
- }
172
- }
173
-
174
- const bazaarPlugin = createPlugin({
175
- id: "bazaar",
176
- routes: {
177
- root: rootRouteRef
178
- },
179
- apis: [
180
- createApiFactory({
181
- api: bazaarApiRef,
182
- deps: {
183
- identityApi: identityApiRef,
184
- discoveryApi: discoveryApiRef,
185
- fetchApi: fetchApiRef
186
- },
187
- factory: ({ identityApi, discoveryApi, fetchApi }) => new BazaarClient({ identityApi, discoveryApi, fetchApi })
188
- })
189
- ]
190
- });
191
- const BazaarPage = bazaarPlugin.provide(
192
- createRoutableExtension({
193
- name: "BazaarPage",
194
- component: () => import('./esm/index-CM8Pdxty.esm.js').then((m) => m.HomePage),
195
- mountPoint: rootRouteRef
196
- })
197
- );
198
-
199
- const statuses = {
200
- proposed: /* @__PURE__ */ React.createElement(StatusWarning, null, "proposed"),
201
- ongoing: /* @__PURE__ */ React.createElement(StatusOK, null, "ongoing")
202
- };
203
- const StatusTag = ({ status, styles }) => {
204
- return /* @__PURE__ */ React.createElement("div", { className: styles }, statuses[status]);
205
- };
206
-
207
- const InputField = ({
208
- inputType,
209
- error,
210
- control,
211
- helperText,
212
- placeholder,
213
- rules
214
- }) => {
215
- const label = inputType.charAt(0).toLocaleUpperCase("en-US") + inputType.slice(1);
216
- return /* @__PURE__ */ React.createElement(
217
- Controller,
218
- {
219
- name: inputType,
220
- control,
221
- rules,
222
- render: ({ field }) => /* @__PURE__ */ React.createElement(
223
- TextField,
224
- {
225
- ...field,
226
- required: rules == null ? void 0 : rules.required,
227
- margin: "dense",
228
- multiline: true,
229
- id: "title",
230
- type: "text",
231
- fullWidth: true,
232
- label,
233
- placeholder,
234
- error: !!error,
235
- helperText: error && helperText
236
- }
237
- )
238
- }
239
- );
240
- };
241
-
242
- const InputSelector = ({ name, options, control, error }) => {
243
- const label = name.charAt(0).toLocaleUpperCase("en-US") + name.slice(1);
244
- return /* @__PURE__ */ React.createElement(
245
- Controller,
246
- {
247
- name,
248
- control,
249
- rules: {
250
- required: true
251
- },
252
- render: ({ field }) => /* @__PURE__ */ React.createElement(FormControl, { fullWidth: true }, /* @__PURE__ */ React.createElement(
253
- InputLabel,
254
- {
255
- required: true,
256
- htmlFor: "demo-simple-select-outlined",
257
- id: "demo-simple-select-outlined-label",
258
- style: {
259
- marginTop: "0.25rem"
260
- }
261
- },
262
- label
263
- ), /* @__PURE__ */ React.createElement(
264
- Select,
265
- {
266
- ...field,
267
- labelId: "demo-simple-select-outlined-label",
268
- id: "demo-simple-select-outlined",
269
- label,
270
- error: !!error
271
- },
272
- options.map((option) => {
273
- return /* @__PURE__ */ React.createElement(MenuItem, { key: option, value: option }, option);
274
- })
275
- ))
276
- }
277
- );
278
- };
279
-
280
- const DateSelector = ({ name, control, setValue }) => {
281
- const label = `${name.charAt(0).toLocaleUpperCase("en-US") + name.slice(1, name.indexOf("D"))} date`;
282
- return /* @__PURE__ */ React.createElement(
283
- Controller,
284
- {
285
- name,
286
- control,
287
- render: ({ field }) => /* @__PURE__ */ React.createElement(FormControl, null, /* @__PURE__ */ React.createElement(MuiPickersUtilsProvider, { utils: LuxonUtils }, /* @__PURE__ */ React.createElement(
288
- KeyboardDatePicker,
289
- {
290
- disableToolbar: true,
291
- format: "dd-MM-yyyy",
292
- label,
293
- value: field.value,
294
- onChange: (date) => {
295
- setValue(name, date == null ? void 0 : date.toISO());
296
- },
297
- InputProps: {
298
- endAdornment: /* @__PURE__ */ React.createElement(IconButton, { onClick: () => setValue(name, null) }, /* @__PURE__ */ React.createElement(ClearIcon, null))
299
- },
300
- InputAdornmentProps: {
301
- position: "start"
302
- }
303
- }
304
- )))
305
- }
306
- );
307
- };
308
-
309
- const useStyles$b = makeStyles({
310
- container: {
311
- marginTop: "0.25rem",
312
- textAlign: "center",
313
- display: "flex",
314
- flexDirection: "row",
315
- justifyContent: "space-between"
316
- },
317
- startDate: {
318
- float: "left"
319
- },
320
- endDate: {
321
- float: "right"
322
- },
323
- dash: {
324
- display: "flex",
325
- justifyContent: "center",
326
- alignItems: "center",
327
- fontSize: "1.5rem",
328
- margin: "0 1rem"
329
- }
330
- });
331
- const DoubleDateSelector = ({ control, setValue }) => {
332
- const classes = useStyles$b();
333
- return /* @__PURE__ */ React.createElement("div", { className: classes.container }, /* @__PURE__ */ React.createElement("div", { className: classes.startDate }, /* @__PURE__ */ React.createElement(DateSelector, { name: "startDate", control, setValue })), /* @__PURE__ */ React.createElement(Typography, { className: classes.dash }, "-"), /* @__PURE__ */ React.createElement("div", { className: classes.endDate }, /* @__PURE__ */ React.createElement(DateSelector, { name: "endDate", control, setValue })));
334
- };
335
-
336
- const styles = (theme) => createStyles({
337
- root: {
338
- margin: 0,
339
- padding: theme.spacing(2)
340
- },
341
- closeButton: {
342
- position: "absolute",
343
- right: theme.spacing(1),
344
- top: theme.spacing(1),
345
- color: theme.palette.grey[500]
346
- }
347
- });
348
- const DialogContent = withStyles((theme) => ({
349
- root: {
350
- padding: theme.spacing(2)
351
- }
352
- }))(MuiDialogContent);
353
- const DialogActions = withStyles((theme) => ({
354
- root: {
355
- margin: 0,
356
- padding: theme.spacing(1)
357
- }
358
- }))(MuiDialogActions);
359
- const CustomDialogTitle = withStyles(styles)(
360
- (props) => {
361
- const { children, classes, onClose, ...other } = props;
362
- return /* @__PURE__ */ React.createElement(MuiDialogTitle, { disableTypography: true, className: classes.root, ...other }, /* @__PURE__ */ React.createElement(Typography, { variant: "h6" }, children), onClose ? /* @__PURE__ */ React.createElement(
363
- IconButton,
364
- {
365
- "aria-label": "close",
366
- className: classes.closeButton,
367
- onClick: onClose
368
- },
369
- /* @__PURE__ */ React.createElement(CloseIcon, null)
370
- ) : null);
371
- }
372
- );
373
-
374
- const ProjectDialog = ({
375
- handleSave,
376
- isAddForm,
377
- title,
378
- defaultValues,
379
- open,
380
- projectSelector,
381
- deleteButton,
382
- handleClose
383
- }) => {
384
- const {
385
- handleSubmit,
386
- reset,
387
- control,
388
- getValues,
389
- formState: { errors },
390
- setValue
391
- } = useForm({
392
- mode: "onChange",
393
- defaultValues
394
- });
395
- const handleSaveForm = () => {
396
- handleSave(getValues, reset);
397
- };
398
- const handleCloseDialog = () => {
399
- handleClose();
400
- reset(defaultValues);
401
- };
402
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
403
- Dialog,
404
- {
405
- fullWidth: true,
406
- maxWidth: "xs",
407
- onClose: handleCloseDialog,
408
- "aria-labelledby": "customized-dialog-title",
409
- open
410
- },
411
- /* @__PURE__ */ React.createElement(
412
- CustomDialogTitle,
413
- {
414
- id: "customized-dialog-title",
415
- onClose: handleCloseDialog
416
- },
417
- title
418
- ),
419
- /* @__PURE__ */ React.createElement(DialogContent, { style: { padding: "1rem", paddingTop: "0rem" }, dividers: true }, /* @__PURE__ */ React.createElement(
420
- InputField,
421
- {
422
- error: errors.title,
423
- control,
424
- rules: {
425
- required: true
426
- },
427
- inputType: "title",
428
- helperText: "Please enter a title for your project"
429
- }
430
- ), /* @__PURE__ */ React.createElement(
431
- InputField,
432
- {
433
- error: errors.description,
434
- control,
435
- rules: {
436
- required: true
437
- },
438
- inputType: "description",
439
- helperText: "Please enter a description"
440
- }
441
- ), /* @__PURE__ */ React.createElement(
442
- InputSelector,
443
- {
444
- control,
445
- name: "status",
446
- options: ["proposed", "ongoing"]
447
- }
448
- ), /* @__PURE__ */ React.createElement(
449
- InputSelector,
450
- {
451
- control,
452
- name: "size",
453
- options: ["small", "medium", "large"]
454
- }
455
- ), /* @__PURE__ */ React.createElement(
456
- InputField,
457
- {
458
- error: errors.responsible,
459
- control,
460
- rules: {
461
- required: true
462
- },
463
- inputType: "responsible",
464
- helperText: "Please enter a contact person",
465
- placeholder: "Contact person of the project"
466
- }
467
- ), isAddForm && projectSelector, /* @__PURE__ */ React.createElement(
468
- InputField,
469
- {
470
- error: errors.community,
471
- control,
472
- rules: {
473
- required: false,
474
- pattern: RegExp("^(https?)://")
475
- },
476
- inputType: "community",
477
- helperText: "Please enter a link starting with http/https",
478
- placeholder: "Community link to e.g. Teams or Discord"
479
- }
480
- ), /* @__PURE__ */ React.createElement(
481
- InputField,
482
- {
483
- error: errors.docs,
484
- control,
485
- rules: {
486
- required: false,
487
- pattern: RegExp("^(https?)://")
488
- },
489
- inputType: "docs",
490
- helperText: "Please enter a link starting with http/https",
491
- placeholder: "Project docs link"
492
- }
493
- ), /* @__PURE__ */ React.createElement(DoubleDateSelector, { setValue, control })),
494
- /* @__PURE__ */ React.createElement(DialogActions, null, !isAddForm && deleteButton, /* @__PURE__ */ React.createElement(
495
- Button,
496
- {
497
- onClick: handleSubmit(handleSaveForm),
498
- color: "primary",
499
- type: "submit"
500
- },
501
- "Submit"
502
- ))
503
- ));
504
- };
505
-
506
- const ConfirmationDialog = ({
507
- open,
508
- handleClose,
509
- message,
510
- type,
511
- handleSubmit
512
- }) => {
513
- return /* @__PURE__ */ React.createElement(
514
- Dialog,
515
- {
516
- fullWidth: true,
517
- maxWidth: "xs",
518
- onClose: handleClose,
519
- "aria-labelledby": "customized-dialog-title",
520
- open
521
- },
522
- /* @__PURE__ */ React.createElement(CustomDialogTitle, { id: "customized-dialog-title", onClose: handleClose }, type.charAt(0).toLocaleUpperCase("en-US") + type.slice(1), " project"),
523
- /* @__PURE__ */ React.createElement(DialogContent, { dividers: true }, message),
524
- /* @__PURE__ */ React.createElement(DialogActions, null, /* @__PURE__ */ React.createElement(Button, { onClick: handleSubmit, color: "primary", type: "submit" }, type))
525
- );
526
- };
527
-
528
- const useStyles$a = makeStyles({
529
- button: {
530
- marginLeft: "0",
531
- marginRight: "auto"
532
- },
533
- wordBreak: {
534
- wordBreak: "break-all",
535
- whiteSpace: "normal",
536
- margin: "-0.25rem 0"
537
- }
538
- });
539
- const EditProjectDialog = ({
540
- bazaarProject,
541
- openEdit,
542
- handleEditClose,
543
- handleCardClose,
544
- fetchBazaarProject
545
- }) => {
546
- var _a, _b;
547
- const classes = useStyles$a();
548
- const bazaarApi = useApi(bazaarApiRef);
549
- const alertApi = useApi(alertApiRef);
550
- const [openDelete, setOpenDelete] = useState(false);
551
- const [defaultValues, setDefaultValues] = useState({
552
- ...bazaarProject,
553
- startDate: (_a = bazaarProject.startDate) != null ? _a : null,
554
- endDate: (_b = bazaarProject.endDate) != null ? _b : null
555
- });
556
- const handleDeleteClose = () => {
557
- setOpenDelete(false);
558
- handleEditClose();
559
- if (handleCardClose)
560
- handleCardClose();
561
- };
562
- const handleDeleteSubmit = async () => {
563
- await bazaarApi.deleteProject(bazaarProject.id);
564
- handleDeleteClose();
565
- fetchBazaarProject();
566
- alertApi.post({
567
- message: `Deleted project '${bazaarProject.title}' from the Bazaar list`,
568
- severity: "success",
569
- display: "transient"
570
- });
571
- };
572
- useEffect(() => {
573
- var _a2, _b2;
574
- setDefaultValues({
575
- ...bazaarProject,
576
- startDate: (_a2 = bazaarProject.startDate) != null ? _a2 : null,
577
- endDate: (_b2 = bazaarProject.endDate) != null ? _b2 : null
578
- });
579
- }, [bazaarProject]);
580
- const handleEditSubmit = async (getValues) => {
581
- var _a2, _b2;
582
- const formValues = getValues();
583
- const updateResponse = await bazaarApi.updateProject({
584
- ...formValues,
585
- id: bazaarProject.id,
586
- entityRef: bazaarProject.entityRef,
587
- membersCount: bazaarProject.membersCount,
588
- startDate: (_a2 = formValues == null ? void 0 : formValues.startDate) != null ? _a2 : null,
589
- endDate: (_b2 = formValues == null ? void 0 : formValues.endDate) != null ? _b2 : null
590
- });
591
- if (updateResponse.status === "ok")
592
- fetchBazaarProject();
593
- handleEditClose();
594
- alertApi.post({
595
- message: `Updated project '${formValues.title}' in the Bazaar list`,
596
- severity: "success",
597
- display: "transient"
598
- });
599
- };
600
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
601
- ConfirmationDialog,
602
- {
603
- open: openDelete,
604
- handleClose: handleDeleteClose,
605
- message: [
606
- "Are you sure you want to delete ",
607
- /* @__PURE__ */ React.createElement("b", { key: bazaarProject.id, className: classes.wordBreak }, bazaarProject.title),
608
- " from the Bazaar?"
609
- ],
610
- type: "delete",
611
- handleSubmit: handleDeleteSubmit
612
- }
613
- ), /* @__PURE__ */ React.createElement(
614
- ProjectDialog,
615
- {
616
- title: "Edit project",
617
- handleSave: handleEditSubmit,
618
- isAddForm: false,
619
- defaultValues,
620
- open: openEdit,
621
- handleClose: handleEditClose,
622
- deleteButton: /* @__PURE__ */ React.createElement(
623
- Button,
624
- {
625
- color: "primary",
626
- type: "submit",
627
- className: classes.button,
628
- onClick: () => {
629
- setOpenDelete(true);
630
- }
631
- },
632
- "Delete project"
633
- )
634
- }
635
- ));
636
- };
637
-
638
- const useStyles$9 = makeStyles((theme) => ({
639
- value: {
640
- fontWeight: "bold",
641
- overflow: "hidden",
642
- lineHeight: "24px",
643
- wordBreak: "break-word"
644
- },
645
- label: {
646
- color: theme.palette.text.secondary,
647
- textTransform: "uppercase",
648
- fontSize: "10px",
649
- fontWeight: "bold",
650
- letterSpacing: 0.5,
651
- overflow: "hidden",
652
- whiteSpace: "nowrap"
653
- }
654
- }));
655
- function AboutField(props) {
656
- const { label, value, gridSizes, children } = props;
657
- const classes = useStyles$9();
658
- const childElements = useElementFilter(children, (c) => c.getElements());
659
- const content = childElements.length > 0 ? childElements : /* @__PURE__ */ React.createElement(Typography, { variant: "body2", className: classes.value }, value || `unknown`);
660
- return /* @__PURE__ */ React.createElement(Grid, { item: true, ...gridSizes }, /* @__PURE__ */ React.createElement(Typography, { variant: "h2", className: classes.label }, label), content);
661
- }
662
-
663
- const useStyles$8 = makeStyles$1(
664
- {
665
- avatar: {
666
- width: "19px",
667
- height: "19px",
668
- float: "left",
669
- marginRight: "0.3rem",
670
- marginTop: "0rem",
671
- marginBottom: "0rem",
672
- alignItems: "left"
673
- },
674
- avatarText: {
675
- fontSize: "8px",
676
- textAlign: "left"
677
- }
678
- },
679
- { name: "CardContentFields" }
680
- );
681
- const CardContentFields = ({
682
- bazaarProject,
683
- members,
684
- descriptionSize,
685
- membersSize
686
- }) => {
687
- var _a, _b;
688
- const catalogEntityRoute = useRouteRef(entityRouteRef);
689
- const classes = useStyles$8();
690
- 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(
691
- Grid,
692
- {
693
- style: {
694
- display: "flex",
695
- justifyContent: "flex-end"
696
- },
697
- item: true,
698
- xs: membersSize
699
- },
700
- /* @__PURE__ */ React.createElement(AboutField, { label: "Latest members" }, members.length ? members.slice(0, 7).map((member) => {
701
- return /* @__PURE__ */ React.createElement(
702
- "div",
703
- {
704
- style: {
705
- textAlign: "left",
706
- backgroundColor: "",
707
- marginBottom: "0.3rem",
708
- marginTop: "0.3rem",
709
- display: "block"
710
- },
711
- key: member.userId
712
- },
713
- /* @__PURE__ */ React.createElement(
714
- Avatar,
715
- {
716
- displayName: member.userId,
717
- classes,
718
- picture: member.picture
719
- }
720
- ),
721
- /* @__PURE__ */ React.createElement(
722
- Link,
723
- {
724
- target: "_blank",
725
- to: member.userRef ? `${catalogEntityRoute(
726
- parseEntityRef(member.userRef)
727
- )}` : `http://github.com/${member.userId}`
728
- },
729
- member == null ? void 0 : member.userId
730
- )
731
- );
732
- }) : /* @__PURE__ */ React.createElement("div", null))
733
- ), /* @__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" }, ((_a = bazaarProject.startDate) == null ? void 0 : _a.substring(0, 10)) || ""))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 2 }, /* @__PURE__ */ React.createElement(AboutField, { label: "End date" }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, ((_b = bazaarProject.endDate) == null ? void 0 : _b.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 || "")))))));
734
- };
735
-
736
- const useStyles$7 = makeStyles({
737
- container: { width: "100%", minWidth: "22rem" },
738
- autocomplete: { overflow: "hidden" }
739
- });
740
- const ProjectSelector = ({
741
- catalogEntities,
742
- onChange,
743
- disableClearable,
744
- defaultValue,
745
- label
746
- }) => {
747
- const classes = useStyles$7();
748
- return /* @__PURE__ */ React.createElement("div", { className: classes.container }, /* @__PURE__ */ React.createElement(
749
- Autocomplete,
750
- {
751
- className: classes.autocomplete,
752
- fullWidth: true,
753
- disableClearable,
754
- defaultValue,
755
- options: catalogEntities,
756
- getOptionLabel: (option) => {
757
- var _a;
758
- return (_a = option == null ? void 0 : option.metadata) == null ? void 0 : _a.name;
759
- },
760
- renderOption: (option) => {
761
- var _a;
762
- return /* @__PURE__ */ React.createElement(Typography, { component: "span" }, (_a = option == null ? void 0 : option.metadata) == null ? void 0 : _a.name);
763
- },
764
- renderInput: (params) => /* @__PURE__ */ React.createElement(TextField, { ...params, label }),
765
- onChange: (_, data) => {
766
- onChange(data);
767
- }
768
- }
769
- ));
770
- };
771
-
772
- const useStyles$6 = makeStyles({
773
- content: { padding: "0 1rem" }
774
- });
775
- const LinkProjectDialog = ({
776
- openProjectSelector,
777
- handleProjectSelectorClose,
778
- catalogEntities,
779
- bazaarProject,
780
- fetchBazaarProject,
781
- initEntity
782
- }) => {
783
- const classes = useStyles$6();
784
- const bazaarApi = useApi(bazaarApiRef);
785
- const alertApi = useApi(alertApiRef);
786
- const [selectedEntity, setSelectedEntity] = useState(initEntity);
787
- const [selectedEntityName, setSelectedEntityName] = useState("");
788
- const handleEntityClick = (entity) => {
789
- setSelectedEntity(entity);
790
- setSelectedEntityName(entity.metadata.name);
791
- };
792
- const handleSubmit = async () => {
793
- handleProjectSelectorClose();
794
- const updateResponse = await bazaarApi.updateProject({
795
- ...bazaarProject,
796
- entityRef: stringifyEntityRef(selectedEntity)
797
- });
798
- if (updateResponse.status === "ok") {
799
- fetchBazaarProject();
800
- alertApi.post({
801
- message: `linked entity '${selectedEntityName}' to the project ${bazaarProject.title}`,
802
- severity: "success",
803
- display: "transient"
804
- });
805
- }
806
- };
807
- return /* @__PURE__ */ React.createElement(Dialog, { onClose: handleProjectSelectorClose, open: openProjectSelector }, /* @__PURE__ */ React.createElement(
808
- CustomDialogTitle,
809
- {
810
- id: "customized-dialog-title",
811
- onClose: handleProjectSelectorClose
812
- },
813
- "Select entity"
814
- ), /* @__PURE__ */ React.createElement(MuiDialogContent, { className: classes.content, dividers: true }, /* @__PURE__ */ React.createElement(
815
- ProjectSelector,
816
- {
817
- label: "",
818
- onChange: handleEntityClick,
819
- catalogEntities: catalogEntities || [],
820
- disableClearable: true,
821
- defaultValue: catalogEntities[0] || null
822
- }
823
- )), /* @__PURE__ */ React.createElement(MuiDialogActions, null, /* @__PURE__ */ React.createElement(Button, { onClick: handleSubmit, color: "primary", type: "submit" }, "OK")));
824
- };
825
-
826
- const sortMembers = (m1, m2) => {
827
- return new Date(m2.joinDate).getTime() - new Date(m1.joinDate).getTime();
828
- };
829
- const sortByDate = (a, b) => {
830
- const dateA = new Date(a.updatedAt).getTime();
831
- const dateB = new Date(b.updatedAt).getTime();
832
- return dateB - dateA;
833
- };
834
- const sortByTitle = (a, b) => {
835
- return a.title.localeCompare(b.title);
836
- };
837
- const sortByTitleDescending = (a, b) => {
838
- return b.title.localeCompare(a.title);
839
- };
840
- const sortByMembers = (a, b) => {
841
- return b.membersCount - a.membersCount;
842
- };
843
-
844
- const parseBazaarProject = (metadata) => {
845
- return {
846
- id: metadata.id,
847
- entityRef: metadata.entity_ref,
848
- title: metadata.title,
849
- community: metadata.community,
850
- description: metadata.description,
851
- status: metadata.status,
852
- updatedAt: metadata.updated_at,
853
- membersCount: metadata.members_count,
854
- size: metadata.size,
855
- startDate: metadata.start_date,
856
- endDate: metadata.end_date,
857
- responsible: metadata.responsible,
858
- docs: metadata.docs
859
- };
860
- };
861
- const parseMember = (member) => {
862
- return {
863
- itemId: member.item_id,
864
- userId: member.user_id,
865
- userRef: member.user_ref,
866
- joinDate: member.join_date,
867
- picture: member.picture
868
- };
869
- };
870
- const parseBazaarResponse = async (response) => {
871
- if (response) {
872
- const metadata = await response.json().then((resp) => resp.data[0]);
873
- if (metadata) {
874
- return parseBazaarProject(metadata);
875
- }
876
- }
877
- return null;
878
- };
879
-
880
- const fetchProjectMembers = async (bazaarApi, project) => {
881
- const response = await bazaarApi.getMembers(project.id);
882
- if (response.data.length > 0) {
883
- const dbMembers = response.data.map((member) => {
884
- return parseMember(member);
885
- });
886
- dbMembers.sort(sortMembers);
887
- return dbMembers;
888
- }
889
- return [];
890
- };
891
- const fetchCatalogItems = async (catalogApi) => {
892
- const entities = await catalogApi.getEntities({
893
- filter: {
894
- kind: ["Component", "Resource"]
895
- },
896
- fields: ["kind", "metadata.name", "metadata.namespace"]
897
- });
898
- return entities.items;
899
- };
900
-
901
- const useStyles$5 = makeStyles({
902
- wordBreak: {
903
- wordBreak: "break-all",
904
- whiteSpace: "normal",
905
- margin: "-0.25rem 0"
906
- }
907
- });
908
- const HomePageBazaarInfoCard = ({
909
- initProject,
910
- handleClose,
911
- initEntity
912
- }) => {
913
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
914
- const classes = useStyles$5();
915
- const entityLink = useRouteRef(entityRouteRef);
916
- const bazaarApi = useApi(bazaarApiRef);
917
- const identity = useApi(identityApiRef);
918
- const alertApi = useApi(alertApiRef);
919
- const catalogApi = useApi(catalogApiRef);
920
- const [openEdit, setOpenEdit] = useState(false);
921
- const [openProjectSelector, setOpenProjectSelector] = useState(false);
922
- const [openUnlink, setOpenUnlink] = useState(false);
923
- const [isMember, setIsMember] = useState(false);
924
- const [catalogEntities, fetchCatalogEntities] = useAsyncFn(async () => {
925
- const entities = await fetchCatalogItems(catalogApi);
926
- const bazaarProjects = await bazaarApi.getProjects();
927
- const bazaarLinkedRefs = bazaarProjects.data.filter((entity) => entity.entity_ref !== null).map((entity) => entity.entity_ref);
928
- return entities.filter(
929
- (entity) => !bazaarLinkedRefs.includes(stringifyEntityRef(entity))
930
- );
931
- });
932
- const [bazaarProject, fetchBazaarProject] = useAsyncFn(async () => {
933
- const response = await bazaarApi.getProjectById(initProject.id);
934
- return await parseBazaarResponse(response);
935
- });
936
- const [members, fetchMembers] = useAsyncFn(async () => {
937
- var _a2;
938
- return fetchProjectMembers(bazaarApi, (_a2 = bazaarProject.value) != null ? _a2 : initProject);
939
- });
940
- const [userId, fetchUserId] = useAsyncFn(async () => {
941
- return await (await identity.getProfileInfo()).displayName;
942
- });
943
- useEffect(() => {
944
- fetchMembers();
945
- fetchBazaarProject();
946
- fetchCatalogEntities();
947
- fetchUserId();
948
- }, [fetchMembers, fetchBazaarProject, fetchCatalogEntities, fetchUserId]);
949
- useEffect(() => {
950
- var _a2;
951
- if (members.value && userId.value) {
952
- setIsMember(
953
- ((_a2 = members.value) == null ? void 0 : _a2.map((member) => member.userId).indexOf(userId.value)) >= 0
954
- );
955
- }
956
- }, [bazaarProject.value, members, identity, userId.value]);
957
- const handleMembersClick = async () => {
958
- if (userId.value) {
959
- if (!isMember) {
960
- await bazaarApi.addMember(bazaarProject.value.id, userId.value);
961
- } else {
962
- await bazaarApi.deleteMember(bazaarProject.value.id, userId.value);
963
- }
964
- setIsMember(!isMember);
965
- fetchMembers();
966
- }
967
- };
968
- const getEntityPageLink = () => {
969
- var _a2;
970
- if ((_a2 = bazaarProject == null ? void 0 : bazaarProject.value) == null ? void 0 : _a2.entityRef) {
971
- const { name, kind, namespace } = parseEntityRef(
972
- bazaarProject.value.entityRef
973
- );
974
- return entityLink({ kind, namespace, name });
975
- }
976
- return "";
977
- };
978
- const handleLink = () => {
979
- var _a2;
980
- if ((_a2 = bazaarProject.value) == null ? void 0 : _a2.entityRef) {
981
- setOpenUnlink(true);
982
- } else {
983
- fetchCatalogEntities();
984
- setOpenProjectSelector(true);
985
- }
986
- };
987
- const links = [
988
- {
989
- label: "Entity page",
990
- icon: /* @__PURE__ */ React.createElement(DashboardIcon, null),
991
- href: ((_a = bazaarProject.value) == null ? void 0 : _a.entityRef) ? getEntityPageLink() : "",
992
- disabled: ((_b = bazaarProject.value) == null ? void 0 : _b.entityRef) === null
993
- },
994
- {
995
- label: ((_c = bazaarProject.value) == null ? void 0 : _c.entityRef) ? "Unlink project" : "Link project",
996
- icon: ((_d = bazaarProject.value) == null ? void 0 : _d.entityRef) ? /* @__PURE__ */ React.createElement(LinkOffIcon, null) : /* @__PURE__ */ React.createElement(InsertLinkIcon, null),
997
- onClick: handleLink
998
- },
999
- {
1000
- label: isMember ? "Leave" : "Join",
1001
- icon: isMember ? /* @__PURE__ */ React.createElement(ExitToAppIcon, null) : /* @__PURE__ */ React.createElement(PersonAddIcon, null),
1002
- href: "",
1003
- onClick: async () => {
1004
- handleMembersClick();
1005
- }
1006
- },
1007
- {
1008
- label: "Community",
1009
- icon: /* @__PURE__ */ React.createElement(ChatIcon, null),
1010
- href: (_e = bazaarProject.value) == null ? void 0 : _e.community,
1011
- disabled: !((_f = bazaarProject.value) == null ? void 0 : _f.community) || !isMember
1012
- },
1013
- {
1014
- label: "Docs",
1015
- icon: /* @__PURE__ */ React.createElement(Description, null),
1016
- href: (_g = bazaarProject.value) == null ? void 0 : _g.docs,
1017
- disabled: ((_h = bazaarProject.value) == null ? void 0 : _h.docs) === null || ((_i = bazaarProject.value) == null ? void 0 : _i.docs) === ""
1018
- }
1019
- ];
1020
- const handleUnlinkSubmit = async () => {
1021
- var _a2, _b2;
1022
- const updateResponse = await bazaarApi.updateProject({
1023
- ...bazaarProject.value,
1024
- entityRef: null
1025
- });
1026
- if (updateResponse.status === "ok") {
1027
- setOpenUnlink(false);
1028
- fetchBazaarProject();
1029
- alertApi.post({
1030
- message: `Unlinked entity '${parseEntityRef((_a2 = bazaarProject.value) == null ? void 0 : _a2.entityRef).name}' from the project ${(_b2 = bazaarProject.value) == null ? void 0 : _b2.title}`,
1031
- severity: "success",
1032
- display: "transient"
1033
- });
1034
- }
1035
- };
1036
- if (bazaarProject.error) {
1037
- return /* @__PURE__ */ React.createElement(Alert, { severity: "error" }, (_j = bazaarProject == null ? void 0 : bazaarProject.error) == null ? void 0 : _j.message);
1038
- } else if (members.error) {
1039
- return /* @__PURE__ */ React.createElement(Alert, { severity: "error" }, (_k = members == null ? void 0 : members.error) == null ? void 0 : _k.message);
1040
- }
1041
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
1042
- LinkProjectDialog,
1043
- {
1044
- openProjectSelector,
1045
- handleProjectSelectorClose: () => setOpenProjectSelector(false),
1046
- catalogEntities: catalogEntities.value || [],
1047
- bazaarProject: bazaarProject.value || initProject,
1048
- fetchBazaarProject,
1049
- initEntity
1050
- }
1051
- ), openUnlink && /* @__PURE__ */ React.createElement(
1052
- ConfirmationDialog,
1053
- {
1054
- open: openUnlink,
1055
- handleClose: () => setOpenUnlink(false),
1056
- message: [
1057
- "Are you sure you want to unlink ",
1058
- /* @__PURE__ */ React.createElement("b", { className: classes.wordBreak }, parseEntityRef((_l = bazaarProject.value) == null ? void 0 : _l.entityRef).name),
1059
- " from ",
1060
- /* @__PURE__ */ React.createElement("b", { className: classes.wordBreak }, (_m = bazaarProject.value) == null ? void 0 : _m.title),
1061
- " ?"
1062
- ],
1063
- type: "unlink",
1064
- handleSubmit: handleUnlinkSubmit
1065
- }
1066
- ), /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(
1067
- EditProjectDialog,
1068
- {
1069
- bazaarProject: bazaarProject.value || initProject,
1070
- openEdit,
1071
- handleEditClose: () => setOpenEdit(false),
1072
- handleCardClose: handleClose,
1073
- fetchBazaarProject
1074
- }
1075
- ), /* @__PURE__ */ React.createElement(
1076
- CardHeader,
1077
- {
1078
- title: /* @__PURE__ */ React.createElement(Typography, { paragraph: true, className: classes.wordBreak }, ((_n = bazaarProject.value) == null ? void 0 : _n.title) || initProject.title),
1079
- action: /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(IconButton, { onClick: () => setOpenEdit(true) }, /* @__PURE__ */ React.createElement(EditIcon, null)), /* @__PURE__ */ React.createElement(IconButton, { onClick: handleClose }, /* @__PURE__ */ React.createElement(CloseIcon, null))),
1080
- subheader: /* @__PURE__ */ React.createElement(HeaderIconLinkRow, { links })
1081
- }
1082
- ), /* @__PURE__ */ React.createElement(Divider, null), /* @__PURE__ */ React.createElement(
1083
- CardContentFields,
1084
- {
1085
- bazaarProject: bazaarProject.value || initProject,
1086
- members: members.value || [],
1087
- descriptionSize: 9,
1088
- membersSize: 3
1089
- }
1090
- )));
1091
- };
1092
-
1093
- const useStyles$4 = makeStyles((theme) => ({
1094
- description: (props) => ({
1095
- height: props.height === "large" ? "10rem" : "4rem",
1096
- WebkitBackgroundClip: "text",
1097
- backgroundImage: `linear-gradient(180deg, ${theme.palette.textContrast} 0%, ${theme.palette.textContrast} 60%, transparent 100%)`,
1098
- color: "transparent"
1099
- }),
1100
- statusTag: {
1101
- display: "inline-block",
1102
- whiteSpace: "nowrap",
1103
- marginBottom: "0.8rem"
1104
- },
1105
- memberCount: {
1106
- float: "right"
1107
- },
1108
- header: {
1109
- whiteSpace: "nowrap",
1110
- overflow: "hidden",
1111
- textOverflow: "ellipsis",
1112
- height: "5rem"
1113
- }
1114
- }));
1115
- const ProjectCard = ({
1116
- project,
1117
- fetchBazaarProjects,
1118
- catalogEntities,
1119
- height
1120
- }) => {
1121
- const classes = useStyles$4({ height });
1122
- const [openCard, setOpenCard] = useState(false);
1123
- const { id, title, status, updatedAt, description, membersCount } = project;
1124
- const handleClose = () => {
1125
- setOpenCard(false);
1126
- fetchBazaarProjects();
1127
- };
1128
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Dialog, { fullWidth: true, onClose: handleClose, open: openCard }, /* @__PURE__ */ React.createElement(
1129
- HomePageBazaarInfoCard,
1130
- {
1131
- initProject: project,
1132
- handleClose,
1133
- initEntity: catalogEntities[0] || null
1134
- }
1135
- )), /* @__PURE__ */ React.createElement(Card, { key: id }, /* @__PURE__ */ React.createElement(CardActionArea, { onClick: () => setOpenCard(true) }, /* @__PURE__ */ React.createElement(
1136
- ItemCardHeader,
1137
- {
1138
- classes: { root: classes.header },
1139
- title,
1140
- subtitle: `updated ${DateTime.fromISO(
1141
- new Date(updatedAt).toISOString()
1142
- ).toRelative({
1143
- base: DateTime.now()
1144
- })}`
1145
- }
1146
- ), /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(StatusTag, { styles: classes.statusTag, status }), /* @__PURE__ */ React.createElement(Typography, { variant: "body2", className: classes.memberCount }, Number(membersCount) === Number(1) ? `${membersCount} member` : `${membersCount} members`), /* @__PURE__ */ React.createElement(Typography, { variant: "body2", className: classes.description }, description)))));
1147
- };
1148
-
1149
- const useStyles$3 = makeStyles({
1150
- content: {
1151
- width: "100%",
1152
- display: "flex",
1153
- flexWrap: "wrap",
1154
- alignItems: "center"
1155
- },
1156
- empty: {
1157
- height: "10rem",
1158
- textAlign: "center",
1159
- verticalAlign: "middle",
1160
- lineHeight: "10rem"
1161
- },
1162
- pagination: {
1163
- marginTop: "1rem",
1164
- marginLeft: "auto",
1165
- marginRight: "0"
1166
- }
1167
- });
1168
- const ProjectPreview = ({
1169
- bazaarProjects,
1170
- fetchBazaarProjects,
1171
- catalogEntities,
1172
- useTablePagination = true,
1173
- gridSize = 2,
1174
- height = "large"
1175
- }) => {
1176
- const classes = useStyles$3();
1177
- const [page, setPage] = useState(1);
1178
- const [rows, setRows] = useState(12);
1179
- const handlePageChange = (_, newPage) => {
1180
- setPage(newPage + 1);
1181
- };
1182
- const handleRowChange = (event) => {
1183
- setRows(parseInt(event.target.value, 10));
1184
- setPage(1);
1185
- };
1186
- if (!bazaarProjects.length) {
1187
- return /* @__PURE__ */ React.createElement("div", { className: classes.empty }, "Please add projects to the Bazaar.");
1188
- }
1189
- return /* @__PURE__ */ React.createElement(Box, { className: classes.content }, /* @__PURE__ */ React.createElement(Grid, { wrap: "wrap", container: true, spacing: 3 }, bazaarProjects.slice((page - 1) * rows, rows * page).map((bazaarProject, i) => {
1190
- return /* @__PURE__ */ React.createElement(Grid, { key: i, item: true, xs: gridSize }, /* @__PURE__ */ React.createElement(
1191
- ProjectCard,
1192
- {
1193
- project: bazaarProject,
1194
- key: i,
1195
- fetchBazaarProjects,
1196
- catalogEntities,
1197
- height
1198
- }
1199
- ));
1200
- })), useTablePagination && /* @__PURE__ */ React.createElement(
1201
- TablePagination,
1202
- {
1203
- component: "div",
1204
- className: classes.pagination,
1205
- rowsPerPageOptions: [12, 24, 48, 96],
1206
- count: bazaarProjects == null ? void 0 : bazaarProjects.length,
1207
- page: page - 1,
1208
- onPageChange: handlePageChange,
1209
- rowsPerPage: rows,
1210
- onRowsPerPageChange: handleRowChange,
1211
- backIconButtonProps: { disabled: page === 1 },
1212
- nextIconButtonProps: {
1213
- disabled: rows * page >= bazaarProjects.length
1214
- }
1215
- }
1216
- ));
1217
- };
1218
-
1219
- const getUnlinkedCatalogEntities$1 = (bazaarProjects, catalogEntities) => {
1220
- const bazaarProjectRefs = bazaarProjects.map(
1221
- (project) => project.entityRef
1222
- );
1223
- return catalogEntities.filter((entity) => {
1224
- return !(bazaarProjectRefs == null ? void 0 : bazaarProjectRefs.includes(stringifyEntityRef(entity)));
1225
- });
1226
- };
1227
- const BazaarOverviewCard = (props) => {
1228
- var _a;
1229
- const { title, order, fullWidth = false, fullHeight = false } = props;
1230
- const bazaarApi = useApi(bazaarApiRef);
1231
- const catalogApi = useApi(catalogApiRef);
1232
- const root = useRouteRef(bazaarPlugin.routes.root);
1233
- const defaultTitle = order === "latest" ? "Bazaar Latest Projects" : "Bazaar Random Projects";
1234
- const bazaarLink = {
1235
- title: "Go to Bazaar",
1236
- link: `${root()}`
1237
- };
1238
- const [unlinkedCatalogEntities, setUnlinkedCatalogEntities] = useState();
1239
- const [catalogEntities, fetchCatalogEntities] = useAsyncFn(async () => {
1240
- return await fetchCatalogItems(catalogApi);
1241
- });
1242
- const [bazaarProjects, fetchBazaarProjects] = useAsyncFn(async () => {
1243
- const limit = fullWidth ? 6 : 3;
1244
- const response = await bazaarApi.getProjects(limit, order);
1245
- return response.data.map(parseBazaarProject);
1246
- });
1247
- const catalogEntityRefs = (_a = catalogEntities.value) == null ? void 0 : _a.map(
1248
- (project) => stringifyEntityRef(project)
1249
- );
1250
- useEffect(() => {
1251
- const filterBrokenLinks = () => {
1252
- var _a2;
1253
- if (catalogEntityRefs) {
1254
- (_a2 = bazaarProjects.value) == null ? void 0 : _a2.forEach(async (project) => {
1255
- if (project.entityRef) {
1256
- if (!(catalogEntityRefs == null ? void 0 : catalogEntityRefs.includes(project.entityRef))) {
1257
- await bazaarApi.updateProject({
1258
- ...project,
1259
- entityRef: null
1260
- });
1261
- }
1262
- }
1263
- });
1264
- }
1265
- };
1266
- filterBrokenLinks();
1267
- }, [
1268
- bazaarApi,
1269
- bazaarProjects.value,
1270
- catalogEntityRefs,
1271
- catalogEntities.value
1272
- ]);
1273
- useEffect(() => {
1274
- fetchCatalogEntities();
1275
- fetchBazaarProjects();
1276
- }, [fetchBazaarProjects, fetchCatalogEntities]);
1277
- useEffect(() => {
1278
- const unlinkedCEntities = getUnlinkedCatalogEntities$1(
1279
- bazaarProjects.value || [],
1280
- catalogEntities.value || []
1281
- );
1282
- if (unlinkedCEntities) {
1283
- setUnlinkedCatalogEntities(unlinkedCEntities);
1284
- }
1285
- }, [bazaarProjects, catalogEntities]);
1286
- if (catalogEntities.error) {
1287
- return /* @__PURE__ */ React.createElement(ErrorPanel, { error: catalogEntities.error });
1288
- }
1289
- if (bazaarProjects.error) {
1290
- return /* @__PURE__ */ React.createElement(ErrorPanel, { error: bazaarProjects.error });
1291
- }
1292
- return /* @__PURE__ */ React.createElement(
1293
- InfoCard,
1294
- {
1295
- title: title != null ? title : defaultTitle,
1296
- action: /* @__PURE__ */ React.createElement(IconButton, null, /* @__PURE__ */ React.createElement(Link, { to: bazaarLink.link, title: bazaarLink.title }, /* @__PURE__ */ React.createElement(StorefrontIcon, null)))
1297
- },
1298
- /* @__PURE__ */ React.createElement(
1299
- ProjectPreview,
1300
- {
1301
- bazaarProjects: bazaarProjects.value || [],
1302
- fetchBazaarProjects,
1303
- catalogEntities: unlinkedCatalogEntities || [],
1304
- useTablePagination: false,
1305
- gridSize: fullWidth ? 2 : 4,
1306
- height: fullHeight ? "large" : "small"
1307
- }
1308
- )
1309
- );
1310
- };
1311
-
1312
- const useStyles$2 = makeStyles({
1313
- wordBreak: {
1314
- wordBreak: "break-all",
1315
- whiteSpace: "normal",
1316
- margin: "-0.25rem 0"
1317
- }
1318
- });
1319
- const EntityBazaarInfoContent = ({
1320
- bazaarProject,
1321
- fetchBazaarProject
1322
- }) => {
1323
- var _a;
1324
- const classes = useStyles$2();
1325
- const bazaarApi = useApi(bazaarApiRef);
1326
- const identity = useApi(identityApiRef);
1327
- const [openEdit, setOpenEdit] = useState(false);
1328
- const [isMember, setIsMember] = useState(false);
1329
- const [openUnlink, setOpenUnlink] = useState(false);
1330
- const [members, fetchMembers] = useAsyncFn(async () => {
1331
- return bazaarProject ? await fetchProjectMembers(bazaarApi, bazaarProject) : [];
1332
- });
1333
- const [userId, fetchUserId] = useAsyncFn(async () => {
1334
- return await (await identity.getProfileInfo()).displayName;
1335
- });
1336
- useEffect(() => {
1337
- fetchMembers();
1338
- fetchUserId();
1339
- }, [fetchMembers, fetchUserId]);
1340
- useEffect(() => {
1341
- var _a2;
1342
- if (members.value && userId.value) {
1343
- setIsMember(
1344
- ((_a2 = members.value) == null ? void 0 : _a2.map((member) => member.userId).indexOf(userId.value)) >= 0
1345
- );
1346
- }
1347
- }, [bazaarProject, members, identity, userId.value]);
1348
- const handleMembersClick = async () => {
1349
- if (userId.value) {
1350
- if (!isMember) {
1351
- await bazaarApi.addMember(bazaarProject == null ? void 0 : bazaarProject.id, userId.value);
1352
- } else {
1353
- await bazaarApi.deleteMember(bazaarProject.id, userId.value);
1354
- }
1355
- setIsMember(!isMember);
1356
- fetchMembers();
1357
- }
1358
- };
1359
- const links = [
1360
- {
1361
- label: "Entity page",
1362
- icon: /* @__PURE__ */ React.createElement(DashboardIcon, null),
1363
- disabled: true
1364
- },
1365
- {
1366
- label: "Unlink project",
1367
- icon: /* @__PURE__ */ React.createElement(LinkOffIcon, null),
1368
- disabled: false,
1369
- onClick: () => {
1370
- setOpenUnlink(true);
1371
- }
1372
- },
1373
- {
1374
- label: isMember ? "Leave" : "Join",
1375
- icon: isMember ? /* @__PURE__ */ React.createElement(ExitToAppIcon, null) : /* @__PURE__ */ React.createElement(PersonAddIcon, null),
1376
- href: "",
1377
- onClick: async () => {
1378
- handleMembersClick();
1379
- }
1380
- },
1381
- {
1382
- label: "Community",
1383
- icon: /* @__PURE__ */ React.createElement(ChatIcon, null),
1384
- href: bazaarProject == null ? void 0 : bazaarProject.community,
1385
- disabled: (bazaarProject == null ? void 0 : bazaarProject.community) === "" || !isMember
1386
- },
1387
- {
1388
- label: "Docs",
1389
- icon: /* @__PURE__ */ React.createElement(Description, null),
1390
- href: bazaarProject == null ? void 0 : bazaarProject.docs,
1391
- disabled: (bazaarProject == null ? void 0 : bazaarProject.docs) === null || (bazaarProject == null ? void 0 : bazaarProject.docs) === ""
1392
- }
1393
- ];
1394
- const handleEditClose = () => {
1395
- setOpenEdit(false);
1396
- };
1397
- const handleUnlinkClose = () => {
1398
- setOpenUnlink(false);
1399
- };
1400
- const handleUnlinkSubmit = async () => {
1401
- const updateResponse = await bazaarApi.updateProject({
1402
- ...bazaarProject,
1403
- entityRef: null
1404
- });
1405
- if (updateResponse.status === "ok") {
1406
- handleUnlinkClose();
1407
- fetchBazaarProject();
1408
- }
1409
- };
1410
- if (members.error) {
1411
- return /* @__PURE__ */ React.createElement(Alert, { severity: "error" }, (_a = members == null ? void 0 : members.error) == null ? void 0 : _a.message);
1412
- }
1413
- if (bazaarProject) {
1414
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
1415
- EditProjectDialog,
1416
- {
1417
- bazaarProject,
1418
- openEdit,
1419
- handleEditClose,
1420
- fetchBazaarProject
1421
- }
1422
- ), openUnlink && /* @__PURE__ */ React.createElement(
1423
- ConfirmationDialog,
1424
- {
1425
- open: openUnlink,
1426
- handleClose: handleUnlinkClose,
1427
- message: [
1428
- "Are you sure you want to unlink ",
1429
- /* @__PURE__ */ React.createElement("b", { className: classes.wordBreak }, parseEntityRef(bazaarProject.entityRef).name),
1430
- " from ",
1431
- /* @__PURE__ */ React.createElement("b", { className: classes.wordBreak }, bazaarProject.title),
1432
- " ?"
1433
- ],
1434
- type: "unlink",
1435
- handleSubmit: handleUnlinkSubmit
1436
- }
1437
- ), /* @__PURE__ */ React.createElement(
1438
- CardHeader,
1439
- {
1440
- title: /* @__PURE__ */ React.createElement(Typography, { paragraph: true, className: classes.wordBreak }, bazaarProject == null ? void 0 : bazaarProject.title),
1441
- action: /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
1442
- IconButton,
1443
- {
1444
- onClick: () => {
1445
- setOpenEdit(true);
1446
- }
1447
- },
1448
- /* @__PURE__ */ React.createElement(EditIcon, null)
1449
- )),
1450
- subheader: /* @__PURE__ */ React.createElement(HeaderIconLinkRow, { links })
1451
- }
1452
- ), /* @__PURE__ */ React.createElement(Divider, null), /* @__PURE__ */ React.createElement(
1453
- CardContentFields,
1454
- {
1455
- bazaarProject,
1456
- members: members.value || [],
1457
- descriptionSize: 10,
1458
- membersSize: 2
1459
- }
1460
- ));
1461
- }
1462
- return null;
1463
- };
1464
-
1465
- const EntityBazaarInfoCard = () => {
1466
- var _a;
1467
- const { entity } = useEntity();
1468
- const bazaarApi = useApi(bazaarApiRef);
1469
- const [bazaarProject, fetchBazaarProject] = useAsyncFn(async () => {
1470
- const response = await bazaarApi.getProjectByRef(
1471
- stringifyEntityRef(entity)
1472
- );
1473
- return await parseBazaarResponse(response);
1474
- });
1475
- const [isBazaar, setIsBazaar] = useState((_a = bazaarProject.value) != null ? _a : false);
1476
- useEffect(() => {
1477
- fetchBazaarProject();
1478
- }, [fetchBazaarProject]);
1479
- useEffect(() => {
1480
- const isBazaarProject = bazaarProject.value !== void 0;
1481
- setIsBazaar(isBazaarProject);
1482
- }, [bazaarProject.value]);
1483
- if (isBazaar) {
1484
- return /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(
1485
- EntityBazaarInfoContent,
1486
- {
1487
- bazaarProject: bazaarProject.value,
1488
- fetchBazaarProject
1489
- }
1490
- ));
1491
- }
1492
- return null;
1493
- };
1494
-
1495
- const AddProjectDialog = ({
1496
- catalogEntities,
1497
- open,
1498
- handleClose,
1499
- fetchBazaarProjects,
1500
- fetchCatalogEntities
1501
- }) => {
1502
- const bazaarApi = useApi(bazaarApiRef);
1503
- const alertApi = useApi(alertApiRef);
1504
- const [selectedEntity, setSelectedEntity] = useState(null);
1505
- const defaultValues = {
1506
- title: "",
1507
- community: "",
1508
- description: "",
1509
- docs: "",
1510
- status: "proposed",
1511
- size: "medium",
1512
- responsible: "",
1513
- startDate: null,
1514
- endDate: null
1515
- };
1516
- const handleEntityClick = (entity) => {
1517
- setSelectedEntity(entity);
1518
- };
1519
- const handleSubmit = async (getValues, reset) => {
1520
- var _a, _b;
1521
- const formValues = getValues();
1522
- const response = await bazaarApi.addProject({
1523
- ...formValues,
1524
- entityRef: selectedEntity ? stringifyEntityRef(selectedEntity) : null,
1525
- startDate: (_a = formValues.startDate) != null ? _a : null,
1526
- endDate: (_b = formValues.endDate) != null ? _b : null
1527
- });
1528
- if (response.status === "ok") {
1529
- fetchBazaarProjects();
1530
- fetchCatalogEntities();
1531
- alertApi.post({
1532
- message: `Added project '${formValues.title}' to the Bazaar list`,
1533
- severity: "success",
1534
- display: "transient"
1535
- });
1536
- }
1537
- handleClose();
1538
- reset(defaultValues);
1539
- };
1540
- return /* @__PURE__ */ React.createElement(
1541
- ProjectDialog,
1542
- {
1543
- handleSave: handleSubmit,
1544
- title: "Add project",
1545
- isAddForm: true,
1546
- defaultValues,
1547
- open,
1548
- projectSelector: /* @__PURE__ */ React.createElement(
1549
- ProjectSelector,
1550
- {
1551
- onChange: handleEntityClick,
1552
- catalogEntities: catalogEntities || [],
1553
- disableClearable: false,
1554
- defaultValue: null,
1555
- label: "Select a project"
1556
- }
1557
- ),
1558
- handleClose
1559
- }
1560
- );
1561
- };
1562
-
1563
- const useStyles$1 = makeStyles({
1564
- select: {
1565
- fontSize: "xx-large",
1566
- fontWeight: "bold",
1567
- width: "16rem"
1568
- }
1569
- });
1570
- const SortMethodSelector = ({
1571
- sortMethodNbr,
1572
- handleSortMethodChange
1573
- }) => {
1574
- const classes = useStyles$1();
1575
- return /* @__PURE__ */ React.createElement(FormControl, { fullWidth: true }, /* @__PURE__ */ React.createElement(
1576
- Select,
1577
- {
1578
- className: classes.select,
1579
- disableUnderline: true,
1580
- value: sortMethodNbr,
1581
- onChange: handleSortMethodChange
1582
- },
1583
- /* @__PURE__ */ React.createElement(MenuItem, { value: 0 }, "Latest updated"),
1584
- /* @__PURE__ */ React.createElement(MenuItem, { value: 1 }, "A-Z"),
1585
- /* @__PURE__ */ React.createElement(MenuItem, { value: 2 }, "Z-A"),
1586
- /* @__PURE__ */ React.createElement(MenuItem, { value: 3 }, "Most members")
1587
- ));
1588
- };
1589
-
1590
- const useStyles = makeStyles({
1591
- button: { minWidth: "11rem" },
1592
- container: {
1593
- marginTop: "2rem"
1594
- },
1595
- header: {
1596
- width: "100%",
1597
- display: "flex",
1598
- flexDirection: "row",
1599
- justifyContent: "center",
1600
- alignItems: "center",
1601
- margin: "0 auto",
1602
- marginBottom: "1.2rem"
1603
- },
1604
- search: {
1605
- marginRight: "1rem",
1606
- height: "2.5rem",
1607
- width: "35rem"
1608
- }
1609
- });
1610
- const getUnlinkedCatalogEntities = (bazaarProjects, catalogEntities) => {
1611
- const bazaarProjectRefs = bazaarProjects.map(
1612
- (project) => project.entityRef
1613
- );
1614
- return catalogEntities.filter((entity) => {
1615
- return !(bazaarProjectRefs == null ? void 0 : bazaarProjectRefs.includes(stringifyEntityRef(entity)));
1616
- });
1617
- };
1618
- const SortView = (props) => {
1619
- var _a;
1620
- const { fullWidth = true, fullHeight = true } = props;
1621
- const bazaarApi = useApi(bazaarApiRef);
1622
- const catalogApi = useApi(catalogApiRef);
1623
- const classes = useStyles();
1624
- const sortMethods = [
1625
- sortByDate,
1626
- sortByTitle,
1627
- sortByTitleDescending,
1628
- sortByMembers
1629
- ];
1630
- const [sortMethodNbr, setSortMethodNbr] = useState(0);
1631
- const [openAdd, setOpenAdd] = useState(false);
1632
- const [searchValue, setSearchValue] = useState("");
1633
- const [unlinkedCatalogEntities, setUnlinkedCatalogEntities] = useState();
1634
- const [catalogEntities, fetchCatalogEntities] = useAsyncFn(async () => {
1635
- return await fetchCatalogItems(catalogApi);
1636
- });
1637
- const [bazaarProjects, fetchBazaarProjects] = useAsyncFn(async () => {
1638
- const response = await bazaarApi.getProjects();
1639
- const dbProjects = [];
1640
- response.data.forEach((project) => {
1641
- dbProjects.push(parseBazaarProject(project));
1642
- });
1643
- return dbProjects;
1644
- });
1645
- const catalogEntityRefs = (_a = catalogEntities.value) == null ? void 0 : _a.map(
1646
- (project) => stringifyEntityRef(project)
1647
- );
1648
- const getSearchResults = () => {
1649
- var _a2;
1650
- return (_a2 = bazaarProjects.value) == null ? void 0 : _a2.filter((project) => project.title.includes(searchValue)).sort(sortMethods[sortMethodNbr]);
1651
- };
1652
- useEffect(() => {
1653
- const filterBrokenLinks = () => {
1654
- var _a2;
1655
- if (catalogEntityRefs) {
1656
- (_a2 = bazaarProjects.value) == null ? void 0 : _a2.forEach(async (project) => {
1657
- if (project.entityRef) {
1658
- if (!(catalogEntityRefs == null ? void 0 : catalogEntityRefs.includes(project.entityRef))) {
1659
- await bazaarApi.updateProject({
1660
- ...project,
1661
- entityRef: null
1662
- });
1663
- }
1664
- }
1665
- });
1666
- }
1667
- };
1668
- filterBrokenLinks();
1669
- }, [
1670
- bazaarApi,
1671
- bazaarProjects.value,
1672
- catalogEntityRefs,
1673
- catalogEntities.value
1674
- ]);
1675
- useEffect(() => {
1676
- fetchCatalogEntities();
1677
- fetchBazaarProjects();
1678
- }, [fetchBazaarProjects, fetchCatalogEntities]);
1679
- useEffect(() => {
1680
- const unlinkedCEntities = getUnlinkedCatalogEntities(
1681
- bazaarProjects.value || [],
1682
- catalogEntities.value || []
1683
- );
1684
- if (unlinkedCEntities) {
1685
- setUnlinkedCatalogEntities(unlinkedCEntities);
1686
- }
1687
- }, [bazaarProjects, catalogEntities]);
1688
- const handleSortMethodChange = (event) => {
1689
- setSortMethodNbr(
1690
- typeof event.target.value === "number" ? event.target.value : 0
1691
- );
1692
- };
1693
- if (catalogEntities.error)
1694
- return /* @__PURE__ */ React.createElement(Alert, { severity: "error" }, catalogEntities.error.message);
1695
- if (bazaarProjects.error)
1696
- return /* @__PURE__ */ React.createElement(Alert, { severity: "error" }, bazaarProjects.error.message);
1697
- return /* @__PURE__ */ React.createElement(Content, { noPadding: true }, /* @__PURE__ */ React.createElement("div", { className: classes.header }, /* @__PURE__ */ React.createElement(
1698
- SortMethodSelector,
1699
- {
1700
- sortMethodNbr,
1701
- handleSortMethodChange
1702
- }
1703
- ), /* @__PURE__ */ React.createElement(
1704
- SearchBar,
1705
- {
1706
- className: classes.search,
1707
- value: searchValue,
1708
- onChange: (newSortMethod) => {
1709
- setSearchValue(newSortMethod);
1710
- },
1711
- onCancelSearch: () => {
1712
- setSearchValue("");
1713
- }
1714
- }
1715
- ), /* @__PURE__ */ React.createElement(
1716
- Button,
1717
- {
1718
- className: classes.button,
1719
- variant: "contained",
1720
- color: "primary",
1721
- onClick: () => {
1722
- setOpenAdd(true);
1723
- }
1724
- },
1725
- "Add project"
1726
- ), /* @__PURE__ */ React.createElement(
1727
- AddProjectDialog,
1728
- {
1729
- catalogEntities: unlinkedCatalogEntities || [],
1730
- handleClose: () => {
1731
- setOpenAdd(false);
1732
- },
1733
- open: openAdd,
1734
- fetchBazaarProjects,
1735
- fetchCatalogEntities
1736
- }
1737
- ), /* @__PURE__ */ React.createElement(SupportButton, null)), /* @__PURE__ */ React.createElement(
1738
- ProjectPreview,
1739
- {
1740
- bazaarProjects: getSearchResults() || [],
1741
- fetchBazaarProjects,
1742
- catalogEntities: unlinkedCatalogEntities || [],
1743
- gridSize: fullWidth ? 2 : 4,
1744
- height: fullHeight ? "large" : "small"
1745
- }
1746
- ), /* @__PURE__ */ React.createElement(Content, { noPadding: true, className: classes.container }));
1747
- };
1748
-
1749
- export { BazaarOverviewCard, BazaarPage, EntityBazaarInfoCard, SortView, bazaarPlugin, isBazaarAvailable };
1
+ export { BazaarPage, bazaarPlugin } from './plugin.esm.js';
2
+ export { isBazaarAvailable } from './api.esm.js';
3
+ export { BazaarOverviewCard } from './components/BazaarOverviewCard/BazaarOverviewCard.esm.js';
4
+ export { EntityBazaarInfoCard } from './components/EntityBazaarInfoCard/EntityBazaarInfoCard.esm.js';
5
+ export { SortView } from './components/SortView/SortView.esm.js';
1750
6
  //# sourceMappingURL=index.esm.js.map