Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addons: allow to set a "Default" or a explicit position for flyout #11891

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions readthedocs/projects/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,3 +443,15 @@
(ADDONS_FLYOUT_SORTING_CALVER, _("CalVer (YYYY.0M.0M)")),
(ADDONS_FLYOUT_SORTING_CUSTOM_PATTERN, _("Define your own pattern")),
)

ADDONS_FLYOUT_POSITION_BOTTOM_LEFT = "bottom-left"
ADDONS_FLYOUT_POSITION_BOTTOM_RIGHT = "bottom-right"
ADDONS_FLYOUT_POSITION_TOP_LEFT = "top-left"
ADDONS_FLYOUT_POSITION_TOP_RIGHT = "top-right"
ADDONS_FLYOUT_POSITION_CHOICES = (
(None, _("Default (from theme or Read the Docs)")),
(ADDONS_FLYOUT_POSITION_BOTTOM_LEFT, _("Bottom left")),
(ADDONS_FLYOUT_POSITION_BOTTOM_RIGHT, _("Bottom right")),
(ADDONS_FLYOUT_POSITION_TOP_LEFT, _("Top left")),
(ADDONS_FLYOUT_POSITION_TOP_RIGHT, _("Top right")),
)
1 change: 1 addition & 0 deletions readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ class Meta:
"flyout_sorting",
"flyout_sorting_latest_stable_at_beginning",
"flyout_sorting_custom_pattern",
"flyout_position",
"hotkeys_enabled",
"search_enabled",
"linkpreviews_enabled",
Expand Down
25 changes: 25 additions & 0 deletions readthedocs/projects/migrations/0143_addons_flyout_position.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.17 on 2025-01-08 11:15

from django.db import migrations, models
from django_safemigrate import Safe


class Migration(migrations.Migration):
safe = Safe.before_deploy

dependencies = [
('projects', '0142_update_dj_simple_history'),
]

operations = [
migrations.AddField(
model_name='addonsconfig',
name='flyout_position',
field=models.CharField(blank=True, choices=[(None, 'Use default'), ('bottom-right', 'Bottom right'), ('bottom-right', 'Top right')], default=None, max_length=64, null=True),
),
migrations.AddField(
model_name='historicaladdonsconfig',
name='flyout_position',
field=models.CharField(blank=True, choices=[(None, 'Use default'), ('bottom-right', 'Bottom right'), ('bottom-right', 'Top right')], default=None, max_length=64, null=True),
),
]
15 changes: 14 additions & 1 deletion readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
from readthedocs.vcs_support.backends import backend_cls

from .constants import (
ADDONS_FLYOUT_POSITION_CHOICES,
ADDONS_FLYOUT_SORTING_CHOICES,
ADDONS_FLYOUT_SORTING_SEMVER_READTHEDOCS_COMPATIBLE,
DOWNLOADABLE_MEDIA_TYPES,
Expand Down Expand Up @@ -194,7 +195,10 @@ class AddonsConfig(TimeStampedModel):
filetreediff_enabled = models.BooleanField(default=False, null=True, blank=True)

# Flyout
flyout_enabled = models.BooleanField(default=True)
flyout_enabled = models.BooleanField(
default=True,
verbose_name=_("Enabled"),
)
flyout_sorting = models.CharField(
verbose_name=_("Sorting of versions"),
choices=ADDONS_FLYOUT_SORTING_CHOICES,
Expand All @@ -217,6 +221,15 @@ class AddonsConfig(TimeStampedModel):
default=True,
)

flyout_position = models.CharField(
choices=ADDONS_FLYOUT_POSITION_CHOICES,
max_length=64,
default=None, # ``None`` means use the default (theme override if present or Read the Docs default)
null=True,
blank=True,
verbose_name=_("Position"),
)

# Hotkeys
hotkeys_enabled = models.BooleanField(default=True)

Expand Down
1 change: 1 addition & 0 deletions readthedocs/proxito/views/hosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ def _v1(self, project, version, build, filename, url, request):
# "branch": version.identifier if version else None,
# "filepath": "/docs/index.rst",
# },
"position": project.addons.flyout_position,
},
"customscript": {
"enabled": project.addons.customscript_enabled,
Expand Down