From f74ec8dce5e8cfee68a16cef51be17bfeca2dc01 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Thu, 20 May 2021 17:10:05 +0300 Subject: [PATCH] wrapping homepage content in permission element --- src/components/organisms/Permission.tsx | 10 +++-- src/components/pages/Home.tsx | 59 +++++++++++++------------ src/utils/rbac.ts | 2 +- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/components/organisms/Permission.tsx b/src/components/organisms/Permission.tsx index 751fa1b86..bee2680aa 100644 --- a/src/components/organisms/Permission.tsx +++ b/src/components/organisms/Permission.tsx @@ -1,10 +1,12 @@ -import React, { ReactElement, useEffect, useState } from 'react' +import React, { Children, ReactElement, useEffect, useState } from 'react' import rbacRequest from '../../utils/rbac' export default function Permission({ - eventType + eventType, + children }: { eventType: string + children: ReactElement }): ReactElement { const [data, updateData] = useState() useEffect(() => { @@ -16,8 +18,8 @@ export default function Permission({ }, []) if (data === false) { - return
Sorry you do not have permission to {eventType}
+ return Sorry you do not have permission to {eventType} } else { - return
permission
+ return <>{children} } } diff --git a/src/components/pages/Home.tsx b/src/components/pages/Home.tsx index 9168bfa06..fbb46c91f 100644 --- a/src/components/pages/Home.tsx +++ b/src/components/pages/Home.tsx @@ -95,38 +95,39 @@ function SectionQueryResult({ export default function HomePage(): ReactElement { return ( <> - - - - + + + + -
-

Bookmarks

- -
+
+

Bookmarks

+ +
- - Data sets and algorithms with pool → - - } - /> + + Data sets and algorithms with pool → + + } + /> - - All data sets and algorithms → - - } - /> + + All data sets and algorithms → + + } + /> +
) } diff --git a/src/utils/rbac.ts b/src/utils/rbac.ts index 01ac9a30d..1b9bec3e6 100644 --- a/src/utils/rbac.ts +++ b/src/utils/rbac.ts @@ -12,7 +12,7 @@ export default async function rbacRequest(eventType: string): Promise { eventType, credentials: { token: - 'eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJDWVdQTTJLY1NKUjJtV0o2ZFBqZTVKVmZ5YTZnZXdhVElVZDBab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