Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local link type added #247

Merged
merged 4 commits into from
Oct 14, 2019
Merged

Conversation

gopherine
Copy link
Contributor

I have added local link type i dont know if i used the right naming convention. I did not wanted to break anything so for now i have just named it linktype but locallink and globallink sounds more sensible or may be if we can add config hirarchy inside the local itself

Copy link
Owner

@danielcaldas danielcaldas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, just some small comments there :)

const d = buildLinkPathDefinition({ source: { x: x1, y: y1 }, target: { x: x2, y: y2 } }, config.link.type);
const d = buildLinkPathDefinition(
{ source: { x: x1, y: y1 }, target: { x: x2, y: y2 }, linktype },
config.link.type
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type is already being passed to buildLinkPathDefinition, there's no need to duplicate the paramenter. I would go with:

const type = linkType || config.link.type;
const d = buildLinkPathDefinition(
        { source: { x: x1, y: y1 }, target: { x: x2, y: y2 }, linktype },
        type,
);

Copy link
Contributor Author

@gopherine gopherine Oct 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o well i over did it i kept thinking that type argument is global scoped now i realized what was wrong haha thanks a lot i have made the changes

@@ -68,10 +68,10 @@ function getRadiusStrategy(type) {
* @returns {string} the path definition for the requested link
* @memberof Link/helper
*/
function buildLinkPathDefinition({ source = {}, target = {} }, type = LINE_TYPES.STRAIGHT) {
function buildLinkPathDefinition({ source = {}, target = {}, linktype }, type = LINE_TYPES.STRAIGHT) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you take my previous suggestion, you don't need to modify the function signature. The type is already passed in the second parameter, this function was already ready to receive a type from the exterior :)

const { x: sx, y: sy } = source;
const { x: tx, y: ty } = target;
const validType = LINE_TYPES[type] || LINE_TYPES.STRAIGHT;
const validType = LINE_TYPES[linktype] || LINE_TYPES[type];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here, in fact, no need to update this function at all, it should work just fine with the previous implementation.

@gopherine
Copy link
Contributor Author

Just taking a second look at it, It is much better to have constant naming as type so i am not destructuring it anymore rather accessing it like this.

const type = link.type || config.link.type;

Now inside the local properties the changes can be seen with type only distinctively locally and globally
let me know if there is a problem with this

@danielcaldas
Copy link
Owner

Just taking a second look at it, It is much better to have constant naming as type so i am not destructuring it anymore rather accessing it like this.

const type = link.type || config.link.type;

Now inside the local properties the changes can be seen with type only distinctively locally and globally
let me know if there is a problem with this

Hey @gopherine makes sense to me.

@danielcaldas danielcaldas self-requested a review October 14, 2019 10:42
@danielcaldas danielcaldas merged commit c3d1ee4 into danielcaldas:master Oct 14, 2019
@danielcaldas
Copy link
Owner

Note, this PR refers to issue #234.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants