Skip to content

Commit

Permalink
Internationalize risk scenario update page
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche committed Feb 26, 2024
1 parent b996255 commit 3da087d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 46 deletions.
10 changes: 9 additions & 1 deletion frontend/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,13 @@
"probability": "Probability",
"riskLevels": "Risk levels",
"cancel": "Cancel",
"save": "Save"
"save": "Save",
"currentAssessment": "Current assessment",
"scope": "Scope",
"assetsImpactedByTheRiskScenario": "Assets impacted by the risk scenario",
"ecistingMeasures": "Existing measures",
"theExistingSecurityMeasuresToManageThisRisk": "The existing security measures to manage this risk",
"currentRiskLevelGivenCurrentMeasures": "The current risk level given the current security measures",
"targetAssessment": "Target assessment",
"riskLevelWhenAllExtraMeasuresDone": "The risk level when all extra measures are done"
}
10 changes: 9 additions & 1 deletion frontend/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,13 @@
"probability": "Probabilité",
"riskLevels": "Niveaux de risque",
"cancel": "Annuler",
"save": "Enregistrer"
"save": "Enregistrer",
"currentAssessment": "Évaluation actuelle",
"scope": "Périmètre",
"assetsImpactedByTheRiskScenario": "Biens sensibles impactés par le scénario de risque",
"ecistingMeasures": "Mesures existantes",
"theExistingSecurityMeasuresToManageThisRisk": "Les mesures de sécurité existantes pour gérer ce risque",
"currentRiskLevelGivenCurrentMeasures": "Niveau de risque courant compte tenu des mesures actuelles",
"targetAssessment": "Évaluation cible",
"riskLevelWhenAllExtraMeasuresDone": "Niveau de risque lorsque toutes les mesures supplémentaires sont appliquées"
}
8 changes: 5 additions & 3 deletions frontend/src/lib/utils/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const LOCALE_MAP = {
};

export function toCamelCase(str: string) {
return str.replace(/[_-]\w/g, match => match.charAt(1).toUpperCase());
return str.replace(/[_-]\w/g, (match) => match.charAt(1).toUpperCase());
}

