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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed deprecation warnings and bugs on page operations #11

Merged
merged 13 commits into from Sep 19, 2023

Conversation

cabidop
Copy link
Contributor

@cabidop cabidop commented Sep 8, 2023

Hi, @angusmcleod! Not sure if you are paying any attention at all to the plugin, but I recently started working with Discourse and found that Landing Pages filled exactly the gap I just needed for a project. Seeing that it was unmaintained I started my own simplified version of your plugin, but this week I decided to give it a go and update yours so here we are now 馃槃 .

Although I am already using my fork, I would appreciate if you could take a look to this PR to include the changes in the main repository so everyone can benefit from them. The list is not huge as I mainly focused on removing deprecation warnings and bringing the basic functionality back to life:

  • Cleaned Ruby and Javascript deprecated code when loading the plugin.
  • Fixed the "export page" functionality which solves Clicking on the export button for a local page throws a JS error and fails聽#4, as some Javascript bits were missing for it to properly trigger.
  • Fixed the "import page" feature too. This required a little bit more effort as the modal needed to be migrated and there were some mismatches in the Ruby code between the exported and the imported information.
  • Small fix to the "delete page" feature to remove the recently deleted page from the list.

There are still some small issues with the save functionality (e.g. you can never remove categories and group once you added them) and I have not reviewed yet the global and remote functionality, but at least the plugin is now on a non-broken state.

If you think it is too much to review in one go let me know as I can definitely make multiple PRs, each commit is more or less self-contained. Thanks a lot in advance and hope that you are still around for this!

@angusmcleod
Copy link
Member

@cabidop Thanks! I'll take a closer look as soon as I can.

@cabidop
Copy link
Contributor Author

cabidop commented Sep 18, 2023

Hi, @angusmcleod ! Any chance to take a look?

Copy link
Member

@angusmcleod angusmcleod left a comment

Choose a reason for hiding this comment

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

@cabidop Thanks a lot for this! I really appreciate the effort you've put in here. I've left a few specific comments.

On the whole, before I can support this is a merge that bring the plugin up to date with Discourse, There are a few changes here that seem to not be strictly about making the plugin work, and it's not clear to me whether they're breaking some existing non-inline functionality.

I definitely don't want to discourage you! But there may need to be some more focus on the other functionality you haven't been directly using, before I can support this as a general "fix". Essentially, when we make that claim by merging this I don't want to be signing up for a fresh round of support from folks who want to use other features that are newly broken, or still broken.

But keen to support you here still. If you'd like more specific feedback than I've given, let me know.

@@ -2,7 +2,7 @@
class LandingPages::InvalidAccess < StandardError; end
class LandingPages::InvalidParameters < StandardError; end

class LandingPages::LandingController < ::ActionController::Base
class LandingPages::LandingController < ApplicationController
Copy link
Member

Choose a reason for hiding this comment

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

@cabidop Inheriting the application controller here means inheriting quite a lot of logic. Could you walk me through why you're doing this? Perhaps this is to make the new "inline" pages you've added? Does it work for non-inline pages though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not directly related to the inline pages (although it simplified quite a bit the implementation), but checking the ActionController::Base documentation seems that by default the only controller that inherits it is the ApplicationController, which seems to also be the approach for the default and official Discourse plugins I checked out (e.g. chat, poll, styleguide, calendar, cakeday, etc).

On the other hand, I have not seen anything specifically discouraging to inherit ActionController::Base directly so let me know your thoughts on this.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, typically you would inherit the ApplicationController because you're serving content within Discourse and you want all the logic included in the ApplicationController (e.g. all it's before_actions). However in this case, sometimes we don't want all of that logic running because a landing page will not be running inside of the main Discourse app. If there wasn't a good reason to make this change then best not to make it.

@@ -24,7 +24,8 @@
<%= discourse_stylesheet_link_tag "landing_page", theme_id: nil %>

<%- if theme_id.present? %>
<%= discourse_stylesheet_link_tag (mobile_view? ? :mobile_theme : :desktop_theme), theme_id: theme_id %>
<%= discourse_color_scheme_stylesheets %>
<%= discourse_stylesheet_link_tag (mobile_view? ? :mobile : :desktop), theme_id: theme_id %>
Copy link
Member

Choose a reason for hiding this comment

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

@cabidop Whether it's this change or some other changes, page styling of non-inline pages seems to be broken. For example if you import pages from https://github.com/paviliondev/pavilion-landing-pages and apply the theme https://github.com/paviliondev/pavilion-landing-theme you see this

Screenshot 2023-09-19 at 10 21 45

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely right, seems that both tags are required as the :mobile/:desktop is used for the base styles and the :mobile_theme/:desktop_theme is used for the imported themes and the "manual" updates on the default one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also the current code it is actually ignoring the page setting for the theme, as all the conditionals use theme_id.* instead of @page.theme_id.*.

lib/landing_pages/page.rb Show resolved Hide resolved
@angusmcleod
Copy link
Member

@cabidop Thanks for the followup.

Let me know when you've made those changes. I've added standard plugin CI in here as a sanity check. That will just run the rspec suite in the plugin. We'll need to make sure that's passing before we merge this.

Thanks again!

@cabidop cabidop changed the title Updated plugin to work with latest Discourse versions Fixed deprecation warnings and bugs on page operations Sep 19, 2023
@cabidop
Copy link
Contributor Author

cabidop commented Sep 19, 2023

Hey @angusmcleod, thanks a lot for the review! I have just pushed some additional commits to address your comments. I fully agree on leaving out the new "inline" functionality (I will add it as a standalone change once the basics are fixed), and I rephrased the PR itself to better reflect its intention. It is now clear that it only impacts the page related functionality, leaving the fixes for both the global and remote functionalities for a different PR.

I also tested the spec locally and added two small fixes for it, but I am unsure if the CI pipeline will run before merging the PR (as the file is obviously not yet in the main branch).

@angusmcleod
Copy link
Member

@cabidop Ok! I think we can address further issues with the plugin separately. You've achieved a baseline of functionality here that we should bank. Thanks again! In terms of follow up:

  • Would you like to be added as an author of the plugin in the plugin.rb?
  • If you want to raise another PR I'll review it as a priority
  • I'm going to move this plugin back to "working" on meta.discourse.org

If you're keen to use this for the long haul I can also make you a maintainer. Let's see how we go in that respect.

@angusmcleod angusmcleod self-requested a review September 19, 2023 22:50
@angusmcleod angusmcleod merged commit 3e30e0b into paviliondev:main Sep 19, 2023
@cabidop cabidop mentioned this pull request Sep 26, 2023
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