Assets: Do Not Show Blank Read-Only Metadata #105812

Merged
Harley Acheson merged 1 commits from Harley/blender:AssetMetaReadOnly into main 2023-04-19 19:55:36 +02:00
Member

Do not show asset metadata "description", "license", "copyright", or
"author" if they are empty AND read-only, since they can't be edited
and contain no useful information to show.


No need to display these if they are both blank and read-only. This mostly allows the bundled assets to leave some items blank and not have them show up.

Do not show asset metadata "description", "license", "copyright", or "author" if they are empty AND read-only, since they can't be edited and contain no useful information to show. --- No need to display these if they are both blank and read-only. This mostly allows the bundled assets to leave some items blank and not have them show up.
Harley Acheson requested review from Julian Eisel 2023-03-15 22:02:25 +01:00
Brecht Van Lommel reviewed 2023-03-21 19:20:06 +01:00
@ -749,2 +747,2 @@
layout.prop(asset_file_handle.asset_data, "copyright")
layout.prop(asset_file_handle.asset_data, "author")
# Don't show these if they are blank and read-only.
if asset_file_handle.asset_data.description or not asset_file_handle.asset_data.is_property_readonly("description"):

Maybe make the code more compact with:

asset_data = asset_file_handle.asset_data
Maybe make the code more compact with: ``` asset_data = asset_file_handle.asset_data ```
Harley marked this conversation as resolved
Harley Acheson force-pushed AssetMetaReadOnly from e5cb86c6e6 to 464b93aadc 2023-03-21 20:57:11 +01:00 Compare
Harley Acheson added this to the User Interface project 2023-04-07 19:22:31 +02:00
Julian Eisel reviewed 2023-04-11 11:49:44 +02:00
@ -750,1 +747,3 @@
layout.prop(asset_file_handle.asset_data, "author")
asset_data = asset_file_handle.asset_data
# Do not show these fields if they are blank and read-only.
if asset_data.description or not asset_data.is_property_readonly("description"):
Member

Would add a function to avoid duplication, give further info in a comment, and to make clear that each conditional follows the same logic:

@staticmethod
def add_metadata_prop(layout, asset_data, propname):
    """
    Only display properties that are either set or can be modified (i.e. the asset is in the current file). Empty, non-editable fields are not really useful.
    """
    if getattr(asset_data, propname) or not asset_data.is_property_readonly(propname):
        layout.prop(asset_data, propname)
Would add a function to avoid duplication, give further info in a comment, and to make clear that each conditional follows the same logic: ```py @staticmethod def add_metadata_prop(layout, asset_data, propname): """ Only display properties that are either set or can be modified (i.e. the asset is in the current file). Empty, non-editable fields are not really useful. """ if getattr(asset_data, propname) or not asset_data.is_property_readonly(propname): layout.prop(asset_data, propname) ```
Harley marked this conversation as resolved
Harley Acheson force-pushed AssetMetaReadOnly from 464b93aadc to c2cd2361d5 2023-04-11 17:36:18 +02:00 Compare
Harley changed target branch from blender-v3.5-release to main 2023-04-11 17:37:36 +02:00
Author
Member

@JulianEisel - Would add a function to avoid duplication...

Yes, that is much nicer. Thanks!

> @JulianEisel - Would add a function to avoid duplication... Yes, that is much nicer. Thanks!
Julian Eisel requested changes 2023-04-11 18:20:59 +02:00
@ -701,2 +701,4 @@
@staticmethod
def add_metadata_prop(layout, asset_data, propname):
Member

Would move this into the ASSETBROWSER_PT_metadata() class, to keep the context more clear. Outside of that class a name like add_metadata_prop() isn't very clear. (Also there's no point in @staticmethod outside of a class).

Coming to think of it, metadata_prop() is probably enough as a name.

So, invocation would read self.metadata_prop(layout, asset_data, "license") then.

Would move this into the `ASSETBROWSER_PT_metadata()` class, to keep the context more clear. Outside of that class a name like `add_metadata_prop()` isn't very clear. (Also there's no point in `@staticmethod` outside of a class). Coming to think of it, `metadata_prop()` is probably enough as a name. So, invocation would read `self.metadata_prop(layout, asset_data, "license")` then.
Harley marked this conversation as resolved
@ -702,1 +702,4 @@
@staticmethod
def add_metadata_prop(layout, asset_data, propname):
# Only display properties that are either set or can be modified (i.e. the asset
Member

This should use a Python docstring, like in my snippet.

This should use a Python [`docstring`](https://www.askpython.com/python/python-docstring), like in my snippet.
Harley marked this conversation as resolved
@ -748,3 +755,1 @@
layout.prop(asset_file_handle.asset_data, "license")
layout.prop(asset_file_handle.asset_data, "copyright")
layout.prop(asset_file_handle.asset_data, "author")
add_metadata_prop(layout, asset_file_handle.asset_data, "description")
Member

Instead of repeating asset_file_handle.asset_data every time, just declare an asset_data variable.

Instead of repeating `asset_file_handle.asset_data` every time, just declare an `asset_data` variable.
Harley marked this conversation as resolved
Harley Acheson force-pushed AssetMetaReadOnly from c2cd2361d5 to 7f930ac771 2023-04-19 01:48:43 +02:00 Compare
Author
Member

@JulianEisel - Sorry, but I somehow missed the notification of your last review comments. I actually thought this was all done.

Updated to include your required changes.

@JulianEisel - Sorry, but I somehow missed the notification of your last review comments. I actually thought this was all done. Updated to include your required changes.
Julian Eisel approved these changes 2023-04-19 18:46:26 +02:00
Harley Acheson merged commit 199c7da06d into main 2023-04-19 19:55:36 +02:00
Harley Acheson deleted branch AssetMetaReadOnly 2023-04-19 19:55:37 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#105812
No description provided.