Skip to content

Commit 4b9e68c

Browse files
committed
Add button to new GH repo overview
1 parent 748887b commit 4b9e68c

File tree

6 files changed

+783
-595
lines changed

6 files changed

+783
-595
lines changed

manifest.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"manifest_version": 2,
3-
"name": "Gitpod - Always ready to code",
3+
"name": "Gitpod - Always ready-to-code",
44
"short_name": "Gitpod",
5-
"version": "1.18",
6-
"description": "Spin up fresh, automated dev environments for each task, in the cloud, in seconds.",
5+
"version": "1.19",
6+
"description": "The developer platform for on-demand cloud development environments. Create software faster and more securely.",
77
"icons": {
88
"16": "icons/gitpod-logo-16.png",
99
"48": "icons/gitpod-logo-48.png",

package.json

+14-12
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"description": "Browser extension (Chrome/Firefox/Edge) for enhancing GitLab, GitHub and Bitbucket with Gitpod buttons",
77
"main": "src/gitpodify.js",
88
"scripts": {
9-
"build": "yarn clean && npx tsc && yarn webpack",
9+
"build": "yarn clean && yarn webpack",
1010
"build:safari": " xcrun safari-web-extension-converter . --app-name Gitpod --bundle-identifier io.gitpod.Gitpod",
11-
"package": "yarn clean:package && zip -rD --exclude='src/*.ts' gitpod.xpi dist/bundles icons src manifest.json",
11+
"package": "yarn build && yarn clean:package && zip -rD gitpod.xpi dist icons src manifest.json",
1212
"clean": "rimraf dist && yarn clean:package",
1313
"clean:package": "rimraf gitpod.xpi",
1414
"webpack": "webpack",
@@ -17,18 +17,20 @@
1717
"dependencies": {
1818
"@types/events": "^3.0.0",
1919
"dom-loaded": "^2.0.0",
20-
"github-injection": "^1.0.1",
20+
"github-injection": "^1.1.0",
2121
"select-dom": "^5.1.0",
22-
"webextension-polyfill": "^0.7.0"
22+
"webextension-polyfill": "^0.10.0"
2323
},
2424
"devDependencies": {
25-
"copy-webpack-plugin": "^7.0.0",
26-
"css-loader": "^5.0.2",
27-
"rimraf": "^3.0.0",
28-
"source-map-loader": "^2.0.1",
29-
"style-loader": "^2.0.0",
30-
"webextension-polyfill-ts": "^0.25.0",
31-
"webpack": "^5.22.0",
32-
"webpack-cli": "^4.5.0"
25+
"copy-webpack-plugin": "^11.0.0",
26+
"css-loader": "^6.8.1",
27+
"rimraf": "^5.0.1",
28+
"source-map-loader": "^4.0.1",
29+
"style-loader": "^3.3.3",
30+
"ts-loader": "^9.4.4",
31+
"typescript": "^5.1.6",
32+
"webextension-polyfill-ts": "^0.26.0",
33+
"webpack": "^5.88.2",
34+
"webpack-cli": "^5.1.4"
3335
}
3436
}

src/injectors/github-injector.ts

+28-12
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export class GitHubInjector extends InjectorBase {
2525
new PullInjector(),
2626
new IssueInjector(),
2727
new FileInjector(),
28-
new EditFileButtonInjector(),
2928
new NavigationInjector(),
3029
new EmptyRepositoryInjector(),
30+
new NewRepositoryOverviewInjector(),
3131
]);
3232
}
3333

