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

Fix risk scenario tag translation #816

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/app_tests/api/test_api_risk_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
"description": "acceptable risk",
"hexcolor": "#00FF00",
}
RISK_SCENARIO_TREATMENT_STATUS = ("accept", "Accept")
RISK_SCENARIO_TREATMENT_STATUS2 = ("mitigate", "Mitigate")
RISK_SCENARIO_TREATMENT_STATUS = ("accept", "accept")
RISK_SCENARIO_TREATMENT_STATUS2 = ("mitigate", "mitigate")
RISK_SCENARIO_JUSTIFICATION = "Test justification"


Expand Down
2 changes: 1 addition & 1 deletion backend/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class RiskScenarioReadSerializer(RiskScenarioWriteSerializer):
threats = FieldsRelatedField(many=True)
assets = FieldsRelatedField(many=True)

treatment = serializers.CharField(source="get_treatment_display")
treatment = serializers.CharField()

current_proba = serializers.JSONField(source="get_current_proba")
current_impact = serializers.JSONField(source="get_current_impact")
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/lib/utils/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,11 @@ export const FIELD_COLORED_TAG_MAP: FieldColoredTagMap = {
name: {
key: 'treatment',
values: {
Open: { text: 'open', cssClasses: 'badge bg-green-300' },
Mitigate: { text: 'mitigate', cssClasses: 'badge bg-lime-200' },
Accept: { text: 'accept', cssClasses: 'badge bg-green-200' },
Avoid: { text: 'avoid', cssClasses: 'badge bg-red-200' },
Transfer: { text: 'transfer', cssClasses: 'badge bg-yellow-300' }
open: { text: 'open', cssClasses: 'badge bg-green-300' },
mitigate: { text: 'mitigate', cssClasses: 'badge bg-lime-200' },
accept: { text: 'accept', cssClasses: 'badge bg-green-200' },
avoid: { text: 'avoid', cssClasses: 'badge bg-red-200' },
transfer: { text: 'transfer', cssClasses: 'badge bg-yellow-300' }
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
avoid: 'bg-red-200',
transfer: 'bg-violet-200'
};
return map[status.toLowerCase()] ?? 'bg-gray-200';
return map[status] ?? 'bg-gray-200';
};

const measureStatusColorMap = (treatment: string) => {
Expand Down Expand Up @@ -68,7 +68,7 @@
href="/risk-scenarios/{scenario.id}">{scenario.name}</a
>
<span class="badge {scenarioTreatmentColorMap(scenario.treatment)}"
>{scenario.treatment}</span
>{safeTranslate(scenario.treatment)}</span
>
</td>
</tr>
Expand Down
Loading