diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index a955899..f6c4e98 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -66,6 +66,9 @@ jobs: python tools/check_core_release.py dist/*.tar.gz dist/*.whl python tools/build_deb.py dist/*.tar.gz dist/*.whl umask 077 - python tools/build_deb.py dist/*.tar.gz dist/*.whl --output rebuilt + git -c user.name='Coulobre CI' -c user.email='ci@hippogrief.nl' \ + tag --annotate coulobre-ci-artifacts -m 'Verify tagged build' + python tools/build_deb.py dist/*.tar.gz dist/*.whl \ + --ref coulobre-ci-artifacts --output rebuilt cmp dist/*.deb rebuilt/*.deb dpkg-deb --info dist/*.deb diff --git a/docs/deployment.md b/docs/deployment.md index ce4c2bb..eb04269 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -145,22 +145,25 @@ and installs the selected operating system services and Python dependencies. ### Use the Gitea APT repository Use the `resolute` suite on Ubuntu 26.04 or `trixie` on Debian 13. The `main` -component carries final releases. Add `candidate` to the component list on a -test host to opt in to release candidates. A version like `0.13.0~rc1` sorts -before `0.13.0` in APT. +component carries final releases. Use `candidate` on a test host to opt in to +release candidates. A version like `0.13.0~rc1` sorts before `0.13.0` in APT. ```sh suite=resolute +component=main registry=https://code.hosting.hippogrief.nl/api/packages/hippogrief/debian sudo install -d -m 0755 /etc/apt/keyrings sudo curl -fsS "$registry/repository.key" -o /etc/apt/keyrings/hippogrief.asc sudo chmod 0644 /etc/apt/keyrings/hippogrief.asc -printf 'deb [signed-by=/etc/apt/keyrings/hippogrief.asc] %s %s main\n' \ - "$registry" "$suite" | sudo tee /etc/apt/sources.list.d/hippogrief.list +printf 'deb [signed-by=/etc/apt/keyrings/hippogrief.asc] %s %s %s\n' \ + "$registry" "$suite" "$component" | sudo tee /etc/apt/sources.list.d/hippogrief.list sudo apt update sudo apt install coulobre-panel ``` +Set `component=candidate` when testing a release candidate. Gitea adds the +`main` component to each suite when its first final package is published. + [Gitea Debian registry documentation](https://docs.gitea.com/usage/packages/debian/) ### Upgrade an installer-managed panel @@ -628,8 +631,8 @@ A verified superuser can assign a Customer or Manager role to an active login from **Customers** or **Managers**. Choose **Assign to existing login** and enter the username. Customer roles use their own assigned hosting accounts. Managers use their own hosting account -assignments and hosting plan policy. New manager assignments use the default -manager profile when one is configured. +assignments and hosting package policy. New manager assignments use the default +manager package when one is configured. Logins with multiple roles can choose **Panel role** in the account area. The role applies to the session, including direct page requests and actions. @@ -952,7 +955,7 @@ first mailbox adds the signing key's public DKIM record. ## Verify a new installation -Use a test hosting plan, account, and domain for these checks. Enable the +Use a test hosting package, account, and domain for these checks. Enable the local services that the installation will offer before checking them. 1. Sign in through the hostname clients will use. Check the HTTPS certificate, @@ -1049,7 +1052,7 @@ to see the latest result. [Website storage measurement](development.md#measure-w To enforce hard limits, prepare a dedicated ext4 volume with user quotas for the managed sites. Use **Change storage limit** on the deployed account to -apply the hosting plan's default or choose a per-site value. +apply the hosting package's default or choose a per-site value. [Website storage quotas](development.md#apply-a-website-storage-limit) ### Choose PHP versions for hosted websites @@ -1069,7 +1072,7 @@ sudo apt install php8.5-fpm php8.6-fpm sudo systemctl enable --now php8.5-fpm php8.6-fpm ``` -Under **Hosting plans**, enter the **Allowed PHP series** as a comma-separated +Under **Hosting packages**, enter the **Allowed PHP series** as a comma-separated list, such as `8.5, 8.6`. A blank list makes every installed stable series available. New website activations select the newest installed stable series in the plan. Each active site retains its recorded series when a package or @@ -1101,7 +1104,7 @@ jobs use their own configured runtimes. Use a versioned command such as ### Configure PHP pool limits per website -Under **Hosting plans**, set default PHP memory, upload size, request timeout, +Under **Hosting packages**, set default PHP memory, upload size, request timeout, or PHP-FPM worker limits. The panel captures these values when an operator first requests local activation. A repeat activation preserves an installed pool's settings. @@ -1154,7 +1157,7 @@ serves no tenant content when unknown hosts should be rejected. ## Host independent websites -Set a hosting plan's **Website limit** above one to allow additional +Set a hosting package's **Website limit** above one to allow additional websites under an account. The limit includes the primary website. Existing plans start with one website. In **Independent websites**, choose **Add website** to provision a domain or subdomain with its own document root, @@ -2121,7 +2124,7 @@ To locate that file, download the manifest and use the node's `apply` command. Reapplying the manifest preserves the password and prints the file path. [Show mailbox connection details in the panel](#show-local-database-and-mailbox-connection-details) -Set a per-mailbox storage limit on the hosting plan for new mailbox requests. +Set a per-mailbox storage limit on the hosting package for new mailbox requests. Enable Dovecot quota enforcement on the mail node before provisioning them. [Mailbox storage limits](development.md#enforce-mailbox-storage-limits) @@ -2164,7 +2167,7 @@ smtpd_reject_unlisted_recipient = yes Run `sudo postfix check` and `sudo postfix reload`. Set `COULOBRE_MAIL_ROUTING=1` in `/etc/coulobre/panel.env`. Operators can opt a -hosting plan into catch-all and external forwarding separately. Plan changes +hosting package into catch-all and external forwarding separately. Plan changes are checked when saving the next routing revision. To revoke an active forwarder or catch-all, remove the rule and apply the update. @@ -2686,9 +2689,9 @@ remote receiver, while databases still use the local credential service. ## Set up manager access Open **Managers** to add a manager login or change an existing manager's -panel access, account limit, and allowed hosting plans. The detail page shows +panel access, account limit, and allowed hosting packages. The detail page shows allocated accounts and audit history. Viewing account names and plan details -requires the corresponding hosting account and hosting plan permissions. +requires the corresponding hosting account and hosting package permissions. The account limit and allowed plans apply when a manager creates a hosting account. Reducing the limit or removing a plan takes effect on the next @@ -2699,13 +2702,17 @@ changes to manager policy and account assignments made through the panel. ### Onboard customers -Managers can open **My users** to create a customer login and its first -hosting account together. Choose an allowed hosting plan and give the +Managers can open **Add User** to create a customer login and its first +hosting account together. Choose an allowed hosting package and give the customer's email address to send a welcome email with a link to set their password. Preview the email before creating the account. To add a login for an existing unassigned hosting account, open the account and choose **Add customer login** or **Link existing customer**. +Operators can open **Contact and invitation** from **Show All Users** to +review the welcome email and send a fresh password setup link to a pending +login. Sending a new invitation replaces the previous link. + Managers handle customer onboarding and hosting assignments in their portfolio. Customers manage their own website files, databases, mailboxes, and other hosting resources in the customer workspace. Operators can diff --git a/docs/development.md b/docs/development.md index 9f35fe1..f230a67 100644 --- a/docs/development.md +++ b/docs/development.md @@ -19,11 +19,11 @@ Select **Add hosting account** and enter a name and a primary domain such as `example.org`. Open an account from the list to edit its details or request an Apache preview. Manage users, groups, and permissions at `/admin/`. -Use **Hosting plans** to add named plans with an optional description. Choose a +Use **Hosting packages** to add named plans with an optional description. Choose a plan when creating or editing an account. Existing accounts start unassigned. -Operators need permission to view hosting plans before they can assign one. +Operators need permission to view hosting packages before they can assign one. -Set a database limit and a mailbox limit on a hosting plan to cap how many +Set a database limit and a mailbox limit on a hosting package to cap how many requests each assigned account can make through the panel. A blank limit allows unlimited requests. Zero blocks new requests of that type. Accounts without a plan have unlimited requests. The account page shows usage for configured @@ -39,7 +39,7 @@ Set **Website storage limit (MiB)** to supply the initial value when an operator applies a website quota from the account page. [Apply a website storage limit](#apply-a-website-storage-limit) -Set optional PHP resource defaults on a hosting plan. Coulobre applies them +Set optional PHP resource defaults on a hosting package. Coulobre applies them on first local activation and when an operator reapplies the plan on the account page. See [website PHP settings](deployment.md#configure-php-pool-limits-per-website). @@ -56,11 +56,11 @@ Then open a hosting account in Coulobre Panel and select the manager when editing the account. Existing accounts start with no manager assigned. Managers can sign in to Coulobre Panel to see their assigned hosting accounts -and plans. They can also onboard customers and assign an allowed hosting plan +and plans. They can also onboard customers and assign an allowed hosting package to an existing account. To let the manager add accounts, set a positive account limit and select the -available hosting plans in the manager's admin record. The manager's account +available hosting packages in the manager's admin record. The manager's account list shows their allowance. The limit applies to self-service creation, and operator assignments also count toward the allowance. New hosting accounts automatically belong to the manager and require an allowed plan. A limit of @@ -83,7 +83,7 @@ should be able to access. To give an existing user customer access, add a The customer signs in after setting or receiving their password. Their account list shows only the hosting accounts assigned to them. Each -account page shows its hosting plan, database requests, DNS zones, and mailbox +account page shows its hosting package, database requests, DNS zones, and mailbox requests. Customers can request databases and mailboxes for their own accounts within their plan limits. Operators deploy those requests on the hosting nodes. @@ -1095,7 +1095,7 @@ user quotas are active with On the local installation, open a deployed hosting account and select **Change storage limit** under **Website storage**. An operator with **Can -change site storage limit** can apply the hosting plan's default or enter +change site storage limit** can apply the hosting package's default or enter another value in MiB. Clear the field to remove the space limit. The page shows the last confirmed limit and any pending update. diff --git a/pyproject.toml b/pyproject.toml index 1dcff53..cacda88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "coulobre-panel" -version = "0.13.0rc1" +version = "0.13.0rc2" description = "A web hosting control panel for hosting providers and resellers." readme = "README.md" requires-python = ">=3.12" diff --git a/src/coulobre/hosting/account_administration.py b/src/coulobre/hosting/account_administration.py index 7edbb66..11097a5 100644 --- a/src/coulobre/hosting/account_administration.py +++ b/src/coulobre/hosting/account_administration.py @@ -51,7 +51,7 @@ class ManagerOnboardingForm(InviteLoginForm): "primary_domain" ).formfield(required=True) plan = forms.ModelChoiceField( - queryset=HostingPlan.objects.none(), label="Hosting plan" + queryset=HostingPlan.objects.none(), label="Hosting package" ) manage_dns = forms.BooleanField( required=False, label="Manage DNS in Coulobre" @@ -122,7 +122,7 @@ class ManagerOnboardingView(UserPassesTestMixin, FormView): form_class = ManagerOnboardingForm template_name = "hosting/workspace_form.html" extra_context = { - "title": "Add a new user", + "title": "Add user", "submit_label": "Create customer and hosting account", "invitation_preview": True, } @@ -277,6 +277,10 @@ class AllUsersView(OperatorOnlyMixin, PermissionRequiredMixin, ListView): (login, measurements.get(profile.pk) if profile else None) for login, profile in zip(context["logins"], profiles, strict=True) ] + actor = self.request.user + context["may_manage_invitations"] = actor.has_perm( + "hosting.change_customer" + ) or actor.has_perm("hosting.change_reseller") return context @@ -301,7 +305,7 @@ class OperatorCreateView(OperatorAuthorization, FormView): template_name = "hosting/workspace_form.html" success_url = reverse_lazy("panel:all_users") extra_context = { - "title": "Add an operator", + "title": "Add operator", "submit_label": "Create operator", } @@ -332,7 +336,7 @@ class MoveHostingForm(forms.Form): ) confirm = forms.BooleanField( required=False, - label="I reviewed the destination and its hosting plan policy", + label="I reviewed the destination and its hosting package policy", ) @@ -398,7 +402,7 @@ class MoveHostingView(OperatorAuthorization, FormView): item.hosting_plan_id not in allowed_plans for item in moving ): raise ValidationError( - "The destination must have room and allow every hosting plan." + "The destination needs room and must allow all packages." ) revision = [ destination.pk, diff --git a/src/coulobre/hosting/independent_websites.py b/src/coulobre/hosting/independent_websites.py index 1945175..7f8081f 100644 --- a/src/coulobre/hosting/independent_websites.py +++ b/src/coulobre/hosting/independent_websites.py @@ -77,7 +77,7 @@ def check_version(account, version): allowed = allowed_versions(account) if allowed and version not in allowed: raise ValidationError( - {"php_version": "This PHP series is outside the hosting plan."} + {"php_version": "This PHP series is outside the hosting package."} ) diff --git a/src/coulobre/hosting/invitations.py b/src/coulobre/hosting/invitations.py index 5d35ba0..cedb495 100644 --- a/src/coulobre/hosting/invitations.py +++ b/src/coulobre/hosting/invitations.py @@ -17,8 +17,10 @@ from django.shortcuts import get_object_or_404, redirect from django.template.loader import render_to_string from django.urls import reverse, reverse_lazy from django.utils import timezone +from django.utils.decorators import method_decorator from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode +from django.views.decorators.cache import never_cache from django.views.decorators.debug import sensitive_variables from django.views.generic import FormView from kombu.exceptions import OperationalError @@ -143,7 +145,7 @@ def enqueue_delivery(invitation_id, revision): ).update(delivery=PanelInvitation.Delivery.FAILED) -@sensitive_variables("path", "message") +@sensitive_variables("path", "context") def deliver_invitation(invitation_id, revision): pending = PanelInvitation.objects.filter( pk=invitation_id, @@ -166,6 +168,28 @@ def deliver_invitation(invitation_id, revision): "token": invitation_token.make_token(user), }, ) + context = invitation_message_context(user, setup_url=origin + path) + try: + sent = send_mail( + "Welcome to Coulobre Panel", + render_to_string("hosting/panel_invitation.txt", context), + None, + [user.email], + html_message=render_to_string( + "hosting/panel_invitation.html", + {"invitation_content": context}, + ), + ) + if sent != 1: + raise OSError("The email backend did not accept the invitation.") + except (OSError, ValueError): + pending.update(delivery=PanelInvitation.Delivery.FAILED) + else: + pending.update(delivery=PanelInvitation.Delivery.SENT) + + +def invitation_message_context(user, *, setup_url=""): + invitation = getattr(user, "panel_invitation", None) account = ( HostingAccount.objects.filter( customer__user=user, retired_at__isnull=True @@ -179,10 +203,10 @@ def deliver_invitation(invitation_id, revision): if account else None ) - message = render_welcome_message( + return welcome_message_context( username=user.get_username(), - welcome_message=invitation.welcome_message, - setup_url=origin + path, + welcome_message=invitation.welcome_message if invitation else "", + setup_url=setup_url, account=account, nameservers=zone.nameservers if zone else (), mail_configured=bool( @@ -192,19 +216,9 @@ def deliver_invitation(invitation_id, revision): ).exists() ), ) - try: - sent = send_mail( - "Your Coulobre Panel invitation", message, None, [user.email] - ) - if sent != 1: - raise OSError("The email backend did not accept the invitation.") - except (OSError, ValueError): - pending.update(delivery=PanelInvitation.Delivery.FAILED) - else: - pending.update(delivery=PanelInvitation.Delivery.SENT) -def render_welcome_message( +def welcome_message_context( *, username, welcome_message, @@ -213,24 +227,31 @@ def render_welcome_message( nameservers, mail_configured, ): + return { + "username": username, + "welcome_message": welcome_message, + "setup_url": setup_url, + "panel_url": ( + settings.PASSWORD_RESET_ORIGIN.rstrip("/") + "/" + if settings.PASSWORD_RESET_ORIGIN + else "" + ), + "account": account, + "nameservers": nameservers, + "website_records": ( + website_records(account.primary_domain, wildcard=False) + if account and not nameservers + else () + ), + "imap_host": settings.MAIL_IMAP_HOST, + "submission_host": settings.MAIL_SUBMISSION_HOST, + "mail_configured": mail_configured, + } + + +def render_welcome_message(**kwargs): return render_to_string( - "hosting/panel_invitation.txt", - { - "username": username, - "welcome_message": welcome_message, - "setup_url": setup_url, - "panel_url": settings.PASSWORD_RESET_ORIGIN.rstrip("/") + "/", - "account": account, - "nameservers": nameservers, - "website_records": ( - website_records(account.primary_domain, wildcard=False) - if account and not nameservers - else () - ), - "imap_host": settings.MAIL_IMAP_HOST, - "submission_host": settings.MAIL_SUBMISSION_HOST, - "mail_configured": mail_configured, - }, + "hosting/panel_invitation.txt", welcome_message_context(**kwargs) ) @@ -259,6 +280,7 @@ class InvitationEmailForm(forms.Form): email = forms.EmailField(label="Contact email") +@method_decorator(never_cache, name="dispatch") class ManageInvitation(AccessMixin, FormView): form_class = InvitationEmailForm template_name = "hosting/manage_invitation.html" @@ -292,10 +314,14 @@ class ManageInvitation(AccessMixin, FormView): def get_context_data(self, **kwargs): user = self.record.user + can_send = user.is_active and not user.has_usable_password() return super().get_context_data( login_user=user, invitation=getattr(user, "panel_invitation", None), - can_send=user.is_active and not user.has_usable_password(), + can_send=can_send, + welcome_preview=( + invitation_message_context(user) if can_send else None + ), **kwargs, ) diff --git a/src/coulobre/hosting/mail_policies.py b/src/coulobre/hosting/mail_policies.py index 88e6533..1721663 100644 --- a/src/coulobre/hosting/mail_policies.py +++ b/src/coulobre/hosting/mail_policies.py @@ -47,7 +47,7 @@ def validate_policy(resource, spec, account): def validate_routing(domain, spec, plan): if spec.catchall and not (plan and plan.allow_mail_catchall): - raise ValidationError("This hosting plan does not allow catch-all.") + raise ValidationError("This hosting package does not allow catch-all.") mailboxes = domain.mailboxes.all() if mailboxes.filter(local_part__in=spec.aliases).exists(): raise ValidationError("An alias cannot replace a requested mailbox.") @@ -68,7 +68,7 @@ def validate_routing(domain, spec, plan): ) elif not (plan and plan.allow_external_mail_forwarding): raise ValidationError( - "This hosting plan does not allow external forwarding." + "This hosting package does not allow external forwarding." ) diff --git a/src/coulobre/hosting/panel_roles.py b/src/coulobre/hosting/panel_roles.py index c2acc7e..fc9ae7a 100644 --- a/src/coulobre/hosting/panel_roles.py +++ b/src/coulobre/hosting/panel_roles.py @@ -22,8 +22,13 @@ from .models import Customer, Reseller, ResellerProfile SESSION_ROLE = "coulobre_panel_role" ROLE_LABELS = { PanelRole.ADMIN: "Server administrator", - PanelRole.CUSTOMER: "Customer", PanelRole.MANAGER: "Manager", + PanelRole.CUSTOMER: "Customer", +} +ROLE_SWITCH_DETAILS = { + PanelRole.ADMIN: ("shield", "Server and all accounts"), + PanelRole.MANAGER: ("resellers", "Customers you manage"), + PanelRole.CUSTOMER: ("customers", "Your own hosting"), } @@ -126,8 +131,12 @@ class PanelRoleMiddleware: return redirect("panel:login") request.active_panel_role = role + request.panel_role_label = ROLE_LABELS[role] + request.panel_role_icon = ROLE_SWITCH_DETAILS[role][0] request.panel_role_options = [ - (option, ROLE_LABELS[option]) for option in roles + (option, ROLE_LABELS[option], *ROLE_SWITCH_DETAILS[option]) + for option in PanelRole + if option in roles ] request.user = scoped_user(user, role) diff --git a/src/coulobre/hosting/php_settings.py b/src/coulobre/hosting/php_settings.py index 0918e46..9ba70e9 100644 --- a/src/coulobre/hosting/php_settings.py +++ b/src/coulobre/hosting/php_settings.py @@ -40,7 +40,7 @@ class SitePhpSettingsForm(forms.Form): ) max_children = php_setting_input("max_children", "Maximum PHP-FPM workers") use_plan = forms.BooleanField( - label="Apply the current hosting plan defaults", + label="Apply the current hosting package defaults", required=False, help_text="Uses the plan's values in place of the limits above.", ) @@ -116,7 +116,7 @@ def limit_customer_php_settings(account, requested): value = values[key] if value is not None and (limit is None or value > limit): raise ValidationError( - "Keep PHP limits within the account's hosting plan." + "Keep PHP limits within the account's hosting package." ) if value is None: values[key] = limit diff --git a/src/coulobre/hosting/reseller_accounts.py b/src/coulobre/hosting/reseller_accounts.py index 676b8ed..ace5e34 100644 --- a/src/coulobre/hosting/reseller_accounts.py +++ b/src/coulobre/hosting/reseller_accounts.py @@ -131,7 +131,7 @@ def create_reseller_account(access, account): raise ValidationError( { "hosting_plan": ( - "This hosting plan is no longer available to you." + "This hosting package is no longer available to you." ) } ) diff --git a/src/coulobre/hosting/reseller_onboarding_views.py b/src/coulobre/hosting/reseller_onboarding_views.py index 8aaafc5..c3a084a 100644 --- a/src/coulobre/hosting/reseller_onboarding_views.py +++ b/src/coulobre/hosting/reseller_onboarding_views.py @@ -134,7 +134,9 @@ def claim_own_customer_hosting(request, pk): class ManagerHostingPlanForm(forms.Form): - plan = forms.ModelChoiceField(queryset=HostingPlan.objects.none()) + plan = forms.ModelChoiceField( + queryset=HostingPlan.objects.none(), label="Hosting package" + ) def __init__(self, *args, manager, **kwargs): super().__init__(*args, **kwargs) @@ -145,8 +147,8 @@ class ManagerHostingPlanView(UserPassesTestMixin, FormView): form_class = ManagerHostingPlanForm template_name = "hosting/workspace_form.html" extra_context = { - "title": "Assign hosting plan", - "submit_label": "Assign plan", + "title": "Assign hosting package", + "submit_label": "Assign package", } def test_func(self): diff --git a/src/coulobre/hosting/reseller_profiles.py b/src/coulobre/hosting/reseller_profiles.py index f4dfe35..a4d1d9d 100644 --- a/src/coulobre/hosting/reseller_profiles.py +++ b/src/coulobre/hosting/reseller_profiles.py @@ -20,6 +20,7 @@ class ResellerProfileForm(forms.ModelForm): class Meta: model = ResellerProfile fields = ("name", "account_limit", "hosting_plans") + labels = {"hosting_plans": "Allowed hosting packages"} help_texts = { "account_limit": "Enter 0 to manage existing accounts only.", } @@ -32,7 +33,7 @@ class ResellerProfileForm(forms.ModelForm): values = super().clean() if values.get("account_limit") and not values.get("hosting_plans"): self.add_error( - "hosting_plans", "Select at least one hosting plan." + "hosting_plans", "Select at least one hosting package." ) return values @@ -67,7 +68,9 @@ class ProfileEditor(ProfilesAccess): try: return super().form_valid(form) except IntegrityError: - form.add_error(None, "The profiles changed. Review and try again.") + form.add_error( + None, "The manager packages changed. Review and try again." + ) return self.form_invalid(form) diff --git a/src/coulobre/hosting/reseller_views.py b/src/coulobre/hosting/reseller_views.py index 755ce51..28a3c71 100644 --- a/src/coulobre/hosting/reseller_views.py +++ b/src/coulobre/hosting/reseller_views.py @@ -33,11 +33,11 @@ class ResellerPolicyForm(forms.ModelForm): class Meta: model = Reseller fields = ("is_active", "account_limit", "hosting_plans") - labels = {"hosting_plans": "Allowed hosting plans"} + labels = {"hosting_plans": "Allowed hosting packages"} help_texts = { "account_limit": "Enter 0 to manage existing accounts only.", "hosting_plans": ( - "Plans available when a manager creates an account." + "Packages available when a manager creates an account." ), } @@ -61,7 +61,7 @@ class ResellerPolicyForm(forms.ModelForm): and not values.get("hosting_plans") ): self.add_error( - "hosting_plans", "Select at least one hosting plan." + "hosting_plans", "Select at least one hosting package." ) return values diff --git a/src/coulobre/hosting/static/hosting/panel-navigation.js b/src/coulobre/hosting/static/hosting/panel-navigation.js index 18b05fd..8336033 100644 --- a/src/coulobre/hosting/static/hosting/panel-navigation.js +++ b/src/coulobre/hosting/static/hosting/panel-navigation.js @@ -33,18 +33,19 @@ updateMenuLayout(); const roleSwitch = document.querySelector("[data-role-switch]"); if (roleSwitch) { - const picker = roleSwitch.querySelector("select"); - const currentRole = picker.value; - roleSwitch.classList.add("role-switch-on-change"); - roleSwitch.querySelector("button").hidden = true; - picker.setAttribute("aria-label", "Panel role (switches when selected)"); - picker.addEventListener("change", () => { - if (picker.value !== currentRole) { - roleSwitch.requestSubmit(); + roleSwitch.addEventListener("keydown", event => { + if (event.key === "Escape" && roleSwitch.open) { + roleSwitch.open = false; + roleSwitch.querySelector("summary").focus(); + } + }); + document.addEventListener("click", event => { + if (roleSwitch.open && !roleSwitch.contains(event.target)) { + roleSwitch.open = false; } }); window.addEventListener("pageshow", () => { - picker.value = currentRole; + roleSwitch.open = false; }); } diff --git a/src/coulobre/hosting/static/hosting/panel.css b/src/coulobre/hosting/static/hosting/panel.css index 6a261c5..a69ed39 100644 --- a/src/coulobre/hosting/static/hosting/panel.css +++ b/src/coulobre/hosting/static/hosting/panel.css @@ -329,25 +329,102 @@ a.sidebar-identity:hover { } .panel-role-switch { - display: grid; - grid-template-columns: minmax(0, 1fr) auto; - gap: 0.35rem; + position: relative; font-size: 0.82rem; } -.panel-role-switch.role-switch-on-change { - display: block; -} - -.panel-role-switch select { - width: 100%; - min-width: 0; +.panel-role-switch summary { + display: flex; + align-items: center; + gap: 0.45rem; min-height: 2.2rem; background: var(--sidebar-active); color: var(--sidebar-text); border: 1px solid var(--sidebar-control-line); border-radius: 6px; - padding: 0.35rem 0.45rem; + padding: 0.35rem 0.55rem; + cursor: pointer; + font-weight: 650; + list-style: none; +} + +.panel-role-switch summary::-webkit-details-marker { + display: none; +} + +.panel-role-switch summary::after { + width: 0.45rem; + height: 0.45rem; + flex: 0 0 auto; + margin-inline-start: auto; + margin-inline-end: 0.15rem; + border-inline-end: 1.5px solid currentColor; + border-block-end: 1.5px solid currentColor; + content: ""; + transform: translateY(-0.1rem) rotate(45deg); +} + +.panel-role-switch[open] summary::after { + transform: translateY(0.1rem) rotate(225deg); +} + +.panel-role-options { + position: absolute; + z-index: 3; + inset-block-end: calc(100% + 0.4rem); + inset-inline-start: 0; + display: grid; + width: max(100%, 16rem); + max-height: 55dvh; + overflow-y: auto; + padding: 0.25rem; + border: 1px solid var(--sidebar-control-line); + border-radius: 8px; + background: var(--sidebar); + box-shadow: 0 4px 14px #0004; +} + +.panel-role-option { + display: grid; + grid-template-columns: auto minmax(0, 1fr) auto; + align-items: center; + gap: 0.5rem; + padding: 0.5rem; + border: 1px solid transparent; + border-radius: 5px; + background: transparent; + color: var(--sidebar-text); + text-align: start; +} + +.panel-role-option:enabled { + cursor: pointer; +} + +.panel-role-option:hover:enabled, +.panel-role-option[aria-current] { + border-color: var(--sidebar-line); + background: var(--sidebar-active); +} + +.sidebar .panel-role-option:focus-visible { + outline-offset: -2px; +} + +.panel-role-option strong, +.panel-role-option small { + display: block; +} + +.panel-role-option small { + color: var(--sidebar-account); + font-size: 0.75rem; +} + +.panel-role-current { + color: var(--sidebar-highlight); + font-size: 0.75rem; + font-weight: 650; } .sidebar-action { @@ -1069,6 +1146,14 @@ dd { margin: 0; padding-top: 0.6rem; } + + .panel-role-options { + inset-block-start: calc(100% + 0.4rem); + inset-block-end: auto; + inset-inline-start: auto; + inset-inline-end: 0; + max-width: calc(100vw - 1.5rem); + } } @media (min-width: 520px) and (max-width: 780px) { diff --git a/src/coulobre/hosting/tasks.py b/src/coulobre/hosting/tasks.py index 3998d13..00453d0 100644 --- a/src/coulobre/hosting/tasks.py +++ b/src/coulobre/hosting/tasks.py @@ -635,7 +635,9 @@ def apply_site_php_version(job): raise ValueError("Activate the current website before changing PHP.") versions = plan_php_versions(account) if versions and job.requested_version not in versions: - raise ValueError("The hosting plan no longer allows this PHP series.") + raise ValueError( + "The hosting package no longer allows this PHP series." + ) site = WebSite(job.account_id, job.domain) return { "applied_version": update_local_php_version( diff --git a/src/coulobre/hosting/templates/hosting/account_detail.html b/src/coulobre/hosting/templates/hosting/account_detail.html index 9e8cab2..905461e 100644 --- a/src/coulobre/hosting/templates/hosting/account_detail.html +++ b/src/coulobre/hosting/templates/hosting/account_detail.html @@ -25,7 +25,7 @@ {% block page_content %}
{% if is_tenant or perms.hosting.view_hostingplan %} -
Hosting plan
{% if account.hosting_plan %}{{ account.hosting_plan.name }}{% else %}Unassigned{% endif %} +
Hosting package
{% if account.hosting_plan %}{{ account.hosting_plan.name }}{% else %}Unassigned{% endif %} {% if is_reseller %}Assign plan{% endif %}
{% endif %} {% if is_operator and perms.hosting.view_reseller %} diff --git a/src/coulobre/hosting/templates/hosting/account_list.html b/src/coulobre/hosting/templates/hosting/account_list.html index d76e801..0906651 100644 --- a/src/coulobre/hosting/templates/hosting/account_list.html +++ b/src/coulobre/hosting/templates/hosting/account_list.html @@ -42,7 +42,7 @@ Account Status {% if is_operator and perms.hosting.view_customer %}Customer{% endif %} - {% if is_tenant or perms.hosting.view_hostingplan %}Hosting plan{% endif %} + {% if is_tenant or perms.hosting.view_hostingplan %}Hosting package{% endif %} Added diff --git a/src/coulobre/hosting/templates/hosting/all_users.html b/src/coulobre/hosting/templates/hosting/all_users.html index c18f5e0..3303601 100644 --- a/src/coulobre/hosting/templates/hosting/all_users.html +++ b/src/coulobre/hosting/templates/hosting/all_users.html @@ -1,6 +1,11 @@ {% extends "hosting/workspace_page.html" %} {% block title %}All users · Coulobre Panel{% endblock %} {% block page_title %}All users{% endblock %} +{% block page_actions %} + {% if perms.hosting.add_customer %} + Add user + {% endif %} +{% endblock %} {% block page_context %}