mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
split trigger or action and webaction
This commit is contained in:
parent
a93c877827
commit
34d66c65bc
5 changed files with 93 additions and 40 deletions
|
|
@ -297,26 +297,45 @@ class AbstractLauncherFrontEnd(AbstractLauncherCommon):
|
|||
@abstractmethod
|
||||
def trigger_action(
|
||||
self,
|
||||
action_label,
|
||||
action_type,
|
||||
action_id,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
addon_name,
|
||||
addon_version,
|
||||
):
|
||||
"""Trigger action on given context.
|
||||
|
||||
Args:
|
||||
action_label (str): Action label.
|
||||
action_type (Literal["webaction", "local"]): Action type.
|
||||
action_id (str): Action identifier.
|
||||
project_name (Union[str, None]): Project name.
|
||||
folder_id (Union[str, None]): Folder id.
|
||||
task_id (Union[str, None]): Task id.
|
||||
addon_name (Union[str, None]): Addon name.
|
||||
addon_version (Union[str, None]): Addon version.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def trigger_webaction(
|
||||
self,
|
||||
identifier,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
action_label,
|
||||
addon_name,
|
||||
addon_version,
|
||||
form_data=None,
|
||||
):
|
||||
"""Trigger action on given context.
|
||||
|
||||
Args:
|
||||
identifier (str): Action identifier.
|
||||
project_name (Union[str, None]): Project name.
|
||||
folder_id (Union[str, None]): Folder id.
|
||||
task_id (Union[str, None]): Task id.
|
||||
action_label (str): Action label.
|
||||
addon_name (str): Addon name.
|
||||
addon_version (str): Addon version.
|
||||
form_data (Optional[dict[str, Any]]): Form values of action.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -137,24 +137,38 @@ class BaseLauncherController(
|
|||
|
||||
def trigger_action(
|
||||
self,
|
||||
action_label,
|
||||
action_type,
|
||||
identifier,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
addon_name,
|
||||
addon_version,
|
||||
):
|
||||
self._actions_model.trigger_action(
|
||||
action_label,
|
||||
action_type,
|
||||
identifier,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
)
|
||||
|
||||
def trigger_webaction(
|
||||
self,
|
||||
identifier,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
action_label,
|
||||
addon_name,
|
||||
addon_version,
|
||||
form_data=None,
|
||||
):
|
||||
self._actions_model.trigger_webaction(
|
||||
identifier,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
action_label,
|
||||
addon_name,
|
||||
addon_version,
|
||||
form_data,
|
||||
)
|
||||
|
||||
def get_action_config_values(
|
||||
|
|
|
|||
|
|
@ -231,27 +231,11 @@ class ActionsModel:
|
|||
|
||||
def trigger_action(
|
||||
self,
|
||||
action_label,
|
||||
acton_type,
|
||||
identifier,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
addon_name,
|
||||
addon_version,
|
||||
):
|
||||
if acton_type == "webaction":
|
||||
self._trigger_webaction(
|
||||
action_label,
|
||||
identifier,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
addon_name,
|
||||
addon_version,
|
||||
)
|
||||
return
|
||||
|
||||
selection = self._prepare_selection(project_name, folder_id, task_id)
|
||||
failed = False
|
||||
error_message = None
|
||||
|
|
@ -285,6 +269,38 @@ class ActionsModel:
|
|||
}
|
||||
)
|
||||
|
||||
def trigger_webaction(
|
||||
self,
|
||||
identifier,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
action_label,
|
||||
addon_name,
|
||||
addon_version,
|
||||
form_data,
|
||||
):
|
||||
entity_type = None
|
||||
entity_ids = []
|
||||
if task_id:
|
||||
entity_type = "task"
|
||||
entity_ids.append(task_id)
|
||||
elif folder_id:
|
||||
entity_type = "folder"
|
||||
entity_ids.append(folder_id)
|
||||
|
||||
query = {
|
||||
"addonName": addon_name,
|
||||
"addonVersion": addon_version,
|
||||
"identifier": identifier,
|
||||
"variant": self._variant,
|
||||
}
|
||||
url = f"actions/execute?{urlencode(query)}"
|
||||
context = {
|
||||
"projectName": project_name,
|
||||
"entityType": entity_type,
|
||||
"entityIds": entity_ids,
|
||||
}
|
||||
def get_action_config_values(
|
||||
self,
|
||||
identifier,
|
||||
|
|
|
|||
|
|
@ -466,16 +466,13 @@ class ActionsWidget(QtWidgets.QWidget):
|
|||
addon_name = index.data(ACTION_ADDON_NAME_ROLE)
|
||||
addon_version = index.data(ACTION_ADDON_VERSION_ROLE)
|
||||
|
||||
self._controller.trigger_action(
|
||||
action_label,
|
||||
action_type,
|
||||
action_id,
|
||||
project_name,
|
||||
folder_id,
|
||||
task_id,
|
||||
addon_name,
|
||||
addon_version,
|
||||
)
|
||||
args = [action_id, project_name, folder_id, task_id]
|
||||
if action_type == "webaction":
|
||||
args.extend([action_label, addon_name, addon_version])
|
||||
self._controller.trigger_webaction(*args)
|
||||
else:
|
||||
self._controller.trigger_action(*args)
|
||||
|
||||
self._start_animation(index)
|
||||
self._start_animation(index)
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,10 @@ class LauncherWindow(QtWidgets.QWidget):
|
|||
"action.trigger.finished",
|
||||
self._on_action_trigger_finished,
|
||||
)
|
||||
controller.register_event_callback(
|
||||
"webaction.trigger.started",
|
||||
self._on_webaction_trigger_started,
|
||||
)
|
||||
|
||||
self._controller = controller
|
||||
|
||||
|
|
@ -223,6 +227,9 @@ class LauncherWindow(QtWidgets.QWidget):
|
|||
return
|
||||
self._echo("Failed: {}".format(event["error_message"]))
|
||||
|
||||
def _on_webaction_trigger_started(self, event):
|
||||
self._echo("Running webaction: {}".format(event["full_label"]))
|
||||
|
||||
def _is_page_slide_anim_running(self):
|
||||
return (
|
||||
self._page_slide_anim.state() == QtCore.QAbstractAnimation.Running
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue