mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Merge branch 'develop' into enhancement/1295-product-base-types-feature-support
This commit is contained in:
commit
86b1efe01d
5 changed files with 96 additions and 9 deletions
|
|
@ -32,16 +32,16 @@ class CollectManagedStagingDir(pyblish.api.InstancePlugin):
|
||||||
label = "Collect Managed Staging Directory"
|
label = "Collect Managed Staging Directory"
|
||||||
order = pyblish.api.CollectorOrder + 0.4990
|
order = pyblish.api.CollectorOrder + 0.4990
|
||||||
|
|
||||||
def process(self, instance):
|
def process(self, instance: pyblish.api.Instance):
|
||||||
""" Collect the staging data and stores it to the instance.
|
""" Collect the staging data and stores it to the instance.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
instance (object): The instance to inspect.
|
instance (object): The instance to inspect.
|
||||||
"""
|
"""
|
||||||
staging_dir_path = get_instance_staging_dir(instance)
|
staging_dir_path = get_instance_staging_dir(instance)
|
||||||
persistance = instance.data.get("stagingDir_persistent", False)
|
persistence: bool = instance.data.get("stagingDir_persistent", False)
|
||||||
|
|
||||||
self.log.info((
|
self.log.debug(
|
||||||
f"Instance staging dir was set to `{staging_dir_path}` "
|
f"Instance staging dir was set to `{staging_dir_path}` "
|
||||||
f"and persistence is set to `{persistance}`"
|
f"and persistence is set to `{persistence}`"
|
||||||
))
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
from dataclasses import dataclass, asdict
|
||||||
from typing import (
|
from typing import (
|
||||||
Optional,
|
Optional,
|
||||||
Dict,
|
Dict,
|
||||||
|
|
@ -28,6 +29,19 @@ if TYPE_CHECKING:
|
||||||
from .models import CreatorItem, PublishErrorInfo, InstanceItem
|
from .models import CreatorItem, PublishErrorInfo, InstanceItem
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class CommentDef:
|
||||||
|
"""Comment attribute definition."""
|
||||||
|
minimum_chars_required: int
|
||||||
|
|
||||||
|
def to_data(self):
|
||||||
|
return asdict(self)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_data(cls, data):
|
||||||
|
return cls(**data)
|
||||||
|
|
||||||
|
|
||||||
class CardMessageTypes:
|
class CardMessageTypes:
|
||||||
standard = None
|
standard = None
|
||||||
info = "info"
|
info = "info"
|
||||||
|
|
@ -135,6 +149,17 @@ class AbstractPublisherCommon(ABC):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_comment_def(self) -> CommentDef:
|
||||||
|
"""Get comment attribute definition.
|
||||||
|
|
||||||
|
This can define how the Comment field should behave, like having
|
||||||
|
a minimum amount of required characters before being allowed to
|
||||||
|
publish.
|
||||||
|
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class AbstractPublisherBackend(AbstractPublisherCommon):
|
class AbstractPublisherBackend(AbstractPublisherCommon):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ from .models import (
|
||||||
from .abstract import (
|
from .abstract import (
|
||||||
AbstractPublisherBackend,
|
AbstractPublisherBackend,
|
||||||
AbstractPublisherFrontend,
|
AbstractPublisherFrontend,
|
||||||
CardMessageTypes
|
CardMessageTypes,
|
||||||
|
CommentDef,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -601,3 +602,17 @@ class PublisherController(
|
||||||
def _start_publish(self, up_validation):
|
def _start_publish(self, up_validation):
|
||||||
self._publish_model.set_publish_up_validation(up_validation)
|
self._publish_model.set_publish_up_validation(up_validation)
|
||||||
self._publish_model.start_publish(wait=True)
|
self._publish_model.start_publish(wait=True)
|
||||||
|
|
||||||
|
def get_comment_def(self) -> CommentDef:
|
||||||
|
# Take the cached settings from the Create Context
|
||||||
|
settings = self.get_create_context().get_current_project_settings()
|
||||||
|
comment_minimum_required_chars: int = (
|
||||||
|
settings
|
||||||
|
.get("core", {})
|
||||||
|
.get("tools", {})
|
||||||
|
.get("publish", {})
|
||||||
|
.get("comment_minimum_required_chars", 0)
|
||||||
|
)
|
||||||
|
return CommentDef(
|
||||||
|
minimum_chars_required=comment_minimum_required_chars
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,13 @@ class PublisherWindow(QtWidgets.QDialog):
|
||||||
show_timer.setInterval(1)
|
show_timer.setInterval(1)
|
||||||
show_timer.timeout.connect(self._on_show_timer)
|
show_timer.timeout.connect(self._on_show_timer)
|
||||||
|
|
||||||
|
comment_invalid_timer = QtCore.QTimer()
|
||||||
|
comment_invalid_timer.setSingleShot(True)
|
||||||
|
comment_invalid_timer.setInterval(2500)
|
||||||
|
comment_invalid_timer.timeout.connect(
|
||||||
|
self._on_comment_invalid_timeout
|
||||||
|
)
|
||||||
|
|
||||||
errors_dialog_message_timer = QtCore.QTimer()
|
errors_dialog_message_timer = QtCore.QTimer()
|
||||||
errors_dialog_message_timer.setInterval(100)
|
errors_dialog_message_timer.setInterval(100)
|
||||||
errors_dialog_message_timer.timeout.connect(
|
errors_dialog_message_timer.timeout.connect(
|
||||||
|
|
@ -395,6 +402,7 @@ class PublisherWindow(QtWidgets.QDialog):
|
||||||
self._app_event_listener_installed = False
|
self._app_event_listener_installed = False
|
||||||
|
|
||||||
self._show_timer = show_timer
|
self._show_timer = show_timer
|
||||||
|
self._comment_invalid_timer = comment_invalid_timer
|
||||||
self._show_counter = 0
|
self._show_counter = 0
|
||||||
self._window_is_visible = False
|
self._window_is_visible = False
|
||||||
|
|
||||||
|
|
@ -823,15 +831,45 @@ class PublisherWindow(QtWidgets.QDialog):
|
||||||
self._controller.set_comment(self._comment_input.text())
|
self._controller.set_comment(self._comment_input.text())
|
||||||
|
|
||||||
def _on_validate_clicked(self):
|
def _on_validate_clicked(self):
|
||||||
if self._save_changes(False):
|
if self._validate_comment() and self._save_changes(False):
|
||||||
self._set_publish_comment()
|
self._set_publish_comment()
|
||||||
self._controller.validate()
|
self._controller.validate()
|
||||||
|
|
||||||
def _on_publish_clicked(self):
|
def _on_publish_clicked(self):
|
||||||
if self._save_changes(False):
|
if self._validate_comment() and self._save_changes(False):
|
||||||
self._set_publish_comment()
|
self._set_publish_comment()
|
||||||
self._controller.publish()
|
self._controller.publish()
|
||||||
|
|
||||||
|
def _validate_comment(self) -> bool:
|
||||||
|
# Validate comment length
|
||||||
|
comment_def = self._controller.get_comment_def()
|
||||||
|
char_count = len(self._comment_input.text().strip())
|
||||||
|
if (
|
||||||
|
comment_def.minimum_chars_required
|
||||||
|
and char_count < comment_def.minimum_chars_required
|
||||||
|
):
|
||||||
|
self._overlay_object.add_message(
|
||||||
|
"Please enter a comment of at least "
|
||||||
|
f"{comment_def.minimum_chars_required} characters",
|
||||||
|
message_type="error"
|
||||||
|
)
|
||||||
|
self._invalidate_comment_field()
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _invalidate_comment_field(self):
|
||||||
|
self._comment_invalid_timer.start()
|
||||||
|
self._comment_input.setStyleSheet("border-color: #DD2020")
|
||||||
|
# Set focus so user can start typing and is pointed towards the field
|
||||||
|
self._comment_input.setFocus()
|
||||||
|
self._comment_input.setCursorPosition(
|
||||||
|
len(self._comment_input.text())
|
||||||
|
)
|
||||||
|
|
||||||
|
def _on_comment_invalid_timeout(self):
|
||||||
|
# Reset style
|
||||||
|
self._comment_input.setStyleSheet("")
|
||||||
|
|
||||||
def _set_footer_enabled(self, enabled):
|
def _set_footer_enabled(self, enabled):
|
||||||
self._save_btn.setEnabled(True)
|
self._save_btn.setEnabled(True)
|
||||||
self._reset_btn.setEnabled(True)
|
self._reset_btn.setEnabled(True)
|
||||||
|
|
|
||||||
|
|
@ -358,6 +358,14 @@ class PublishToolModel(BaseSettingsModel):
|
||||||
title="Custom Staging Dir Profiles"
|
title="Custom Staging Dir Profiles"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
comment_minimum_required_chars: int = SettingsField(
|
||||||
|
0,
|
||||||
|
title="Publish comment minimum required characters",
|
||||||
|
description=(
|
||||||
|
"Minimum number of characters required in the comment field "
|
||||||
|
"before the publisher UI is allowed to continue publishing"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class GlobalToolsModel(BaseSettingsModel):
|
class GlobalToolsModel(BaseSettingsModel):
|
||||||
|
|
@ -671,6 +679,7 @@ DEFAULT_TOOLS_VALUES = {
|
||||||
"task_names": [],
|
"task_names": [],
|
||||||
"template_name": "simpleUnrealTextureHero"
|
"template_name": "simpleUnrealTextureHero"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"comment_minimum_required_chars": 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue