mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
push to project uses simple action
This commit is contained in:
parent
48cc1719e3
commit
bc5c162a00
1 changed files with 31 additions and 45 deletions
|
|
@ -5,65 +5,51 @@ from ayon_core import AYON_CORE_ROOT
|
|||
from ayon_core.lib import get_ayon_launcher_args, run_detached_process
|
||||
|
||||
from ayon_core.pipeline.actions import (
|
||||
LoaderActionPlugin,
|
||||
LoaderActionItem,
|
||||
LoaderSimpleActionPlugin,
|
||||
LoaderActionSelection,
|
||||
LoaderActionResult,
|
||||
)
|
||||
|
||||
|
||||
class PushToProject(LoaderActionPlugin):
|
||||
class PushToProject(LoaderSimpleActionPlugin):
|
||||
identifier = "core.push-to-project"
|
||||
label = "Push to project"
|
||||
order = 35
|
||||
icon = {
|
||||
"type": "material-symbols",
|
||||
"name": "send",
|
||||
"color": "#d8d8d8",
|
||||
}
|
||||
|
||||
def get_action_items(
|
||||
def is_compatible(
|
||||
self, selection: LoaderActionSelection
|
||||
) -> list[LoaderActionItem]:
|
||||
folder_ids = set()
|
||||
version_ids = set()
|
||||
if selection.selected_type == "version":
|
||||
version_ids = set(selection.selected_ids)
|
||||
product_ids = {
|
||||
product["id"]
|
||||
for product in selection.entities.get_versions_products(
|
||||
version_ids
|
||||
)
|
||||
}
|
||||
folder_ids = {
|
||||
folder["id"]
|
||||
for folder in selection.entities.get_products_folders(
|
||||
product_ids
|
||||
)
|
||||
}
|
||||
) -> bool:
|
||||
if not selection.versions_selected():
|
||||
return False
|
||||
|
||||
output = []
|
||||
if version_ids and len(folder_ids) == 1:
|
||||
output.append(
|
||||
LoaderActionItem(
|
||||
label="Push to project",
|
||||
order=35,
|
||||
data={"version_ids": list(version_ids)},
|
||||
icon={
|
||||
"type": "material-symbols",
|
||||
"name": "send",
|
||||
"color": "#d8d8d8",
|
||||
}
|
||||
)
|
||||
version_ids = set(selection.selected_ids)
|
||||
product_ids = {
|
||||
product["id"]
|
||||
for product in selection.entities.get_versions_products(
|
||||
version_ids
|
||||
)
|
||||
return output
|
||||
}
|
||||
folder_ids = {
|
||||
folder["id"]
|
||||
for folder in selection.entities.get_products_folders(
|
||||
product_ids
|
||||
)
|
||||
}
|
||||
|
||||
def execute_action(
|
||||
if len(folder_ids) == 1:
|
||||
return True
|
||||
return False
|
||||
|
||||
def execute_simple_action(
|
||||
self,
|
||||
selection: LoaderActionSelection,
|
||||
data: dict[str, Any],
|
||||
form_values: dict[str, Any],
|
||||
) -> Optional[LoaderActionResult]:
|
||||
version_ids = data["version_ids"]
|
||||
if len(version_ids) > 1:
|
||||
return LoaderActionResult(
|
||||
message="Please select only one version",
|
||||
success=False,
|
||||
)
|
||||
|
||||
push_tool_script_path = os.path.join(
|
||||
AYON_CORE_ROOT,
|
||||
"tools",
|
||||
|
|
@ -74,7 +60,7 @@ class PushToProject(LoaderActionPlugin):
|
|||
args = get_ayon_launcher_args(
|
||||
push_tool_script_path,
|
||||
"--project", selection.project_name,
|
||||
"--versions", ",".join(version_ids)
|
||||
"--versions", ",".join(selection.selected_ids)
|
||||
)
|
||||
run_detached_process(args)
|
||||
return LoaderActionResult(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue