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

Replace head_title with Kicker #140

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Replace head_title with Kicker #140

wants to merge 4 commits into from

Conversation

iFlameing
Copy link
Member

@davisagli I don't know how to create an alias for headtitle. can you please take care of it?

@mister-roboto
Copy link

@iFlameing thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@davisagli
Copy link
Sponsor Member

@iFlameing I think we need to:

  1. Create IKicker like you did already
  2. Add IHeadTitle = IKicker in Python (so the old name still works if someone is importing it)
  3. Register 2 behaviors, the old one and the new one. I don't think there's an easy way to avoid this, since one behavior can only have one name.

@iFlameing
Copy link
Member Author

@davisagli I added the head title once again but I haven't tested it because I don't know how to test it. Also, it is a breaking change. where and how I should mention it?

@davisagli
Copy link
Sponsor Member

I added the head title once again but I haven't tested it because I don't know how to test it.

@iFlameing For starters, look at the result of the existing tests, which are failing. It looks like it is a problem to have 2 behavior registrations for the same interface, and here it is the same object even though it has an alias. To fix this, define IHeadTitle as a subclass of IKicker:

class IHeadTitle(IKicker):
    """alias for backwards-compatibility"""

Next, test this change with our customer project. You can pip install this branch from github (https://pip.pypa.io/en/stable/topics/vcs-support/). If our backwards-compatibility efforts are successful, everything in that project should still work even if you don't change the content types to use the new behavior.

Also, it is a breaking change. where and how I should mention it?

  1. Update the readme where it discusses the head title behavior
  2. Mention the new title of the field in the changelog. I think we decided we can call this one a bugfix.

@tisto
Copy link
Sponsor Member

tisto commented Apr 16, 2024

@iFlameing do you have time to look into this during the week? I would love to start using this for our different Plone distribution projects.

<plone:behavior
name="volto.kicker"
title="Kicker field"
description="Adds kicker field"
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Suggested change
description="Adds kicker field"
description="Adds kicker field (text to be shown above the headline)"

description="Adds kicker field"
provides=".kicker.IKicker"
/>

<plone:behavior
name="volto.head_title"
title="Head title field"
description="Adds Head title field"
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Suggested change
description="Adds Head title field"
description="Deprecated (use volto.kicker instead)"


head_title = schema.TextLine(
title=_("label_head_title", default="Header title"),
kicker = schema.TextLine(
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

If we change the name of the field, it won't be backward-compatible.

There are a bunch of places in volto and in volto-light-theme which assume there is a field called head_title, not kicker.

We also have a catalog column which copies the value of the head_title field.

So, it'll be a lot easier if we keep the existing internal field name and only change the name of the behavior and the user-visible text.

Suggested change
kicker = schema.TextLine(
head_title = schema.TextLine(

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

@davisagli didn't we agree to add a new "kicker" field in addition to the head_title field and then deprecate head_title? Of course we would have to write a migration for existing projects at some point. However, we would have a clean codebase and not an inconsistency in our code base.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

@tisto No, I thought the plan was to add a new behavior but keep the old field name. If we change the field name then any component which displays the kicker needs to check both the old and new field name, so it would make a lot of code more messy (and also take some time to find and update each location).

We can talk about it tomorrow but I don't think it's worth the effort to change the field name.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

@davisagli ok, then this was a misunderstanding from my side. I leave this decision up to you. Just wanted to mention what I understood from our discussion.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Just one last thing. I was under the assumption that we only support "kicker" in future releases. Since head_title never made it into core this would be a breaking change that is acceptable IMO.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

@tisto There are already references to head_title in core: https://github.com/search?q=repo%3Aplone%2Fvolto%20head_title&type=code

@@ -38,8 +38,8 @@ msgid "Creates a default page for the site using slate blocks"
msgstr ""

#: plone/volto/behaviors/configure.zcml:42
msgid "Head title field"
msgstr "Kopftitel Feld"
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I think we should keep the existing translations for "head title"; it's better than removing the translations.

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

4 participants