-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Implement assessment settings columns
Signed-off-by: ibolton336 <ibolton@redhat.com>
- Loading branch information
1 parent
4ab5428
commit 65eeaeb
Showing
9 changed files
with
82 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
...s/assessment-management/assessment-settings/components/questionnaire-questions-column.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from "react"; | ||
import { Text } from "@patternfly/react-core"; | ||
import { Questionnaire } from "@app/api/models"; | ||
|
||
export const QuestionnaireQuestionsColumn: React.FC<{ | ||
questionnaire: Questionnaire; | ||
}> = ({ questionnaire }) => { | ||
const totalQuestions = (questionnaire.sections || []).reduce( | ||
(total, section) => { | ||
return total + (section.questions ? section.questions.length : 0); | ||
}, | ||
0 | ||
); | ||
return <Text>{totalQuestions}</Text>; | ||
}; |
27 changes: 27 additions & 0 deletions
27
.../assessment-management/assessment-settings/components/questionnaire-thresholds-column.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from "react"; | ||
import { ListItem } from "@patternfly/react-core"; | ||
import { Questionnaire, Thresholds } from "@app/api/models"; | ||
|
||
export const QuestionnaireThresholdsColumn: React.FC<{ | ||
questionnaire: Questionnaire; | ||
}> = ({ questionnaire }) => { | ||
const thresholdsToListItems = (thresholds: Thresholds) => { | ||
const thresholdKeys: (keyof Thresholds)[] = Object.keys( | ||
thresholds | ||
) as (keyof Thresholds)[]; | ||
|
||
return ( | ||
<> | ||
{thresholdKeys.map((color) => { | ||
const percentage: number = thresholds[color] || 0; | ||
return ( | ||
<ListItem key={color}> | ||
{color} {percentage}% | ||
</ListItem> | ||
); | ||
})} | ||
</> | ||
); | ||
}; | ||
return thresholdsToListItems(questionnaire.thresholds || {}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters