Skip to content

Commit 3834a74

Browse files
authored
Fix organization create form slugging (#628)
- Point form to tab url - Use the same slugging logic from our application to render a slug This does not add tests, we could use those though. - Requires readthedocs/readthedocs.org#12306
1 parent c0a74a2 commit 3834a74

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
2-
- repo: https://github.com/pre-commit/mirrors-prettier
3-
rev: "v3.0.3"
2+
- repo: https://github.com/rbubley/mirrors-prettier
3+
rev: "v3.5.3"
44
hooks:
55
- id: prettier
66
args: ["--write", "."]

readthedocsext/theme/static/readthedocsext/theme/js/site.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readthedocsext/theme/templates/organizations/organization_form.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
<h2 class="ui medium heading">{% trans "Join or create an organization" %}</h2>
1717

1818
<div class="ui segment">
19-
<div class="ui link list" data-bind="semanticui: { tabmenu: {} }">
19+
<div class="ui link list"
20+
data-bind="semanticui: { tabs: {history: true, autoTabActivation: true} }">
2021
<a class="item" data-tab="empty">
2122
{% comment %}
2223
Show nothing when the user arrives at this page.
@@ -86,7 +87,7 @@ <h2 class="ui medium heading">{% trans "Join or create an organization" %}</h2>
8687
<div class="ui tab"
8788
data-tab="new"
8889
data-bind="using: new OrganizationCreateView()">
89-
<form class="ui form" action="" method="post">
90+
<form class="ui form" action="#/new" method="post">
9091
{% csrf_token %}
9192
{% alter_field form.name data_bind="valueInit: name, textInput: name" %}
9293
{% alter_field form.slug data_bind="valueInit:slug, text: slug, textInput: slug" %}

src/js/organization/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ export class OrganizationCreateView {
7272
// https://github.com/django/django/blob/1e9db35/django/utils/text.py#L469-L470
7373
.replace(/[^\w\s-_]+/g, "-")
7474
.replace(/[-\s]+/g, "-")
75+
// And then also replicate our dns_safe slugging from
76+
// :py:method:`readthedocs.core.utils.sluggify`
77+
.replace(/[\-\_]+/g, "-")
78+
.replace(/^\-+/, "")
79+
.replace(/\-+$/, "")
7580
);
7681
}
7782
}

0 commit comments

Comments
 (0)