Skip to content

Commit

Permalink
Fix for fragment labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Bogusz authored and ForrestFairy committed Feb 25, 2025
1 parent eb1fb2e commit 7f6d894
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 52 deletions.
4 changes: 2 additions & 2 deletions designer/client/cypress/e2e/nodeWindow.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("Node window", () => {
.should("exist")
.scrollIntoView();
cy.layoutScenario();
cy.get("[data-testid='component:event-generator']")
cy.get("[data-testid='component:event generator']")
.should("be.visible")
.drag("#nk-graph-main", {
target: {
Expand All @@ -29,7 +29,7 @@ describe("Node window", () => {
force: true,
});

cy.getNode("event-generator").dblclick();
cy.getNode("event generator").dblclick();

// TODO: fix validation display in node windows
cy.intercept("POST", "/api/nodes/*/validation").as("validation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,46 +53,6 @@ package object component {

object ComponentListElement {
def sortMethod(component: ComponentListElement): (String, String) = (component.name, component.id.value)

def apply(
id: DesignerWideComponentId,
name: String,
icon: String,
componentType: ComponentType,
componentGroupName: ComponentGroupName,
categories: List[String],
links: List[ComponentLink],
usageCount: Long,
allowedProcessingModes: AllowedProcessingModes
): ComponentListElement = {
if (componentType == ComponentType.Fragment)
ComponentListElement(
id,
name,
icon,
componentType,
componentGroupName,
categories,
links,
usageCount,
allowedProcessingModes,
id.value
)
else
ComponentListElement(
id,
name,
icon,
componentType,
componentGroupName,
categories,
links,
usageCount,
allowedProcessingModes,
name
)
}

}

implicit val allowedProcessingModesEncoder: Encoder[AllowedProcessingModes] = Encoder.instance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ package object definition {
icon: String,
docsUrl: Option[String],
// This field is defined only for fragments
outputParameters: Option[List[String]],
label: String
outputParameters: Option[List[String]]
)

@JsonCodec final case class UISourceParameters(sourceId: String, parameters: List[UIParameter])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ class DefinitionsService(
docsUrl = componentDefinition.component.docsUrl,
outputParameters = Option(componentDefinition.component.componentTypeSpecificData).collect {
case FragmentSpecificData(outputNames) => outputNames
},
label = componentDefinition.component.label
}
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ class DefaultComponentServiceSpec
availableCategories,
links,
usageCount,
nonDefaultAllowedProcessingModes.getOrElse(AllowedProcessingModes.All)
nonDefaultAllowedProcessingModes.getOrElse(AllowedProcessingModes.All),
componentId.name
)
}

Expand All @@ -389,7 +390,8 @@ class DefaultComponentServiceSpec
List(cat),
links,
0,
AllowedProcessingModes.SetOf(ProcessingMode.UnboundedStream)
AllowedProcessingModes.SetOf(ProcessingMode.UnboundedStream),
componentId.name
)
)
}
Expand All @@ -409,7 +411,8 @@ class DefaultComponentServiceSpec
List(cat),
links,
0,
AllowedProcessingModes.SetOf(ProcessingMode.UnboundedStream)
AllowedProcessingModes.SetOf(ProcessingMode.UnboundedStream),
componentId.name
)
)
}
Expand Down Expand Up @@ -473,7 +476,8 @@ class DefaultComponentServiceSpec
categories,
links,
usageCount,
nonDefaultAllowedProcessingModes.getOrElse(AllowedProcessingModes.All)
nonDefaultAllowedProcessingModes.getOrElse(AllowedProcessingModes.All),
componentId.name,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ trait ComponentDefinitionWithImplementation extends ObjectOperatingOnTypes {

protected def uiDefinition: ComponentUiDefinition

final def label: String = uiDefinition.label.getOrElse(name)
final def label: String = {
uiDefinition.label.getOrElse {
if (componentType != ComponentType.Fragment) {
name
} else {
id.name
}
}
}

final def designerWideId: DesignerWideComponentId = uiDefinition.designerWideId

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object DefaultComponentConfigDeterminer {
icon = icon.getOrElse(DefaultsComponentIcon.FragmentIcon),
docsUrl = docsUrl,
designerWideId = designerWideId,
label = Option(designerWideId.value)
label = None
)
}

Expand Down

0 comments on commit 7f6d894

Please sign in to comment.