Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Dynamic assess button and view assessments page #1325

Merged
merged 1 commit into from
Sep 11, 2023

Conversation

ibolton336
Copy link
Member

@ibolton336 ibolton336 commented Aug 31, 2023

Resolves #1299 #1301 #1300

  • Moves QuestionsTable and AnswersTable components to shared root components directory
  • Adds assessment summary page - this page is reached via the "View" button on the assessment actions page. It shows the current assessment's answers by using the shared "QuestionnaireSummary" component which is also used by the questionnaire page referenced by assessment-settings-page in the admin view. The QuestionnaireSummary covers both cases with a conditional option for showing the answer key.
  • Adds Dynamic assessment actions button for view/take/retake/continue actions
  • Adds delete assessment button and functionality.
  • Add table for archived questionnaires in assessment actions page

Note: Will need to uncomment these lines for testing https://github.com/konveyor/tackle2-ui/pull/1325/files#diff-b0560fce9e9111641c87e7daa6648f4d60fd0b620522ff84501ec5dadd7f4128R38-R51

@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Patch coverage: 27.77% and project coverage change: -0.41% ⚠️

Comparison is base (f52d7e2) 42.69% compared to head (abd3144) 42.29%.

❗ Current head abd3144 differs from pull request most recent head b3c085b. Consider uploading reports for the commit b3c085b to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1325      +/-   ##
==========================================
- Coverage   42.69%   42.29%   -0.41%     
==========================================
  Files         136      137       +1     
  Lines        4223     4287      +64     
  Branches     1000     1005       +5     
==========================================
+ Hits         1803     1813      +10     
- Misses       2408     2462      +54     
  Partials       12       12              
Flag Coverage Δ
client 42.29% <27.77%> (-0.41%) ⬇️
server ∅ <ø> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...s/components/application-form/application-form.tsx 59.31% <0.00%> (-0.30%) ⬇️
client/src/app/queries/assessments.ts 20.68% <23.80%> (+1.17%) ⬆️
client/src/app/queries/questionnaires.ts 21.42% <25.00%> (ø)
client/src/app/api/rest.ts 55.05% <40.00%> (-0.35%) ⬇️
client/src/app/Paths.ts 91.11% <100.00%> (-8.89%) ⬇️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ibolton336 ibolton336 changed the title [WIP] Dynamic assess button ✨ Dynamic assess button and view assessments page Sep 5, 2023
@ibolton336 ibolton336 marked this pull request as ready for review September 5, 2023 20:33
@ibolton336 ibolton336 force-pushed the dynamic-assess-button branch 2 times, most recently from e0527b2 to 88c5234 Compare September 5, 2023 20:41
@ibolton336 ibolton336 marked this pull request as draft September 6, 2023 14:59
@ibolton336 ibolton336 force-pushed the dynamic-assess-button branch 2 times, most recently from fa44853 to e9899cd Compare September 6, 2023 20:55
@ibolton336 ibolton336 marked this pull request as ready for review September 6, 2023 20:56
// rest.get(AppRest.APPLICATIONS, (req, res, ctx) => {
// return res(ctx.json(mockApplicationArray));
// }),
// Commented out to avoid conflict with the real API
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to commit these uncommented or comment them back out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks.

Comment on lines +203 to +230
// const commentValues = values["comments"];
// const fieldName = getCommentFieldName(category, false);
// const commentValue = commentValues[fieldName];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the commented out code here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what we are doing about comments since they are yet another thing not available on the new API. Wa just going to leave them for now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, ok. I wonder if we should leave a TODO then.

Copy link
Collaborator

@mturley mturley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM, just a couple things.

status: "STARTED",
};

