diff --git a/.changeset/cyan-toes-repeat.md b/.changeset/cyan-toes-repeat.md new file mode 100644 index 0000000000..7963e0cb36 --- /dev/null +++ b/.changeset/cyan-toes-repeat.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-entity-feedback-backend': patch +--- + +Add in description for 400 response when encountering an invalid rating request diff --git a/.changeset/perfect-shoes-arrive.md b/.changeset/perfect-shoes-arrive.md new file mode 100644 index 0000000000..93862df24d --- /dev/null +++ b/.changeset/perfect-shoes-arrive.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-entity-feedback': patch +--- + +Remove empty Chip in `FeedbackResponseTable.tsx` when there is no response, and fix typo in Feedback Dialog Box. diff --git a/plugins/entity-feedback-backend/package.json b/plugins/entity-feedback-backend/package.json index 8906b52aae..b249cefcf6 100644 --- a/plugins/entity-feedback-backend/package.json +++ b/plugins/entity-feedback-backend/package.json @@ -33,6 +33,7 @@ "@backstage/catalog-client": "workspace:^", "@backstage/catalog-model": "workspace:^", "@backstage/config": "workspace:^", + "@backstage/errors": "workspace:^", "@backstage/plugin-auth-node": "workspace:^", "@backstage/plugin-entity-feedback-common": "workspace:^", "@types/express": "*", diff --git a/plugins/entity-feedback-backend/src/service/router.ts b/plugins/entity-feedback-backend/src/service/router.ts index 7cf89bfd5c..8d8cb0d600 100644 --- a/plugins/entity-feedback-backend/src/service/router.ts +++ b/plugins/entity-feedback-backend/src/service/router.ts @@ -28,6 +28,7 @@ import { EntityRatingsData, Ratings, } from '@backstage/plugin-entity-feedback-common'; +import { InputError } from '@backstage/errors'; import express from 'express'; import Router from 'express-promise-router'; import { Logger } from 'winston'; @@ -138,11 +139,9 @@ export async function createRouter( const rating = req.body.rating; if (!rating) { - logger.warn( + throw new InputError( `Can't save rating because there is not enough info: user=${credentials.principal.userEntityRef}, rating=${rating}`, ); - res.status(400).end(); - return; } await dbHandler.recordRating({ diff --git a/plugins/entity-feedback/src/components/FeedbackResponseDialog/FeedbackResponseDialog.tsx b/plugins/entity-feedback/src/components/FeedbackResponseDialog/FeedbackResponseDialog.tsx index c3f935e432..6bd4510d3e 100644 --- a/plugins/entity-feedback/src/components/FeedbackResponseDialog/FeedbackResponseDialog.tsx +++ b/plugins/entity-feedback/src/components/FeedbackResponseDialog/FeedbackResponseDialog.tsx @@ -108,7 +108,7 @@ export const FeedbackResponseDialog = (props: FeedbackResponseDialogProps) => { {feedbackDialogTitle} - Choose all that applies + Choose all that apply {feedbackDialogResponses.map(response => ( { width: '35%', render: (response: ResponseRow) => ( <> - {response.response?.split(',').map(res => ( - - ))} + {(response.response || '') + .split(',') + .map(v => v.trim()) // removes whitespace + .filter(Boolean) // removes accidental empty entries + .map(res => ( + + ))} ), }, diff --git a/yarn.lock b/yarn.lock index fafc485f01..840fed8cd6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6522,6 +6522,7 @@ __metadata: "@backstage/catalog-model": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" + "@backstage/errors": "workspace:^" "@backstage/plugin-auth-node": "workspace:^" "@backstage/plugin-entity-feedback-common": "workspace:^" "@types/express": "*"