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

Rename Twitter/X workflow task to match updated view names #15930

Conversation

davidpuplava
Copy link
Contributor

@davidpuplava davidpuplava commented May 1, 2024

This PR fixes the following error Exception: The shape type 'UpdateTwitterStatusTask_Fields_Thumbnail' is not found and similar exceptions when editing a workflow while the X Integration feature is enabled.

image

Steps to Reproduce

  1. Pull latest version of main branch or any branch that contains commit 9e03d4f85267762e5446b42ad16d281e06f61f41
  2. Create a tenant or site with the blog recipe
  3. Enable the following features: Workflows, X Integration, Sign in with X
  4. Create new workflow called test (or whatever name)
  5. Click Save
  6. Expect workflow editor to display, but observe runtime exception

Analysis

Looks to be related to the this PR to rebrand Twitter to X. The view files for the Workflow Activity Task were renamed but the task itself was not renamed.

Solution

After I renamed the Task to match the view names, the exception disappears and I can add the Update Status task a workflow.

Considerations

  • In this PR, I only updated the Task name and left other type names that include the word Twitter. If desired, I can update this PR to rename those as well, but not sure if that will have any adverse consequences.
  • Renaming the UpdateTwitterStatusTask to UpdateXStatusTask breaks existing Workflows that were created with the original UpdateTwitterStatusTask name. The workaround is to manually edit the database JSON to update the workflow definition to the new task name. Ideally, this change would happen automatically but I'm not sure how. This is why I opened a discussion on whether a DataMigration can be used to achieve this. In all honestly though, this Twitter/X may not be used enough to try and solve this automatically, especially since editing the database entry was trivial.

Fixes #16349

Summary by CodeRabbit

  • Refactor
    • Renamed UpdateTwitterStatusTask to UpdateXStatusTask across various components in the OrchardCore.Twitter module to reflect updated functionality.
  • New Features
    • Enhanced the Twitter module's workflow activities to support new status update tasks.
  • Bug Fixes
    • Fixed issues related to the editing and updating of Twitter status tasks in the workflow drivers.

Copy link
Contributor

coderabbitai bot commented May 1, 2024

Walkthrough

Walkthrough

The updates across various files in the OrchardCore.Twitter module involve renaming the UpdateTwitterStatusTask to UpdateXStatusTask. This change affects class declarations, method signatures, and references in views and startup configurations, aligning the entire module to the new task name. This renaming likely indicates a broader shift in functionality or branding within the module.

Changes

File Path Change Summary
.../UpdateXStatusTask.Fields.Design.cshtml Updated model reference from UpdateTwitterStatusTask to UpdateXStatusTask.
.../UpdateXStatusTask.cs Renamed class UpdateTwitterStatusTask to UpdateXStatusTask. Updated constructor and localizer references.
.../UpdateTwitterStatusTaskDisplayDriver.cs Updated class and methods to work with UpdateXStatusTask instead of UpdateTwitterStatusTask.
.../Startup.cs Updated AddActivity method call to use UpdateXStatusTask.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented May 1, 2024

Thank you for submitting your first pull request, awesome! 🚀 If you haven't already, please take a moment to review our contribution guide. This guide provides helpful information to ensure your contribution aligns with our standards. A core team member will review your pull request.

If you like Orchard Core, please star our repo and join our community channels

@davidpuplava
Copy link
Contributor Author

@dotnet-policy-service agree

@hishamco
Copy link
Member

hishamco commented May 1, 2024

Renaming the UpdateTwitterStatusTask to UpdateXStatusTask breaks existing Workflows that were created with the original UpdateTwitterStatusTask name. The workaround is to manually edit the database JSON to update the workflow definition to the new task name. Ideally, this change would happen automatically but I'm not sure how. This is why I #15928 on whether a DataMigration can be used to achieve this. In all honestly though, this Twitter/X may not be used enough to try and solve this automatically, especially since editing the database entry was trivial.

Thanks, @davidpuplava for opening this PR, IMHO we either revert the task rename or create a migration to avoid breaking existing workflows, please create a database migration and let me know if you need help on this

@davidpuplava
Copy link
Contributor Author

IMHO we either revert the task rename or create a migration to avoid breaking existing workflows

That's the right thing to do. I'll try and add a database migration to do that and will let you know if I have any questions.

@davidpuplava davidpuplava marked this pull request as draft May 1, 2024 14:01
@sebastienros
Copy link
Member

Yeah, this rename is not showing all the things it can break. I would revert everything IMO. As long as X doesn't sue us for using the Twitter name ;) We could also clone the module to use the X language and deprecate the other one, while providing an opt-in migration path to the new module until a version when we definitely remove it. Users could even do it manually at least since both would exist.

@davidpuplava
Copy link
Contributor Author

please create a database migration and let me know if you need help on this

@hishamco I added a Data Migration but it doesn't seem to run even though I added it to Startup. Looks like the GetFeaturesThatNeedUpdateAsync method in the DataMigrationManager isn't picking up that the OrchardCore.Twitter feature needs to be updated. But given @sebastienros's about all the things that could break, I think I'll just rename the views back to UpdateTwitterStatusTask_... to resolve the exception.

Yeah, this rename is not showing all the things it can break. I would revert everything IMO

Thanks for pointing this out @sebastienros. I'll revise this PR to change the view names back.

