From 4cfedbb87f3dadac2c2380018ef176ec41ee3e71 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Wed, 13 May 2020 14:47:27 +1100 Subject: [PATCH] Admin UI: fixed no-access indicators not showing up in list table --- .changeset/popular-mayflies-doubt.md | 5 +++++ packages/app-admin-ui/client/components/ListTable.js | 2 +- packages/app-admin-ui/client/pages/List/index.js | 6 +++--- packages/app-admin-ui/client/providers/List.js | 9 +++++---- 4 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 .changeset/popular-mayflies-doubt.md diff --git a/.changeset/popular-mayflies-doubt.md b/.changeset/popular-mayflies-doubt.md new file mode 100644 index 00000000000..a57ecd942a5 --- /dev/null +++ b/.changeset/popular-mayflies-doubt.md @@ -0,0 +1,5 @@ +--- +'@keystonejs/app-admin-ui': patch +--- + +Fixed no-access indicators not showing up in list table. diff --git a/packages/app-admin-ui/client/components/ListTable.js b/packages/app-admin-ui/client/components/ListTable.js index d4060e59192..8fd1b8ac3a1 100644 --- a/packages/app-admin-ui/client/components/ListTable.js +++ b/packages/app-admin-ui/client/components/ListTable.js @@ -216,7 +216,7 @@ class ListRow extends Component { if (itemErrors[path] instanceof Error && itemErrors[path].name === 'AccessDeniedError') { return ( - + {itemErrors[path].message} ); diff --git a/packages/app-admin-ui/client/pages/List/index.js b/packages/app-admin-ui/client/pages/List/index.js index ade5ecb46d9..2b4d219f476 100644 --- a/packages/app-admin-ui/client/pages/List/index.js +++ b/packages/app-admin-ui/client/pages/List/index.js @@ -240,7 +240,8 @@ export function ListLayout(props) { const ListPage = props => { const { list, - listData: { items, itemCount, queryErrors }, + listData: { items, itemCount }, + queryErrorsParsed, query, } = useList(); @@ -268,7 +269,6 @@ const ListPage = props => { // ------------------------------ // Only show error page if there is no data // (ie; there could be partial data + partial errors) - // Note this is the error returned from Apollo, *not* any that are part of the GQL result. if (query.error && (!query.data || !items || !Object.keys(items).length)) { let message = query.error.message; @@ -306,7 +306,7 @@ const ListPage = props => { items={items} itemCount={itemCount} query={query} - queryErrors={queryErrors} + queryErrors={queryErrorsParsed} /> ); diff --git a/packages/app-admin-ui/client/providers/List.js b/packages/app-admin-ui/client/providers/List.js index 342921a0036..ccdf530caf7 100644 --- a/packages/app-admin-ui/client/providers/List.js +++ b/packages/app-admin-ui/client/providers/List.js @@ -2,6 +2,7 @@ import React, { useContext, createContext, useState, useMemo } from 'react'; import { useQuery } from '@apollo/react-hooks'; import { useListUrlState } from '../pages/List/dataHooks'; +import { deconstructErrorsToDataShape } from '../util'; const ListContext = createContext(); @@ -53,17 +54,17 @@ export const ListProvider = ({ list, children }) => { // Organize the data for easier use. // TODO: consider doing this at the query level with an alias - // TODO: should we use deconstructErrorsToDataShape on the error? - // Need to check all uses of this data before deciding. const { - data: { error, [listQueryName]: items, [listQueryMetaName]: { count } = {} } = {}, + error, + data: { [listQueryName]: items, [listQueryMetaName]: { count } = {} } = {}, } = query; return (