export function capitalizeFirstLetter(str: string) {
Expand Down Expand Up @@ -162,11 +162,13 @@ export function localItems(languageTag: string): LocalItems {
associatedRiskAssessments: m.associatedRiskAssessments({ languageTag: languageTag }),
associatedRiskScenarios: m.associatedRiskScenarios({ languageTag: languageTag }),
associatedRiskAcceptances: m.associatedRiskAcceptances({ languageTag: languageTag }),
associatedComplianceAssessments: m.associatedComplianceAssessments({ languageTag: languageTag }),
associatedComplianceAssessments: m.associatedComplianceAssessments({
languageTag: languageTag
}),
associatedEvidences: m.associatedEvidences({ languageTag: languageTag }),
associatedDomains: m.associatedDomains({ languageTag: languageTag }),
associatedProjects: m.associatedProjects({ languageTag: languageTag }),
associatedUsers: m.associatedUsers({ languageTag: languageTag }),
associatedUsers: m.associatedUsers({ languageTag: languageTag })
};
return LOCAL_ITEMS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@
>
<div class="flex flex-row space-x-2">
<div class="card px-4 py-2 bg-white shadow-lg w-3/4">
<h4 class="h4 font-semibold">Scope</h4>
<h4 class="h4 font-semibold">{m.scope()}</h4>
<div class="flex flex-row justify-between">
<span>
<p class="text-sm font-semibold text-gray-400">Project</p>
<p class="text-sm font-semibold text-gray-400">{m.project()}</p>
<a class="anchor text-sm font-semibold" href="/projects/{data.scenario.project.id}"
>{data.scenario.project.str}</a
>
Expand All @@ -147,27 +147,19 @@
{form}
options={getOptions({ objects: data.foreignKeys['risk_assessment'] })}
field="risk_assessment"
label="RiskAssessment"
label={m.riskAssessments()}
/>
<span>
<p class="text-sm font-semibold text-gray-400">Auditor</p>
{#if data.scenario.auditor}
<a class="anchor text-sm font-semibold" href="/users/{data.scenario.auditor.id}"
>{data.scenario.auditor.str}</a
>
{/if}
</span>
<span>
<p class="text-sm font-semibold text-gray-400">Version</p>
<p class="text-sm font-semibold text-gray-400">{m.version()}</p>
<p class="text-sm font-semibold">{data.scenario.version}</p>
</span>
</div>
</div>
<div class="card px-4 py-2 bg-white shadow-lg w-1/4">
<h4 class="h4 font-semibold">Status</h4>
<h4 class="h4 font-semibold">{m.status()}</h4>
<div class="flex flex-row justify-between">
<span>
<p class="text-sm font-semibold text-gray-400">Last update</p>
<p class="text-sm font-semibold text-gray-400">{m.updatedAt()}</p>
<p class="text-sm font-semibold">
{new Date(data.scenario.updated_at).toLocaleString()}
</p>
Expand All @@ -176,7 +168,7 @@
{form}
options={data.treatmentChoices}
field="treatment"
label="Treatment status"
label={m.treatmentStatus()}
/>
</div>
</div>
Expand All @@ -189,116 +181,115 @@
multiple
options={getOptions({ objects: data.foreignKeys['threats'] })}
field="threats"
label="Threats"
label={m.threats()}
/>
<TextField {form} field="name" label="Name" />
<TextArea {form} field="description" label="Description" />
<TextField {form} field="name" label={m.name()} />
<TextArea {form} field="description" label={m.description()} />
</div>
<div class="card px-4 py-2 bg-white shadow-lg w-1/2 max-h-96 overflow-y-scroll">
<AutocompleteSelect
multiple
{form}
options={getOptions({ objects: data.foreignKeys['assets'] })}
field="assets"
label="Assets"
helpText="Assets impacted by this risk scenario"
label={m.assets()}
helpText={m.assetsImpactedByTheRiskScenario()}
/>
<ModelTable source={data.tables['assets']} URLModel="assets" />
</div>
</div>
<input type="hidden" name="urlmodel" value={data.model.urlModel} />

<div class="card px-4 py-2 bg-white shadow-lg">
<h4 class="h4 font-semibold">Current risk</h4>
<h4 class="h4 font-semibold">{m.currentRisk()}</h4>
<div class="flex flex-row space-x-4 justify-between">
<TextArea
{form}
field="existing_measures"
label="Existing measures"
helpText="The existing security measures to manage this risk"
label={m.ecistingMeasures()}
helpText={m.theExistingSecurityMeasuresToManageThisRisk()}
regionContainer="w-1/2"
/>
<div class="flex flex-col">
<h5 class="h5 font-medium">Current assessment</h5>
<h5 class="h5 font-medium">{m.currentAssessment()}</h5>
<div class="flex flex-row space-x-4 my-auto">
<Select
{form}
options={data.probabilityChoices}
color_map={riskColorMap()}
field="current_proba"
label="Current probability"
label={m.currentProba()}
/>
<i class="fa-solid fa-xmark my-auto" />
<Select
{form}
options={data.impactChoices}
color_map={riskColorMap()}
field="current_impact"
label="Current impact"
label={m.currentImpact()}
/>
<i class="fa-solid fa-equals my-auto" />
<RiskLevel
{form}
field="current_risk_level"
label="Current risk level"
label={m.currentRisk()}
riskMatrix={data.riskMatrix}
probabilityField="current_proba"
impactField="current_impact"
helpText="The risk level given the current measures"
helpText={m.currentRiskLevelGivenCurrentMeasures()}
/>
</div>
</div>
</div>
</div>

<div class="card px-4 py-2 bg-white shadow-lg">
<h4 class="h4 font-semibold">Residual risk</h4>
<h4 class="h4 font-semibold">{m.residualRisk()}</h4>
<div class="flex flex-row space-x-4 justify-between">
<div class="flex flex-col w-1/2">
<div class="flex flex-col space-y-4 w-1/2">
<span class="flex flex-row justify-between items-center">
<h5 class="h5 font-medium">Associated security measures</h5>
<h5 class="h5 font-medium">{m.associatedSecurityMeasures()}</h5>
<button
class="btn variant-filled-primary self-end"
on:click={modalMeasureCreateForm}
type="button"><i class="fa-solid fa-plus mr-2" />New security measure</button
type="button"><i class="fa-solid fa-plus mr-2" />{m.addSecurityMeasure()}</button
>
</span>
<AutocompleteSelect
multiple
{form}
options={getOptions({ objects: data.foreignKeys['security_measures'] })}
field="security_measures"
label="Security measures"
/>
<ModelTable source={data.tables['security-measures']} URLModel="security-measures" />
</div>
<div class="flex flex-col">
<h5 class="h5 font-medium">Target assessment</h5>
<h5 class="h5 font-medium">{m.targetAssessment()}</h5>
<div class="flex flex-row space-x-4 my-auto">
<Select
{form}
options={data.probabilityChoices}
color_map={riskColorMap()}
field="residual_proba"
label="Residual probability"
label={m.residualProba()}
/>
<i class="fa-solid fa-xmark my-auto" />
<Select
{form}
options={data.impactChoices}
color_map={riskColorMap()}
field="residual_impact"
label="Residual impact"
label={m.residualImpact()}
/>
<i class="fa-solid fa-equals my-auto" />
<RiskLevel
{form}
field="current_risk_level"
label="Current risk level"
field="residual_risk_level"
label={m.residualRisk()}
riskMatrix={data.riskMatrix}
probabilityField="residual_proba"
impactField="residual_impact"
helpText="The risk level when all the extra measures are done"
helpText={m.riskLevelWhenAllExtraMeasuresDone()}
/>
</div>
</div>
Expand All @@ -309,9 +300,9 @@
{form}
options={strengthOfKnowledgeFormChoices}
field="strength_of_knowledge"
label="Strength of knowledge"
label={m.strengthOfKnowledge()}
/>
<TextArea {form} field="justification" label="Justification" />
<TextArea {form} field="justification" label={m.justification()} />
</div>
<div class="flex flex-row justify-between space-x-4">
<button
Expand Down

0 comments on commit 3da087d

Please sign in to comment.