Sfoglia il codice sorgente

#15908: Introduce FeatureSet dataclass for tracking release features

Jeremy Stretch 1 anno fa
parent
commit
954eadcdc5

+ 2 - 2
netbox/templates/core/plugin.html

@@ -32,7 +32,7 @@
         {% trans "Overview" %}
       </a>
     </li>
-    {% if True or not plugin.is_local and 'commercial' not in settings.RELEASE.features %}
+    {% if not plugin.is_local and not settings.RELEASE.features.commercial %}
       <li class="nav-item" role="presentation">
         <button class="nav-link" id="install-tab" data-bs-toggle="tab" data-bs-target="#install" type="button" role="tab" aria-controls="object-list" aria-selected="false">
           {% trans "Install" %}
@@ -100,7 +100,7 @@
       </div>
     </div>
   </div>
-  {% if True or not plugin.is_local and 'commercial' not in settings.RELEASE.features %}
+  {% if not plugin.is_local and not settings.RELEASE.features.commercial %}
     <div class="tab-pane" id="install" role="tabpanel" aria-labelledby="install-tab">
       <div class="card">
         <h5 class="card-header">{% trans "Local Installation Instructions" %}</h5>

+ 1 - 1
netbox/templates/inc/user_menu.html

@@ -1,7 +1,7 @@
 {% load i18n %}
 {% load navigation %}
 
-{% if 'help-center' in settings.RELEASE.features %}
+{% if settings.RELEASE.features.help_center %}
   {# Help center control #}
   <a href="#" class="nav-link px-1" aria-label="{% trans "Help center" %}">
     <i class="mdi mdi-forum-outline"></i>

+ 13 - 1
netbox/utilities/release.py

@@ -12,13 +12,25 @@ RELEASE_PATH = 'release.yaml'
 LOCAL_RELEASE_PATH = 'local/release.yaml'
 
 
+@dataclass
+class FeatureSet:
+    """
+    A map of all available NetBox features.
+    """
+    # Commercial support is provided by NetBox Labs
+    commercial: bool = False
+
+    # Live help center is enabled
+    help_center: bool = False
+
+
 @dataclass
 class ReleaseInfo:
     version: str
     edition: str
     published: Union[datetime.date, None] = None
     designation: Union[str, None] = None
-    features: List = field(default_factory=list)
+    features: FeatureSet = field(default_factory=FeatureSet)
 
     @property
     def full_version(self):