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

Publisher: Refresh of create/publish values under correct conditions #990

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

iLLiCiTiT
Copy link
Member

Changelog Description

Fixed conditions triggering refresh of values in UI.

Additional info

I've noticed that the condition that should trigger refresh of values in UI has opposite condition to what it should be. Both create and publish attributes should be updated if happened changes in those keys.

Testing notes:

As far as I know this feature is not used at this moment. It should be possible to fake it. For example in Create plugin, register listen to value changes and make sure instance has 2 checkboxes, when checkbox 1 changes value, also change value of checkbox 2 to the same value in the callback. That change done by create plugin should be propagated to UI.

@ynbot ynbot added type: bug Something isn't working size/XS labels Nov 6, 2024
@BigRoy BigRoy changed the title Publisher: Refresh of create/publush values under correct conditions Publisher: Refresh of create/publish values under correct conditions Nov 6, 2024
Copy link
Collaborator

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

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

I guess the changed code does make sense. :) didn't test.

@iLLiCiTiT
Copy link
Member Author

For future reference, this was my testing create plugin in traypublisher

from ayon_core.lib.attribute_definitions import BoolDef

from ayon_traypublisher.api.plugin import TrayPublishCreator


class ExampleCreator(TrayPublishCreator):
    """Creates instance from file and retains its original name."""

    identifier = "io.ayon.example"
    label = "Example test"
    product_type = "example"
    description = "Example create plugin"
    extensions = [
        ".mov", ".mp4", ".mxf", ".m4v", ".mpg", ".exr",
        ".dpx", ".tif", ".png", ".jpg"
    ]

    def get_icon(self):
        return "fa.file"

    def create(self, product_name, instance_data, pre_create_data):
        # Create new instance
        self._create_instance(product_name, instance_data, self.product_type)

    def register_callbacks(self):
        self.create_context.add_value_changed_callback(self._on_value_change)

    def _on_value_change(self, event):
        for item in event["changes"]:
            instance = item["instance"]
            if (
                instance is None
                or instance.creator_identifier != self.identifier
            ):
                continue
            changes = item["changes"].get("creator_attributes", {})

            if "bool_value_1" in changes:
                value = changes["bool_value_1"]
                instance.creator_attributes["bool_value_2"] = value

    def get_attr_defs_for_instance(self, instance):
        return [
            BoolDef(
                "bool_value_1",
                default=True,
                label="Bool 1",
            ),
            BoolDef(
                "bool_value_2",
                default=True,
                label="Bool 2",
            ),
        ]

    def get_pre_create_attr_defs(self):
        return []

    def get_product_name(self, *args, **kwargs):
        return f"An Instance"

@iLLiCiTiT iLLiCiTiT merged commit a1f5270 into develop Nov 6, 2024
6 checks passed
@iLLiCiTiT iLLiCiTiT deleted the bugfix/publisher-refresh-of-values-fix branch November 6, 2024 10:36
@BigRoy
Copy link
Collaborator

BigRoy commented Nov 6, 2024

In that case - it looks like this use case? Are you sure it didn't work before?

@iLLiCiTiT iLLiCiTiT self-assigned this Nov 6, 2024
@iLLiCiTiT
Copy link
Member Author

Are you sure it didn't work before?

Not for me in traypublisher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants