improve variable names and update docs

Signed-off-by: nikolar <reyna.nikolayev@autodesk.com>
This commit is contained in:
nikolar
2024-01-24 09:56:23 -08:00
parent 20c445b18f
commit 8ac7843c7e
3 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
<!-- @backstage/plugin-entity-feedback -->
Add in logic to require comments for specific feedback responses
Add in logic to link the feedback comment box to specific feedback responses
const requireComments = (
<Grid container spacing={3} alignItems="stretch">
...
+1 -1
View File
@@ -90,7 +90,7 @@ const overviewContent = (
</Grid>
);
// Require comments for specific feedback responses
// Link the feedback comment box to specific feedback responses
const overviewContent = (
<Grid container spacing={3} alignItems="stretch">
...
@@ -97,7 +97,7 @@ export const FeedbackResponseDialog = (props: FeedbackResponseDialogProps) => {
.filter(r => r.mustComment)
.map(r => r.id);
const isMandatedBoxChecked = () => {
const isLinkedBoxChecked = () => {
const checkedBoxes = Object.keys(responseSelections).filter(
id => responseSelections[id],
);
@@ -106,7 +106,7 @@ export const FeedbackResponseDialog = (props: FeedbackResponseDialogProps) => {
const [{ loading: saving }, saveResponse] = useAsyncFn(async () => {
if (requireComments.length > 0) {
if (comments.length === 0 && isMandatedBoxChecked()) {
if (comments.length === 0 && isLinkedBoxChecked()) {
alertApi.post({
message:
'The selected option(s) require a comment. Please provide a comment.',
@@ -114,7 +114,7 @@ export const FeedbackResponseDialog = (props: FeedbackResponseDialogProps) => {
});
return;
}
if (comments.length > 0 && !isMandatedBoxChecked()) {
if (comments.length > 0 && !isLinkedBoxChecked()) {
alertApi.post({
message: 'Please select the option(s) that require a comment.',
severity: 'info',
@@ -136,7 +136,7 @@ export const FeedbackResponseDialog = (props: FeedbackResponseDialogProps) => {
}
}, [comments, consent, entity, feedbackApi, onClose, responseSelections]);
const selectMandatedBox = (res: boolean) => {
const selectLinkedBox = (res: boolean) => {
const newResponseSelections = { ...responseSelections };
requireComments.forEach(id => newResponseSelections[id] === res);
setResponseSelections(newResponseSelections);
@@ -145,9 +145,9 @@ export const FeedbackResponseDialog = (props: FeedbackResponseDialogProps) => {
const verifyComments = (e: any) => {
setComments(e.target.value);
if (requireComments.length > 0) {
selectMandatedBox(true);
selectLinkedBox(true);
if (e.target.value.length === 0) {
selectMandatedBox(false);
selectLinkedBox(false);
}
}
};