Skip to content

Commit

Permalink
feat: Create incident from config API integration
Browse files Browse the repository at this point in the history
  • Loading branch information
johngohrw committed Apr 4, 2022
1 parent e75cddb commit fb8f1e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/components/Incidents/IncidentCreate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,28 @@ export function IncidentCreate({ callback, evidence, ...rest }) {
payload.id = uuidv4();
createIncident(user, payload)
.then((created) => {
const create = createHypothesis(user, uuidv4(), payload.id, {
createHypothesis(user, uuidv4(), payload.id, {
title: payload.title,
type: "root",
status: "possible"
});

if (location.state && location.state.evidence != null) {
create.then((hypotheis) => {
}).then((hypothesis) => {
if (hypothesis?.data[0]?.id && evidence) {
createEvidence(
user,
uuidv4(),
hypotheis.data[0].id,
location.state.evidence,
hypothesis.data[0].id,
{
lines: evidence?.lines,
configId: evidence?.configId,
fullConfig: evidence?.config
},
{
description: "test",
type: location.state.evidenceType
description: evidence?.configName,
type: evidence?.type
}
);
});
}
}
});

if (created)
if (callback != null) {
Expand Down
10 changes: 10 additions & 0 deletions src/pages/config/config-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ export function ConfigDetailsPage() {
callback={(response) => {
navigate(`/incidents/${response.id}`, { replace: true });
}}
evidence={{
configId: id,
configName: configDetails?.name,
config: jsonLines,
type: "config",
lines: Object.keys(checked).reduce((acc, lineNum) => {
acc[lineNum] = jsonLines[lineNum];
return acc;
}, {})
}}
/>
</Modal>
</div>
Expand Down

0 comments on commit fb8f1e5

Please sign in to comment.