Commit 8d019237 authored by Flavio TARSETTI's avatar Flavio TARSETTI
Browse files

[widgets][assetwidget] Pop a warning box for truncated description

parent d32806b8
Pipeline #38301 passed with stage
in 15 minutes and 50 seconds
......@@ -439,6 +439,20 @@ class AssetWidget(QWidget):
self.__update_editors_icon(is_valid)
declaration = asset.declaration
# Check if asset description size is bigger to what is allowed by the current editor
if (
len(declaration.get("description", ""))
> self.current_editor.description_max_length
):
QMessageBox.warning(
self,
self.tr("Description size"),
self.tr(
"The loaded description is too big and will be truncated. Please update your description."
),
)
if asset.type == AssetType.ALGORITHM:
if declaration.get("api_version", 0) < 2:
answer = QMessageBox.question(
......
......@@ -72,7 +72,7 @@ class AbstractAssetEditor(QWidget):
common_data = json.loads(common_data)
definitions = common_data["definitions"]
description = definitions["description"]
description_length = description["maxLength"]
description_max_length = description["maxLength"]
self.clearDirty()
......@@ -80,7 +80,7 @@ class AbstractAssetEditor(QWidget):
self.title_label = QLabel(self.tr("Unknown"))
self.description_lineedit = QLineEdit()
self.description_lineedit.setMaxLength(description_length)
self.description_lineedit.setMaxLength(description_max_length)
self.information_group_box = QGroupBox(self.tr("Information"))
self.information_layout = QFormLayout(self.information_group_box)
......@@ -97,6 +97,10 @@ class AbstractAssetEditor(QWidget):
self.description_lineedit.textChanged.connect(self.dataChanged)
self.dataChanged.connect(self.setDirty)
@property
def description_max_length(self):
return self.description_lineedit.maxLength()
def _add_information_widget(self, label, widget):
"""Add field to information widget
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment