Skip to content
This repository has been archived by the owner on Oct 29, 2022. It is now read-only.

Commit

Permalink
fix: lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed May 2, 2022
1 parent adc405c commit ce66206
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 45 deletions.
118 changes: 75 additions & 43 deletions library/src/components/NodeFactories/AsyncAPIApplication.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import React from 'react';
import { ApplicationLicenseData, ApplicationNodeData, ApplicationServerData, MessageData } from '../../types';
import {
ApplicationLicenseData,
ApplicationNodeData,
ApplicationServerData,
MessageData,
} from '../../types';
import { Application } from './Application';
import { Outgoing } from './Outgoing';
import {AsyncAPIDocument} from '@asyncapi/parser';
import { AsyncAPIDocument } from '@asyncapi/parser';
import { Incoming } from './Incoming';
type InternalApplicationProps = {
internal?: {
addElementCallback?: any;
};
document: AsyncAPIDocument
document: AsyncAPIDocument;
};

type ApplicationProps = ApplicationNodeData & InternalApplicationProps;
Expand All @@ -21,55 +26,82 @@ type ApplicationProps = ApplicationNodeData & InternalApplicationProps;
export const AsyncAPIApplication: React.FunctionComponent<ApplicationProps> = props => {
const outgoingNodes = [];
const incomingNodes = [];
for (const [channelPath, channel] of Object.entries(props.document.channels())) {
if(channel.hasPublish()) {
for (const [channelPath, channel] of Object.entries(
props.document.channels(),
)) {
if (channel.hasPublish()) {
const channelId = props.document.info().title() + channelPath;
const messages: MessageData[] = channel.publish().messages().map((message) => {
return {title: message.name() || 'Unknown'}
});
incomingNodes.push(<Incoming
internal={{addElementCallback: props.internal?.addElementCallback}}
channel={channelPath}
description={channel.description() || 'No description'}
id={channelId}
messages={messages}></Incoming>);
const messages: MessageData[] = channel
.publish()
.messages()
.map(message => {
return { title: message.name() || 'Unknown' };
});
incomingNodes.push(
<Incoming
internal={{ addElementCallback: props.internal?.addElementCallback }}
channel={channelPath}
description={channel.description() || 'No description'}
id={channelId}
messages={messages}
/>,
);
} else if (channel.hasSubscribe()) {
const channelId = props.document.info().title() + channelPath;
const messages: MessageData[] = channel.subscribe().messages().map((message) => {
return {title: message.name() || 'Unknown'}
});
outgoingNodes.push(<Outgoing
internal={{addElementCallback: props.internal?.addElementCallback}}
channel={channelPath}
description={channel.description() || 'No description'}
id={channelId}
messages={messages}></Outgoing>);
const messages: MessageData[] = channel
.subscribe()
.messages()
.map(message => {
return { title: message.name() || 'Unknown' };
});
outgoingNodes.push(
<Outgoing
internal={{ addElementCallback: props.internal?.addElementCallback }}
channel={channelPath}
description={channel.description() || 'No description'}
id={channelId}
messages={messages}
/>,
);
}
}
const license: ApplicationLicenseData = {
name: props.document.info()?.license()?.name() || 'Not defined',
url: props.document.info()?.license()?.url() || 'Not defined'
}
const servers: ApplicationServerData[] = Object.entries(props.document.servers()).map(([serverId, server]) => {
name:
props.document
.info()
?.license()
?.name() || 'Not defined',
url:
props.document
.info()
?.license()
?.url() || 'Not defined',
};
const servers: ApplicationServerData[] = Object.entries(
props.document.servers(),
).map(([serverId, server]) => {
return {
description: server.description() || 'No description',
name: serverId,
protocol: server.protocol() || 'No protocol',
protocolVersion: server.protocolVersion() || 'No protocol version',
url: server.url()
}
})
return <Application
internal={{addElementCallback: props.internal?.addElementCallback}}
defaultContentType={props.document.defaultContentType() || 'Undefined'}
description={props.document.info().description() || 'No description'}
id={props.document.info().title()}
license={license}
externalDocs={props.document.externalDocs()?.url() || 'No external docs'}
servers={servers}
title={props.document.info().title()}
version={props.document.info().version()}>
{incomingNodes}
{outgoingNodes}
</Application>
url: server.url(),
};
});
return (
<Application
internal={{ addElementCallback: props.internal?.addElementCallback }}
defaultContentType={props.document.defaultContentType() || 'Undefined'}
description={props.document.info().description() || 'No description'}
id={props.document.info().title()}
license={license}
externalDocs={props.document.externalDocs()?.url() || 'No external docs'}
servers={servers}
title={props.document.info().title()}
version={props.document.info().version()}
>
{incomingNodes}
{outgoingNodes}
</Application>
);
};
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"prettier": "^1.18.2",
"semantic-release": "^17.4.3",
"tslib": "^1.10.0",
"tslint": "^5.17.0",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"tslint-react": "^4.0.0",
"tslint-react-hooks": "^2.1.1",
Expand Down

0 comments on commit ce66206

Please sign in to comment.