File tree 15 files changed +317
-313
lines changed
ApiDetails/gloo-gateway-components
15 files changed +317
-313
lines changed Original file line number Diff line number Diff line change
1
+ changelog :
2
+ - type : FIX
3
+ issueLink : https://github.com/solo-io/gloo-mesh-enterprise/issues/18658
4
+ description : >-
5
+ Adds links for the new teams + apps pages to the OIDC auth header variant.
6
+ This also includes some refactoring of that area.
Original file line number Diff line number Diff line change 1
1
import { Box , Flex , Select } from "@mantine/core" ;
2
- import { useContext , useState } from "react" ;
2
+ import { useState } from "react" ;
3
3
import toast from "react-hot-toast" ;
4
4
import {
5
5
ApiProductSummary ,
6
6
ApiVersion ,
7
7
ApiVersionSchema ,
8
8
} from "../../../Apis/api-types" ;
9
9
import { Icon } from "../../../Assets/Icons" ;
10
- import { AuthContext } from "../../../Context/AuthContext" ;
10
+ import { useIsLoggedIn } from "../../../Context/AuthContext" ;
11
11
import { FormModalStyles } from "../../../Styles/shared/FormModalStyles" ;
12
12
import { useGetImageURL } from "../../../Utility/custom-image-utility" ;
13
13
import {
@@ -34,7 +34,7 @@ const ApiProductDetailsPageHeading = ({
34
34
onSelectedApiVersionChange : ( newVersionId : string | null ) => void ;
35
35
apiVersionSpec : ApiVersionSchema | undefined ;
36
36
} ) => {
37
- const { isLoggedIn } = useContext ( AuthContext ) ;
37
+ const isLoggedIn = useIsLoggedIn ( ) ;
38
38
const [ showSubscribeModal , setShowSubscribeModal ] = useState ( false ) ;
39
39
40
40
const downloadApiSpec = ( ) => {
Original file line number Diff line number Diff line change 1
1
import { Code } from "@mantine/core" ;
2
- import { useContext } from "react" ;
3
2
import { Icon } from "../../Assets/Icons" ;
4
- import { AuthContext } from "../../Context/AuthContext" ;
3
+ import { useIsLoggedIn } from "../../Context/AuthContext" ;
5
4
import { apisImageURL } from "../../user_variables.tmplr" ;
6
5
import { BannerHeading } from "../Common/Banner/BannerHeading" ;
7
6
import { BannerHeadingTitle } from "../Common/Banner/BannerHeadingTitle" ;
@@ -28,7 +27,7 @@ export function EmptyApisPage() {
28
27
}
29
28
30
29
export const EmptyApisPageContent = ( ) => {
31
- const { isLoggedIn } = useContext ( AuthContext ) ;
30
+ const isLoggedIn = useIsLoggedIn ( ) ;
32
31
33
32
if ( ! ! isLoggedIn )
34
33
return < EmptyData > No API Products have been created.</ EmptyData > ;
Original file line number Diff line number Diff line change @@ -2,10 +2,8 @@ import { css } from "@emotion/react";
2
2
import styled from "@emotion/styled" ;
3
3
import { useContext } from "react" ;
4
4
import { AppContext } from "../Context/AppContext" ;
5
- import { appliedOidcAuthCodeConfig } from "../user_variables.tmplr" ;
6
5
import AppContentRoutes from "./AppContentRoutes" ;
7
- import { Header } from "./Structure/BasicAuthVariant/Header" ;
8
- import OidcAuthCodeHeaderVariant from "./Structure/OidcAuthCodeHeaderVariant/OidcAuthCodeHeaderVariant" ;
6
+ import Header from "./Structure/Header" ;
9
7
10
8
export const StyledAppContainer = styled . div (
11
9
( { theme } ) => css `
@@ -32,7 +30,7 @@ function AppContent() {
32
30
*/
33
31
return (
34
32
< StyledAppContainer data-theme = { isDarkMode ? "dark" : "light" } >
35
- { ! ! appliedOidcAuthCodeConfig ? < OidcAuthCodeHeaderVariant /> : < Header /> }
33
+ < Header />
36
34
< AppContentRoutes />
37
35
</ StyledAppContainer >
38
36
) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import styled from "@emotion/styled";
2
2
import { useContext } from "react" ;
3
3
import { Navigate , Route , Routes } from "react-router-dom" ;
4
4
import { AppContext } from "../Context/AppContext" ;
5
- import { AuthContext } from "../Context/AuthContext" ;
5
+ import { useIsLoggedIn } from "../Context/AuthContext" ;
6
6
import {
7
7
customPages ,
8
8
oidcAuthCodeConfigCallbackPath ,
@@ -46,7 +46,7 @@ const MainContentContainer = styled.div`
46
46
* know the area that failed.
47
47
**/
48
48
function AppContentRoutes ( ) {
49
- const { isLoggedIn } = useContext ( AuthContext ) ;
49
+ const isLoggedIn = useIsLoggedIn ( ) ;
50
50
const { portalServerType } = useContext ( AppContext ) ;
51
51
52
52
return (
Original file line number Diff line number Diff line change
1
+ import { useIsLoggedIn } from "../../../Context/AuthContext" ;
2
+ import HeaderSectionLoggedIn from "./HeaderSectionLoggedIn" ;
3
+ import HeaderSectionLoggedOut from "./HeaderSectionLoggedOut" ;
4
+
5
+ if ( ! window . isSecureContext ) {
6
+ // eslint-disable-next-line no-console
7
+ console . error (
8
+ "This page is not being delivered in a secure context (see https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts), " +
9
+ "so login will not work."
10
+ ) ;
11
+ }
12
+
13
+ /**
14
+ * MAIN COMPONENT
15
+ **/
16
+ export function BasicAuthHeaderSection ( ) {
17
+ const isLoggedIn = useIsLoggedIn ( ) ;
18
+
19
+ if ( isLoggedIn ) {
20
+ return < HeaderSectionLoggedIn /> ;
21
+ }
22
+ return < HeaderSectionLoggedOut /> ;
23
+ }
Original file line number Diff line number Diff line change @@ -79,8 +79,8 @@ const HeaderSectionLoggedIn = () => {
79
79
onClick = { ( ) => setOpened ( ! opened ) }
80
80
>
81
81
< div className = "userHolder" >
82
- < Icon . UserProfile className = "userCircle" /> { " " }
83
- { ! ! user ? user . username : " " }
82
+ < Icon . UserProfile className = "userCircle" />
83
+ { ! ! user ? user . username : " NO USER " + JSON . stringify ( user ) }
84
84
< Icon . DownArrow
85
85
className = { `dropdownArrow canRotate ${ opened ? "rotate180" : "" } ` }
86
86
/>
Original file line number Diff line number Diff line change 4
4
AuthContext ,
5
5
LOCAL_STORAGE_AUTH_STATE ,
6
6
LOCAL_STORAGE_AUTH_VERIFIER ,
7
+ useIsLoggedIn ,
7
8
} from "../../../Context/AuthContext" ;
8
9
import { doAccessTokenRequest } from "../../../Utility/accessTokenRequest" ;
9
10
import {
@@ -103,7 +104,8 @@ const AuthFlowStarter = () => {
103
104
} ;
104
105
105
106
const HeaderSectionLoggedOut = ( ) => {
106
- const { onLogin, isLoggedIn } = useContext ( AuthContext ) ;
107
+ const { onLogin } = useContext ( AuthContext ) ;
108
+ const isLoggedIn = useIsLoggedIn ( ) ;
107
109
const [ searchParams ] = useSearchParams ( ) ;
108
110
109
111
//
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments