From 01e54f21fef84296c08332f4b05a5497d4cd3edf Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 22 Nov 2022 18:08:09 +0100 Subject: [PATCH 01/30] 638: add route for region, restrict route to admins, add region button to dashboard --- administration/src/App.tsx | 9 ++++++++- .../src/components/home/HomeController.tsx | 11 ++++++++--- .../src/components/regions/RegionController.tsx | 13 +++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 administration/src/components/regions/RegionController.tsx diff --git a/administration/src/App.tsx b/administration/src/App.tsx index 012c0d1e3..050c444c0 100644 --- a/administration/src/App.tsx +++ b/administration/src/App.tsx @@ -2,7 +2,7 @@ import React from 'react' import Navigation from './components/Navigation' import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client' import { setContext } from '@apollo/client/link/context' -import { BrowserRouter, Route, Routes } from 'react-router-dom' +import { BrowserRouter, Route, Routes, Navigate } from 'react-router-dom' import GenerationController from './components/generation/GenerationController' import styled from 'styled-components' import RegionProvider from './RegionProvider' @@ -12,6 +12,7 @@ import KeepAliveToken from './KeepAliveToken' import ApplicationsController from './components/applications/ApplicationsController' import { ProjectConfigProvider } from './project-configs/ProjectConfigContext' import HomeController from './components/home/HomeController' +import RegionsController from './components/regions/RegionController' import MetaTagsManager from './components/MetaTagsManager' import { AppToasterProvider } from './components/AppToaster' import UserSettingsController from './components/user-settings/UserSettingsController' @@ -19,6 +20,7 @@ import ResetPasswordController from './components/auth/ResetPasswordController' import ForgotPasswordController from './components/auth/ForgotPasswordController' import ApplyController from './application/components/ApplyController' import { createUploadLink } from 'apollo-upload-client' +import {Role} from "./generated/graphql"; if (!process.env.REACT_APP_API_BASE_URL) { throw new Error('REACT_APP_API_BASE_URL is not set!') @@ -47,6 +49,8 @@ const Main = styled.div` justify-content: center; ` +const isAdmin = (role: Role): boolean => role === Role.ProjectAdmin || role === Role.RegionAdmin + const App = () => ( @@ -75,6 +79,9 @@ const App = () => ( path={'/applications'} element={} /> + : } + /> } /> } /> } /> diff --git a/administration/src/components/home/HomeController.tsx b/administration/src/components/home/HomeController.tsx index 81d6bfbd3..d6a028b24 100644 --- a/administration/src/components/home/HomeController.tsx +++ b/administration/src/components/home/HomeController.tsx @@ -21,9 +21,14 @@ const HomeController = () => { ) : null} {role === Role.ProjectAdmin || role === Role.RegionAdmin ? ( - -