Override or hide built-in tabs

Use the replaces parameter in a UI extension’s @tab_extension decorator to replace or hide a built-in tab

By default, tab extensions are appended to the end of the tab list on a detail view. With the replaces parameter, you can instead target a specific built-in tab by its slug, and either replace it with your extension tab or hide it entirely.

This feature applies to the following detail views:

  • User profiles
  • Groups
  • Environments
  • Servers
  • Resource handlers
  • Resources
  • Blueprints

Prerequisites

Before you begin, ensure:

  • A UI extension is imported and enabled
  • You have SSH access to the Cloud Management Platform (CMP) instance with root permissions

Find a tab slug

Each built-in tab has a slug that identifies it. To find a slug, hover over a tab in the CMP UI and look at the URL fragment in the browser status bar. The slug is the portion that follows tab-.

For example, hovering over the History tab shows #tab-history in the status bar — the slug for the History tab is history.

Replace a built-in tab

Add the replaces parameter to your UI extension’s @tab_extension decorator, passing the slug of the built-in tab you want to replace.

  1. SSH into your CMP instance as root.

  2. Open the UI extension’s views.py file for editing, for example:

    vim /var/opt/cloudbolt/proserv/xui/scheduled_snapshots/views.py
    
  3. Locate the @tab_extension decorator.

  4. Using the tab slug to replace, append replaces="<tab-slug>", for example:

    @tab_extension(model=Server, title="Snapshots", description="Manage scheduled snapshots",
            delegate=ScheduledSnapshotsTabDelegate, replaces="history")
    
  5. Locate the tab extension’s delegate class, for example, ScheduledSnapshotsTabDelegate, and confirm that should_display returns True for the target object.

  6. Save and exit the file.

  7. Restart the Apache HTTP Server:

    systemctl restart httpd
    
  8. In the CMP UI, go to a view to see the result.

Result: The built-in tab is removed, and your extension tab appears in its position.

In this example, the built-in History tab is replaced by the Snapshots tab from the Scheduled Snapshot UI extension.

Screenshot of a server’s Details view with the built-in History tab replaced by a UI extension tab. (opens full-size image in a new tab)

If multiple extensions declare the same replaces slug, the last processed extension takes effect, and a warning is logged. Check your logs if a replacement is not behaving as expected.

Hide a built-in tab

To remove a built-in tab without replacing it with anything, use replaces together with hide_ootb_tab=True, and have should_display return False.

  1. SSH into your CMP instance as root.

  2. Open the UI extension’s views.py file for editing, for example:

    vim /var/opt/cloudbolt/proserv/xui/scheduled_snapshots/views.py
    
  3. Locate the @tab_extension decorator.

  4. Using the tab slug to hide, append replaces="<tab-slug>", hide_ootb_tab=True, for example:

    @tab_extension(model=Server, title="Snapshots", description="Manage scheduled snapshots",
            delegate=ScheduledSnapshotsTabDelegate, replaces="history", hide_ootb_tab=True)
    
  5. Locate the tab extension’s delegate class, for example, ScheduledSnapshotsTabDelegate, and set should_display to return False for the target object.

  6. Save and exit the file.

  7. Restart the Apache HTTP Server:

    systemctl restart httpd
    
  8. In the CMP UI, go to a view to see the result.

Result: The built-in tab is hidden, and the UI extension tab is not displayed.

In this example, the built-in History tab is hidden, and the Snapshots tab of the Scheduled Snapshot UI extension is not displayed.

Screenshot of a server’s Details view with a UI extension tab overriding and hiding the built-in History tab. (opens full-size image in a new tab)

Behavior reference

Overview of scenarios and results when using the replaces parameter:

Scenario Result
replaces not set The extension tab is appended to the tab list.
replaces matches a built-in tab slug and should_display returns True The built-in tab is replaced by the extension tab.
replaces matches a built-in tab slug, should_display returns False, and hide_ootb_tab=True The built-in tab is hidden, and no replacement tab is shown.
replaces matches a built-in tab slug, should_display returns False, and hide_ootb_tab=False The built-in tab is kept, and no extension tab is shown.
replaces does not match any built-in tab slug. The extension tab is appended, and a warning is logged.
Multiple extensions use the same replaces slug The last-processed extension is used, and a warning is logged.