Skip to content

Commit

Permalink
Merge pull request #287 from ynput/252-add-documentation-for-webactions
Browse files Browse the repository at this point in the history
Add documentation for webactions and enhance production tracker docs
  • Loading branch information
MustafaJafar authored Oct 17, 2024
2 parents cfb9aa1 + 970a51c commit 63ec695
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 4 deletions.
23 changes: 21 additions & 2 deletions website/docs/addon_applications_admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ import versions from '@site/docs/assets/json/Ayon_addons_version.json'
{versions.Applications_Badge}
</ReactMarkdown>

## Introduction

The Applications addon streamlines the setup of applications and tools across your studio. It empowers you to set executable paths and startup environments, with support for various operating systems including Windows, Linux, and macOS.
## Applications Addon Features

### Applications, Tools and Filters

The Applications addon streamlines the setup of applications and tools across your studio. It allows you to set executable paths and startup environments, with support for various operating systems including Windows, Linux, and macOS.

:::info
Please note that the addon does not differentiate between different Linux distributions.
Expand All @@ -30,6 +33,22 @@ The Addon features two primary settings categories: Definitions and Filters:
1. **Definitions:** available only in studio settings, allows to define all possible applications and tools that can be used across all projects.
2. **Filters:** defines when certain applications and tools are used on project level. This filters whether a certain application or tool should be enabled in a certain launch context, like a specific task type or project-wide.


### Applications Web Actions

:::info
The web actions feature requires AYON Server version `1.3.0` or higher, core addon version `0.4.4` or higher, and Launcher version `1.1.0` or higher.

Web actions run through **shims**, which are automatically set up when users install the AYON launcher version `1.1.0` or higher.
:::

Web actions let you launch applications directly through the AYON web server. You can find these actions in the [details panel](artist_details_panel.md).

The application addon handles the logic for web actions. Currently, there are no specific settings for web actions.

The application web actions are generated from your application's definitions in your production or development bundles, depending on the developer mode setting, and they adhere to your application’s filter settings.


## Applications Addon Settings
### Show only available applications
![](assets/applications/show_only_available_apps.png)
Expand Down
33 changes: 33 additions & 0 deletions website/docs/artist_details_panel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
id: artist_details_panel
title: The Details Panel
sidebar_label: Details Panel
---

## Overview
When using the AYON production tracker, you'll encounter the details panel frequently. It's essential for team interactions.
As the name suggests, the details panel is packed with information, serving as a communication tool and offering useful actions.


## Panel Content

![](assets/details_panel/details_panel_overview.png)

