Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkp96 committed Oct 28, 2024
1 parent cd38bee commit b393946
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ trait NuResourcesTest
deploymentManagerProvider.defaultEngineSetupName,
processingTypeConfig.deploymentConfig,
processingTypeConfig.category,
ComponentDefinitionExtractionMode.FinalDefinition
modelDependencies.componentDefinitionExtractionMode
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ object TestFactory {
componentId => DesignerWideComponentId(componentId.toString),
workingDirectoryOpt = None,
_ => true,
ComponentDefinitionExtractionMode.FinalDefinition
ComponentDefinitionExtractionMode.FinalAndBasicDefinitions
)

val deploymentManagerDependencies: DeploymentManagerDependencies = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ import pl.touk.nussknacker.ui.definition.{
}
import pl.touk.nussknacker.ui.process.marshall.CanonicalProcessConverter

import scala.concurrent.Await
import scala.concurrent.duration._

class DefinitionResourcesSpec
extends AnyFunSpec
with ScalatestRouteTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ object Components {
}
)

sealed trait ComponentDefinitionExtractionMode
sealed abstract class ComponentDefinitionExtractionMode(val extractBasicDefinitions: Boolean)

object ComponentDefinitionExtractionMode {
case object FinalDefinition extends ComponentDefinitionExtractionMode
case object FinalAndBasicDefinitions extends ComponentDefinitionExtractionMode
case object FinalDefinition extends ComponentDefinitionExtractionMode(false)
case object FinalAndBasicDefinitions extends ComponentDefinitionExtractionMode(true)
}

def withComponent(
Expand Down Expand Up @@ -100,17 +100,14 @@ object Components {
)
}

val finalDefinitions = extractComponentDefinition(componentsUiConfig, additionalConfigsFromProvider)
componentDefinitionExtractionMode match {
case ComponentDefinitionExtractionMode.FinalDefinition =>
Components(components = finalDefinitions.toList, basicComponents = None)
case ComponentDefinitionExtractionMode.FinalAndBasicDefinitions =>
Components(
components = finalDefinitions.toList,
basicComponents =
Some(extractComponentDefinition(uiConfig = ComponentsUiConfig.Empty, configFromProvider = Map.empty).toList)
)
}
Components(
components = extractComponentDefinition(componentsUiConfig, additionalConfigsFromProvider).toList,
basicComponents =
if (componentDefinitionExtractionMode.extractBasicDefinitions)
Some(extractComponentDefinition(uiConfig = ComponentsUiConfig.Empty, configFromProvider = Map.empty).toList)
else
None
)
}

def forList(
Expand All @@ -120,28 +117,29 @@ object Components {
additionalConfigsFromProvider: Map[DesignerWideComponentId, ComponentAdditionalConfig],
componentDefinitionExtractionMode: ComponentDefinitionExtractionMode
): Components = {
val componentsWithAdditionalConfig = ComponentDefinitionWithImplementation.forList(
components,
componentsUiConfig,
determineDesignerWideId,
additionalConfigsFromProvider
)
componentDefinitionExtractionMode match {
case ComponentDefinitionExtractionMode.FinalDefinition =>
Components(components = componentsWithAdditionalConfig, basicComponents = None)
case ComponentDefinitionExtractionMode.FinalAndBasicDefinitions =>
Components(
components = componentsWithAdditionalConfig,
basicComponents = Some(
ComponentDefinitionWithImplementation.forList(
components,
componentsUiConfig,
determineDesignerWideId,
additionalConfigsFromProvider = Map.empty
)
)
)

def extractComponentDefinitions(
uiConfig: ComponentsUiConfig,
configFromProvider: Map[DesignerWideComponentId, ComponentAdditionalConfig]
) = {
ComponentDefinitionWithImplementation.forList(
components,
uiConfig,
determineDesignerWideId,
configFromProvider
)
}

Components(
components = extractComponentDefinitions(componentsUiConfig, additionalConfigsFromProvider).toList,
basicComponents =
if (componentDefinitionExtractionMode.extractBasicDefinitions)
Some(
extractComponentDefinitions(uiConfig = ComponentsUiConfig.Empty, configFromProvider = Map.empty).toList
)
else
None
)
}

def combine(x: Components, y: Components): Components = {
Expand Down

0 comments on commit b393946

Please sign in to comment.