modify loader tool to match changes in backend

This commit is contained in:
Jakub Trllo 2025-09-18 16:37:07 +02:00
parent a7b379059f
commit 8fdbda78ee
7 changed files with 65 additions and 76 deletions

View file

@ -316,13 +316,12 @@ class ActionItem:
Args:
plugin_identifier (str): Action identifier.
identifier (str): Action identifier.
entity_ids (set[str]): Entity ids.
entity_type (str): Entity type.
label (str): Action label.
group_label (Optional[str]): Group label.
icon (Optional[dict[str, Any]]): Action icon definition.
tooltip (Optional[str]): Action tooltip.
order (int): Action order.
data (Optional[dict[str, Any]]): Additional action data.
options (Union[list[AbstractAttrDef], list[qargparse.QArgument]]):
Action options. Note: 'qargparse' is considered as deprecated.
@ -331,23 +330,21 @@ class ActionItem:
self,
plugin_identifier: str,
identifier: str,
entity_ids: set[str],
entity_type: str,
label: str,
group_label: Optional[str],
icon: Optional[dict[str, Any]],
tooltip: Optional[str],
order: int,
data: Optional[dict[str, Any]],
options: Optional[list],
):
self.plugin_identifier = plugin_identifier
self.identifier = identifier
self.entity_ids = entity_ids
self.entity_type = entity_type
self.label = label
self.group_label = group_label
self.icon = icon
self.tooltip = tooltip
self.data = data
self.order = order
self.options = options
@ -371,13 +368,12 @@ class ActionItem:
return {
"plugin_identifier": self.plugin_identifier,
"identifier": self.identifier,
"entity_ids": list(self.entity_ids),
"entity_type": self.entity_type,
"label": self.label,
"group_label": self.group_label,
"icon": self.icon,
"tooltip": self.tooltip,
"order": self.order,
"data": self.data,
"options": options,
}
@ -387,7 +383,6 @@ class ActionItem:
if options:
options = deserialize_attr_defs(options)
data["options"] = options
data["entity_ids"] = set(data["entity_ids"])
return cls(**data)
@ -1011,10 +1006,9 @@ class FrontendLoaderController(_BaseLoaderController):
plugin_identifier: str,
identifier: str,
project_name: str,
entity_ids: set[str],
entity_type: str,
selected_ids: set[str],
selected_entity_type: str,
data: Optional[dict[str, Any]],
options: dict[str, Any],
form_values: dict[str, Any],
):
@ -1037,10 +1031,9 @@ class FrontendLoaderController(_BaseLoaderController):
plugin_identifier (sttr): Plugin identifier.
identifier (sttr): Action identifier.
project_name (str): Project name.
entity_ids (set[str]): Entity ids stored on action item.
entity_type (str): Entity type stored on action item.
selected_ids (set[str]): Selected entity ids.
selected_entity_type (str): Selected entity type.
data (Optional[dict[str, Any]]): Additional action item data.
options (dict[str, Any]): Action option values from UI.
form_values (dict[str, Any]): Action form values from UI.

View file

@ -318,10 +318,9 @@ class LoaderController(BackendLoaderController, FrontendLoaderController):
plugin_identifier: str,
identifier: str,
project_name: str,
entity_ids: set[str],
entity_type: str,
selected_ids: set[str],
selected_entity_type: str,
data: Optional[dict[str, Any]],
options: dict[str, Any],
form_values: dict[str, Any],
):
@ -329,20 +328,19 @@ class LoaderController(BackendLoaderController, FrontendLoaderController):
self._sitesync_model.trigger_action_item(
identifier,
project_name,
entity_ids,
data,
)
return
self._loader_actions_model.trigger_action_item(
plugin_identifier,
identifier,
project_name,
entity_ids,
entity_type,
selected_ids,
selected_entity_type,
options,
form_values,
plugin_identifier=plugin_identifier,
identifier=identifier,
project_name=project_name,
selected_ids=selected_ids,
selected_entity_type=selected_entity_type,
data=data,
options=options,
form_values=form_values,
)
# Selection model wrappers

View file

