Skip to content

Commit

Permalink
hide resources by condition
Browse files Browse the repository at this point in the history
  • Loading branch information
anmalkov committed Feb 1, 2024
1 parent 95cc665 commit 1df8bc1
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/Crisp.Ui/ClientApp/src/components/AddThreatModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,29 @@ const AddThreatModel = () => {
</div>
))}
</FormGroup>
<FormGroup>
<div className="mb-4">
<h5>Resources</h5>
</div>
<Row>
{resourceNames.isLoading ? (
<div className="text-center">
<Spinner>
Loading...
</Spinner>
</div>
) : resourceNames.data.resources.map(r => (
<Col key={r}><Button className="resource-small" onClick={() => changeResourcesHandler(r)} color={resourceButtonColor(r)}>{r}</Button></Col>
))}
</Row>
</FormGroup>
{selectedRecommendationsCount > 0 ? (
<FormGroup switch className="mb-3">
<Input className="form-check-input me-3" type="switch" role="switch" checked={addResourcesRecommendations} onChange={() => setAddResourcesRecommendations(!addResourcesRecommendations)} /> Add resources recommendations to threats (preview)
</FormGroup>
) : null}
{addResourcesRecommendations ? (
<FormGroup>
<div className="mb-4">
<h5>Resources</h5>
</div>
<Row>
{resourceNames.isLoading ? (
<div className="text-center">
<Spinner>
Loading...
</Spinner>
</div>
) : resourceNames.data.resources.map(r => (
<Col key={r}><Button className="resource-small" onClick={() => changeResourcesHandler(r)} color={resourceButtonColor(r)}>{r}</Button></Col>
))}
</Row>
</FormGroup>
) : null}
<FormGroup>
<h5>Data flow diagram</h5>
<input id="image-flow" className="form-control mb-3" type="file" accept="image/*" onChange={(e) => onDiagramChange('flow', e)} />
Expand Down Expand Up @@ -351,11 +358,6 @@ const AddThreatModel = () => {
</>
)}
</FormGroup>
{selectedRecommendationsCount > 0 ? (
<FormGroup switch className="mb-3">
<Input className="form-check-input me-3" type="switch" role="switch" checked={addResourcesRecommendations} onChange={() => setAddResourcesRecommendations(!addResourcesRecommendations)} /> Add resources recommendations to threats
</FormGroup>
): null}
<FormGroup className="border-top border-3 border-dark pt-3">
<Button color="success" onClick={saveThreatModelHandler} disabled={saveButtonDisabled}><FiCheck /> Save security plan</Button>
{createThreatModelMutation.isLoading &&
Expand Down

0 comments on commit 1df8bc1

Please sign in to comment.