summaryrefslogtreecommitdiffstats
path: root/frontend/components
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/components')
-rw-r--r--frontend/components/CreateItem.js12
-rw-r--r--frontend/components/PleaseSignIn.js28
2 files changed, 22 insertions, 18 deletions
diff --git a/frontend/components/CreateItem.js b/frontend/components/CreateItem.js
index 49f2f8f..8072905 100644
--- a/frontend/components/CreateItem.js
+++ b/frontend/components/CreateItem.js
@@ -42,21 +42,13 @@ class CreateItem extends Component {
});
};
- // TODO: Problem here - if I refetch page 1, page 2 to infinity are still out of date. I need to refetch all the pages somehow? without @connection
+ // TODO: Problem here - if I refetch page 1, page 2 to infinity are still out of date. I need to refetch all the pages somehow? Or use @connection
render() {
return (
<Mutation
mutation={CREATE_ITEM_MUTATION}
variables={this.state}
- refetchQueries={[
- {
- query: ALL_ITEMS_QUERY,
- variables: {
- skip: 0,
- first: 2,
- },
- },
- ]}
+ refetchQueries={[{ query: ALL_ITEMS_QUERY }]}
>
{(createItem, { loading, error }) => (
<Form
diff --git a/frontend/components/PleaseSignIn.js b/frontend/components/PleaseSignIn.js
index bd96842..1533dbd 100644
--- a/frontend/components/PleaseSignIn.js
+++ b/frontend/components/PleaseSignIn.js
@@ -1,19 +1,31 @@
import { Query } from 'react-apollo';
import { CURRENT_USER_QUERY } from '../queries/index';
import Signin from './Signin';
+import Dump from './Dump';
const PleaseSignIn = props => (
<Query query={CURRENT_USER_QUERY}>
{({ data }) => {
- if (data.me) {
- return props.children;
+ // check if they are signed in
+ if (!data.me) {
+ return (
+ <div>
+ <p>Please sign in before continuing!</p>
+ <Signin />
+ </div>
+ );
}
- return (
- <div>
- <p>Please sign in before continuing!</p>
- <Signin />
- </div>
- );
+ // check if they need permissions
+ if (props.allowedPermissions) {
+ // check if they NO permissions, or they don't meet the requmrenets
+ if (
+ !data.me.permissions ||
+ !props.allowedPermissions.some(permission => data.me.permissions.contains(permission))
+ ) {
+ return <p>Insufficient Permissions to Manage Permissions</p>;
+ }
+ }
+ return props.children;
}}
</Query>
);