@ -5,7 +5,7 @@ import traceback
import inspect
import collections
import uuid
from typing import Callable, Any
from typing import Optional, Callable, Any
import ayon_api
@ -125,10 +125,9 @@ class LoaderActionsModel:
plugin_identifier: str,
identifier: str,
project_name: str,
entity_ids: set[str],
entity_type: str,
selected_ids: set[str],
selected_entity_type: str,
data: Optional[dict[str, Any]],
options: dict[str, Any],
form_values: dict[str, Any],
):
@ -144,10 +143,9 @@ class LoaderActionsModel:
plugin_identifier (str): Plugin identifier.
identifier (str): Action identifier.
project_name (str): Project name.
entity_ids (set[str]): Entity ids on action item.
entity_type (str): Entity type on action item.
selected_ids (set[str]): Selected entity ids.
selected_entity_type (str): Selected entity type.
data (Optional[dict[str, Any]]): Additional action item data.
options (dict[str, Any]): Loader option values.
form_values (dict[str, Any]): Form values.
@ -156,10 +154,9 @@ class LoaderActionsModel:
"plugin_identifier": plugin_identifier,
"identifier": identifier,
"project_name": project_name,
"entity_ids": list(entity_ids),
"entity_type": entity_type,
"selected_ids": list(selected_ids),
"selected_entity_type": selected_entity_type,
"data": data,
"id": uuid.uuid4().hex,
}
self._controller.emit_event(
@ -172,16 +169,15 @@ class LoaderActionsModel:
crashed = False
try:
result = self._loader_actions.execute_action(
plugin_identifier,
identifier,
entity_ids,
entity_type,
LoaderActionSelection(
plugin_identifier=plugin_identifier,
action_identifier=identifier,
selection=LoaderActionSelection(
project_name,
selected_ids,
selected_entity_type,
),
form_values,
data=data,
form_values=form_values,
)
except Exception:
@ -203,7 +199,8 @@ class LoaderActionsModel:
loader = self._get_loader_by_identifier(
project_name, identifier
)
entity_type = data["entity_type"]
entity_ids = data["entity_ids"]
if entity_type == "version":
error_info = self._trigger_version_loader(
loader,
@ -346,8 +343,10 @@ class LoaderActionsModel:
return ActionItem(
LOADER_PLUGIN_ID,
get_loader_identifier(loader),
entity_ids=entity_ids,
entity_type=entity_type,
data={
"entity_ids": entity_ids,
"entity_type": entity_type,
},
label=label,
group_label=None,
icon=self._get_action_icon(loader),
@ -807,13 +806,12 @@ class LoaderActionsModel:
items.append(ActionItem(
action.plugin_identifier,
action.identifier,
action.entity_ids,
action.entity_type,
label=action.label,
group_label=action.group_label,
icon=action.icon,
tooltip=None, # action.tooltip,
order=action.order,
data=action.data,
options=None, # action.options,
))
return items

View file

@ -1,6 +1,7 @@
from __future__ import annotations
import collections
from typing import Any
from ayon_api import (
get_representations,
@ -315,16 +316,17 @@ class SiteSyncModel:
self,
identifier: str,
project_name: str,
representation_ids: set[str],
data: dict[str, Any],
):
"""Resets status for site_name or remove local files.
Args:
identifier (str): Action identifier.
project_name (str): Project name.
representation_ids (Iterable[str]): Representation ids.
data (dict[str, Any]): Action item data.
"""
representation_ids = data["representation_ids"]
active_site = self.get_active_site(project_name)
remote_site = self.get_remote_site(project_name)
@ -495,9 +497,10 @@ class SiteSyncModel:
},
tooltip=tooltip,
order=1,
entity_ids=representation_ids,
entity_type="representation",
options={},
data={
"representation_ids": representation_ids,
},
options=None,
)
def _add_site(self, project_name, repre_entity, site_name, product_type):

View file

@ -438,15 +438,14 @@ class ProductsWidget(QtWidgets.QWidget):
return
self._controller.trigger_action_item(
action_item.plugin_identifier,
action_item.identifier,
project_name,
action_item.entity_ids,
action_item.entity_type,
version_ids,
"version",
options,
{},
plugin_identifier=action_item.plugin_identifier,
identifier=action_item.identifier,
project_name=project_name,
selected_ids=version_ids,
selected_entity_type="version",
data=action_item.data,
options=options,
form_values={},
)
def _on_selection_change(self):

View file

@ -399,13 +399,12 @@ class RepresentationsWidget(QtWidgets.QWidget):
return
self._controller.trigger_action_item(
action_item.plugin_identifier,
action_item.identifier,
self._selected_project_name,
action_item.entity_ids,
action_item.entity_type,
repre_ids,
"representation",
options,
{},
plugin_identifier=action_item.plugin_identifier,
identifier=action_item.identifier,
project_name=self._selected_project_name,
selected_ids=repre_ids,
selected_entity_type="representation",
data=action_item.data,
options=options,
form_values={},
)

View file

@ -582,17 +582,16 @@ class LoaderWindow(QtWidgets.QWidget):
if result != QtWidgets.QDialog.Accepted:
return
form_data = dialog.get_values()
form_values = dialog.get_values()
self._controller.trigger_action_item(
event["plugin_identifier"],
event["identifier"],
event["project_name"],
event["entity_ids"],
event["entity_type"],
event["selected_ids"],
event["selected_entity_type"],
{},
form_data,
plugin_identifier=event["plugin_identifier"],
identifier=event["identifier"],
project_name=event["project_name"],
selected_ids=event["selected_ids"],
selected_entity_type=event["selected_entity_type"],
options={},
data=event["data"],
form_values=form_values,
)
def _on_project_selection_changed(self, event):