webui: stop using defaultRepository

Quentin Gliech created

Change summary

webui/src/CurrentIdentity.graphql    | 2 +-
webui/src/CurrentIdentity.tsx        | 4 ++--
webui/src/bug/BugQuery.graphql       | 2 +-
webui/src/bug/BugQuery.tsx           | 4 ++--
webui/src/bug/TimelineQuery.graphql  | 2 +-
webui/src/bug/TimelineQuery.js       | 5 +----
webui/src/list/FilterToolbar.graphql | 2 +-
webui/src/list/FilterToolbar.tsx     | 4 ++--
webui/src/list/ListQuery.graphql     | 2 +-
webui/src/list/ListQuery.tsx         | 8 ++++----
10 files changed, 16 insertions(+), 19 deletions(-)

Detailed changes

webui/src/CurrentIdentity.tsx 🔗

@@ -14,9 +14,9 @@ const CurrentIdentity = () => {
   const classes = useStyles();
   const { loading, error, data } = useCurrentIdentityQuery();
 
-  if (error || loading || !data?.defaultRepository?.userIdentity) return null;
+  if (error || loading || !data?.repository?.userIdentity) return null;
 
-  const user = data.defaultRepository.userIdentity;
+  const user = data.repository.userIdentity;
   return (
     <>
       <Avatar src={user.avatarUrl ? user.avatarUrl : undefined}>

webui/src/bug/BugQuery.graphql 🔗

@@ -1,7 +1,7 @@
 #import "./Bug.graphql"
 
 query GetBug($id: String!) {
-  defaultRepository {
+  repository {
     bug(prefix: $id) {
       ...Bug
     }

webui/src/bug/BugQuery.tsx 🔗

@@ -15,8 +15,8 @@ const BugQuery: React.FC<Props> = ({ match }: Props) => {
   });
   if (loading) return <CircularProgress />;
   if (error) return <p>Error: {error}</p>;
-  if (!data?.defaultRepository?.bug) return <p>404.</p>;
-  return <Bug bug={data.defaultRepository.bug} />;
+  if (!data?.repository?.bug) return <p>404.</p>;
+  return <Bug bug={data.repository.bug} />;
 };
 
 export default BugQuery;

webui/src/bug/TimelineQuery.graphql 🔗

@@ -5,7 +5,7 @@
 #import "./SetStatusFragment.graphql"
 
 query Timeline($id: String!, $first: Int = 10, $after: String) {
-  defaultRepository {
+  repository {
     bug(prefix: $id) {
       timeline(first: $first, after: $after) {
         nodes {

webui/src/bug/TimelineQuery.js 🔗

@@ -15,10 +15,7 @@ const TimelineQuery = ({ id }) => {
   if (loading) return <CircularProgress />;
   if (error) return <p>Error: {error}</p>;
   return (
-    <Timeline
-      ops={data.defaultRepository.bug.timeline.nodes}
-      fetchMore={fetchMore}
-    />
+    <Timeline ops={data.repository.bug.timeline.nodes} fetchMore={fetchMore} />
   );
 };
 

webui/src/list/FilterToolbar.tsx 🔗

@@ -41,9 +41,9 @@ function CountingFilter({ query, children, ...props }: CountingFilterProps) {
 
   var prefix;
   if (loading) prefix = '...';
-  else if (error || !data?.defaultRepository) prefix = '???';
+  else if (error || !data?.repository) prefix = '???';
   // TODO: better prefixes & error handling
-  else prefix = data.defaultRepository.bugs.totalCount;
+  else prefix = data.repository.bugs.totalCount;
 
   return (
     <Filter {...props}>

webui/src/list/ListQuery.graphql 🔗

@@ -7,7 +7,7 @@ query ListBugs(
   $before: String
   $query: String
 ) {
-  defaultRepository {
+  repository {
     bugs: allBugs(
       first: $first
       last: $last

webui/src/list/ListQuery.tsx 🔗

@@ -203,8 +203,8 @@ function ListQuery() {
   let nextPage = null;
   let previousPage = null;
   let count = 0;
-  if (!loading && !error && data?.defaultRepository?.bugs) {
-    const bugs = data.defaultRepository.bugs;
+  if (!loading && !error && data?.repository?.bugs) {
+    const bugs = data.repository.bugs;
     count = bugs.totalCount;
     // This computes the URL for the next page
     if (bugs.pageInfo.hasNextPage) {
@@ -250,8 +250,8 @@ function ListQuery() {
     content = <Placeholder count={10} />;
   } else if (error) {
     content = <Error error={error} />;
-  } else if (data?.defaultRepository) {
-    const bugs = data.defaultRepository.bugs;
+  } else if (data?.repository) {
+    const bugs = data.repository.bugs;
 
     if (bugs.totalCount === 0) {
       content = <NoBug />;