- **Folder Path**: Displays the folder path to the entity.
- **Name & Thumbnail**: Shows the name and thumbnail of the entity.
:::tip Update Thumbnail
You can update the thumbnail by right-clicking the thumbnail and selecting Upload new thumbnail.
:::
- **Tags**: View and add tags.
- **Status**: View and update status.
- **Web Actions**: Access available web actions, e.g. applications, directly via the AYON web server.
- **[Activity Feed](artist_activity_feed.md)**: Leave comments and track activity.
- **[Watchers](artist_inbox.md#watchers)**: Update notification settings for the current folder or task and choose who receives updates.
- **Picture in Picture**: Open a panel that can stay open as you navigate to different pages.
- **Escape**: Close the current details panel.
- **Assigned Users**: Shows the assignees of the current task.
- **Priority**: View and update the priority of the current task.
- **Attributes**: Provides task details like `fps`, `Start frame`, `End frame`.
:::tip Attributes and Pipeline
These attributes are used within the pipeline and can be modified by the admin via the project editor.
:::
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
162 changes: 160 additions & 2 deletions website/docs/dev_addon_creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,168 @@ If you are curious, here's what happens when you access the api without logging


### Web Action
:::note TODO
Write about it and add an example.

Web actions let users trigger AYON Addons CLI actions directly from the AYON server to perform actions on their machines. They run through **shims**, which are automatically set up when users install the AYON launcher version `1.1.0` or higher.

Web actions are added in two steps:

1. **Client-Side CLI Actions**: Develop the addon CLI actions in the client-side code of the addon. More about them in the next section [CLI Interface](dev_addon_creation.md#cli-interface).
2. **Server-Side Web Actions**: Implement web actions in the server-side code of the addon and link them to their corresponding addon CLI actions.

<!-- TODO: We may expand later on `SimpleActionManifest` and `ActionExecutor`. -->

<details><summary>Simple Web Action Example</summary>

This simple example triggers a QT dialog on the user's machine, showing the folder path from which the action was triggered.

![](assets/addon_dev/web_action_example.png)

```python title="my_addon/client/my_addon/__init__.py"
from qtpy import QtWidgets
import ayon_api

from ayon_core.addon import AYONAddon, click_wrap
from .version import __version__


class MyAddonCode(AYONAddon):
"""My addon class."""

label = "My Addon"
name = "my_addon"
version = __version__

# Add CLI
def cli(self, click_group):
# Convert `cli_main` command to click object and add it to parent group
click_group.add_command(cli_main.to_click_obj())


@click_wrap.group(
MyAddonCode.name,
help="My Addon cli commands.")
def cli_main():
pass

@cli_main.command() # Add child command
@click_wrap.option(
"--project",
help="project name",
type=str,
required=False
)
@click_wrap.option(
"--entity-id",
help="entity id",
type=str,
required=False
)
def show_selected_path(project, entity_id):
"""Display a dialog showing the folder path from which the action was triggered."""

# Process the input arguments
con = ayon_api.get_server_api_connection()
entity = con.get_folder_by_id(project, entity_id)

folder_path = f"{project}{entity['path']}"

# Show Dialog
app = QtWidgets.QApplication()
QtWidgets.QMessageBox.information(
None,
"Triggered from AYON Server",
f"The action was triggered from folder: '{folder_path}'",
)
```

```python title="my_addon/server/__init__.py"
from ayon_server.actions import (
ActionExecutor,
ExecuteResponseModel,
SimpleActionManifest,
)

from ayon_server.addons import BaseServerAddon


IDENTIFIER_PREFIX = "myaddon.launch"


class MyAddonSettings(BaseServerAddon):
# Set settings
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 a web actions to folders.
label = "Trigger Simple Action"
icon = {
"type": "material-symbols",
"name": "switch_access_2",
}
output.append(
SimpleActionManifest(
identifier=f"{IDENTIFIER_PREFIX}.show_dialog",
label=label,
icon=icon,
order=100,
entity_type="folder",
entity_subtypes=None,
allow_multiselection=False,
)
)

return output

async def execute_action(
self,
executor: "ActionExecutor",
) -> "ExecuteResponseModel":
"""Execute an action provided by the addon.
Note:
Executes CLI actions defined in the addon's client code or other addons.
"""

project_name = executor.context.project_name
entity_id = executor.context.entity_ids[0]

if executor.identifier == f"{IDENTIFIER_PREFIX}.show_dialog":
return await executor.get_launcher_action_response(
args=[
"addon", "my_addon", "show-selected-path",
"--project", project_name,
"--entity-id", entity_id,
]
)

raise ValueError(f"Unknown action: {executor.identifier}")

```

:::tip icons
Icons support [material-symbols](https://fonts.google.com/icons) as well as addon static icons, more info check [Private and Public Dirs](dev_addon_creation.md#private-and-public-dirs).
```python
icon = {
"type": "url",
"url": "{addon_url}/public/icons/" + icon_name
}

```

:::tip entity_type
For `SimpleActionManifest`, you can use different entity types.
- `"folder"`: Any folder path that is not a task.
- `"task"`: Tasks.
:::

</details>

## Addon Client Code
Also, we can refer to this section as Unlock Pipeline Powers since client code is used to direct the pipeline!

Expand Down
1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ module.exports = {
label: "Production Tracking",
items: [
"artist_my_tasks_page",
"artist_details_panel",
"artist_activity_feed",
"artist_reviewables",
"artist_inbox",
Expand Down

0 comments on commit 63ec695

Please sign in to comment.