mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +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.lib import get_ayon_launcher_args, run_detached_process
|
||||||
|
|
||||||
from ayon_core.pipeline.actions import (
|
from ayon_core.pipeline.actions import (
|
||||||
LoaderActionPlugin,
|
LoaderSimpleActionPlugin,
|
||||||
LoaderActionItem,
|
|
||||||
LoaderActionSelection,
|
LoaderActionSelection,
|
||||||
LoaderActionResult,
|
LoaderActionResult,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class PushToProject(LoaderActionPlugin):
|
class PushToProject(LoaderSimpleActionPlugin):
|
||||||
identifier = "core.push-to-project"
|
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
|
self, selection: LoaderActionSelection
|
||||||
) -> list[LoaderActionItem]:
|
) -> bool:
|
||||||
folder_ids = set()
|
if not selection.versions_selected():
|
||||||
version_ids = set()
|
return False
|
||||||
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
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
output = []
|
version_ids = set(selection.selected_ids)
|
||||||
if version_ids and len(folder_ids) == 1:
|
product_ids = {
|
||||||
output.append(
|
product["id"]
|
||||||
LoaderActionItem(
|
for product in selection.entities.get_versions_products(
|
||||||
label="Push to project",
|
version_ids
|
||||||
order=35,
|
|
||||||
data={"version_ids": list(version_ids)},
|
|
||||||
icon={
|
|
||||||
"type": "material-symbols",
|
|
||||||
"name": "send",
|
|
||||||
"color": "#d8d8d8",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
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,
|
self,
|
||||||
selection: LoaderActionSelection,
|
selection: LoaderActionSelection,
|
||||||
data: dict[str, Any],
|
|
||||||
form_values: dict[str, Any],
|
form_values: dict[str, Any],
|
||||||
) -> Optional[LoaderActionResult]:
|
) -> 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(
|
push_tool_script_path = os.path.join(
|
||||||
AYON_CORE_ROOT,
|
AYON_CORE_ROOT,
|
||||||
"tools",
|
"tools",
|
||||||
|
|
@ -74,7 +60,7 @@ class PushToProject(LoaderActionPlugin):
|
||||||
args = get_ayon_launcher_args(
|
args = get_ayon_launcher_args(
|
||||||
push_tool_script_path,
|
push_tool_script_path,
|
||||||
"--project", selection.project_name,
|
"--project", selection.project_name,
|
||||||
"--versions", ",".join(version_ids)
|
"--versions", ",".join(selection.selected_ids)
|
||||||
)
|
)
|
||||||
run_detached_process(args)
|
run_detached_process(args)
|
||||||
return LoaderActionResult(
|
return LoaderActionResult(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue