Skip to content

Commit 382f155

Browse files
authored
Merge pull request #219 from OpenWebhook/hide-store-url
Hide store url
2 parents 91a6044 + 1d21bed commit 382f155

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

src/NavBar/WebhookStoreUrl/WebhookStoreUrl.component.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { Label } from "@pluralsight/ps-design-system-text";
22
import TextInput from "@pluralsight/ps-design-system-textinput";
33
import React, { useContext } from "react";
44
import { WebhookStoreUrlContext } from "./WebhookStoreUrl.context";
5+
import NavItem from "@pluralsight/ps-design-system-navitem";
56

67
export function WebhookStoreUrlInput() {
78
const { value, setValue } = useContext(WebhookStoreUrlContext);
89
return (
9-
<>
10+
<NavItem key={"WebhookStoreUrlInput"}>
1011
<Label
1112
size={Label.sizes.xSmall}
1213
style={{ marginRight: "8px", marginLeft: "8px" }}
@@ -22,6 +23,6 @@ export function WebhookStoreUrlInput() {
2223
setValue(new URL(event.target.value).origin);
2324
}}
2425
></TextInput>
25-
</>
26+
</NavItem>
2627
);
2728
}

src/TopNav.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import NavItem from "@pluralsight/ps-design-system-navitem";
77
import { ProxyStatus } from "./NavBar/ProxyStatus/ProxyStatus.component";
88
import { LoginOrDisplayUser } from "./NavBar/User/LoginOrDisplayUser";
99
import { StoreConfigNavItem } from "./NavBar/StoreConfig/StoreConfigNavItem";
10+
import { ENVIRONMENT_KEY } from "./local-storage";
1011

1112
function SkillsLogo() {
1213
return (
@@ -66,13 +67,12 @@ function SkillsBranding(props: any) {
6667
}
6768

6869
export default function TopNav() {
70+
const isDevEnv = localStorage.getItem(ENVIRONMENT_KEY) === "development";
6971
return (
7072
<NavBar
7173
brand={<SkillsBranding />}
7274
items={[
73-
<NavItem key={"WebhookStoreUrlInput"}>
74-
<WebhookStoreUrlInput />
75-
</NavItem>,
75+
isDevEnv ? <WebhookStoreUrlInput key={"WebhookStoreUrlInput"} /> : null,
7676
<ProxyStatus key={"ProxyStatus"} />,
7777
<StoreConfigNavItem key={"StoreConfig"} />,
7878
]}

src/local-storage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export const IDENTITY_TOKEN_KEY = "identityToken";
22
export const ACCESS_TOKEN_KEY = "accessToken";
3+
export const ENVIRONMENT_KEY = "environment";

src/main.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import App from "./App";
55
import Honeybadger from "@honeybadger-io/js";
66
import { HoneybadgerErrorBoundary } from "@honeybadger-io/react";
77
import posthog from "posthog-js";
8+
import { ENVIRONMENT_KEY } from "./local-storage";
89

910
const autoRedirectOnGithubAuth =
1011
window.location.hostname === "github.webhook.store";
@@ -21,7 +22,18 @@ posthog.init(import.meta.env.VITE_POSTHOG_API_KEY as string, {
2122
api_host: "https://app.posthog.com",
2223
});
2324

24-
posthog.capture("my event", { property: "value" });
25+
const initEnvInLocalStorage = () => {
26+
const env = localStorage.getItem(ENVIRONMENT_KEY);
27+
if (!env) {
28+
if (window.location.origin.startsWith("http://localhost:")) {
29+
localStorage.setItem(ENVIRONMENT_KEY, "development");
30+
} else {
31+
localStorage.setItem(ENVIRONMENT_KEY, "production");
32+
}
33+
}
34+
};
35+
36+
initEnvInLocalStorage();
2537

2638
const root = ReactDOM.createRoot(
2739
document.getElementById("root") as HTMLElement

0 commit comments

Comments
 (0)