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

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

Conversation

davidpuplava
Copy link

@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.

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

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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration 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

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
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
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
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
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
await using var connection = dbConnectionAccessor.CreateConnection();
await connection.OpenAsync();
await using var transaction = await connection.BeginTransactionAsync(session.Store.Configuration.IsolationLevel);
var dialect = session.Store.Configuration.SqlDialect;
Copy link
Member

@hishamco hishamco May 3, 2024

Choose a reason for hiding this comment

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

I think this is wrong, no need to rely on specific data storage

Copy link
Author

Choose a reason for hiding this comment

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

I think this is wrong, no need to rely on specific data storage

What do you mean? I think those variables are all using interfaces from System.Data.Common to avoid relying on a specific database implementation. Is there different way to update the Workflow item types aside from updating the database directly?

Copy link
Member

Choose a reason for hiding this comment

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

Ignore my above comment, seems I conflict with other PR :)

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