@backstage-community/plugin-entity-feedback 0.2.18 → 0.3.0

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 (55) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +19 -0
  3. package/dist/api/EntityFeedbackApi.esm.js +8 -0
  4. package/dist/api/EntityFeedbackApi.esm.js.map +1 -0
  5. package/dist/api/EntityFeedbackClient.esm.js +109 -0
  6. package/dist/api/EntityFeedbackClient.esm.js.map +1 -0
  7. package/dist/{esm/FeedbackRatingsTable-O2SrWgAE.esm.js → components/FeedbackRatingsTable/FeedbackRatingsTable.esm.js} +3 -3
  8. package/dist/components/FeedbackRatingsTable/FeedbackRatingsTable.esm.js.map +1 -0
  9. package/dist/components/FeedbackResponseDialog/FeedbackResponseDialog.esm.js +169 -0
  10. package/dist/components/FeedbackResponseDialog/FeedbackResponseDialog.esm.js.map +1 -0
  11. package/dist/components/FeedbackResponseDialog/index.esm.js +2 -0
  12. package/dist/components/FeedbackResponseDialog/index.esm.js.map +1 -0
  13. package/dist/{esm/index-xB2VxWp7.esm.js → components/FeedbackResponseTable/FeedbackResponseTable.esm.js} +27 -4
  14. package/dist/components/FeedbackResponseTable/FeedbackResponseTable.esm.js.map +1 -0
  15. package/dist/components/FeedbackResponseTable/index.esm.js +2 -0
  16. package/dist/components/FeedbackResponseTable/index.esm.js.map +1 -0
  17. package/dist/{esm/LikeDislikeButtons-D7M8hiAk.esm.js → components/LikeDislikeButtons/LikeDislikeButtons.esm.js} +4 -4
  18. package/dist/components/LikeDislikeButtons/LikeDislikeButtons.esm.js.map +1 -0
  19. package/dist/components/LikeDislikeButtons/index.esm.js +2 -0
  20. package/dist/components/LikeDislikeButtons/index.esm.js.map +1 -0
  21. package/dist/components/LikeDislikeRatingsTable/LikeDislikeRatingsTable.esm.js +21 -0
  22. package/dist/components/LikeDislikeRatingsTable/LikeDislikeRatingsTable.esm.js.map +1 -0
  23. package/dist/components/LikeDislikeRatingsTable/index.esm.js +2 -0
  24. package/dist/components/LikeDislikeRatingsTable/index.esm.js.map +1 -0
  25. package/dist/{esm/StarredRatingButtons-7kGQPIqk.esm.js → components/StarredRatingButtons/StarredRatingButtons.esm.js} +4 -4
  26. package/dist/components/StarredRatingButtons/StarredRatingButtons.esm.js.map +1 -0
  27. package/dist/components/StarredRatingButtons/index.esm.js +2 -0
  28. package/dist/components/StarredRatingButtons/index.esm.js.map +1 -0
  29. package/dist/components/StarredRatingsTable/StarredRatingsTable.esm.js +19 -0
  30. package/dist/components/StarredRatingsTable/StarredRatingsTable.esm.js.map +1 -0
  31. package/dist/components/StarredRatingsTable/index.esm.js +2 -0
  32. package/dist/components/StarredRatingsTable/index.esm.js.map +1 -0
  33. package/dist/index.esm.js +3 -256
  34. package/dist/index.esm.js.map +1 -1
  35. package/dist/plugin.esm.js +146 -0
  36. package/dist/plugin.esm.js.map +1 -0
  37. package/dist/routes.esm.js +8 -0
  38. package/dist/routes.esm.js.map +1 -0
  39. package/package.json +9 -7
  40. package/dist/esm/FeedbackRatingsTable-O2SrWgAE.esm.js.map +0 -1
  41. package/dist/esm/FeedbackResponseDialog-FxuGsr7u.esm.js +0 -112
  42. package/dist/esm/FeedbackResponseDialog-FxuGsr7u.esm.js.map +0 -1
  43. package/dist/esm/LikeDislikeButtons-D7M8hiAk.esm.js.map +0 -1
  44. package/dist/esm/StarredRatingButtons-7kGQPIqk.esm.js.map +0 -1
  45. package/dist/esm/index-6WuZOQ2W.esm.js +0 -51
  46. package/dist/esm/index-6WuZOQ2W.esm.js.map +0 -1
  47. package/dist/esm/index-BNjpfNYP.esm.js +0 -30
  48. package/dist/esm/index-BNjpfNYP.esm.js.map +0 -1
  49. package/dist/esm/index-CV29yHQA.esm.js +0 -33
  50. package/dist/esm/index-CV29yHQA.esm.js.map +0 -1
  51. package/dist/esm/index-DKWcikxI.esm.js +0 -25
  52. package/dist/esm/index-DKWcikxI.esm.js.map +0 -1
  53. package/dist/esm/index-iIL-rmvF.esm.js +0 -46
  54. package/dist/esm/index-iIL-rmvF.esm.js.map +0 -1
  55. package/dist/esm/index-xB2VxWp7.esm.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StarredRatingButtons.esm.js","sources":["../../../src/components/StarredRatingButtons/StarredRatingButtons.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { stringifyEntityRef } from '@backstage/catalog-model';\nimport { Progress } from '@backstage/core-components';\nimport {\n ErrorApiError,\n errorApiRef,\n identityApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\nimport { useAsyncEntity } from '@backstage/plugin-catalog-react';\nimport IconButton from '@material-ui/core/IconButton';\nimport StarOutlineIcon from '@material-ui/icons/StarOutline';\nimport StarIcon from '@material-ui/icons/Star';\nimport React, { ReactNode, useCallback, useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport useAsyncFn from 'react-use/esm/useAsyncFn';\n\nimport { entityFeedbackApiRef } from '../../api';\nimport {\n EntityFeedbackResponse,\n FeedbackResponseDialog,\n} from '../FeedbackResponseDialog';\n\nexport enum FeedbackRatings {\n one = 1,\n two = 2,\n three = 3,\n four = 4,\n five = 5,\n}\n\n/**\n * @public\n */\nexport interface StarredRatingButtonsProps {\n feedbackDialogResponses?: EntityFeedbackResponse[];\n feedbackDialogTitle?: ReactNode;\n requestResponse?: boolean;\n requestResponseThreshold?: number;\n}\n\nexport const StarredRatingButtons = (props: StarredRatingButtonsProps) => {\n const {\n feedbackDialogResponses,\n feedbackDialogTitle,\n requestResponse = true,\n requestResponseThreshold = FeedbackRatings.two,\n } = props;\n const errorApi = useApi(errorApiRef);\n const feedbackApi = useApi(entityFeedbackApiRef);\n const identityApi = useApi(identityApiRef);\n const [rating, setRating] = useState<FeedbackRatings>();\n const [openFeedbackDialog, setOpenFeedbackDialog] = useState(false);\n const { entity, loading: loadingEntity } = useAsyncEntity();\n\n const { loading: loadingFeedback } = useAsync(async () => {\n // Wait until entity is loaded\n if (!entity) {\n return;\n }\n\n try {\n const identity = await identityApi.getBackstageIdentity();\n const prevFeedback = await feedbackApi.getRatings(\n stringifyEntityRef(entity),\n );\n\n const prevRating = prevFeedback.find(\n r => r.userRef === identity.userEntityRef,\n )?.rating;\n if (prevRating) {\n setRating(parseInt(prevRating, 10));\n }\n } catch (e) {\n errorApi.post(e as ErrorApiError);\n }\n }, [entity, feedbackApi, setRating]);\n\n const [{ loading: savingFeedback }, saveFeedback] = useAsyncFn(\n async (feedback: FeedbackRatings) => {\n try {\n await feedbackApi.recordRating(\n stringifyEntityRef(entity!),\n feedback.toString(),\n );\n setRating(feedback);\n } catch (e) {\n errorApi.post(e as ErrorApiError);\n }\n },\n [entity, feedbackApi, setRating],\n );\n\n const applyRating = useCallback(\n (feedback: FeedbackRatings) => {\n // Ignore rating if feedback is same as current\n if (feedback === rating) {\n return;\n }\n\n saveFeedback(feedback);\n if (feedback <= requestResponseThreshold && requestResponse) {\n setOpenFeedbackDialog(true);\n }\n },\n [\n rating,\n requestResponse,\n requestResponseThreshold,\n saveFeedback,\n setOpenFeedbackDialog,\n ],\n );\n\n if (loadingEntity || loadingFeedback || savingFeedback) {\n return <Progress />;\n }\n\n return (\n <>\n {Object.values(FeedbackRatings)\n .filter((o): o is number => typeof o === 'number')\n .map(starRating => (\n <IconButton\n key={starRating}\n data-testid={`entity-feedback-star-button-${starRating}`}\n onClick={() => applyRating(starRating as FeedbackRatings)}\n >\n {rating && rating >= starRating ? (\n <StarIcon fontSize=\"small\" />\n ) : (\n <StarOutlineIcon fontSize=\"small\" />\n )}\n </IconButton>\n ))}\n <FeedbackResponseDialog\n entity={entity!}\n open={openFeedbackDialog}\n onClose={() => setOpenFeedbackDialog(false)}\n feedbackDialogResponses={feedbackDialogResponses}\n feedbackDialogTitle={feedbackDialogTitle}\n />\n </>\n );\n};\n"],"names":["FeedbackRatings"],"mappings":";;;;;;;;;;;;;;AAsCY,IAAA,eAAA,qBAAAA,gBAAL,KAAA;AACL,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,SAAM,CAAN,CAAA,GAAA,KAAA,CAAA;AACA,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,SAAM,CAAN,CAAA,GAAA,KAAA,CAAA;AACA,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,WAAQ,CAAR,CAAA,GAAA,OAAA,CAAA;AACA,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,UAAO,CAAP,CAAA,GAAA,MAAA,CAAA;AACA,EAAAA,gBAAAA,CAAAA,gBAAAA,CAAA,UAAO,CAAP,CAAA,GAAA,MAAA,CAAA;AALU,EAAAA,OAAAA,gBAAAA,CAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA,EAAA;AAkBC,MAAA,oBAAA,GAAuB,CAAC,KAAqC,KAAA;AACxE,EAAM,MAAA;AAAA,IACJ,uBAAA;AAAA,IACA,mBAAA;AAAA,IACA,eAAkB,GAAA,IAAA;AAAA,IAClB,wBAA2B,GAAA,CAAA;AAAA,GACzB,GAAA,KAAA,CAAA;AACJ,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAM,MAAA,WAAA,GAAc,OAAO,oBAAoB,CAAA,CAAA;AAC/C,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA,CAAA;AACzC,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,QAA0B,EAAA,CAAA;AACtD,EAAA,MAAM,CAAC,kBAAA,EAAoB,qBAAqB,CAAA,GAAI,SAAS,KAAK,CAAA,CA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AAC,eAAgB,EAAA,EAAA,QAAA,EAAS,OAAQ,EAAA,CAAA;AAAA,GAGvC,CACH,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,sBAAA;AAAA,IAAA;AAAA,MACC,MAAA;AAAA,MACA,IAAM,EAAA,kBAAA;AAAA,MACN,OAAA,EAAS,MAAM,qBAAA,CAAsB,KAAK,CAAA;AAAA,MAC1C,uBAAA;AAAA,MACA,mBAAA;AAAA,KAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,2 @@
1
+ export { FeedbackRatings, StarredRatingButtons } from './StarredRatingButtons.esm.js';
2
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { FeedbackRatingsTable } from '../FeedbackRatingsTable/FeedbackRatingsTable.esm.js';
3
+ import { FeedbackRatings } from '../StarredRatingButtons/StarredRatingButtons.esm.js';
4
+
5
+ const StarredRatingsTable = (props) => {
6
+ const { allEntities, ownerRef, title } = props;
7
+ return /* @__PURE__ */ React.createElement(
8
+ FeedbackRatingsTable,
9
+ {
10
+ allEntities,
11
+ ownerRef,
12
+ ratingValues: Object.values(FeedbackRatings).filter((o) => typeof o === "number").map((r) => r.toString()),
13
+ title
14
+ }
15
+ );
16
+ };
17
+
18
+ export { StarredRatingsTable };
19
+ //# sourceMappingURL=StarredRatingsTable.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StarredRatingsTable.esm.js","sources":["../../../src/components/StarredRatingsTable/StarredRatingsTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 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';\n\nimport { FeedbackRatingsTable } from '../FeedbackRatingsTable';\nimport { FeedbackRatings } from '../StarredRatingButtons';\n\n/**\n * @public\n */\nexport interface StarredRatingsTableProps {\n allEntities?: boolean;\n ownerRef?: string;\n title?: string;\n}\n\nexport const StarredRatingsTable = (props: StarredRatingsTableProps) => {\n const { allEntities, ownerRef, title } = props;\n\n return (\n <FeedbackRatingsTable\n allEntities={allEntities}\n ownerRef={ownerRef}\n ratingValues={Object.values(FeedbackRatings)\n .filter(o => typeof o === 'number')\n .map(r => r.toString())}\n title={title}\n />\n );\n};\n"],"names":[],"mappings":";;;;AA8Ba,MAAA,mBAAA,GAAsB,CAAC,KAAoC,KAAA;AACtE,EAAA,MAAM,EAAE,WAAA,EAAa,QAAU,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AAEzC,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,oBAAA;AAAA,IAAA;AAAA,MACC,WAAA;AAAA,MACA,QAAA;AAAA,MACA,YAAc,EAAA,MAAA,CAAO,MAAO,CAAA,eAAe,EACxC,MAAO,CAAA,CAAA,CAAA,KAAK,OAAO,CAAA,KAAM,QAAQ,CACjC,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAA,CAAE,UAAU,CAAA;AAAA,MACxB,KAAA;AAAA,KAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,2 @@
1
+ export { StarredRatingsTable } from './StarredRatingsTable.esm.js';
2
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/index.esm.js CHANGED
@@ -1,257 +1,4 @@
1
- import { stringifyEntityRef } from '@backstage/catalog-model';
2
- import { createApiRef, createRouteRef, createPlugin, createApiFactory, discoveryApiRef, fetchApiRef, createComponentExtension, createRoutableExtension } from '@backstage/core-plugin-api';
3
- import { useAsyncEntity } from '@backstage/plugin-catalog-react';
4
- import React from 'react';
5
- import { ResponseError } from '@backstage/errors';
6
-
7
- var __defProp = Object.defineProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __publicField = (obj, key, value) => {
10
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
- return value;
12
- };
13
- class EntityFeedbackClient {
14
- constructor(options) {
15
- __publicField(this, "discoveryApi");
16
- __publicField(this, "fetchApi");
17
- this.discoveryApi = options.discoveryApi;
18
- this.fetchApi = options.fetchApi;
19
- }
20
- async getAllRatings() {
21
- const baseUrl = await this.discoveryApi.getBaseUrl("entity-feedback");
22
- const resp = await this.fetchApi.fetch(`${baseUrl}/ratings`, {
23
- method: "GET"
24
- });
25
- if (!resp.ok) {
26
- throw await ResponseError.fromResponse(resp);
27
- }
28
- return resp.json();
29
- }
30
- async getOwnedRatings(ownerRef) {
31
- const baseUrl = await this.discoveryApi.getBaseUrl("entity-feedback");
32
- const resp = await this.fetchApi.fetch(
33
- `${baseUrl}/ratings?ownerRef=${encodeURIComponent(ownerRef)}`,
34
- {
35
- method: "GET"
36
- }
37
- );
38
- if (!resp.ok) {
39
- throw await ResponseError.fromResponse(resp);
40
- }
41
- return resp.json();
42
- }
43
- async recordRating(entityRef, rating) {
44
- const baseUrl = await this.discoveryApi.getBaseUrl("entity-feedback");
45
- const resp = await this.fetchApi.fetch(
46
- `${baseUrl}/ratings/${encodeURIComponent(entityRef)}`,
47
- {
48
- headers: { "Content-Type": "application/json" },
49
- method: "POST",
50
- body: JSON.stringify({ rating })
51
- }
52
- );
53
- if (!resp.ok) {
54
- throw await ResponseError.fromResponse(resp);
55
- }
56
- }
57
- async getRatings(entityRef) {
58
- const baseUrl = await this.discoveryApi.getBaseUrl("entity-feedback");
59
- const resp = await this.fetchApi.fetch(
60
- `${baseUrl}/ratings/${encodeURIComponent(entityRef)}`,
61
- {
62
- method: "GET"
63
- }
64
- );
65
- if (!resp.ok) {
66
- throw await ResponseError.fromResponse(resp);
67
- }
68
- return resp.json();
69
- }
70
- async getRatingAggregates(entityRef) {
71
- const baseUrl = await this.discoveryApi.getBaseUrl("entity-feedback");
72
- const resp = await this.fetchApi.fetch(
73
- `${baseUrl}/ratings/${encodeURIComponent(entityRef)}/aggregate`,
74
- {
75
- method: "GET"
76
- }
77
- );
78
- if (!resp.ok) {
79
- throw await ResponseError.fromResponse(resp);
80
- }
81
- return resp.json();
82
- }
83
- async recordResponse(entityRef, response) {
84
- const baseUrl = await this.discoveryApi.getBaseUrl("entity-feedback");
85
- const resp = await this.fetchApi.fetch(
86
- `${baseUrl}/responses/${encodeURIComponent(entityRef)}`,
87
- {
88
- headers: { "Content-Type": "application/json" },
89
- method: "POST",
90
- body: JSON.stringify(response)
91
- }
92
- );
93
- if (!resp.ok) {
94
- throw await ResponseError.fromResponse(resp);
95
- }
96
- }
97
- async getResponses(entityRef) {
98
- const baseUrl = await this.discoveryApi.getBaseUrl("entity-feedback");
99
- const resp = await this.fetchApi.fetch(
100
- `${baseUrl}/responses/${encodeURIComponent(entityRef)}`,
101
- {
102
- method: "GET"
103
- }
104
- );
105
- if (!resp.ok) {
106
- throw await ResponseError.fromResponse(resp);
107
- }
108
- return resp.json();
109
- }
110
- }
111
-
112
- const entityFeedbackApiRef = createApiRef({
113
- id: "plugin.entity-feedback.service"
114
- });
115
-
116
- const rootRouteRef = createRouteRef({
117
- id: "entity-feedback"
118
- });
119
-
120
- const entityFeedbackPlugin = createPlugin({
121
- id: "entity-feedback",
122
- routes: {
123
- root: rootRouteRef
124
- },
125
- apis: [
126
- createApiFactory({
127
- api: entityFeedbackApiRef,
128
- deps: {
129
- discoveryApi: discoveryApiRef,
130
- fetchApi: fetchApiRef
131
- },
132
- factory: ({ discoveryApi, fetchApi }) => new EntityFeedbackClient({ discoveryApi, fetchApi })
133
- })
134
- ]
135
- });
136
- const LikeDislikeButtons = entityFeedbackPlugin.provide(
137
- createComponentExtension({
138
- name: "LikeDislikeButtons",
139
- component: {
140
- lazy: () => import('./esm/index-CV29yHQA.esm.js').then(
141
- (m) => m.LikeDislikeButtons
142
- )
143
- }
144
- })
145
- );
146
- const StarredRatingButtons = entityFeedbackPlugin.provide(
147
- createComponentExtension({
148
- name: "StarredRatingButtons",
149
- component: {
150
- lazy: () => import('./esm/index-BNjpfNYP.esm.js').then(
151
- (m) => m.StarredRatingButtons
152
- )
153
- }
154
- })
155
- );
156
- const FeedbackResponseDialog = entityFeedbackPlugin.provide(
157
- createComponentExtension({
158
- name: "FeedbackResponseDialog",
159
- component: {
160
- lazy: () => import('./esm/index-DKWcikxI.esm.js').then(
161
- (m) => m.FeedbackResponseDialog
162
- )
163
- }
164
- })
165
- );
166
- const EntityFeedbackResponseContent = entityFeedbackPlugin.provide(
167
- createRoutableExtension({
168
- name: "EntityFeedbackResponseContent",
169
- mountPoint: rootRouteRef,
170
- component: () => import('./esm/index-xB2VxWp7.esm.js').then(
171
- ({ FeedbackResponseTable: FeedbackResponseTable2 }) => {
172
- return () => {
173
- const { entity } = useAsyncEntity();
174
- return /* @__PURE__ */ React.createElement(
175
- FeedbackResponseTable2,
176
- {
177
- entityRef: entity ? stringifyEntityRef(entity) : ""
178
- }
179
- );
180
- };
181
- }
182
- )
183
- })
184
- );
185
- const FeedbackResponseTable = entityFeedbackPlugin.provide(
186
- createComponentExtension({
187
- name: "FeedbackResponseTable",
188
- component: {
189
- lazy: () => import('./esm/index-xB2VxWp7.esm.js').then(
190
- (m) => m.FeedbackResponseTable
191
- )
192
- }
193
- })
194
- );
195
- const EntityLikeDislikeRatingsCard = entityFeedbackPlugin.provide(
196
- createComponentExtension({
197
- name: "EntityLikeDislikeRatingsCard",
198
- component: {
199
- lazy: () => import('./esm/index-6WuZOQ2W.esm.js').then(
200
- ({ LikeDislikeRatingsTable: LikeDislikeRatingsTable2 }) => {
201
- return () => {
202
- const { entity } = useAsyncEntity();
203
- return /* @__PURE__ */ React.createElement(
204
- LikeDislikeRatingsTable2,
205
- {
206
- ownerRef: entity ? stringifyEntityRef(entity) : ""
207
- }
208
- );
209
- };
210
- }
211
- )
212
- }
213
- })
214
- );
215
- const LikeDislikeRatingsTable = entityFeedbackPlugin.provide(
216
- createComponentExtension({
217
- name: "LikeDislikeRatingsTable",
218
- component: {
219
- lazy: () => import('./esm/index-6WuZOQ2W.esm.js').then(
220
- (m) => m.LikeDislikeRatingsTable
221
- )
222
- }
223
- })
224
- );
225
- const EntityStarredRatingsCard = entityFeedbackPlugin.provide(
226
- createComponentExtension({
227
- name: "EntityStarredRatingsCard",
228
- component: {
229
- lazy: () => import('./esm/index-iIL-rmvF.esm.js').then(
230
- ({ StarredRatingsTable: StarredRatingsTable2 }) => {
231
- return () => {
232
- const { entity } = useAsyncEntity();
233
- return /* @__PURE__ */ React.createElement(
234
- StarredRatingsTable2,
235
- {
236
- ownerRef: entity ? stringifyEntityRef(entity) : ""
237
- }
238
- );
239
- };
240
- }
241
- )
242
- }
243
- })
244
- );
245
- const StarredRatingsTable = entityFeedbackPlugin.provide(
246
- createComponentExtension({
247
- name: "StarredRatingsTable",
248
- component: {
249
- lazy: () => import('./esm/index-iIL-rmvF.esm.js').then(
250
- (m) => m.StarredRatingsTable
251
- )
252
- }
253
- })
254
- );
255
-
256
- export { EntityFeedbackClient, EntityFeedbackResponseContent, EntityLikeDislikeRatingsCard, EntityStarredRatingsCard, FeedbackResponseDialog, FeedbackResponseTable, LikeDislikeButtons, LikeDislikeRatingsTable, StarredRatingButtons, StarredRatingsTable, entityFeedbackApiRef, entityFeedbackPlugin };
1
+ export { EntityFeedbackResponseContent, EntityLikeDislikeRatingsCard, EntityStarredRatingsCard, FeedbackResponseDialog, FeedbackResponseTable, LikeDislikeButtons, LikeDislikeRatingsTable, StarredRatingButtons, StarredRatingsTable, entityFeedbackPlugin } from './plugin.esm.js';
2
+ export { EntityFeedbackClient } from './api/EntityFeedbackClient.esm.js';
3
+ export { entityFeedbackApiRef } from './api/EntityFeedbackApi.esm.js';
257
4
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/api/EntityFeedbackClient.ts","../src/api/EntityFeedbackApi.ts","../src/routes.ts","../src/plugin.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport { ResponseError } from '@backstage/errors';\nimport {\n EntityRatingsData,\n FeedbackResponse,\n Rating,\n Ratings,\n} from '@backstage-community/plugin-entity-feedback-common';\n\nimport { EntityFeedbackApi } from './EntityFeedbackApi';\n\n/**\n * @public\n */\nexport class EntityFeedbackClient implements EntityFeedbackApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n\n constructor(options: { discoveryApi: DiscoveryApi; fetchApi: FetchApi }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi;\n }\n\n async getAllRatings(): Promise<EntityRatingsData[]> {\n const baseUrl = await this.discoveryApi.getBaseUrl('entity-feedback');\n const resp = await this.fetchApi.fetch(`${baseUrl}/ratings`, {\n method: 'GET',\n });\n\n if (!resp.ok) {\n throw await ResponseError.fromResponse(resp);\n }\n\n return resp.json();\n }\n\n async getOwnedRatings(ownerRef: string): Promise<EntityRatingsData[]> {\n const baseUrl = await this.discoveryApi.getBaseUrl('entity-feedback');\n const resp = await this.fetchApi.fetch(\n `${baseUrl}/ratings?ownerRef=${encodeURIComponent(ownerRef)}`,\n {\n method: 'GET',\n },\n );\n\n if (!resp.ok) {\n throw await ResponseError.fromResponse(resp);\n }\n\n return resp.json();\n }\n\n async recordRating(entityRef: string, rating: string) {\n const baseUrl = await this.discoveryApi.getBaseUrl('entity-feedback');\n const resp = await this.fetchApi.fetch(\n `${baseUrl}/ratings/${encodeURIComponent(entityRef)}`,\n {\n headers: { 'Content-Type': 'application/json' },\n method: 'POST',\n body: JSON.stringify({ rating }),\n },\n );\n\n if (!resp.ok) {\n throw await ResponseError.fromResponse(resp);\n }\n }\n\n async getRatings(entityRef: string): Promise<Omit<Rating, 'entityRef'>[]> {\n const baseUrl = await this.discoveryApi.getBaseUrl('entity-feedback');\n const resp = await this.fetchApi.fetch(\n `${baseUrl}/ratings/${encodeURIComponent(entityRef)}`,\n {\n method: 'GET',\n },\n );\n\n if (!resp.ok) {\n throw await ResponseError.fromResponse(resp);\n }\n\n return resp.json();\n }\n\n async getRatingAggregates(entityRef: string): Promise<Ratings> {\n const baseUrl = await this.discoveryApi.getBaseUrl('entity-feedback');\n const resp = await this.fetchApi.fetch(\n `${baseUrl}/ratings/${encodeURIComponent(entityRef)}/aggregate`,\n {\n method: 'GET',\n },\n );\n\n if (!resp.ok) {\n throw await ResponseError.fromResponse(resp);\n }\n\n return resp.json();\n }\n\n async recordResponse(\n entityRef: string,\n response: Omit<FeedbackResponse, 'entityRef' | 'userRef'>,\n ) {\n const baseUrl = await this.discoveryApi.getBaseUrl('entity-feedback');\n const resp = await this.fetchApi.fetch(\n `${baseUrl}/responses/${encodeURIComponent(entityRef)}`,\n {\n headers: { 'Content-Type': 'application/json' },\n method: 'POST',\n body: JSON.stringify(response),\n },\n );\n\n if (!resp.ok) {\n throw await ResponseError.fromResponse(resp);\n }\n }\n\n async getResponses(\n entityRef: string,\n ): Promise<Omit<FeedbackResponse, 'entityRef'>[]> {\n const baseUrl = await this.discoveryApi.getBaseUrl('entity-feedback');\n const resp = await this.fetchApi.fetch(\n `${baseUrl}/responses/${encodeURIComponent(entityRef)}`,\n {\n method: 'GET',\n },\n );\n\n if (!resp.ok) {\n throw await ResponseError.fromResponse(resp);\n }\n\n return resp.json();\n }\n}\n","/*\n * Copyright 2023 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 { createApiRef } from '@backstage/core-plugin-api';\nimport {\n EntityRatingsData,\n FeedbackResponse,\n Rating,\n Ratings,\n} from '@backstage-community/plugin-entity-feedback-common';\n\n/**\n * @public\n */\nexport const entityFeedbackApiRef = createApiRef<EntityFeedbackApi>({\n id: 'plugin.entity-feedback.service',\n});\n\n/**\n * @public\n */\nexport interface EntityFeedbackApi {\n getAllRatings(): Promise<EntityRatingsData[]>;\n\n getOwnedRatings(ownerRef: string): Promise<EntityRatingsData[]>;\n\n recordRating(entityRef: string, rating: string): Promise<void>;\n\n getRatings(entityRef: string): Promise<Omit<Rating, 'entityRef'>[]>;\n\n /**\n * Returns anonymized aggregated results for one entityRef\n */\n getRatingAggregates(entityRef: string): Promise<Ratings>;\n\n recordResponse(\n entityRef: string,\n response: Omit<FeedbackResponse, 'entityRef' | 'userRef'>,\n ): Promise<void>;\n\n getResponses(\n entityRef: string,\n ): Promise<Omit<FeedbackResponse, 'entityRef'>[]>;\n}\n","/*\n * Copyright 2023 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 { createRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'entity-feedback',\n});\n","/*\n * Copyright 2023 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 { stringifyEntityRef } from '@backstage/catalog-model';\nimport {\n createApiFactory,\n createComponentExtension,\n createPlugin,\n createRoutableExtension,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\nimport { useAsyncEntity } from '@backstage/plugin-catalog-react';\nimport React from 'react';\n\nimport { entityFeedbackApiRef, EntityFeedbackClient } from './api';\nimport { rootRouteRef } from './routes';\n\n/**\n * @public\n */\nexport const entityFeedbackPlugin = createPlugin({\n id: 'entity-feedback',\n routes: {\n root: rootRouteRef,\n },\n apis: [\n createApiFactory({\n api: entityFeedbackApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n fetchApi: fetchApiRef,\n },\n factory: ({ discoveryApi, fetchApi }) =>\n new EntityFeedbackClient({ discoveryApi, fetchApi }),\n }),\n ],\n});\n\n/**\n * @public\n */\nexport const LikeDislikeButtons = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'LikeDislikeButtons',\n component: {\n lazy: () =>\n import('./components/LikeDislikeButtons').then(\n m => m.LikeDislikeButtons,\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const StarredRatingButtons = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'StarredRatingButtons',\n component: {\n lazy: () =>\n import('./components/StarredRatingButtons').then(\n m => m.StarredRatingButtons,\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const FeedbackResponseDialog = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'FeedbackResponseDialog',\n component: {\n lazy: () =>\n import('./components/FeedbackResponseDialog').then(\n m => m.FeedbackResponseDialog,\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const EntityFeedbackResponseContent = entityFeedbackPlugin.provide(\n createRoutableExtension({\n name: 'EntityFeedbackResponseContent',\n mountPoint: rootRouteRef,\n component: () =>\n import('./components/FeedbackResponseTable').then(\n ({ FeedbackResponseTable }) => {\n return () => {\n const { entity } = useAsyncEntity();\n return (\n <FeedbackResponseTable\n entityRef={entity ? stringifyEntityRef(entity) : ''}\n />\n );\n };\n },\n ),\n }),\n);\n\n/**\n * @public\n */\nexport const FeedbackResponseTable = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'FeedbackResponseTable',\n component: {\n lazy: () =>\n import('./components/FeedbackResponseTable').then(\n m => m.FeedbackResponseTable,\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const EntityLikeDislikeRatingsCard = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'EntityLikeDislikeRatingsCard',\n component: {\n lazy: () =>\n import('./components/LikeDislikeRatingsTable').then(\n ({ LikeDislikeRatingsTable }) => {\n return () => {\n const { entity } = useAsyncEntity();\n return (\n <LikeDislikeRatingsTable\n ownerRef={entity ? stringifyEntityRef(entity) : ''}\n />\n );\n };\n },\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const LikeDislikeRatingsTable = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'LikeDislikeRatingsTable',\n component: {\n lazy: () =>\n import('./components/LikeDislikeRatingsTable').then(\n m => m.LikeDislikeRatingsTable,\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const EntityStarredRatingsCard = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'EntityStarredRatingsCard',\n component: {\n lazy: () =>\n import('./components/StarredRatingsTable').then(\n ({ StarredRatingsTable }) => {\n return () => {\n const { entity } = useAsyncEntity();\n return (\n <StarredRatingsTable\n ownerRef={entity ? stringifyEntityRef(entity) : ''}\n />\n );\n };\n },\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const StarredRatingsTable = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'StarredRatingsTable',\n component: {\n lazy: () =>\n import('./components/StarredRatingsTable').then(\n m => m.StarredRatingsTable,\n ),\n },\n }),\n);\n"],"names":["FeedbackResponseTable","LikeDislikeRatingsTable","StarredRatingsTable"],"mappings":";;;;;;;;;;;;AA8BO,MAAM,oBAAkD,CAAA;AAAA,EAI7D,YAAY,OAA6D,EAAA;AAHzE,IAAiB,aAAA,CAAA,IAAA,EAAA,cAAA,CAAA,CAAA;AACjB,IAAiB,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA,CAAA;AAGf,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA,CAAA;AAC5B,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA,CAAA;AAAA,GAC1B;AAAA,EAEA,MAAM,aAA8C,GAAA;AAClD,IAAA,MAAM,OAAU,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,WAAW,iBAAiB,CAAA,CAAA;AACpE,IAAA,MAAM,OAAO,MAAM,IAAA,CAAK,SAAS,KAAM,CAAA,CAAA,EAAG,OAAO,CAAY,QAAA,CAAA,EAAA;AAAA,MAC3D,MAAQ,EAAA,KAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAI,IAAA,CAAC,KAAK,EAAI,EAAA;AACZ,MAAM,MAAA,MAAM,aAAc,CAAA,YAAA,CAAa,IAAI,CAAA,CAAA;AAAA,KAC7C;AAEA,IAAA,OAAO,KAAK,IAAK,EAAA,CAAA;AAAA,GACnB;AAAA,EAEA,MAAM,gBAAgB,QAAgD,EAAA;AACpE,IAAA,MAAM,OAAU,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,WAAW,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OAAA;AAAA,EAC1D,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,yBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,6BAAsC,CAAE,CAAA,IAAA;AAAA,QAC7C,OAAK,CAAE,CAAA,uBAAA;AAAA,OACT;AAAA,KACJ;AAAA,GACD,CAAA;AACH,EAAA;AAKO,MAAM,2BAA2B,oBAAqB,CAAA,OAAA;AAAA,EAC3D,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,0BAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,6BAAkC,CAAE,CAAA,IAAA;AAAA,QACzC,CAAC,EAAE,mBAAAC,EAAAA,oBAAAA,EAA0B,KAAA;AAC3B,UAAA,OAAO,MAAM;AACX,YAAM,MAAA,EAAE,MAAO,EAAA,GAAI,cAAe,EAAA,CAAA;AAClC,YACE,uBAAA,KAAA,CAAA,aAAA;AAAA,cAACA,oBAAAA;AAAA,cAAA;AAAA,gBACC,QAAU,EAAA,MAAA,GAAS,kBAAmB,CAAA,MAAM,CAAI,GAAA,EAAA;AAAA,eAAA;AAAA,aAClD,CAAA;AAAA,WAEJ,CAAA;AAAA,SACF;AAAA,OACF;AAAA,KACJ;AAAA,GACD,CAAA;AACH,EAAA;AAKO,MAAM,sBAAsB,oBAAqB,CAAA,OAAA;AAAA,EACtD,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,qBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,6BAAkC,CAAE,CAAA,IAAA;AAAA,QACzC,OAAK,CAAE,CAAA,mBAAA;AAAA,OACT;AAAA,KACJ;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,146 @@
1
+ import { stringifyEntityRef } from '@backstage/catalog-model';
2
+ import { createPlugin, createApiFactory, discoveryApiRef, fetchApiRef, createComponentExtension, createRoutableExtension } from '@backstage/core-plugin-api';
3
+ import { useAsyncEntity } from '@backstage/plugin-catalog-react';
4
+ import React from 'react';
5
+ import { EntityFeedbackClient } from './api/EntityFeedbackClient.esm.js';
6
+ import { entityFeedbackApiRef } from './api/EntityFeedbackApi.esm.js';
7
+ import { rootRouteRef } from './routes.esm.js';
8
+
9
+ const entityFeedbackPlugin = createPlugin({
10
+ id: "entity-feedback",
11
+ routes: {
12
+ root: rootRouteRef
13
+ },
14
+ apis: [
15
+ createApiFactory({
16
+ api: entityFeedbackApiRef,
17
+ deps: {
18
+ discoveryApi: discoveryApiRef,
19
+ fetchApi: fetchApiRef
20
+ },
21
+ factory: ({ discoveryApi, fetchApi }) => new EntityFeedbackClient({ discoveryApi, fetchApi })
22
+ })
23
+ ]
24
+ });
25
+ const LikeDislikeButtons = entityFeedbackPlugin.provide(
26
+ createComponentExtension({
27
+ name: "LikeDislikeButtons",
28
+ component: {
29
+ lazy: () => import('./components/LikeDislikeButtons/index.esm.js').then(
30
+ (m) => m.LikeDislikeButtons
31
+ )
32
+ }
33
+ })
34
+ );
35
+ const StarredRatingButtons = entityFeedbackPlugin.provide(
36
+ createComponentExtension({
37
+ name: "StarredRatingButtons",
38
+ component: {
39
+ lazy: () => import('./components/StarredRatingButtons/index.esm.js').then(
40
+ (m) => m.StarredRatingButtons
41
+ )
42
+ }
43
+ })
44
+ );
45
+ const FeedbackResponseDialog = entityFeedbackPlugin.provide(
46
+ createComponentExtension({
47
+ name: "FeedbackResponseDialog",
48
+ component: {
49
+ lazy: () => import('./components/FeedbackResponseDialog/index.esm.js').then(
50
+ (m) => m.FeedbackResponseDialog
51
+ )
52
+ }
53
+ })
54
+ );
55
+ const EntityFeedbackResponseContent = entityFeedbackPlugin.provide(
56
+ createRoutableExtension({
57
+ name: "EntityFeedbackResponseContent",
58
+ mountPoint: rootRouteRef,
59
+ component: () => import('./components/FeedbackResponseTable/index.esm.js').then(
60
+ ({ FeedbackResponseTable: FeedbackResponseTable2 }) => {
61
+ return () => {
62
+ const { entity } = useAsyncEntity();
63
+ return /* @__PURE__ */ React.createElement(
64
+ FeedbackResponseTable2,
65
+ {
66
+ entityRef: entity ? stringifyEntityRef(entity) : ""
67
+ }
68
+ );
69
+ };
70
+ }
71
+ )
72
+ })
73
+ );
74
+ const FeedbackResponseTable = entityFeedbackPlugin.provide(
75
+ createComponentExtension({
76
+ name: "FeedbackResponseTable",
77
+ component: {
78
+ lazy: () => import('./components/FeedbackResponseTable/index.esm.js').then(
79
+ (m) => m.FeedbackResponseTable
80
+ )
81
+ }
82
+ })
83
+ );
84
+ const EntityLikeDislikeRatingsCard = entityFeedbackPlugin.provide(
85
+ createComponentExtension({
86
+ name: "EntityLikeDislikeRatingsCard",
87
+ component: {
88
+ lazy: () => import('./components/LikeDislikeRatingsTable/index.esm.js').then(
89
+ ({ LikeDislikeRatingsTable: LikeDislikeRatingsTable2 }) => {
90
+ return () => {
91
+ const { entity } = useAsyncEntity();
92
+ return /* @__PURE__ */ React.createElement(
93
+ LikeDislikeRatingsTable2,
94
+ {
95
+ ownerRef: entity ? stringifyEntityRef(entity) : ""
96
+ }
97
+ );
98
+ };
99
+ }
100
+ )
101
+ }
102
+ })
103
+ );
104
+ const LikeDislikeRatingsTable = entityFeedbackPlugin.provide(
105
+ createComponentExtension({
106
+ name: "LikeDislikeRatingsTable",
107
+ component: {
108
+ lazy: () => import('./components/LikeDislikeRatingsTable/index.esm.js').then(
109
+ (m) => m.LikeDislikeRatingsTable
110
+ )
111
+ }
112
+ })
113
+ );
114
+ const EntityStarredRatingsCard = entityFeedbackPlugin.provide(
115
+ createComponentExtension({
116
+ name: "EntityStarredRatingsCard",
117
+ component: {
118
+ lazy: () => import('./components/StarredRatingsTable/index.esm.js').then(
119
+ ({ StarredRatingsTable: StarredRatingsTable2 }) => {
120
+ return () => {
121
+ const { entity } = useAsyncEntity();
122
+ return /* @__PURE__ */ React.createElement(
123
+ StarredRatingsTable2,
124
+ {
125
+ ownerRef: entity ? stringifyEntityRef(entity) : ""
126
+ }
127
+ );
128
+ };
129
+ }
130
+ )
131
+ }
132
+ })
133
+ );
134
+ const StarredRatingsTable = entityFeedbackPlugin.provide(
135
+ createComponentExtension({
136
+ name: "StarredRatingsTable",
137
+ component: {
138
+ lazy: () => import('./components/StarredRatingsTable/index.esm.js').then(
139
+ (m) => m.StarredRatingsTable
140
+ )
141
+ }
142
+ })
143
+ );
144
+
145
+ export { EntityFeedbackResponseContent, EntityLikeDislikeRatingsCard, EntityStarredRatingsCard, FeedbackResponseDialog, FeedbackResponseTable, LikeDislikeButtons, LikeDislikeRatingsTable, StarredRatingButtons, StarredRatingsTable, entityFeedbackPlugin };
146
+ //# sourceMappingURL=plugin.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.esm.js","sources":["../src/plugin.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { stringifyEntityRef } from '@backstage/catalog-model';\nimport {\n createApiFactory,\n createComponentExtension,\n createPlugin,\n createRoutableExtension,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\nimport { useAsyncEntity } from '@backstage/plugin-catalog-react';\nimport React from 'react';\n\nimport { entityFeedbackApiRef, EntityFeedbackClient } from './api';\nimport { rootRouteRef } from './routes';\n\n/**\n * @public\n */\nexport const entityFeedbackPlugin = createPlugin({\n id: 'entity-feedback',\n routes: {\n root: rootRouteRef,\n },\n apis: [\n createApiFactory({\n api: entityFeedbackApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n fetchApi: fetchApiRef,\n },\n factory: ({ discoveryApi, fetchApi }) =>\n new EntityFeedbackClient({ discoveryApi, fetchApi }),\n }),\n ],\n});\n\n/**\n * @public\n */\nexport const LikeDislikeButtons = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'LikeDislikeButtons',\n component: {\n lazy: () =>\n import('./components/LikeDislikeButtons').then(\n m => m.LikeDislikeButtons,\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const StarredRatingButtons = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'StarredRatingButtons',\n component: {\n lazy: () =>\n import('./components/StarredRatingButtons').then(\n m => m.StarredRatingButtons,\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const FeedbackResponseDialog = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'FeedbackResponseDialog',\n component: {\n lazy: () =>\n import('./components/FeedbackResponseDialog').then(\n m => m.FeedbackResponseDialog,\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const EntityFeedbackResponseContent = entityFeedbackPlugin.provide(\n createRoutableExtension({\n name: 'EntityFeedbackResponseContent',\n mountPoint: rootRouteRef,\n component: () =>\n import('./components/FeedbackResponseTable').then(\n ({ FeedbackResponseTable }) => {\n return () => {\n const { entity } = useAsyncEntity();\n return (\n <FeedbackResponseTable\n entityRef={entity ? stringifyEntityRef(entity) : ''}\n />\n );\n };\n },\n ),\n }),\n);\n\n/**\n * @public\n */\nexport const FeedbackResponseTable = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'FeedbackResponseTable',\n component: {\n lazy: () =>\n import('./components/FeedbackResponseTable').then(\n m => m.FeedbackResponseTable,\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const EntityLikeDislikeRatingsCard = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'EntityLikeDislikeRatingsCard',\n component: {\n lazy: () =>\n import('./components/LikeDislikeRatingsTable').then(\n ({ LikeDislikeRatingsTable }) => {\n return () => {\n const { entity } = useAsyncEntity();\n return (\n <LikeDislikeRatingsTable\n ownerRef={entity ? stringifyEntityRef(entity) : ''}\n />\n );\n };\n },\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const LikeDislikeRatingsTable = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'LikeDislikeRatingsTable',\n component: {\n lazy: () =>\n import('./components/LikeDislikeRatingsTable').then(\n m => m.LikeDislikeRatingsTable,\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const EntityStarredRatingsCard = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'EntityStarredRatingsCard',\n component: {\n lazy: () =>\n import('./components/StarredRatingsTable').then(\n ({ StarredRatingsTable }) => {\n return () => {\n const { entity } = useAsyncEntity();\n return (\n <StarredRatingsTable\n ownerRef={entity ? stringifyEntityRef(entity) : ''}\n />\n );\n };\n },\n ),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const StarredRatingsTable = entityFeedbackPlugin.provide(\n createComponentExtension({\n name: 'StarredRatingsTable',\n component: {\n lazy: () =>\n import('./components/StarredRatingsTable').then(\n m => m.StarredRatingsTable,\n ),\n },\n }),\n);\n"],"names":["FeedbackResponseTable","LikeDislikeRatingsTable","StarredRatingsTable"],"mappings":";;;;;;;;AAkCO,MAAM,uBAAuB,YAAa,CAAA;AAAA,EAC/C,EAAI,EAAA,iBAAA;AAAA,EACJ,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,YAAA;AAAA,GACR;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,oBAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,YAAc,EAAA,eAAA;AAAA,QACd,QAAU,EAAA,WAAA;AAAA,OACZ;AAAA,MACA,OAAA,EAAS,CAAC,EAAE,YAAc,EAAA,QAAA,EACxB,KAAA,IAAI,oBAAqB,CAAA,EAAE,YAAc,EAAA,QAAA,EAAU,CAAA;AAAA,KACtD,CAAA;AAAA,GACH;AACF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CAAE,CAAA,uBAAA;AAAA,OACT;AAAA,KACJ;AAAA,GACD,CAAA;AACH,EAAA;AAKO,MAAM,2BAA2B,oBAAqB,CAAA,OAAA;AAAA,EAC3D,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,0BAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,+CAAkC,CAAE,CAAA,IAAA;AAAA,QACzC,CAAC,EAAE,mBAAAC,EAAAA,oBAAAA,EAA0B,KAAA;AAC3B,UAAA,OAAO,MAAM;AACX,YAAM,MAAA,EAAE,MAAO,EAAA,GAAI,cAAe,EAAA,CAAA;AAClC,YACE,uBAAA,KAAA,CAAA,aAAA;AAAA,cAACA,oBAAAA;AAAA,cAAA;AAAA,gBACC,QAAU,EAAA,MAAA,GAAS,kBAAmB,CAAA,MAAM,CAAI,GAAA,EAAA;AAAA,eAAA;AAAA,aAClD,CAAA;AAAA,WAEJ,CAAA;AAAA,SACF;AAAA,OACF;AAAA,KACJ;AAAA,GACD,CAAA;AACH,EAAA;AAKO,MAAM,sBAAsB,oBAAqB,CAAA,OAAA;AAAA,EACtD,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,qBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,+CAAkC,CAAE,CAAA,IAAA;AAAA,QACzC,OAAK,CAAE,CAAA,mBAAA;AAAA,OACT;AAAA,KACJ;AAAA,GACD,CAAA;AACH;;;;"}
@@ -0,0 +1,8 @@
1
+ import { createRouteRef } from '@backstage/core-plugin-api';
2
+
3
+ const rootRouteRef = createRouteRef({
4
+ id: "entity-feedback"
5
+ });
6
+
7
+ export { rootRouteRef };
8
+ //# sourceMappingURL=routes.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.esm.js","sources":["../src/routes.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { createRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'entity-feedback',\n});\n"],"names":[],"mappings":";;AAkBO,MAAM,eAAe,cAAe,CAAA;AAAA,EACzC,EAAI,EAAA,iBAAA;AACN,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-entity-feedback",
3
- "version": "0.2.18",
3
+ "version": "0.3.0",
4
4
  "backstage": {
5
5
  "role": "frontend-plugin"
6
6
  },
@@ -32,20 +32,22 @@
32
32
  "test": "backstage-cli package test"
33
33
  },
34
34
  "dependencies": {
35
- "@backstage-community/plugin-entity-feedback-common": "^0.1.4",
36
- "@backstage/catalog-model": "^1.4.5",
37
- "@backstage/core-components": "^0.14.4",
35
+ "@backstage-community/plugin-entity-feedback-common": "^0.1.5",
36
+ "@backstage/catalog-model": "^1.5.0",
37
+ "@backstage/core-components": "^0.14.7",
38
38
  "@backstage/core-plugin-api": "^1.9.2",
39
39
  "@backstage/errors": "^1.2.4",
40
- "@backstage/plugin-catalog-react": "^1.11.3",
40
+ "@backstage/plugin-catalog-react": "^1.12.0",
41
41
  "@material-ui/core": "^4.9.13",
42
42
  "@material-ui/icons": "^4.9.1",
43
43
  "@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
44
44
  "react-use": "^17.2.4"
45
45
  },
46
46
  "devDependencies": {
47
- "@backstage/cli": "^0.26.3",
48
- "@backstage/test-utils": "^1.5.4",
47
+ "@backstage/cli": "^0.26.5",
48
+ "@backstage/dev-utils": "^1.0.32",
49
+ "@backstage/plugin-catalog": "^1.20.0",
50
+ "@backstage/test-utils": "^1.5.5",
49
51
  "@testing-library/dom": "^10.0.0",
50
52
  "@testing-library/jest-dom": "^6.0.0",
51
53
  "@testing-library/react": "^15.0.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"FeedbackRatingsTable-O2SrWgAE.esm.js","sources":["../../src/components/FeedbackRatingsTable/FeedbackRatingsTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { parseEntityRef } from '@backstage/catalog-model';\nimport { ErrorPanel, SubvalueCell, Table } from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { EntityRefLink } from '@backstage/plugin-catalog-react';\nimport { EntityRatingsData } from '@backstage-community/plugin-entity-feedback-common';\nimport React from 'react';\nimport useAsync from 'react-use/esm/useAsync';\n\nimport { entityFeedbackApiRef } from '../../api';\n\ninterface FeedbackRatingsTableProps {\n allEntities?: boolean;\n ownerRef?: string;\n ratingValues: string[];\n title?: string;\n}\n\nexport const FeedbackRatingsTable = (props: FeedbackRatingsTableProps) => {\n const {\n allEntities,\n ownerRef,\n ratingValues,\n title = 'Entity Ratings',\n } = props;\n const feedbackApi = useApi(entityFeedbackApiRef);\n\n const {\n error,\n loading,\n value: ratings,\n } = useAsync(async () => {\n if (allEntities) {\n return feedbackApi.getAllRatings();\n }\n\n if (!ownerRef) {\n return [];\n }\n\n return feedbackApi.getOwnedRatings(ownerRef);\n }, [allEntities, feedbackApi, ownerRef]);\n\n const columns = [\n { title: 'Title', field: 'entityTitle', hidden: true, searchable: true },\n {\n title: 'Entity',\n field: 'entityRef',\n highlight: true,\n customSort: (a: EntityRatingsData, b: EntityRatingsData) => {\n const titleA = a.entityTitle ?? parseEntityRef(a.entityRef).name;\n const titleB = b.entityTitle ?? parseEntityRef(b.entityRef).name;\n return titleA.localeCompare(titleB);\n },\n render: (rating: EntityRatingsData) => {\n const compoundRef = parseEntityRef(rating.entityRef);\n return (\n <SubvalueCell\n value={\n <EntityRefLink\n entityRef={rating.entityRef}\n defaultKind={compoundRef.kind}\n title={rating.entityTitle}\n />\n }\n subvalue={compoundRef.kind}\n />\n );\n },\n },\n ...ratingValues.map(ratingVal => ({\n title: ratingVal,\n field: `ratings.${ratingVal}`,\n })),\n ];\n\n // Exclude entities that don't have applicable ratings\n const ratingsRows = ratings?.filter(r =>\n Object.keys(r.ratings).some(v => ratingValues.includes(v)),\n );\n\n if (error) {\n return (\n <ErrorPanel\n defaultExpanded\n title=\"Failed to load feedback ratings\"\n error={error}\n />\n );\n }\n\n return (\n <Table<EntityRatingsData>\n columns={columns}\n data={ratingsRows ?? []}\n isLoading={loading}\n options={{\n emptyRowsWhenPaging: false,\n loadingType: 'linear',\n pageSize: 20,\n pageSizeOptions: [20, 50, 100],\n paging: true,\n showEmptyDataSourceMessage: !loading,\n }}\n title={title}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAiCa,MAAA,oBAAA,GAAuB,CAAC,KAAqC,KAAA;AACxE,EAAM,MAAA;AAAA,IACJ,WAAA;AAAA,IACA,QAAA;AAAA,IACA,YAAA;AAAA,IACA,KAAQ,GAAA,gBAAA;AAAA,GACN,GAAA,KAAA,CAAA;AACJ,EAAM,MAAA,WAAA,GAAc,OAAO,oBAAoB,CAAA,CAAA;AAE/C,EAAM,MAAA;AAAA,IACJ,KAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAO,EAAA,OAAA;AAAA,GACT,GAAI,SAAS,YAAY;AACvB,IAAA,IAAI,WAAa,EAAA;AACf,MAAA,OAAO,YAAY,aAAc,EAAA,CAAA;AAAA,KACnC;AAEA,IAA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