playgrounds: Rename name field to playground_name.

The browser seems to autofill the `Name` field of the add-playground
form. Most likely this behavior is a result of  value of the `name`
input field being `name`, causing the browser do to something weird
here. This name is now changed to `playground_name`.
This commit is contained in:
Sumanth V Rao
2021-05-10 21:59:56 +05:30
committed by Tim Abbott
parent b15941610d
commit 72ead6e097
3 changed files with 11 additions and 7 deletions

View File

@@ -5,7 +5,7 @@ import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common";
type Playground = {
name: string;
playground_name: string;
pygments_language: string;
url_prefix: string;
};
@@ -34,7 +34,7 @@ async function _add_playground_and_return_status(page: Page, payload: Playground
async function test_successful_playground_creation(page: Page): Promise<void> {
const payload = {
pygments_language: "Python",
name: "Python3 playground",
playground_name: "Python3 playground",
url_prefix: "https://python.example.com",
};
const status = await _add_playground_and_return_status(page, payload);
@@ -60,7 +60,7 @@ async function test_successful_playground_creation(page: Page): Promise<void> {
async function test_invalid_playground_parameters(page: Page): Promise<void> {
const payload = {
pygments_language: "Python",
name: "Python3 playground",
playground_name: "Python3 playground",
url_prefix: "not_a_url",
};
let status = await _add_playground_and_return_status(page, payload);

View File

@@ -108,17 +108,21 @@ function build_page() {
$(".organization form.admin-playground-form")
.off("submit")
.on("submit", function (e) {
.on("submit", (e) => {
e.preventDefault();
e.stopPropagation();
const playground_status = $("#admin-playground-status");
const add_playground_button = $(".new-playground-form button");
add_playground_button.prop("disabled", true);
playground_status.hide();
const data = {
name: $("#playground_name").val(),
pygments_language: $("#playground_pygments_language").val(),
url_prefix: $("#playground_url_prefix").val(),
};
channel.post({
url: "/json/realm/playgrounds",
data: $(this).serialize(),
data,
success() {
$("#playground_pygments_language").val("");
$("#playground_name").val("");

View File

@@ -36,7 +36,7 @@
</div>
<div class="control-group">
<label for="playground_name" class="control-label"> {{t "Name" }}</label>
<input type="text" id="playground_name" name="name" autocomplete="off" placeholder="Python3 playground" />
<input type="text" id="playground_name" name="playground_name" autocomplete="off" placeholder="Python3 playground" />
</div>
<div class="control-group">
<label for="playground_url_prefix" class="control-label"> {{t "URL prefix" }}</label>