backstage / community-plugins

Community plugins for Backstage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸš€ Entity Feedback Plugin: Providing multiple feedbacks per entity

mbrettschneider opened this issue Β· comments

Plugin Name

Entity Feedback Plugin

πŸ”– Feature description

It might be that a user wants to provide multiple feedbacks. Currently, the old feedback gets overwritten. Instead, it should be listed as an additional feedback.

🎀 Context

In my use-case, I would expect that entities could have multiple issues, found by one user in multiple usages of the entity.

✌️ Possible Implementation

No response

πŸ‘€ Have you spent some time to check if this feature request has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

Are you willing to submit PR?

No, I don't have time to work on this right now

Thanks for requesting this issue - I think it makes sense to allow this as an option for configuring this plugin.

I think this can be supported by making a simple change to the current ratings components:

const { loading: loadingFeedback } = useAsync(async () => {
// Wait until entity is loaded
if (!entity) {
return;
}
try {
const identity = await identityApi.getBackstageIdentity();
const prevFeedback = await feedbackApi.getRatings(
stringifyEntityRef(entity),
);
setRating(
(prevFeedback.find(r => r.userRef === identity.userEntityRef)?.rating ??
rating) as FeedbackRatings,
);
} catch (e) {
errorApi.post(e as ErrorApiError);
}
}, [entity, feedbackApi, setRating]);

const { loading: loadingFeedback } = useAsync(async () => {
// Wait until entity is loaded
if (!entity) {
return;
}
try {
const identity = await identityApi.getBackstageIdentity();
const prevFeedback = await feedbackApi.getRatings(
stringifyEntityRef(entity),
);
const prevRating = prevFeedback.find(
r => r.userRef === identity.userEntityRef,
)?.rating;
if (prevRating) {
setRating(parseInt(prevRating, 10));
}
} catch (e) {
errorApi.post(e as ErrorApiError);
}
}, [entity, feedbackApi, setRating]);

A component prop can probably be added to disable the hooks above - something like showPreviousRating = false, defaulted to true to preserve current behavior. This should allow a user to enter a new rating every time they visit the entity since the backend should already handle persisting each submission appropriately timestamped.

It should be a relatively straightforward change if someone is willing to contribute this enhancement πŸ™‚