await patchAssessment(payload);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we want to switch to using a useMutation here eventually for these patchAssessment calls so we can separate API logic from the component. Sounds out of scope for this PR though since it's a preexisting pattern.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment on lines 36 to 50
const AssessmentSummaryPage: React.FC = () => {
const { assessmentId } = useParams<AssessmentSummaryRouteParams>();

const { t } = useTranslation();

const [activeSectionIndex, setActiveSectionIndex] = React.useState<
"all" | number
>("all");

const handleTabClick = (
_event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent,
tabKey: string | number
) => {
setActiveSectionIndex(tabKey as "all" | number);
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create a component shared by AssessmentSummaryPage and QuestionnairePage for the layout of tabs and search logic instead of copying that code here? I think maybe there's a higher level of stuff we can reuse here than just the QuestionsTable. We could create something like a QuestionnaireSummary that can handle either the questionnaire itself or an assessment with conditional logic for the parts that differ.

If that's too much hassle for this PR we could do it in a followup.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing";
import { Question } from "@app/api/models";

const QuestionnaireSectionTabTitle: React.FC<{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this component is straight up copied from the other page, I bet it could exist in one place and be used in the shared component.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment on lines 55 to 75
const determineButtonBackgroundColor = () => {
const action = determineAction();
if (action === AssessmentAction.Continue) {
return "#5ba353"; // Continue background color
} else if (action === AssessmentAction.Retake) {
return "#F0AB01"; // Retake background color
} else {
return ""; // Default background color for "Take"
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if instead we should conditionally apply CSS classNames to the buttons and define these colors in CSS?

Also we could use the CSS variables from the PF color palette instead of hard coded hash values. That way if we ever introduce dark mode the colors should be able to adjust automatically.

@ibolton336 ibolton336 marked this pull request as draft September 8, 2023 16:07
@ibolton336 ibolton336 marked this pull request as ready for review September 8, 2023 19:47
Copy link
Collaborator

@mturley mturley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome!

Comment on lines +121 to +126
<div
style={{
backgroundColor: "var(--pf-v5-global--BackgroundColor--100)",
}}
>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point we might want to see if we can get rid of this inline style somehow


export const ApplicationAssessment: React.FC = () => {
const { t } = useTranslation();

const { assessmentId } = useParams<AssessmentRoute>();
const { assessment, isFetching, fetchError } =
useFetchAssessmentByID(assessmentId);
useFetchAssessmentById(assessmentId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ibolton336 ibolton336 force-pushed the dynamic-assess-button branch 4 times, most recently from 8c87d63 to a481e0b Compare September 11, 2023 17:30
Signed-off-by: ibolton336 <ibolton@redhat.com>

Take/retake flow for assessments

Share questions and answers tables

Hide answer key in assessment review screen

Navigate back to assessment actions after assessment

Signed-off-by: ibolton336 <ibolton@redhat.com>

Separate out archived questionnaires

Add continue button logic

Add delete assessment mock and functionality

Move shared questionnaire data

Signed-off-by: ibolton336 <ibolton@redhat.com>

Add comments

Signed-off-by: ibolton336 <ibolton@redhat.com>

Use RQ for patchAssessment

Signed-off-by: ibolton336 <ibolton@redhat.com>

Refactor assessment / questionnaire summary

Signed-off-by: ibolton336 <ibolton@redhat.com>

wire up delete for mock apps

Signed-off-by: ibolton336 <ibolton@redhat.com>

cleanup

Signed-off-by: ibolton336 <ibolton@redhat.com>

Fix invalidate queries after assessment patch

Signed-off-by: ibolton336 <ibolton@redhat.com>

Fix css

Signed-off-by: ibolton336 <ibolton@redhat.com>

Updates to match api

Signed-off-by: ibolton336 <ibolton@redhat.com>

Match hub status with api

Signed-off-by: ibolton336 <ibolton@redhat.com>

Test question updates

Signed-off-by: ibolton336 <ibolton@redhat.com>

Fix questionnaire by ID

Signed-off-by: ibolton336 <ibolton@redhat.com>

update tests

Signed-off-by: ibolton336 <ibolton@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic assessment actions buttons component
2 participants