mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Merge pull request #1899 from pypeclub/feature/private_project_server_actions
Ftrack: Private project server actions
This commit is contained in:
commit
1598c5641c
2 changed files with 74 additions and 6 deletions
|
|
@ -0,0 +1,61 @@
|
|||
from openpype.modules.ftrack.lib import ServerAction
|
||||
|
||||
|
||||
class PrivateProjectDetectionAction(ServerAction):
|
||||
"""Action helps to identify if does not have access to project."""
|
||||
|
||||
identifier = "server.missing.perm.private.project"
|
||||
label = "Missing permissions"
|
||||
description = (
|
||||
"Main ftrack event server does not have access to this project."
|
||||
)
|
||||
|
||||
def _discover(self, event):
|
||||
"""Show action only if there is a selection in event data."""
|
||||
entities = self._translate_event(event)
|
||||
if entities:
|
||||
return None
|
||||
|
||||
selection = event["data"].get("selection")
|
||||
if not selection:
|
||||
return None
|
||||
|
||||
return {
|
||||
"items": [{
|
||||
"label": self.label,
|
||||
"variant": self.variant,
|
||||
"description": self.description,
|
||||
"actionIdentifier": self.discover_identifier,
|
||||
"icon": self.icon,
|
||||
}]
|
||||
}
|
||||
|
||||
def _launch(self, event):
|
||||
# Ignore if there are values in event data
|
||||
# - somebody clicked on submit button
|
||||
values = event["data"].get("values")
|
||||
if values:
|
||||
return None
|
||||
|
||||
title = "# Private project (missing permissions) #"
|
||||
msg = (
|
||||
"User ({}) or API Key used on Ftrack event server"
|
||||
" does not have permissions to access this private project."
|
||||
).format(self.session.api_user)
|
||||
return {
|
||||
"type": "form",
|
||||
"title": "Missing permissions",
|
||||
"items": [
|
||||
{"type": "label", "value": title},
|
||||
{"type": "label", "value": msg},
|
||||
# Add hidden to be able detect if was clicked on submit
|
||||
{"type": "hidden", "value": "1", "name": "hidden"}
|
||||
],
|
||||
"submit_button_label": "Got it"
|
||||
}
|
||||
|
||||
|
||||
def register(session):
|
||||
'''Register plugin. Called when used as an plugin.'''
|
||||
|
||||
PrivateProjectDetectionAction(session).register()
|
||||
|
|
@ -191,15 +191,22 @@ class BaseHandler(object):
|
|||
if session is None:
|
||||
session = self.session
|
||||
|
||||
_entities = event['data'].get('entities_object', None)
|
||||
_entities = event["data"].get("entities_object", None)
|
||||
if _entities is not None and not _entities:
|
||||
return _entities
|
||||
|
||||
if (
|
||||
_entities is None or
|
||||
_entities[0].get(
|
||||
'link', None
|
||||
_entities is None
|
||||
or _entities[0].get(
|
||||
"link", None
|
||||
) == ftrack_api.symbol.NOT_SET
|
||||
):
|
||||
_entities = self._get_entities(event)
|
||||
event['data']['entities_object'] = _entities
|
||||
_entities = [
|
||||
item
|
||||
for item in self._get_entities(event)
|
||||
if item is not None
|
||||
]
|
||||
event["data"]["entities_object"] = _entities
|
||||
|
||||
return _entities
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue