Skip to content

Commit f41d72c

Browse files
Merge pull request #109 from solo-io/charlesthebird/apisPageReload
/apis page full reload
2 parents 084bcd6 + 6ff6184 commit f41d72c

File tree

7 files changed

+29
-2
lines changed

7 files changed

+29
-2
lines changed

Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ ENV VITE_PORTAL_SERVER_URL=$VITE_PORTAL_SERVER_URL \
4545
VITE_HOME_IMAGE_URL=$VITE_HOME_IMAGE_URL \
4646
VITE_APIS_IMAGE_URL=$VITE_APIS_IMAGE_URL \
4747
VITE_LOGO_IMAGE_URL=$VITE_LOGO_IMAGE_URL \
48-
VITE_COMPANY_NAME=$VITE_COMPANY_NAME
48+
VITE_COMPANY_NAME=$VITE_COMPANY_NAME \
49+
VITE_API_PAGE_RELOAD=$VITE_API_PAGE_RELOAD
4950

5051
# Copy the server files, (this includes the UI build).
5152
WORKDIR /app
@@ -70,4 +71,5 @@ ENTRYPOINT VITE_PORTAL_SERVER_URL=$VITE_PORTAL_SERVER_URL \
7071
VITE_APIS_IMAGE_URL=$VITE_APIS_IMAGE_URL \
7172
VITE_LOGO_IMAGE_URL=$VITE_LOGO_IMAGE_URL \
7273
VITE_COMPANY_NAME=$VITE_COMPANY_NAME \
74+
VITE_API_PAGE_RELOAD=$VITE_API_PAGE_RELOAD \
7375
node ./bin/www

Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ ifneq ($(VITE_COMPANY_NAME),)
104104
else ifneq ($(COMPANY_NAME),)
105105
UI_ARGS += VITE_COMPANY_NAME=$(COMPANY_NAME)
106106
endif
107+
#
108+
# API_PAGE_RELOAD
109+
ifneq ($(VITE_API_PAGE_RELOAD),)
110+
UI_ARGS += VITE_API_PAGE_RELOAD=$(VITE_API_PAGE_RELOAD)
111+
else ifneq ($(API_PAGE_RELOAD),)
112+
UI_ARGS += VITE_API_PAGE_RELOAD=$(API_PAGE_RELOAD)
113+
endif
107114

108115

109116

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ You can add these environment variables to a `.env.local` file in the `projects/
137137
- `VITE_HOME_IMAGE_URL` - This is an optional parameter to set the image URL on the home page.
138138
- `VITE_APIS_IMAGE_URL` - This is an optional parameter to set the image URL on the apis page.
139139
- `VITE_LOGO_IMAGE_URL` - This is an optional parameter to set the image URL for the logo in the upper left.
140+
- `VITE_API_PAGE_RELOAD` - This is an optional parameter that ensures the API page reloads when navigating to it. This is useful when gating the API page behind an auth flow.
140141

141142
#### Environment Variables for PKCE Authorization Flow
142143

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
changelog:
2+
- type: NEW_FEATURE
3+
description: >-
4+
Adds a new env var for ensuring the API page reloads when navigating to it. This is necessary when using
5+
auth with the portal frontend for gloo v1.17.x installations.

projects/ui/src/Components/Structure/Header.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Link, NavLink, useLocation } from "react-router-dom";
33
import { ReactComponent as Logo } from "../../Assets/logo.svg";
44
import { AppContext } from "../../Context/AppContext";
55
import { AuthContext } from "../../Context/AuthContext";
6-
import { logoImageURL } from "../../user_variables.tmplr";
6+
import {apiPageReload, logoImageURL} from "../../user_variables.tmplr";
77
import { ErrorBoundary } from "../Common/ErrorBoundary";
88
import { HeaderStyles } from "./Header.style";
99
import HeaderSectionLoggedIn from "./HeaderSectionLoggedIn";
@@ -89,6 +89,8 @@ export function Header() {
8989
*/}
9090
<NavLink
9191
to={"/apis"}
92+
// if apiPageReload is true use the onclick to reload the page
93+
onClick={apiPageReload === "true" ? () => (window.location.href = "/apis") : undefined}
9294
className={`navLink ${inAPIsArea ? "active" : ""}`}
9395
>
9496
APIs

projects/ui/src/Components/Structure/OidcAuthCodeHeaderVariant/OidcAuthCodeHeaderVariant.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AppContext } from "../../../Context/AppContext";
55
import { ErrorBoundary } from "../../Common/ErrorBoundary";
66
import { HeaderStyles } from "../Header.style";
77
import { OidcAuthCodeHeaderDropdown } from "./OidcAuthCodeHeaderDropdown";
8+
import {apiPageReload} from "../../../user_variables.tmplr";
89

910
/**
1011
* This is for when there is an
@@ -36,6 +37,7 @@ const OidcAuthCodeHeaderVariant = () => {
3637
</NavLink>
3738
<NavLink
3839
to={"/apis"}
40+
onClick={apiPageReload === "true" ? () => (window.location.href = "/apis") : undefined}
3941
className={`navLink ${inAPIsArea ? "active" : ""}`}
4042
>
4143
APIs

projects/ui/src/user_variables.tmplr.ts

+8
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,11 @@ export const logoImageURL = templateString(
168168
import.meta.env.VITE_LOGO_IMAGE_URL,
169169
""
170170
);
171+
172+
export const apiPageReload = templateString(
173+
"{{ tmplr.apiPageReload }}",
174+
insertedEnvironmentVariables?.VITE_API_PAGE_RELOAD,
175+
import.meta.env.VITE_API_PAGE_RELOAD,
176+
"false"
177+
);
178+

0 commit comments

Comments
 (0)