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

Use Link component for links instead of mithril route patch #2315

Merged
merged 7 commits into from
Oct 2, 2020

Conversation

askvortsov1
Copy link
Sponsor Member

This PR:

  • Separates out the patched mithril link into an explicit component
  • Adds functionality so that this component can also process external links (so we can remove the hacky workaround in Notification and in fof links)
  • Deprecates the route mithril patch. This is deprecated and not removed because:
    • It existed in Mithril 0.2
    • Deprecating allows us to test these changes locally without immediately converting ALL bundled and fof extensions

@franzliedke
Copy link
Contributor

This is deprecated and not removed because: It existed in Mithril 0.2

Huh? I thought we changed all occurrences of <a href="#" config={m.route}> into <a route="#">? IMO, the BC layer is fine for testing this out (and before enforcing it for all extensions), but it should be removed again before release - no point in creating BC layers for never-released features from between two releases, right?

@askvortsov1
Copy link
Sponsor Member Author

I'm fine with that, I just want to get the core structure finalized before updating 30 extensions.

Copy link
Member

@clarkwinkelmann clarkwinkelmann left a comment

Choose a reason for hiding this comment

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

I'm globally ok with the change, I'm just unsure how much we want to document the changes to LinkButton?

Previously all links would be handled internally, unless an empty config method was passed to override the default m.route.

Now the new implementation uses what I see at line 26 of the Link component that is based on absolute vs relative links.

Don't we also sometime use absolute links for internal routing? Like for Mentions. That would be a change of behavior. I'm not entirely convinced it's a good idea to change the type on link based on whether the link is absolute. Also is the includes() test completely resilient against :// appearing elsewhere in the URL?

@askvortsov1
Copy link
Sponsor Member Author

I'm globally ok with the change, I'm just unsure how much we want to document the changes to LinkButton?

Previously all links would be handled internally, unless an empty config method was passed to override the default m.route.

Now the new implementation uses what I see at line 26 of the Link component that is based on absolute vs relative links.

Don't we also sometime use absolute links for internal routing? Like for Mentions. That would be a change of behavior. I'm not entirely convinced it's a good idea to change the type on link based on whether the link is absolute. Also is the includes() test completely resilient against :// appearing elsewhere in the URL?

You bring up a good point. The absolute/relative link thing would be cool, but needs more testing and discussion to make sure it is right. Let's remove that part for now, but keep the rest?

@clarkwinkelmann
Copy link
Member

You bring up a good point. The absolute/relative link thing would be cool, but needs more testing and discussion to make sure it is right. Let's remove that part for now, but keep the rest?

That would seem good to me 👍

We just need to add some way for LinkButton to be used for external links in the meantime. Maybe some external: true or internal:false attr?

@askvortsov1
Copy link
Sponsor Member Author

Yeah that sounds good... Actually.... I suppose we could pass that "external" flag all the way to Link, and use that instead of ://? Would still be nicer than what we're doing now for notifications

@dsevillamartin
Copy link
Member

Any reason why we are specifying external links? Does m.route.Link not work with external links? Apart from that, LGTM.

@askvortsov1
Copy link
Sponsor Member Author

From what I remember, it doesn't

@dsevillamartin
Copy link
Member

I approved, but I do also wonder why we decided to not extend m.route.Link. It's not important tho, and without extending it we can handle external links as well.

@askvortsov1
Copy link
Sponsor Member Author

Given that the goal is to make things more direct, I thought that explictly including one link or another by composition would be preferable

@askvortsov1 askvortsov1 merged commit 5ecb74f into master Oct 2, 2020
@askvortsov1 askvortsov1 deleted the as/link-component-poc branch October 2, 2020 20:56
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.

4 participants