Skip to content

Commit

Permalink
fixing build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelpiano committed Apr 15, 2024
1 parent d65de53 commit 9f99815
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export enum NodeTypes {
}

export interface CustomNodeOptions extends BasePositionModelOptions {
forward_connection: any[];
to?: Array<{ name: string; type: string }>;
from?: Array<{ name: string; type: string }>;
anatomicalType?: string;
forward_connection?: any[];
}

const ViaTypeMapping: Record<TypeB60Enum, string> = {
Expand Down Expand Up @@ -81,7 +81,7 @@ const processData = (
origins: AnatomicalEntity[] | undefined,
vias: ViaSerializerDetails[] | undefined,
destinations: DestinationSerializerDetails[] | undefined,
forward_connection?: any[] | undefined
forward_connection: any[],
): { nodes: CustomNodeModel[], links: DefaultLinkModel[] } => {
const nodes: CustomNodeModel[] = [];
const links: DefaultLinkModel[] = [];
Expand All @@ -97,11 +97,13 @@ const processData = (
const id = getId(NodeTypes.Origin, origin)
const name = origin.simple_entity !== null ? origin.simple_entity.name : origin.region_layer.region.name + '(' + origin.region_layer.layer.name + ')';
const ontology_uri = origin.simple_entity !== null ? origin.simple_entity.ontology_uri : origin.region_layer.region.ontology_uri + ', ' + origin.region_layer.layer.ontology_uri;
const fws: never[] = []
const originNode = new CustomNodeModel(
NodeTypes.Origin,
name,
ontology_uri,
{
forward_connection: fws,
to: [],
}
);
Expand All @@ -120,11 +122,13 @@ const processData = (
const id = getId(NodeTypes.Via + layerIndex, entity)
const name = entity.simple_entity !== null ? entity.simple_entity.name : entity.region_layer.region.name + '(' + entity.region_layer.layer.name + ')';
const ontology_uri = entity.simple_entity !== null ? entity.simple_entity.ontology_uri : entity.region_layer.region.ontology_uri + ', ' + entity.region_layer.layer.ontology_uri;
const fws: never[] = []
const viaNode = new CustomNodeModel(
NodeTypes.Via,
name,
ontology_uri,
{
forward_connection: fws,
from: [],
to: [],
anatomicalType: via?.type ? ViaTypeMapping[via.type] : ''
Expand Down Expand Up @@ -162,7 +166,7 @@ const processData = (
destination.anatomical_entities.forEach(entity => {
const name = entity.simple_entity !== null ? entity.simple_entity.name : entity.region_layer.region.name + '(' + entity.region_layer.layer.name + ')';
const ontology_uri = entity.simple_entity !== null ? entity.simple_entity.ontology_uri : entity.region_layer.region.ontology_uri + ', ' + entity.region_layer.layer.ontology_uri;
const fws = forward_connection?.filter(single_fw => {
const fws = forward_connection.filter(single_fw => {
const origins = single_fw.origins.map((origin: { id: string } | string) => typeof origin === 'object' ? origin.id : origin);
if (origins.includes(entity.id)) {
return true;
Expand All @@ -174,9 +178,9 @@ const processData = (
name,
ontology_uri,
{
forward_connection: fws,
from: [],
anatomicalType: destination?.type ? DestinationTypeMapping[destination.type] : '',
forward_connection: fws
}
);
destinationNode.setPosition(xDestination, yDestination);
Expand All @@ -202,7 +206,7 @@ const processData = (
return {nodes, links};
};

const GraphDiagram: React.FC<GraphDiagramProps> = ({origins, vias, destinations, forward_connection}) => {
const GraphDiagram: React.FC<GraphDiagramProps> = ({origins, vias, destinations, forward_connection = []}) => {
const [engine] = useState(() => createEngine());
const [modelUpdated, setModelUpdated] = useState(false)
const [modelFitted, setModelFitted] = useState(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export class CustomNodeModel extends NodeModel {
customType: NodeTypes;
name: string;
externalId: string;
constructor(customType: NodeTypes, name: string, externalId: string = '', options: CustomNodeOptions = {}) {
constructor(customType: NodeTypes, name: string, externalId: string = '', options: CustomNodeOptions = {
forward_connection: []
}) {
super({
...options,
type: 'custom',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface DestinationNodeProps {
export const DestinationNodeWidget: React.FC<DestinationNodeProps> = ({
model,
engine,
forwardConnection,
}) => {
// State to toggle the color
const [isActive, setIsActive] = useState(false);
Expand All @@ -30,6 +29,7 @@ export const DestinationNodeWidget: React.FC<DestinationNodeProps> = ({


const inPort = model.getPort("in");
const hasForwardConnections = model.getOptions()?.forward_connection?.length > 0;

Check warning on line 32 in frontend/src/components/ProofingTab/GraphDiagram/Widgets/DestinationNodeWidget.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint

'hasForwardConnections' is assigned a value but never used

return (
<Box
Expand Down Expand Up @@ -65,7 +65,7 @@ export const DestinationNodeWidget: React.FC<DestinationNodeProps> = ({
>
{model.name}
</Typography>
{forwardConnection && <ArrowDownwardIcon style={{ position: 'absolute', bottom: '-0.5rem', left: '50%', transform: 'translateX(-50%)' }} />}
{model.getOptions().forward_connection?.length > 0 && <ArrowDownwardIcon style={{ position: 'absolute', bottom: '-0.5rem', left: '50%', transform: 'translateX(-50%)' }} />}
</Box>
{inPort && <PortWidget className="inPortDestination" engine={engine} port={inPort}>
<div className="inPortDestination"/>
Expand Down Expand Up @@ -191,7 +191,7 @@ export const DestinationNodeWidget: React.FC<DestinationNodeProps> = ({
</Stack>

<Box width={1} mt={2}>
{!forwardConnection && <ArrowDownwardIcon style={{ display: 'block', margin: '0 auto 0.25rem' }} />}
{model.getOptions()?.forward_connection?.length > 0 && <ArrowDownwardIcon style={{ display: 'block', margin: '0 auto 0.25rem' }} />}
<Box
sx={{
borderRadius: "0.625rem",
Expand Down

0 comments on commit 9f99815

Please sign in to comment.