From 9737cc49d5a6ad4c74944e77cb549542185986c0 Mon Sep 17 00:00:00 2001 From: Alan Greene Date: Fri, 9 Sep 2022 11:48:29 +0100 Subject: [PATCH] More preparation for React Router v6 update Composition of `` elements https://gist.github.com/mjackson/d54b40a094277b7afdd6b81f51a0393f#get-started-upgrading-today `` inside `` https://gist.github.com/mjackson/b5748add2795ce7448a366ae8f8ae3bb#get-started-upgrading-today --- src/containers/App/App.js | 44 ++++++++++++------- .../ReadWriteRoute/ReadWriteRoute.js | 19 +++----- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/containers/App/App.js b/src/containers/App/App.js index 574b6e34e..848116a22 100644 --- a/src/containers/App/App.js +++ b/src/containers/App/App.js @@ -80,7 +80,6 @@ import { import { NamespaceContext, useExtensions, - useIsReadOnly, useLogoutURL, useNamespaces, useProperties, @@ -157,7 +156,6 @@ export function App({ lang }) { isFetching: isFetchingProperties, isPlaceholderData: isPropertiesPlaceholder } = useProperties(); - const isReadOnly = useIsReadOnly(); const logoutURL = useLogoutURL(); const tenantNamespace = useTenantNamespace(); @@ -240,18 +238,25 @@ export function App({ lang }) { > - + } + /> - ( + + + + )} /> @@ -274,11 +279,14 @@ export function App({ lang }) { - ( + + + + )} /> @@ -287,11 +295,14 @@ export function App({ lang }) { - ( + + + + )} /> @@ -327,10 +338,13 @@ export function App({ lang }) { - ( + + + + )} /> diff --git a/src/containers/ReadWriteRoute/ReadWriteRoute.js b/src/containers/ReadWriteRoute/ReadWriteRoute.js index 55e4dab69..849b0c912 100644 --- a/src/containers/ReadWriteRoute/ReadWriteRoute.js +++ b/src/containers/ReadWriteRoute/ReadWriteRoute.js @@ -1,5 +1,5 @@ /* -Copyright 2020-2021 The Tekton Authors +Copyright 2020-2022 The Tekton Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -12,20 +12,13 @@ limitations under the License. */ /* istanbul ignore file */ import React from 'react'; -import { Route } from 'react-router-dom'; +import { useIsReadOnly } from '../../api'; import { NotFound } from '..'; -const ReadWriteRoute = ({ - component: Component, - exact, - isReadOnly, - path, - ...rest -}) => ( - - {isReadOnly ? : } - -); +const ReadWriteRoute = ({ children }) => { + const isReadOnly = useIsReadOnly(); + return isReadOnly ? : children; +}; export default ReadWriteRoute;