Skip to content

Commit 8a625d3

Browse files
AlexTugarevsvenefftinge
authored andcommitted
[dashboard] Add Git Providers
1 parent 1bd34c3 commit 8a625d3

File tree

7 files changed

+354
-39
lines changed

7 files changed

+354
-39
lines changed

components/dashboard/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Account = React.lazy(() => import(/* webpackPrefetch: true */ './settings/
1414
const Notifications = React.lazy(() => import(/* webpackPrefetch: true */ './settings/Notifications'));
1515
const Plans = React.lazy(() => import(/* webpackPrefetch: true */ './settings/Plans'));
1616
const EnvironmentVariables = React.lazy(() => import(/* webpackPrefetch: true */ './settings/EnvironmentVariables'));
17-
const GitIntegrations = React.lazy(() => import(/* webpackPrefetch: true */ './settings/GitIntegrations'));
17+
const Integrations = React.lazy(() => import(/* webpackPrefetch: true */ './settings/Integrations'));
1818
const Preferences = React.lazy(() => import(/* webpackPrefetch: true */ './settings/Preferences'));
1919

2020
function Loading() {
@@ -70,10 +70,10 @@ function App() {
7070
<Route path={["/", "/workspaces"]} exact render={
7171
() => <Workspaces />} />
7272
<Route path="/account" exact component={Account} />
73+
<Route path={["/integrations", "/access-control"]} exact component={Integrations} />
7374
<Route path="/notifications" exact component={Notifications} />
7475
<Route path="/plans" exact component={Plans} />
7576
<Route path="/variables" exact component={EnvironmentVariables} />
76-
<Route path="/integrations" exact component={GitIntegrations} />
7777
<Route path="/preferences" exact component={Preferences} />
7878
</React.Fragment>
7979
)}

components/dashboard/src/Login.tsx

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AuthProviderInfo } from "@gitpod/gitpod-protocol";
22
import { useContext, useEffect, useState } from "react";
33
import { UserContext } from "./user-context";
44
import { getGitpodService, gitpodHostUrl, reconnectGitpodService } from "./service/service";
5+
import { iconForAuthProvider, simplifyProviderName } from "./provider-utils";
56

67
export function Login() {
78
const { setUser } = useContext(UserContext);
@@ -92,32 +93,6 @@ export function Login() {
9293
</div>);
9394
}
9495

95-
function iconForAuthProvider(type: string) {
96-
switch (type) {
97-
case "GitHub":
98-
return "/images/github.svg"
99-
case "GitLab":
100-
return "/images/gitlab.svg"
101-
case "BitBucket":
102-
return "/images/bitbucket.svg"
103-
default:
104-
break;
105-
}
106-
}
107-
108-
function simplifyProviderName(host: string) {
109-
switch (host) {
110-
case "github.com":
111-
return "GitHub"
112-
case "gitlab.com":
113-
return "GitLab"
114-
case "bitbucket.org":
115-
return "BitBucket"
116-
default:
117-
return host;
118-
}
119-
}
120-
12196
function getLoginUrl(host: string) {
12297
const returnTo = gitpodHostUrl.with({ pathname: 'login-success' }).toString();
12398
return gitpodHostUrl.withApi({

components/dashboard/src/components/ContextMenu.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ function ContextMenu(props: ContextMenuProps) {
4343
})
4444

4545
const font = "text-gray-600 hover:text-gray-800"
46+
47+
const menuId = String(Math.random());
48+
4649
return (
4750
<div className="relative cursor-pointer">
4851
<div onClick={(e) => {
@@ -53,15 +56,15 @@ function ContextMenu(props: ContextMenuProps) {
5356
</div>
5457
{expanded?
5558
<div className={`mt-2 z-50 ${props.width || 'w-48'} bg-white absolute right-0 flex flex-col border border-gray-200 rounded-lg truncated`}>
56-
{enhancedEntries.map(e => {
59+
{enhancedEntries.map((e, index) => {
5760
const clickable = e.href || e.onClick;
5861
const entry = <div key={e.title} className={`px-4 flex py-3 ${clickable?'hover:bg-gray-200':''} text-sm leading-1 ${e.customFontStyle || font} ${e.separator? ' border-b border-gray-200':''}`} >
5962
<div>{e.title}</div><div className="flex-1"></div>{e.active ? <div className="pl-1 font-semibold">&#x2713;</div>: null}
6063
</div>
6164
if (!clickable) {
6265
return entry;
6366
}
64-
return <a key={e.title} href={e.href} onClick={e.onClick}>
67+
return <a key={`entry-${menuId}-${index}-${e.title}`} href={e.href} onClick={e.onClick}>
6568
{entry}
6669
</a>
6770
})}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
function iconForAuthProvider(type: string) {
3+
switch (type) {
4+
case "GitHub":
5+
return "/images/github.svg"
6+
case "GitLab":
7+
return "/images/gitlab.svg"
8+
case "BitBucket":
9+
return "/images/bitbucket.svg"
10+
default:
11+
break;
12+
}
13+
}
14+
15+
function simplifyProviderName(host: string) {
16+
switch (host) {
17+
case "github.com":
18+
return "GitHub"
19+
case "gitlab.com":
20+
return "GitLab"
21+
case "bitbucket.org":
22+
return "BitBucket"
23+
default:
24+
return host;
25+
}
26+
}
27+
28+
export { iconForAuthProvider, simplifyProviderName }

components/dashboard/src/service/service-mock.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ const gitpodServiceMock = createServiceMock({
4141
"isReadonly": false
4242
}]
4343
},
44+
getOwnAuthProviders: async () => {
45+
return [{
46+
"id": "foobar123",
47+
"ownerId": "1234",
48+
"status": "verified",
49+
"host": "testing.doptig.com/gitlab",
50+
"type": "GitLab",
51+
"oauth": {
52+
"authorizationUrl": "https://testing.doptig.com/gitlab/oauth/authorize",
53+
"tokenUrl": "https://testing.doptig.com/gitlab/oauth/token",
54+
"settingsUrl": "https://testing.doptig.com/gitlab/profile/applications",
55+
"callBackUrl": "https://gitpod-staging.com/auth/testing.doptig.com/gitlab/callback",
56+
"clientId": "clientid-123",
57+
"clientSecret": "redacted"
58+
},
59+
"deleted": false
60+
}]
61+
},
4462
onDidOpenConnection: Event.None,
4563
onDidCloseConnection: Event.None,
4664

components/dashboard/src/settings/GitIntegrations.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)