Add basic bug listing

Lena created

Change summary

api/graphql/schema/repository.graphql          |  6 +++
webui/src/pages/identity/BugList.tsx           | 32 ++++++++++++++++++++
webui/src/pages/identity/GetBugsByUser.graphql | 10 ++++++
webui/src/pages/identity/Identity.tsx          |  5 +++
4 files changed, 52 insertions(+), 1 deletion(-)

Detailed changes

api/graphql/schema/repository.graphql 🔗

@@ -17,6 +17,10 @@ type Repository {
         query: String
     ): BugConnection!
 
+    allBugsDetail(
+        query: String
+    ): [Bug]!
+
     bug(prefix: String!): Bug
 
     """All the identities"""
@@ -47,4 +51,4 @@ type Repository {
         """Returns the last _n_ elements from the list."""
         last: Int
     ): LabelConnection!
-}
+}

webui/src/pages/identity/BugList.tsx 🔗

@@ -0,0 +1,32 @@
+import React from 'react';
+
+import { Link } from '@material-ui/core';
+import CircularProgress from '@material-ui/core/CircularProgress';
+
+import { useGetBugsByUserQuery } from './GetBugsByUser.generated';
+
+type Props = {
+  humanId: string;
+};
+
+function BugList({ humanId }: Props) {
+  const { loading, error, data } = useGetBugsByUserQuery({
+    variables: {
+      query: 'author:' + humanId,
+    },
+  });
+
+  if (loading) return <CircularProgress />;
+  if (error) return <p>Error: {error}</p>;
+  const bugs = data?.repository?.allBugs.nodes;
+
+  console.log(bugs);
+  return (
+    <ol>
+      <li>{bugs ? bugs[0].title : ''}</li>
+      <Link href={'/bug/' + (bugs ? bugs[0].id : '')}>Klick</Link>
+    </ol>
+  );
+}
+
+export default BugList;

webui/src/pages/identity/Identity.tsx 🔗

@@ -14,6 +14,9 @@ import Avatar from '@material-ui/core/Avatar';
 import { makeStyles } from '@material-ui/core/styles';
 
 import { useCurrentIdentityQuery } from '../../components/CurrentIdentity/CurrentIdentity.generated';
+
+import BugList from './BugList';
+
 const useStyles = makeStyles((theme) => ({
   main: {
     maxWidth: 1200,
@@ -59,6 +62,7 @@ const Identity = () => {
   const { data } = useCurrentIdentityQuery();
   const user = data?.repository?.userIdentity;
   console.log(user);
+
   return (
     <main className={classes.main}>
       <div className={classes.container}>
@@ -126,6 +130,7 @@ const Identity = () => {
           </Avatar>
         </div>
       </div>
+      <BugList humanId={user?.humanId ? user?.humanId : ''} />
     </main>
   );
 };