Ver código fonte

pulling gitrepos from backend

jusrhee 5 anos atrás
pai
commit
a75216c962

+ 10 - 2
dashboard/src/components/image-selector/TagList.tsx

@@ -82,18 +82,26 @@ export default class TagList extends Component<PropsType, StateType> {
 
   render() {
     return (
-      <div>
+<>
         <TagNameAlt>
           <img src={info} /> Select Image Tag
         </TagNameAlt>
+              <StyledTagList>
         {this.renderTagList()}
-      </div>
+      </StyledTagList>
+      </>
     );
   }
 }
 
 TagList.contextType = Context;
 
+const StyledTagList = styled.div`
+  max-height: 175px;
+  position: relative;
+  overflow: auto;
+`;
+
 const TagName = styled.div`
   display: flex;
   width: 100%;

+ 4 - 2
dashboard/src/components/repo-selector/RepoSelector.tsx

@@ -40,8 +40,8 @@ export default class RepoSelector extends Component<PropsType, StateType> {
     let { currentProject, currentCluster } = this.context;
 
     // Get repos
-    api.getRepos('<token>', {
-    }, { id: currentProject.id }, (err: any, res: any) => {
+    api.getGitRepos('<token>', {
+    }, { project_id: currentProject.id }, (err: any, res: any) => {
       if (err) {
         this.setState({ loading: false, error: true });
       } else {
@@ -56,6 +56,8 @@ export default class RepoSelector extends Component<PropsType, StateType> {
       return <LoadingWrapper><Loading /></LoadingWrapper>
     } else if (error || !repos) {
       return <LoadingWrapper>Error loading repos</LoadingWrapper>
+    } else if (repos.length == 0) {
+      return <LoadingWrapper>Hola Senorita</LoadingWrapper>
     }
 
     return repos.map((repo: RepoType, i: number) => {

+ 4 - 4
dashboard/src/main/home/cluster-dashboard/expanded-chart/SettingsSection.tsx

@@ -111,9 +111,9 @@ export default class SettingsSection extends Component<PropsType, StateType> {
       return (
         <>
           <Helper>
-            Specify a container image and tag
+            Specify a container image and tag or
             <Highlight onClick={() => this.setState({ sourceType: 'repo' })}>
-              or link a repo
+              link a repo
             </Highlight>.
           </Helper>
           <ImageSelector
@@ -130,9 +130,9 @@ export default class SettingsSection extends Component<PropsType, StateType> {
     return (
       <>
         <Helper>
-          Select a repo to conenct to
+          Select a repo to connect to. Log in with or
           <Highlight onClick={() => this.setState({ sourceType: 'registry' })}>
-            or link a container registry
+            link an image registry
           </Highlight>.
         </Helper>
         <RepoSelector

+ 25 - 6
dashboard/src/shared/api.tsx

@@ -137,7 +137,9 @@ const getBranches = baseApi<{}, { kind: string, repo: string }>('GET', pathParam
   return `/api/repos/${pathParams.kind}/${pathParams.repo}/branches`;
 });
 
-const getBranchContents = baseApi<{ dir: string }, {
+const getBranchContents = baseApi<{ 
+  dir: string 
+}, {
   kind: string,
   repo: string,
   branch: string
@@ -215,24 +217,41 @@ const createECR = baseApi<{
   return `/api/projects/${pathParams.id}/registries`;
 });
 
-const getImageRepos = baseApi<{}, {   
-  project_id: number,
-  registry_id: number,
+const getImageRepos = baseApi<{
+}, {
+  project_id: number, 
+  registry_id: number 
 }>('GET', pathParams => {
   return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories`;
 });
 
-const getImageTags = baseApi<{}, {   
+const getImageTags = baseApi<{
+}, {   
   project_id: number,
   registry_id: number,
   repo_name: string,
- }>('GET', pathParams => {
+}>('GET', pathParams => {
   return `/api/projects/${pathParams.project_id}/registries/${pathParams.registry_id}/repositories/${pathParams.repo_name}`;
 });
 
+const linkGithubProject = baseApi<{
+}, {
+  project_id: number,
+}>('GET', pathParams => {
+  return `/api/oauth/projects/${pathParams.project_id}/github`;
+});
+
+const getGitRepos = baseApi<{  
+}, {
+  project_id: number,
+}>('GET', pathParams => {
+  return `/api/projects/${pathParams.project_id}/gitrepos`;
+});
 
 // Bundle export to allow default api import (api.<method> is more readable)
 export default {
+  linkGithubProject,
+  getGitRepos,
   checkAuth,
   registerUser,
   logInUser,

+ 14 - 14
server/router/router.go

@@ -132,21 +132,21 @@ func New(a *api.App) *chi.Mux {
 		)
 
 		// /api/oauth routes
-		// r.Method(
-		// 	"GET",
-		// 	"/oauth/projects/{project_id}/github",
-		// 	auth.DoesUserHaveProjectAccess(
-		// 		requestlog.NewHandler(a.HandleGithubOAuthStartProject, l),
-		// 		mw.URLParam,
-		// 		mw.WriteAccess,
-		// 	),
-		// )
+		r.Method(
+			"GET",
+			"/oauth/projects/{project_id}/github",
+			auth.DoesUserHaveProjectAccess(
+				requestlog.NewHandler(a.HandleGithubOAuthStartProject, l),
+				mw.URLParam,
+				mw.WriteAccess,
+			),
+		)
 
-		// r.Method(
-		// 	"GET",
-		// 	"/oauth/github/callback",
-		// 	requestlog.NewHandler(a.HandleGithubOAuthCallback, l),
-		// )
+		r.Method(
+			"GET",
+			"/oauth/github/callback",
+			requestlog.NewHandler(a.HandleGithubOAuthCallback, l),
+		)
 
 		// /api/projects routes
 		r.Method(