mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Implement Create Project Folder Structure web action
This commit is contained in:
parent
d5b2642e8d
commit
4f6ea87092
1 changed files with 59 additions and 0 deletions
|
|
@ -1,6 +1,11 @@
|
|||
from typing import Any
|
||||
|
||||
from ayon_server.addons import BaseServerAddon
|
||||
from ayon_server.actions import (
|
||||
ActionExecutor,
|
||||
ExecuteResponseModel,
|
||||
SimpleActionManifest,
|
||||
)
|
||||
|
||||
from .settings import (
|
||||
CoreSettings,
|
||||
|
|
@ -9,6 +14,9 @@ from .settings import (
|
|||
)
|
||||
|
||||
|
||||
IDENTIFIER_PREFIX = "core.launch"
|
||||
|
||||
|
||||
class CoreAddon(BaseServerAddon):
|
||||
settings_model = CoreSettings
|
||||
|
||||
|
|
@ -26,3 +34,54 @@ class CoreAddon(BaseServerAddon):
|
|||
return await super().convert_settings_overrides(
|
||||
source_version, overrides
|
||||
)
|
||||
|
||||
async def get_simple_actions(
|
||||
self,
|
||||
project_name: str | None = None,
|
||||
variant: str = "production",
|
||||
) -> list[SimpleActionManifest]:
|
||||
"""Return a list of simple actions provided by the addon"""
|
||||
output = []
|
||||
|
||||
# Add 'Create Project Folder Structure' action to folders.
|
||||
output.append(
|
||||
SimpleActionManifest(
|
||||
identifier=f"{IDENTIFIER_PREFIX}.createprojectstructure",
|
||||
label="Create Project Folder Structure",
|
||||
icon={
|
||||
"type": "material-symbols",
|
||||
"name": "create_new_folder",
|
||||
},
|
||||
order=100,
|
||||
entity_type="folder",
|
||||
entity_subtypes=None,
|
||||
allow_multiselection=False,
|
||||
)
|
||||
)
|
||||
|
||||
return output
|
||||
|
||||
async def execute_action(
|
||||
self,
|
||||
executor: "ActionExecutor",
|
||||
) -> "ExecuteResponseModel":
|
||||
"""Execute actions.
|
||||
|
||||
Note:
|
||||
Executes CLI actions defined in the
|
||||
addon's client code or other addons.
|
||||
|
||||
"""
|
||||
|
||||
project_name = executor.context.project_name
|
||||
|
||||
if executor.identifier == \
|
||||
f"{IDENTIFIER_PREFIX}.createprojectstructure":
|
||||
return await executor.get_launcher_action_response(
|
||||
args=[
|
||||
"createprojectstructure",
|
||||
"--project", project_name,
|
||||
]
|
||||
)
|
||||
|
||||
raise ValueError(f"Unknown action: {executor.identifier}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue