-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Nu-1858] separate properties and node details (#7129)
* NU-1858 separate properties and node details
- Loading branch information
Showing
66 changed files
with
573 additions
and
392 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { ProcessDefinitionData, PropertiesType, ScenarioGraph, ScenarioGraphWithName, ValidationResult } from "../../types"; | ||
import { alignFragmentWithSchema } from "../../components/graph/utils/fragmentSchemaAligner"; | ||
import { fetchProcessDefinition } from "./processDefinitionData"; | ||
import { Scenario } from "../../components/Process/types"; | ||
import HttpService from "../../http/HttpService"; | ||
import { ThunkAction } from "../reduxTypes"; | ||
|
||
type EditPropertiesAction = { | ||
type: "EDIT_PROPERTIES"; | ||
validationResult: ValidationResult; | ||
scenarioGraphAfterChange: ScenarioGraph; | ||
}; | ||
|
||
type RenameProcessAction = { | ||
type: "PROCESS_RENAME"; | ||
name: string; | ||
}; | ||
|
||
export type PropertiesActions = EditPropertiesAction | RenameProcessAction; | ||
|
||
// TODO: We synchronize fragment changes with a scenario in case of properties changes. We need to find a better way to hande it | ||
function alignFragmentsNodeWithSchema(scenarioGraph: ScenarioGraph, processDefinitionData: ProcessDefinitionData): ScenarioGraph { | ||
return { | ||
...scenarioGraph, | ||
nodes: scenarioGraph.nodes.map((node) => { | ||
return node.type === "FragmentInput" ? alignFragmentWithSchema(processDefinitionData, node) : node; | ||
}), | ||
}; | ||
} | ||
|
||
const calculateProperties = (scenario: Scenario, changedProperties: PropertiesType): ThunkAction<Promise<ScenarioGraphWithName>> => { | ||
return async (dispatch) => { | ||
const processDefinitionData = await dispatch(fetchProcessDefinition(scenario.processingType, scenario.isFragment)); | ||
const processWithNewFragmentSchema = alignFragmentsNodeWithSchema(scenario.scenarioGraph, processDefinitionData); | ||
|
||
if (scenario.name !== changedProperties.name) { | ||
dispatch({ type: "PROCESS_RENAME", name: changedProperties.name }); | ||
} | ||
|
||
return { | ||
processName: changedProperties.name, | ||
scenarioGraph: { ...processWithNewFragmentSchema, properties: changedProperties }, | ||
}; | ||
}; | ||
}; | ||
|
||
export function editProperties(scenario: Scenario, changedProperties: PropertiesType): ThunkAction { | ||
return async (dispatch) => { | ||
const { processName, scenarioGraph } = await dispatch(calculateProperties(scenario, changedProperties)); | ||
const response = await HttpService.validateProcess(scenario.name, processName, scenarioGraph); | ||
|
||
dispatch({ | ||
type: "EDIT_PROPERTIES", | ||
validationResult: response.data, | ||
scenarioGraphAfterChange: scenarioGraph, | ||
}); | ||
}; | ||
} |
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
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
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
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
Oops, something went wrong.