Skip to content

Allow hiding instances from the admin instance chooser#266

Open
bbliem wants to merge 1 commit into
mainfrom
feature/hide-instances-in-chooser
Open

Allow hiding instances from the admin instance chooser#266
bbliem wants to merge 1 commit into
mainfrom
feature/hide-instances-in-chooser

Conversation

@bbliem

@bbliem bbliem commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What

Adds an is_hidden flag on InstanceConfig that omits an instance from the admin "Choose instance" chooser. The hiding is listing-only: a hidden instance stays fully reachable directly (by URL / hostname / identifier) and via permissions — it is just removed from the chooser menu.

Why

The instance chooser can accumulate a lot of noise (e.g., instances migrated to other clusters), especially for superusers who see every instance. This gives us a way to declutter the list without changing who can access what.

How

  • nodes/models.py — new field on InstanceConfig (next to is_locked):
    is_hidden = models.BooleanField(
        default=False,
        help_text=_('Hide this instance from the admin instance chooser. '
                    'It remains reachable directly and via permissions.'),
    )
  • nodes/migrations/0050_instanceconfig_is_hidden.py — generated migration.
  • admin_site/wagtail_hooks.pyInstanceChooserMenu.menu_items_for_request now filters out is_hidden instances, except the currently-active realm, so a user who is on a hidden instance still sees it and can switch away. Crucially, this filters the listing onlyget_adminable_instances(), the authorization gate used by the change_admin_instance view, is left untouched, which is what preserves direct reachability.
  • admin_site/tests.py — three tests:
    • hidden instance is omitted from the chooser,
    • an active hidden instance is kept visible (the escape hatch),
    • reachability is preserved (user_is_admin_for_instance / get_adminable_instances still include it).

Setting the flag

There is no admin form for this yet; set it from the shell:

InstanceConfig.objects.filter(identifier='some-instance').update(is_hidden=True)

.update() (rather than .save()) is the safe choice for a programmatic field flip and avoids triggering a Wagtail revision.

Out of scope

  • The public availableInstances(hostname) GraphQL query is not affected.
  • Permission policy is not touched — hidden instances remain accessible to anyone who already had access (this is not access control).

Related issue

Asana task


✅ Pre-Merge Checklist

Type of Change

  • Set the PR's label to match the nature of this change

Testing

  • Built Unit tests (unit tests added/updated)
  • Manually tested locally (functionality verified)

Internationalization & Accessibility

  • New strings are translatable (all user-facing text uses i18n)

Add an is_hidden boolean field on InstanceConfig that omits an instance
from the admin "Choose instance" chooser. The hiding is listing-only:
the chooser menu filters out hidden instances (except the currently-active
realm, so a user on a hidden instance can still switch away), while
get_adminable_instances() -- the authorization gate for direct switching --
is left untouched, so hidden instances remain reachable directly and via
permissions. Includes the migration and tests covering omission, the
active-realm escape hatch, and preserved reachability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant