From 498de81147436165f2a174a6f69f4605655b07ad Mon Sep 17 00:00:00 2001 From: Jeremy Danyow Date: Sun, 27 Jan 2019 17:12:24 -0800 Subject: [PATCH] label support (#110) --- src/configuration-component.ts | 25 +++++++++++++++++++++++-- src/github.ts | 5 +++-- src/index.html | 1 + src/page-attributes.ts | 1 + src/utterances.ts | 3 ++- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/configuration-component.ts b/src/configuration-component.ts index 1631baa..bf15c69 100644 --- a/src/configuration-component.ts +++ b/src/configuration-component.ts @@ -2,6 +2,7 @@ export class ConfigurationComponent { public readonly element: HTMLFormElement; private readonly script: HTMLDivElement; private readonly repo: HTMLInputElement; + private readonly label: HTMLInputElement; private readonly theme: HTMLSelectElement; constructor() { @@ -30,8 +31,8 @@ export class ConfigurationComponent { -

Blog Post<->Issue Mapping

-

Choose how Utterances will map blog posts to GitHub issues.

+

Blog Post ↔️ Issue Mapping

+

Choose the mapping between blog posts and GitHub issues.

+

Issue Label

+

+ Choose the label that will be assigned to issues created by Utterances. +

+
+
+
+ +

+ Label names are case sensitive. + The label must exist in your repo- + Utterances cannot attach labels that do not exist. + Emoji are supported in label names.✨💬✨ +

+
+
+

Theme

Choose an Utterances theme that matches your blog. @@ -131,6 +149,8 @@ export class ConfigurationComponent { this.repo = this.element.querySelector('#repo') as HTMLInputElement; + this.label = this.element.querySelector('#label') as HTMLInputElement; + this.theme = this.element.querySelector('#theme') as HTMLSelectElement; const themeStylesheet = document.getElementById('theme-stylesheet') as HTMLLinkElement; @@ -168,6 +188,7 @@ export class ConfigurationComponent { this.script.innerHTML = this.makeConfigScript( this.makeConfigScriptAttribute('repo', this.repo.value === '' ? '[ENTER REPO HERE]' : this.repo.value) + '\n' + mappingAttr + '\n' + + (this.label.value ? this.makeConfigScriptAttribute('label', this.label.value) + '\n' : '') + this.makeConfigScriptAttribute('theme', this.theme.value) + '\n' + this.makeConfigScriptAttribute('crossorigin', 'anonymous')); } diff --git a/src/github.ts b/src/github.ts index 0ad152c..9f65cc3 100644 --- a/src/github.ts +++ b/src/github.ts @@ -188,8 +188,9 @@ export function loadUser(): Promise { }); } -export function createIssue(issueTerm: string, documentUrl: string, title: string, description: string) { - const request = new Request(`${UTTERANCES_API}/repos/${owner}/${repo}/issues`, { +export function createIssue(issueTerm: string, documentUrl: string, title: string, description: string, label: string) { + const url = `${UTTERANCES_API}/repos/${owner}/${repo}/issues${label ? `?label=${encodeURIComponent(label)}` : ''}`; + const request = new Request(url, { method: 'POST', body: JSON.stringify({ title: issueTerm, diff --git a/src/index.html b/src/index.html index 9b2c25d..e5268bf 100644 --- a/src/index.html +++ b/src/index.html @@ -70,6 +70,7 @@