Skip to content

Commit

Permalink
Merge pull request #487 from apache/issue-report-page
Browse files Browse the repository at this point in the history
Remove report an issue from options_ui
  • Loading branch information
Jyyjy authored Aug 19, 2024
2 parents 8465a35 + ef2eb2f commit bda79c6
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 13 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions build/UserALEWebExtension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
}
],
"options_ui": {
"page": "optionsPage.html"
"page": "options.html"
},
"browser_action": {
"default_popup": "optionsPage.html"
"default_popup": "browserAction.html"
}
}
57 changes: 57 additions & 0 deletions build/UserALEWebExtension/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!--
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->

<!doctype html>
<html>
<head>
<title>User ALE Web Extension - Options</title>
<script src="options.js"></script>
<meta charset="utf-8" />
</head>
<body>
<h1>Logging Options</h1>
<form name="optionsForm" id="optionsForm">
<label>Logging Endpoint URL:</label>
<input name="url" id="url" />
<br />

<label>User:</label>
<input name="userId" id="user" />
<br />

<label>Password:</label>
<input name="password" type="password" id="password" />
<br />

<label>Tool Name:</label>
<input name="toolName" id="tool" />
<br />

<label>Tool Version:</label>
<input name="toolVersion" id="toolVersion" />
<br />

<label>URL whitelist regex:</label>
<input name="filter" id="filter" />
<br />

<div align="right">
<button type="submit" id="submitOptions">Save Changes</button>
</div>
</form>
</body>
</html>
5 changes: 4 additions & 1 deletion build/UserALEWebExtension/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,10 @@ function getConfig() {
payload.pluginConfig.urlWhitelist;
});
document.getElementById("optionsForm").addEventListener("submit", setConfig);
document.getElementById("issueForm").addEventListener("submit", reportIssue);
const issueForm = document.getElementById("issueForm");
if (issueForm instanceof HTMLElement) {
issueForm.addEventListener("submit", reportIssue);
}
}
function reportIssue() {
browser.runtime.sendMessage({
Expand Down
3 changes: 2 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export default [
targets: [
{src: srcWebExtensionDir + 'icons/**/*.*', dest: buildWebExtensionDir + 'icons'},
{src: srcWebExtensionDir + 'manifest.json', dest: buildWebExtensionDir},
{src: srcWebExtensionDir + 'optionsPage.html', dest: buildWebExtensionDir}
{src: srcWebExtensionDir + 'options.html', dest: buildWebExtensionDir},
{src: srcWebExtensionDir + 'browserAction.html', dest: buildWebExtensionDir}
],
copyOnce: true
}),
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/UserALEWebExtension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
}
],
"options_ui": {
"page": "optionsPage.html"
"page": "options.html"
},
"browser_action": {
"default_popup": "optionsPage.html"
"default_popup": "browserAction.html"
}
}
57 changes: 57 additions & 0 deletions src/UserALEWebExtension/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!--
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->

<!doctype html>
<html>
<head>
<title>User ALE Web Extension - Options</title>
<script src="options.js"></script>
<meta charset="utf-8" />
</head>
<body>
<h1>Logging Options</h1>
<form name="optionsForm" id="optionsForm">
<label>Logging Endpoint URL:</label>
<input name="url" id="url" />
<br />

<label>User:</label>
<input name="userId" id="user" />
<br />

<label>Password:</label>
<input name="password" type="password" id="password" />
<br />

<label>Tool Name:</label>
<input name="toolName" id="tool" />
<br />

<label>Tool Version:</label>
<input name="toolVersion" id="toolVersion" />
<br />

<label>URL whitelist regex:</label>
<input name="filter" id="filter" />
<br />

<div align="right">
<button type="submit" id="submitOptions">Save Changes</button>
</div>
</form>
</body>
</html>
8 changes: 4 additions & 4 deletions src/UserALEWebExtension/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ function getConfig() {
"submit",
setConfig,
);
(document.getElementById("issueForm") as HTMLFormElement).addEventListener(
"submit",
reportIssue,
);
const issueForm = document.getElementById("issueForm");
if (issueForm instanceof HTMLElement) {
issueForm.addEventListener("submit", reportIssue);
}
}

function reportIssue() {
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/spec/01-extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test.describe("Userale extension", () => {
const requestPromise = sender.waitForRequest(
(request) => request.method() === "POST",
);
await page.goto(`chrome-extension://${extensionId}/optionsPage.html`);
await page.goto(`chrome-extension://${extensionId}/options.html`);
// Sleep so options.js can update the html with values from local storage.
await new Promise((r) => setTimeout(r, 1000));
await page.fill("#filter", ".*");
Expand All @@ -60,7 +60,7 @@ test.describe("Userale extension", () => {
const postData = request.postData();
return Boolean(postData && postData.includes("testUser"));
});
await page.goto(`chrome-extension://${extensionId}/optionsPage.html`);
await page.goto(`chrome-extension://${extensionId}/options.html`);
await page.waitForLoadState("load");
await page.fill("#user", id);
await page.click("#submitOptions");
Expand All @@ -87,7 +87,7 @@ test.describe("Userale extension", () => {
const postData = request.postData();
return Boolean(postData && postData.includes(description));
});
await page.goto(`chrome-extension://${extensionId}/optionsPage.html`);
await page.goto(`chrome-extension://${extensionId}/browserAction.html`);
await page.waitForLoadState("load");
await page.fill("#issueDescription", description);
await page.click("#submitIssue");
Expand Down

0 comments on commit bda79c6

Please sign in to comment.