@hishamco
Copy link
Member

hishamco commented May 2, 2024

Please update the PR to show why the migration is not working, which might be a bug that needs a fix, otherwise, we will revert the rename change

@davidpuplava
Copy link
Contributor Author

davidpuplava commented May 3, 2024

Please update the PR to show why the migration is not working

False alarm. I have the migrations working now. I overlooked that migration was already applied while testing. I've pushed up a data migration that renames the task in any workflow type definitions.

I tested on my existing tenant that had workflows created prior to rebranding. I confirmed that instances do not need a rename because they refer back to the workflow type by id.

I tested a blocking workflow that was in progress and that too does not seem to be a problem as @Piedone pointed out while answering my question about how to migrate.

Do recipes and deployments need to be considered for migrating?

I see that there is an IRecipeMigrator concept but I think that is more for recipes that are packaged with a module.

EDIT

I should point out that I modeled the migrations after similar code I found in the Lucene Search module rename here, and Orchard Users module rename here.

Admittedly, I don't know what ShellScope.DeferredTask() does or if it appropriate here, but I thought best to match how other modules migrated content items in the document table.

@davidpuplava davidpuplava marked this pull request as ready for review May 3, 2024 05:04
Copy link
Contributor

This pull request has merge conflicts. Please resolve those before requesting a review.

@MikeAlhayek
Copy link
Member

@davidpuplava for instructions on how to resolve the merge conflicts due to #16572 please follow the step listed in this comment.

Copy link
Contributor

This pull request has merge conflicts. Please resolve those before requesting a review.

@davidpuplava
Copy link
Contributor Author

I've tested against the X/Twitter v1.1 API and confirm the UpdateXTwitterStatusTask works as expected. I've re-requested reviews as mentioned I should do earlier.

But...I'm not certain that changing the workflow task type name (UpdateXTwitterStatusTask.cs) makes sense anymore.

Changing the UI strings to "X (Twitter)" is beneficial for the user. Changing type names benefits developers, but the single letter company name X is ambiguous enough that "XTwitter" is more descriptive anyway.

So the question stands, is the risk of changing the type name worth the value gained in simply adding and 'X' in front of Twitter.
Probably not.

I originally opened this PR only to get past the unhandled exception that was ultimately fixed with #16350 by changing the type names back.

That said, it's worth considering if this PR should be closed without merging.

Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

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

Checking this out again, I agree. My head hurts due to all the wasted effort to adapt to such a pointless rebranding, but I'd keep every technical identifier (file names, types, HTML IDs...) as they were (#16350 reverted the shape template renames already). We shouldn't have done anything else than update UI labels. So, please in this PR:

  • Only keep the UI string renames (but do keep all of those), having "(Twitter)" everywhere makes it possible to search for things.
  • Even revert the AdminMenuSignin class/ID "X" rename, including in NavigationItemText-x.Id.cshtml, but do add "(Twitter)" here too.
  • Check the module for other cases of these and do the same.

If you @hishamco @sebastienros object to this please comment.

@hishamco
Copy link
Member

hishamco commented Aug 17, 2024

My head hurts due to all the wasted effort to adapt to such a pointless rebranding

Zoltan I think we did similar things in both Azure AD & Facebook Meta

Let me review this one more time and processed forward

@Piedone
Copy link
Member

Piedone commented Aug 17, 2024

Yes, and that was a waste of time as well. I'm complaining about the companies doing the rebranding, i.e. Twitter in this case.

@hishamco
Copy link
Member

Hopefully this is not a matter for Lombiq one day :)

@davidpuplava
Copy link
Contributor Author

Zoltan I think we did similar things in both Azure AD & Facebook Meta

Yes, looks like UI strings were updated to use the Meta and EntraID names, but the type names were left as is, mostly. I'll work towards @Piedone instructions to put the type names back and focus on the UI Strings.

My interest in the X/Twitter module is because I implemented the v2 endpoint for posting to X. I'll submit that as a PR after I take care of this one.

The v2 API for X is substantial enough that I could clone the Twitter module and make a new OrchardCore.X module like @sebastienros suggested. But with pricing tiers of $100 / $5000 / $42000 per month, I don't know how much demand for twitter integration their is out there. Their API urls still use 'tweets', so they're not yet fully committed to their own rebrand.

@davidpuplava
Copy link
Contributor Author

This PR is ready for review. I changed type/class/id names back to their original names prior to the rebrand based on what I could find in #15528 but I left the changes to the documentation pages. I tested both workflows for both new and old Update Twitter Status tasks, and confirm they hit the v1.1 API for X/Twitter.

…isted to update workflow task names in Documents table
@Piedone Piedone added this to the 2.0 milestone Aug 20, 2024
davidpuplava and others added 4 commits August 20, 2024 16:19
Co-authored-by: Zoltán Lehóczky <zoltan.lehoczky@lombiq.com>
Co-authored-by: Zoltán Lehóczky <zoltan.lehoczky@lombiq.com>
@Piedone
Copy link
Member

Piedone commented Aug 20, 2024

Would you like to also review this, @hishamco?

@hishamco
Copy link
Member

I will do a quick one now

@Piedone Piedone merged commit 51f24d7 into OrchardCMS:main Aug 20, 2024
10 checks passed
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.

OrchardCore.Twitter breaks workflow editor
5 participants