jomarko commented on code in PR #2628:
URL: 
https://github.com/apache/incubator-kie-tools/pull/2628#discussion_r1800557650


##########
packages/scesim-editor/src/table/TestScenarioTable.tsx:
##########
@@ -833,127 +580,54 @@ function TestScenarioTable({
    */
   const onColumnDeleted = useCallback(
     (args: { columnIndex: number; groupType: string }) => {
-      updateTestScenarioModel((prevState) => {
-        const isInstance =
-          args.groupType === TestScenarioTableColumnInstanceGroup.EXPECT ||
-          args.groupType === TestScenarioTableColumnInstanceGroup.GIVEN;
-
-        const factMappings = 
retrieveModelDescriptor(prevState.ScenarioSimulationModel, 
isBackground).factMappings
-          .FactMapping!;
-        const columnIndexToRemove = determineSelectedColumnIndex(factMappings, 
args.columnIndex + 1, isInstance);
-
-        /* Retriving the FactMapping (Column) to be removed). If the user 
selected a single column, it finds the exact
-           FactMapping to delete. If the user selected an instance (group of 
columns), it retrives all the FactMappings
-           that belongs to the the instance group */
-        const factMappingToRemove = factMappings[columnIndexToRemove];
-        const groupType = 
factMappingToRemove.expressionIdentifier.type!.__$$text;
-        const instanceName = factMappingToRemove.factIdentifier.name!.__$$text;
-        const instanceType = 
factMappingToRemove.factIdentifier.className!.__$$text;
-
-        const allFactMappingWithIndexesToRemove = isInstance
-          ? factMappings
-              .map((factMapping, index) => {
-                if (
-                  factMapping.expressionIdentifier.type!.__$$text === 
groupType &&
-                  factMapping.factIdentifier.name?.__$$text === instanceName &&
-                  factMapping.factIdentifier.className?.__$$text === 
instanceType
-                ) {
-                  return { factMappingIndex: index, factMapping: factMapping };
-                } else {
-                  return {};
-                }
-              })
-              .filter((item) => isNumber(item.factMappingIndex))
-          : [{ factMappingIndex: args.columnIndex + columnIndexStart, 
factMapping: factMappingToRemove }];
-
-        /* Cloning the FactMappings list (Columns) and and removing the 
FactMapping (Column) at given index */
-        const deepClonedFactMappings = JSON.parse(
-          JSON.stringify(
-            retrieveModelDescriptor(prevState.ScenarioSimulationModel, 
isBackground).factMappings.FactMapping
-          )
-        );
-        deepClonedFactMappings.splice(
-          allFactMappingWithIndexesToRemove[0].factMappingIndex,
-          allFactMappingWithIndexesToRemove.length
-        );
-
-        /* Cloning the Scenario List (Rows) and finding the Cell(s) to remove 
accordingly to the factMapping data of 
-          the removed columns */
-        const deepClonedRowsData: SceSim__FactMappingValuesTypes[] = 
JSON.parse(
-          
JSON.stringify(retrieveRowsDataFromModel(prevState.ScenarioSimulationModel, 
isBackground) ?? [])
-        );
-        deepClonedRowsData.forEach((rowData) => {
-          allFactMappingWithIndexesToRemove.forEach((itemToRemove) => {
-            const factMappingValueColumnIndexToRemove = 
retrieveFactMappingValueIndexByIdentifiers(
-              rowData.factMappingValues.FactMappingValue!,
-              itemToRemove.factMapping!.factIdentifier,
-              itemToRemove.factMapping!.expressionIdentifier
-            )!;
-
-            return {
-              factMappingValues: {
-                FactMappingValue: 
rowData.factMappingValues.FactMappingValue!.splice(
-                  factMappingValueColumnIndexToRemove,
-                  1
-                ),
-              },
-            };
-          });
+      /* GIVEN and EXPECTED of FIELD and INSTANCE column types can be deleted 
only */
+      if (
+        TestScenarioTableColumnFieldGroup.OTHER === args.groupType ||
+        TestScenarioTableColumnHeaderGroup.EXPECT === args.groupType ||
+        TestScenarioTableColumnHeaderGroup.GIVEN === args.groupType
+      ) {
+        console.error("Can't add a " + args.groupType + " type column.");

Review Comment:
   ```suggestion
           console.error("Can't delete a " + args.groupType + " type column.");
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to