templates: Move subdomain and import realm creation form fields.

As prep for adding demo organization registration via forms and
templates, we separate the base fields used for both demo and
permanent organization registration, and the URL subdomain and
import chat history fields that are only used for permanent
organization registration.
This commit is contained in:
Lauryn Menard 2025-10-02 18:02:51 +02:00 committed by Tim Abbott
parent a06d188b49
commit 829400de18
6 changed files with 71 additions and 63 deletions

View File

@ -21,6 +21,10 @@
{{ csrf_input }}
{% include 'zerver/realm_creation_base_form_fields.html' %}
{% include 'zerver/realm_creation_subdomain_form_field.html' %}
{% if is_realm_import_enabled %}
{% include 'zerver/realm_creation_import_form_field.html' %}
{% endif %}
<div class="input-box horizontal">
<div class="inline-block relative">

View File

@ -49,66 +49,4 @@
</a>
</label>
</div>
<div class="input-box">
<label class="static org-url">
{{ _('Organization URL') }}
</label>
{% if root_domain_available %}
<label class="checkbox static" for="realm_in_root_domain">
<input type="checkbox" name="realm_in_root_domain" id="realm_in_root_domain"
{% if not form.realm_subdomain.value() and not form.realm_subdomain.errors %}checked="checked"{% endif %}/>
<span class="rendered-checkbox"></span>
{% trans %}Use {{ external_host }}{% endtrans %}
</label>
{% endif %}
<div id="subdomain_section" {% if root_domain_available and
not form.realm_subdomain.errors and not form.realm_subdomain.value() %}style="display: none;"{% endif %}>
<div class="or"><span>{{ _('OR') }}</span></div>
<div class="inline-block relative">
<input id="id_team_subdomain"
class="{% if root_domain_landing_page %}required{% endif %} subdomain" type="text"
placeholder="acme"
value="{% if form.realm_subdomain.value() %}{{ form.realm_subdomain.value() }}{% endif %}"
name="realm_subdomain" maxlength="{{ MAX_REALM_SUBDOMAIN_LENGTH }}"
{% if root_domain_landing_page %}required{% endif %} />
<label for="id_team_subdomain" class="realm_subdomain_label">.{{ external_host }}</label>
<p id="id_team_subdomain_error_client" class="error help-inline text-error"></p>
</div>
{% if form.realm_subdomain.errors %}
{% for error in form.realm_subdomain.errors %}
<p class="error help-inline text-error team_subdomain_error_server">{{ error }}</p>
{% endfor %}
{% endif %}
</div>
</div>
{% if is_realm_import_enabled %}
<div class="input-box">
<div class="inline-block" id="realm-creation-import-from-wrapper">
<select id="import_from" name="import_from"
{% if user_registration_form %}
disabled
{% endif %}
>
{% for key, choice in import_from_choices %}
<option value="{{ key }}" {% if key == "none" %}selected{% endif %}>{{ _(choice) }}</option>
{% endfor %}
</select>
{% if not user_registration_form %}
<p class="extra-info-realm-creation-import-from registration-form-hint">
{% trans %}
Learn how to import from
<a href="/help/import-from-mattermost">Mattermost</a> or
<a href="/help/import-from-rocketchat">Rocket.Chat</a>.
{% endtrans %}
</p>
{% endif %}
</div>
<label for="import_from" class="inline-block">
{{ _('Import chat history?') }}
</label>
</div>
{% endif %}
</div>

View File

@ -0,0 +1,27 @@
<div class="realm-creation-editable-inputs {% if user_registration_form and not form.realm_subdomain.errors %}hide{% endif %}">
<div class="input-box">
<div class="inline-block" id="realm-creation-import-from-wrapper">
<select id="import_from" name="import_from"
{% if user_registration_form %}
disabled
{% endif %}
>
{% for key, choice in import_from_choices %}
<option value="{{ key }}" {% if key == "none" %}selected{% endif %}>{{ _(choice) }}</option>
{% endfor %}
</select>
{% if not user_registration_form %}
<p class="extra-info-realm-creation-import-from registration-form-hint">
{% trans %}
Learn how to import from
<a href="/help/import-from-mattermost">Mattermost</a> or
<a href="/help/import-from-rocketchat">Rocket.Chat</a>.
{% endtrans %}
</p>
{% endif %}
</div>
<label for="import_from" class="inline-block">
{{ _('Import chat history?') }}
</label>
</div>
</div>

View File

@ -0,0 +1,35 @@
<div class="realm-creation-editable-inputs {% if user_registration_form and not form.realm_subdomain.errors %}hide{% endif %}">
<div class="input-box">
<label class="static org-url">
{{ _('Organization URL') }}
</label>
{% if root_domain_available %}
<label class="checkbox static" for="realm_in_root_domain">
<input type="checkbox" name="realm_in_root_domain" id="realm_in_root_domain"
{% if not form.realm_subdomain.value() and not form.realm_subdomain.errors %}checked="checked"{% endif %}/>
<span class="rendered-checkbox"></span>
{% trans %}Use {{ external_host }}{% endtrans %}
</label>
{% endif %}
<div id="subdomain_section" {% if root_domain_available and
not form.realm_subdomain.errors and not form.realm_subdomain.value() %}style="display: none;"{% endif %}>
<div class="or"><span>{{ _('OR') }}</span></div>
<div class="inline-block relative">
<input id="id_team_subdomain"
class="{% if root_domain_landing_page %}required{% endif %} subdomain" type="text"
placeholder="acme"
value="{% if form.realm_subdomain.value() %}{{ form.realm_subdomain.value() }}{% endif %}"
name="realm_subdomain" maxlength="{{ MAX_REALM_SUBDOMAIN_LENGTH }}"
{% if root_domain_landing_page %}required{% endif %} />
<label for="id_team_subdomain" class="realm_subdomain_label">.{{ external_host }}</label>
<p id="id_team_subdomain_error_client" class="error help-inline text-error"></p>
</div>
{% if form.realm_subdomain.errors %}
{% for error in form.realm_subdomain.errors %}
<p class="error help-inline text-error team_subdomain_error_server">{{ error }}</p>
{% endfor %}
{% endif %}
</div>
</div>
</div>

View File

@ -41,6 +41,10 @@ Form is validated both client-side using jquery-validation (see signup.js) and s
{% with %}
{% set user_registration_form = "true" %}
{% include 'zerver/realm_creation_base_form_fields.html' %}
{% include 'zerver/realm_creation_subdomain_form_field.html' %}
{% if is_realm_import_enabled %}
{% include 'zerver/realm_creation_import_form_field.html' %}
{% endif %}
{% endwith %}
{% if not form.realm_subdomain.errors %}
<div class="not-editable-realm-details">

View File

@ -577,7 +577,7 @@ html_rules: list["Rule"] = [
"pattern": r'placeholder="[^{#](?:(?!\.com).)+$',
"description": "`placeholder` value should be translatable.",
"exclude_line": {
("templates/zerver/realm_creation_base_form_fields.html", 'placeholder="acme"'),
("templates/zerver/realm_creation_subdomain_form_field.html", 'placeholder="acme"'),
("templates/zerver/slack_import.html", 'placeholder="xoxb-…"'),
},
"exclude": {