@@ -146,7 +146,7 @@ abstract class ButtonInjectorBase implements ButtonInjector {
146146
if (openAsPopup) {
147147
makeOpenInPopup(a);
148148
}
149-
a.className = "btn btn-sm btn-primary";
149+
a.className = "btn btn-sm";
150150

151151
this.adjustButton(a);
152152

@@ -174,7 +174,11 @@ abstract class ButtonInjectorBase implements ButtonInjector {
174174

175175
class PullInjector extends ButtonInjectorBase {
176176
constructor() {
177-
super(".gh-header-actions", "");
177+
super(".gh-header-actions", "flex-md-order-2");
178+
}
179+
180+
protected adjustButton(a: HTMLAnchorElement): void {
181+
a.className = "btn btn-sm btn-primary";
178182
}
179183

180184
isApplicableToCurrentPage(): boolean {
@@ -192,41 +196,53 @@ class IssueInjector extends ButtonInjectorBase {
192196
}
193197
}
194198

195-
class EditFileButtonInjector extends ButtonInjectorBase {
199+
class FileInjector extends ButtonInjectorBase {
196200
constructor() {
197-
super("", "gitpod-file-edit-btn");
201+
super("#StickyHeader > div > div > div:nth-child(2)", "gitpod-file-btn");
202+
}
203+
204+
protected adjustButton(a: HTMLAnchorElement): void {
205+
a.style.marginLeft = "8px";
206+
a.className = "btn btn-primary";
198207
}
199208

200209
isApplicableToCurrentPage(): boolean {
201210
return window.location.pathname.includes("/blob/");
202211
}
203212
}
204213

205-
class FileInjector extends ButtonInjectorBase {
214+
class NavigationInjector extends ButtonInjectorBase {
206215
constructor() {
207-
super(".repository-content > div > div > div", "gitpod-file-btn");
216+
super(".file-navigation", "empty-icon position-relative");
208217
}
209218

210219
protected adjustButton(a: HTMLAnchorElement): void {
211220
a.className = "btn btn-primary";
212221
}
213222

214223
isApplicableToCurrentPage(): boolean {
215-
return window.location.pathname.includes("/blob/");
224+
return !!select.exists(".file-navigation");
216225
}
217226
}
218227

219-
class NavigationInjector extends ButtonInjectorBase {
228+
class NewRepositoryOverviewInjector extends ButtonInjectorBase {
220229
constructor() {
221-
super(".file-navigation", "empty-icon position-relative");
230+
super(".pagehead-actions", "empty-icon position-relative");
222231
}
223232

224233
protected adjustButton(a: HTMLAnchorElement): void {
225-
a.className = "btn btn-primary";
234+
a.className = "btn btn-sm btn-primary";
226235
}
227236

228237
isApplicableToCurrentPage(): boolean {
229-
return !!select.exists(".file-navigation");
238+
return !!select.exists(".pagehead-actions");
239+
}
240+
241+
protected renderButton(url: string, openAsPopup: boolean): HTMLElement {
242+
const button = super.renderButton(url, openAsPopup);
243+
const container = document.createElement('li');
244+
container.appendChild(button);
245+
return container;
230246
}
231247
}
232248

tsconfig.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
"downlevelIteration": true,
1212
"module": "commonjs",
1313
"moduleResolution": "node",
14-
"target": "es5",
14+
"target": "es6",
1515
"jsx": "react",
1616
"lib": [
1717
"es6",
1818
"dom"
1919
],
20-
"sourceMap": false,
21-
"declaration": false,
22-
"declarationMap": false,
20+
"sourceMap": true,
21+
"declaration": true,
22+
"declarationMap": true,
2323
"skipLibCheck": true
2424
},
2525
"include": [

webpack.config.js

+27-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
1-
'use strict';
21
const path = require('path');
2+
const CopyWebpackPlugin = require('copy-webpack-plugin');
33

44
module.exports = {
55
mode: 'production',
66
entry: {
7-
gitpodify: './dist/gitpodify.js',
8-
options: './dist/options/options.js',
9-
background: './dist/background.js'
10-
},
11-
output: {
12-
filename: 'bundles/[name].bundle.js',
13-
path: path.resolve(__dirname, 'dist')
7+
gitpodify: './src/gitpodify.ts',
8+
options: './src/options/options.ts',
9+
background: './src/background.ts'
1410
},
1511
module: {
1612
rules: [
13+
{
14+
test: /\.tsx?$/,
15+
use: [{
16+
loader: 'ts-loader',
17+
options: {
18+
// This will make sure ts-loader compiles in a way that works well with source maps
19+
compilerOptions: {
20+
sourceMap: true,
21+
inlineSourceMap: false,
22+
}
23+
},
24+
}],
25+
exclude: /node_modules/,
26+
},
1727
{
1828
test: /\.css$/,
1929
use: ['style-loader', 'css-loader'],
@@ -23,5 +33,13 @@ module.exports = {
2333
exclude: /node_modules/,
2434
}
2535
]
26-
}
36+
},
37+
resolve: {
38+
extensions: ['.tsx', '.ts', '.js'],
39+
},
40+
output: {
41+
filename: 'bundles/[name].bundle.js',
42+
path: path.resolve(__dirname, 'dist')
43+
},
44+
devtool: 'inline-source-map',
2745
};

0 commit comments

Comments
 (0)