Skip to content

Commit

Permalink
Link to user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
laushinka committed Dec 21, 2021
1 parent 81372bc commit ed0450e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion components/dashboard/src/projects/NewProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ export default function NewProject() {

const showSearchInput = !!repoSearchFilter || filteredRepos.length > 0;

const userLink = (r: ProviderRepository) => {
return `https://${new URL(r.cloneUrl).host}/${r.inUse?.userName}`
}

const projectText = () => {
return <p className="text-gray-500 text-center text-base">Projects allow you to manage prebuilds and workspaces for your repository. <a href="https://www.gitpod.io/docs/teams-and-projects" rel="noopener" className="gp-link">Learn more</a></p>
}
Expand Down Expand Up @@ -324,7 +328,7 @@ export default function NewProject() {
<button className="primary" onClick={() => setSelectedRepo(r)}>Select</button>
) : (
<p className="text-gray-500 font-medium">
@{r.inUse.userName} already<br/>added this repo
<a rel="noopener" className="gp-link" href={userLink(r)}>@{r.inUse.userName}</a> already<br/>added this repo
</p>
)}
</div>
Expand Down
10 changes: 8 additions & 2 deletions components/server/ee/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { SnapshotService, WaitForSnapshotOptions } from "./snapshot-service";
import { SafePromise } from "@gitpod/gitpod-protocol/lib/util/safe-promise";
import { ClientMetadata } from "../../../src/websocket/websocket-connection-manager";
import { BitbucketAppSupport } from "../bitbucket/bitbucket-app-support";
import { URL } from 'url';

@injectable()
export class GitpodServerEEImpl extends GitpodServerImpl {
Expand Down Expand Up @@ -1444,12 +1445,17 @@ export class GitpodServerEEImpl extends GitpodServerImpl {

for (const repo of repositories) {
const p = cloneUrlToProject.get(repo.cloneUrl);
const repoProvider = new URL(repo.cloneUrl).host.split(".")[0];

if (p) {
if (p.userId) {
const owner = await this.userDB.findUserById(p.userId);
if (owner) {
repo.inUse = {
userName: owner?.name || owner?.fullName || 'somebody'
const ownerProviderMatchingRepoProvider = owner.identities.find((identity, index) => identity.authProviderId.toLowerCase().includes(repoProvider));
if (ownerProviderMatchingRepoProvider) {
repo.inUse = {
userName: ownerProviderMatchingRepoProvider?.authName
}
}
}
} else if (p.teamOwners && p.teamOwners[0]) {
Expand Down

0 comments on commit ed0450e

Please sign in to comment.