refactor(repository): refactor the getRepositoryDetailsView controller
+ 37
- 36
* Rewrite most of the props related thing so they are not duplicated anymore,
  making the code clearer to read and understand.

* Also minor responsive fix on the related view so that the details sidebar does
  not grows outside of its max-width.

app/controllers/repository/getRepositoryDetailsView.ts
@@ -84,56 +84,53 @@ const getRepositoryDetailsView: ReqHandler = async (request, reply) => {
   };
 
   const reqHandler = reply.makeRequestHandler(request, reply);
+  const props = {
+    branches,
+    currentRef,
+    currentUser,
+    cloneUrl,
+    lastCommit,
+    parentOrg,
+    path,
+    readmeFileContent,
+    repo,
+    repoHead: null,
+    repoFiles: [],
+    tags,
+  } as Omit<RepositoryDetailsViewProps, "commonProps">;
 
   try {
-    const repoHead = await repoService.getRepositoryHead(repo, currentRef);
-    const repoFiles = await repoService.getRepositoryFiles(
-      repo,
-      "",
-      currentRef
-    );
-
-    return reqHandler<RepositoryDetailsViewProps>(RepositoryDetailsView.name, {
-      branches,
-      currentRef,
-      currentUser,
-      cloneUrl,
-      lastCommit,
-      parentOrg,
-      path,
-      readmeFileContent,
-      repo,
-      repoHead,
-      repoFiles,
-      tags,
-    });
+    props.repoHead = await repoService.getRepositoryHead(repo, currentRef);
   } catch (err) {
     const error = err as Error;
     if (error.message.includes(`${currentRef} is not a valid object name`)) {
       return reqHandler<RepositoryDetailsViewProps>(
         RepositoryDetailsView.name,
-        {
-          branches,
-          currentRef,
-          currentUser,
-          cloneUrl,
-          parentOrg,
-          path,
-          readmeFileContent,
-          repo,
-          repoHead: null,
-          repoFiles: [],
-          tags,
-        }
+        props
       );
     } else if (
       error.message.includes("Could not find a valid git repository")
     ) {
       return reply.status(404).callNotFound();
     } else {
-      throw err;
+      console.log(`Could not get repo head. Error: ${error.message}`);
     }
   }
+
+  try {
+    props.repoFiles = await repoService.getRepositoryFiles(
+      repo,
+      "",
+      currentRef
+    );
+  } catch (err) {
+    console.log(`Could not get repo files. Error: ${(err as Error).message}`);
+  }
+
+  return reqHandler<RepositoryDetailsViewProps>(
+    RepositoryDetailsView.name,
+    props
+  );
 };
 
 export default getRepositoryDetailsView;

app/views/repository/RepositoryDetailsView.tsx
@@ -164,7 +164,11 @@ const RepositoryDetailsView: ReactView<RepositoryDetailsViewProps> = ({
               </div>
             )}
           </Grid.Col>
-          <Grid.Col flex={0.3} nowrap style={{ minWidth: 320, width: "100%" }}>
+          <Grid.Col
+            flex={0.3}
+            nowrap
+            style={{ minWidth: 320, width: "100%", maxWidth: 380 }}
+          >
             <Card
               style={{ width: "100%" }}
               themeScheme={commonProps.themeScheme}