From 11b927189bab258a226e251c1bd87504feee51f4 Mon Sep 17 00:00:00 2001
From: Federico Brigante <github@bfred.it>
Date: Thu, 17 Jan 2019 19:57:53 +0700
Subject: Drop Babel in favor of esm and TypeScript (#1726)

To get some meaningful errors during feature development, I thought it'd be useful to use TypeScript on `features.js` only, hoping to keep it contained to that file.

@sindresorhus suggested we just extend it the whole extension and maybe that can be done incrementally, without having to necessarily use types on everything.
---
 source/features/patch-diff-links.tsx | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 source/features/patch-diff-links.tsx

(limited to 'source/features/patch-diff-links.tsx')

diff --git a/source/features/patch-diff-links.tsx b/source/features/patch-diff-links.tsx
new file mode 100644
index 00000000..58bf5947
--- /dev/null
+++ b/source/features/patch-diff-links.tsx
@@ -0,0 +1,29 @@
+import {React} from 'dom-chef/react';
+import select from 'select-dom';
+import features from '../libs/features';
+import {isPRCommit} from '../libs/page-detect';
+
+function init() {
+	let commitUrl = location.pathname.replace(/\/$/, '');
+
+	if (isPRCommit()) {
+		commitUrl = commitUrl.replace(/\/pull\/\d+\/commits/, '/commit');
+	}
+
+	select('.commit-meta > :last-child').append(
+		<span class="sha-block patch-diff-links">
+			<a href={`${commitUrl}.patch`} class="sha">patch</a>
+			{ ' ' /* Workaround for: JSX eats whitespace between elements */ }
+			<a href={`${commitUrl}.diff`} class="sha">diff</a>
+		</span>
+	);
+}
+
+features.add({
+	id: 'patch-diff-links',
+	include: [
+		features.isCommit
+	],
+	load: features.onAjaxedPages,
+	init
+});
-- 
cgit v1.2.3

