Merge pull request #1442 from tridactyl/autofill_new_issues

Add `:issue` excmd and autocmd to autofill new issues
This commit is contained in:
Oliver Blanthorn 2019-04-08 20:32:08 +01:00 committed by GitHub
commit d736117a38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 1 deletions

View file

@ -5,6 +5,7 @@ manversion=$(grep '"version":' ./src/manifest.json | cut -d":" -f2 | tr -d \" |
version=$manversion-$gitversion version=$manversion-$gitversion
sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/background.js sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/background.js
sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/content.js
sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/static/newtab.html sed -i.bak 's/REPLACE_ME_WITH_THE_VERSION_USING_SED/'"$version"'/' ./build/static/newtab.html
rm ./build/background.js.bak rm ./build/background.js.bak
rm ./build/static/newtab.html.bak rm ./build/static/newtab.html.bak

View file

@ -4083,6 +4083,44 @@ export async function jsb(...str: string[]) {
} }
} }
/**
* Opens a new tab the url of which is "https://github.com/tridactyl/tridactyl/issues/new" and automatically fill add tridactyl, firefox and os version to the issue.
*/
//#content
export async function issue() {
const newIssueUrl = "https://github.com/tridactyl/tridactyl/issues/new"
if (window.location.href !== newIssueUrl) {
return Messaging.message("controller_background", "acceptExCmd", ["tabopen " + newIssueUrl])
}
const textarea = document.getElementById("issue_body")
if (!(textarea instanceof HTMLTextAreaElement)) {
logger.warning("issue(): Couldn't find textarea element in github issue page.")
return
}
let template = await (fetch(browser.extension.getURL("issue_template.md"))
.then(resp => resp.body.getReader())
.then(reader => reader.read())
.then(r => (new TextDecoder("utf-8")).decode(r.value)))
if (textarea.value !== template) {
logger.debug("issue(): Textarea value differs from template, exiting early.")
return
}
const platform = await browserBg.runtime.getPlatformInfo();
// Remove the bit asking the user
template = template.replace("* Operating system:\n", "")
// Add this piece of information to the top of the template
template = `Operating system: ${platform.os}\n` + template
const info = await browserBg.runtime.getBrowserInfo()
template = template.replace("* Firefox version (Top right menu > Help > About Firefox):\n\n", "")
template = `Firefox version: ${info.vendor} ${info.name} ${info.version}\n` + template
template = template.replace("* Tridactyl version (`:version`):\n\n", "")
template = `Tridactyl version: ${TRI_VERSION}\n` + template
textarea.value = template
}
//#background_helper //#background_helper
import * as Parser from "rss-parser" import * as Parser from "rss-parser"
import * as semverCompare from "semver-compare" import * as semverCompare from "semver-compare"

View file

@ -322,7 +322,9 @@ class default_config {
* *
* Each key corresponds to a URL fragment which, if contained within the page URL, will run the corresponding command. * Each key corresponds to a URL fragment which, if contained within the page URL, will run the corresponding command.
*/ */
DocLoad: {}, DocLoad: {
"https://github.com/tridactyl/tridactyl/issues/new": "issue"
},
/** /**
* Commands that will be run when pages are unloaded. * Commands that will be run when pages are unloaded.

View file

@ -56,6 +56,7 @@ module.exports = {
ignore: ["*.psd", "*1024px.png"], ignore: ["*.psd", "*1024px.png"],
}, },
{ from: "generated/static", to: "static" }, { from: "generated/static", to: "static" },
{ from: "issue_template.md" },
]), ]),
], ],
// Fix css // Fix css