Skip to content

Commit 0c88ada

Browse files
committed
Add github repo info to project tile
1 parent ec3c2d2 commit 0c88ada

12 files changed

+47
-19
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
DROP TABLE IF EXISTS integrations;
1+
DROP TABLE integrations;

app/db/migrations/20240718105113_create_integrations_table.up.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CREATE TABLE IF NOT EXISTS integrations
1+
CREATE TABLE integrations
22
(
33
id SERIAL PRIMARY KEY,
44
created_at TIMESTAMP NOT NULL,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE projects DROP repository;
2+
ALTER TABLE projects DROP repository_url;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE projects ADD repository VARCHAR(1024);
2+
ALTER TABLE projects ADD repository_url VARCHAR(1024);

app/models/project.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ type Project struct {
1313
Name string `gorm:"type:varchar(100);"`
1414
BackendFramework string `gorm:"type:varchar(100);not null"`
1515
FrontendFramework string `gorm:"type:varchar(100);not null"`
16+
Repository *string `gorm:"type:varchar(1024);"`
17+
RepositoryUrl *string `gorm:"type:varchar(1024);"`
1618
Description string `gorm:"type:text"`
1719
OrganisationID uint `gorm:"not null"`
1820
CreatedAt time.Time `gorm:"autoCreateTime"`

app/services/project_service.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func (s *ProjectService) GetAllProjectsOfOrganisation(organisationId int) ([]res
6666
ProjectBackendURL: project.BackendURL,
6767
ProjectFrontendURL: project.FrontendURL,
6868
PullRequestCount: len(projectPullRequestMap[int(project.ID)]),
69+
ProjectRepository: project.Repository,
6970
})
7071
}
7172

@@ -112,6 +113,8 @@ func (s *ProjectService) CreateProjectFromGit(userId uint, orgId uint, requestDa
112113
Url: url,
113114
BackendURL: backend_url,
114115
FrontendURL: frontend_url,
116+
Repository: requestData.Repository,
117+
RepositoryUrl: requestData.RepositoryUrl,
115118
}
116119

117120
organisation, err := s.organisationRepository.GetOrganisationByID(uint(int(project.OrganisationID)))
@@ -132,7 +135,7 @@ func (s *ProjectService) CreateProjectFromGit(userId uint, orgId uint, requestDa
132135
_, err = s.workspaceServiceClient.ImportGitRepository(
133136
&request.ImportGitRepository{
134137
WorkspaceId: hashID,
135-
Repository: *requestData.Repository,
138+
Repository: *requestData.RepositoryUrl,
136139
Username: integrationDetails.GithubUserId,
137140
Password: integrationDetails.AccessToken,
138141
RemoteURL: remoteGitURL,

app/types/request/create_project_request.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ type CreateProjectRequest struct {
66
FrontendFramework string `json:"frontend_framework"`
77
Description string `json:"description"`
88
Repository *string `json:"repository"`
9+
RepositoryUrl *string `json:"repository_url"`
910
}
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package response
22

33
type GetAllProjectsResponse struct {
4-
ProjectId uint `json:"project_id"`
5-
ProjectName string `json:"project_name"`
6-
ProjectDescription string `json:"project_description"`
7-
ProjectFramework string `json:"project_framework"`
8-
ProjectFrontendFramework string `json:"project_frontend_framework"`
9-
ProjectHashID string `json:"project_hash_id"`
10-
ProjectUrl string `json:"project_url"`
11-
ProjectBackendURL string `json:"project_backend_url"`
12-
ProjectFrontendURL string `json:"project_frontend_url"`
13-
PullRequestCount int `json:"pull_request_count"`
4+
ProjectId uint `json:"project_id"`
5+
ProjectName string `json:"project_name"`
6+
ProjectDescription string `json:"project_description"`
7+
ProjectFramework string `json:"project_framework"`
8+
ProjectFrontendFramework string `json:"project_frontend_framework"`
9+
ProjectHashID string `json:"project_hash_id"`
10+
ProjectUrl string `json:"project_url"`
11+
ProjectBackendURL string `json:"project_backend_url"`
12+
ProjectFrontendURL string `json:"project_frontend_url"`
13+
PullRequestCount int `json:"pull_request_count"`
14+
ProjectRepository *string `json:"project_repository"`
1415
}

gui/src/app/projects/page.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,19 @@ export default function Projects() {
7878
</span>
7979
</div>
8080

81+
8182
<div className={'flex flex-row items-center gap-3'}>
83+
{project.project_repository && (
84+
<div className="flex items-center">
85+
<div className="w-3.5 h-3.5 -mt-1 mr-2">
86+
<svg viewBox="0 0 24 24" className="fill-current">
87+
<path
88+
d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/>
89+
</svg>
90+
</div>
91+
<span className="text-[11px] secondary_color font-normal">{project.project_repository.split("/").join(" / ")}</span>
92+
</div>
93+
)}
8294
<CustomTextImage
8395
gap={'gap-1'}
8496
textCSS={'text-[11px] secondary_color font-normal'}

gui/src/components/HomeComponents/CreateOrEditProjectBody.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default function CreateOrEditProjectBody({
7676
const [isExternalGitIntegration, setIsExternalGitIntegration] = useState<boolean>(false);
7777
const [useExternalGit, setUseExternalGit] = useState<boolean>(false);
7878
const [repositories, setRepositories] = useState<any[]>([]);
79-
const [selectedRepository, setSelectedRepository] = useState<string | null>(null);
79+
const [selectedRepository, setSelectedRepository] = useState<{ label: string, value: string } | null>(null);
8080

8181
async function redirectToGithubIntegration() {
8282
setIntegrationLoading(true);
@@ -113,6 +113,10 @@ export default function CreateOrEditProjectBody({
113113
const handleCreateNewProject = async () => {
114114
setIsLoading(true);
115115
const projectErrors = [
116+
{
117+
validation: selectedRepository === null && useExternalGit,
118+
message: 'Please select a github repository to import.',
119+
},
116120
{
117121
validation: handleProjectDuplicationCheck(),
118122
message: 'A project with the name entered already exists.',
@@ -148,7 +152,8 @@ export default function CreateOrEditProjectBody({
148152
framework: selectedBackendFramework,
149153
frontend_framework: selectedFrontendFramework,
150154
description: projectDescription,
151-
repository: useExternalGit ? selectedRepository : undefined,
155+
repository: useExternalGit ? selectedRepository.label : undefined,
156+
repository_url: useExternalGit ? selectedRepository.value : undefined,
152157
};
153158
await toCreateNewProject(newProjectPayload);
154159
}
@@ -351,7 +356,7 @@ export default function CreateOrEditProjectBody({
351356
{(useExternalGit && isExternalGitIntegration) && (
352357
<>
353358
<Select
354-
onChange={(e) => setSelectedRepository(e.value)}
359+
onChange={(e) => setSelectedRepository(e)}
355360
className="text-white" styles={customStyles}
356361
options={repositories}
357362
/>

0 commit comments

Comments
 (0)