From 80101d66efd1a6081e96f1dd71215284e33f9973 Mon Sep 17 00:00:00 2001 From: Sammy Teillet Date: Tue, 21 Mar 2023 15:03:51 +0100 Subject: [PATCH 1/8] refactor: move components in nav bar folder --- src/App.tsx | 2 +- src/{ => NavBar}/ProxyStatus/HelpButton.component.tsx | 4 ++-- src/{ => NavBar}/ProxyStatus/ProxyStatus.component.tsx | 0 src/{ => NavBar}/ProxyStatus/Pulser.component.tsx | 0 src/{ => NavBar}/ProxyStatus/pulser.css | 0 src/{ => NavBar}/User/LoginOrDisplayUser.tsx | 4 ++-- .../WebhookStoreUrl/WebhookStoreUrl.component.tsx | 0 src/{ => NavBar}/WebhookStoreUrl/WebhookStoreUrl.context.ts | 0 src/TopNav.tsx | 6 +++--- src/WebhookDisplay/WebhookList.component.tsx | 2 +- 10 files changed, 9 insertions(+), 9 deletions(-) rename src/{ => NavBar}/ProxyStatus/HelpButton.component.tsx (93%) rename src/{ => NavBar}/ProxyStatus/ProxyStatus.component.tsx (100%) rename src/{ => NavBar}/ProxyStatus/Pulser.component.tsx (100%) rename src/{ => NavBar}/ProxyStatus/pulser.css (100%) rename src/{ => NavBar}/User/LoginOrDisplayUser.tsx (91%) rename src/{ => NavBar}/WebhookStoreUrl/WebhookStoreUrl.component.tsx (100%) rename src/{ => NavBar}/WebhookStoreUrl/WebhookStoreUrl.context.ts (100%) diff --git a/src/App.tsx b/src/App.tsx index 324989c..6fb791a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -12,7 +12,7 @@ const WebhookList = React.lazy( () => import("./WebhookDisplay/WebhookList.component") ); import { ApolloProvider } from "@apollo/client"; -import { WebhookStoreUrlContext } from "./WebhookStoreUrl/WebhookStoreUrl.context"; +import { WebhookStoreUrlContext } from "./NavBar/WebhookStoreUrl/WebhookStoreUrl.context"; import { createApolloClient } from "./apollo.client"; import { useStateInLocalStorage } from "./use-state-with-local-storage.hook"; import { isValidHttpUrl } from "./utils/is-valid-url"; diff --git a/src/ProxyStatus/HelpButton.component.tsx b/src/NavBar/ProxyStatus/HelpButton.component.tsx similarity index 93% rename from src/ProxyStatus/HelpButton.component.tsx rename to src/NavBar/ProxyStatus/HelpButton.component.tsx index 2ff2d51..512dd68 100644 --- a/src/ProxyStatus/HelpButton.component.tsx +++ b/src/NavBar/ProxyStatus/HelpButton.component.tsx @@ -1,8 +1,8 @@ import React, { useEffect, useRef } from "react"; -import helpIcon from "../animations/help.json"; +import helpIcon from "../../animations/help.json"; import lottie from "lottie-web"; import { Label } from "@pluralsight/ps-design-system-text"; -import "../animations/animation-container.css"; +import "../../animations/animation-container.css"; const animationName = "help"; diff --git a/src/ProxyStatus/ProxyStatus.component.tsx b/src/NavBar/ProxyStatus/ProxyStatus.component.tsx similarity index 100% rename from src/ProxyStatus/ProxyStatus.component.tsx rename to src/NavBar/ProxyStatus/ProxyStatus.component.tsx diff --git a/src/ProxyStatus/Pulser.component.tsx b/src/NavBar/ProxyStatus/Pulser.component.tsx similarity index 100% rename from src/ProxyStatus/Pulser.component.tsx rename to src/NavBar/ProxyStatus/Pulser.component.tsx diff --git a/src/ProxyStatus/pulser.css b/src/NavBar/ProxyStatus/pulser.css similarity index 100% rename from src/ProxyStatus/pulser.css rename to src/NavBar/ProxyStatus/pulser.css diff --git a/src/User/LoginOrDisplayUser.tsx b/src/NavBar/User/LoginOrDisplayUser.tsx similarity index 91% rename from src/User/LoginOrDisplayUser.tsx rename to src/NavBar/User/LoginOrDisplayUser.tsx index d3c7202..7892a2c 100644 --- a/src/User/LoginOrDisplayUser.tsx +++ b/src/NavBar/User/LoginOrDisplayUser.tsx @@ -1,7 +1,7 @@ import React, { useCallback } from "react"; import NavUser from "@pluralsight/ps-design-system-navuser"; -import { decodeJWT } from "../utils/decode-jwt"; -import { ACCESS_TOKEN_KEY, IDENTITY_TOKEN_KEY } from "../local-storage"; +import { decodeJWT } from "../../utils/decode-jwt"; +import { ACCESS_TOKEN_KEY, IDENTITY_TOKEN_KEY } from "../../local-storage"; const getIdentityTokenFromStorageAndCleanUrl = (): string | null => { const storedIdentityToken = localStorage.getItem(IDENTITY_TOKEN_KEY); diff --git a/src/WebhookStoreUrl/WebhookStoreUrl.component.tsx b/src/NavBar/WebhookStoreUrl/WebhookStoreUrl.component.tsx similarity index 100% rename from src/WebhookStoreUrl/WebhookStoreUrl.component.tsx rename to src/NavBar/WebhookStoreUrl/WebhookStoreUrl.component.tsx diff --git a/src/WebhookStoreUrl/WebhookStoreUrl.context.ts b/src/NavBar/WebhookStoreUrl/WebhookStoreUrl.context.ts similarity index 100% rename from src/WebhookStoreUrl/WebhookStoreUrl.context.ts rename to src/NavBar/WebhookStoreUrl/WebhookStoreUrl.context.ts diff --git a/src/TopNav.tsx b/src/TopNav.tsx index 0be9ed5..7de48c1 100644 --- a/src/TopNav.tsx +++ b/src/TopNav.tsx @@ -1,11 +1,11 @@ import NavBar from "@pluralsight/ps-design-system-navbar"; import NavBrand from "@pluralsight/ps-design-system-navbrand"; import React from "react"; -import { WebhookStoreUrlInput } from "./WebhookStoreUrl/WebhookStoreUrl.component"; +import { WebhookStoreUrlInput } from "./NavBar/WebhookStoreUrl/WebhookStoreUrl.component"; import GitHubButton from "react-github-btn"; import NavItem from "@pluralsight/ps-design-system-navitem"; -import { ProxyStatus } from "./ProxyStatus/ProxyStatus.component"; -import { LoginOrDisplayUser } from "./User/LoginOrDisplayUser"; +import { ProxyStatus } from "./NavBar/ProxyStatus/ProxyStatus.component"; +import { LoginOrDisplayUser } from "./NavBar/User/LoginOrDisplayUser"; function SkillsLogo() { return ( diff --git a/src/WebhookDisplay/WebhookList.component.tsx b/src/WebhookDisplay/WebhookList.component.tsx index 6227def..89d5f8b 100644 --- a/src/WebhookDisplay/WebhookList.component.tsx +++ b/src/WebhookDisplay/WebhookList.component.tsx @@ -11,7 +11,7 @@ import { } from "react-table"; import { forwardWebhookToLocalhost } from "../forward-to-localhost"; import posthog from "posthog-js"; -import { WebhookStoreUrlContext } from "../WebhookStoreUrl/WebhookStoreUrl.context"; +import { WebhookStoreUrlContext } from "../NavBar/WebhookStoreUrl/WebhookStoreUrl.context"; import { UpdateQueryFn } from "@apollo/client/core/watchQueryOptions"; const largePayloadCellStyle: React.CSSProperties = { From 739de42031c9a3134c4548c8c36a20e43415cdc3 Mon Sep 17 00:00:00 2001 From: Sammy Teillet Date: Tue, 21 Mar 2023 15:38:41 +0100 Subject: [PATCH 2/8] feature: add store config button and dialog --- package.json | 2 ++ src/NavBar/StoreConfig/StoreConfigNavItem.tsx | 21 ++++++++++++++++++ src/TopNav.tsx | 2 ++ yarn.lock | 22 +++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 src/NavBar/StoreConfig/StoreConfigNavItem.tsx diff --git a/package.json b/package.json index 55a8b59..28b57f5 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@pluralsight/ps-design-system-button": "^24.1.1", "@pluralsight/ps-design-system-carousel": "^14.1.1", "@pluralsight/ps-design-system-core": "^10.0.4", + "@pluralsight/ps-design-system-dialog": "^15.0.12", "@pluralsight/ps-design-system-dropdown": "^13.1.1", "@pluralsight/ps-design-system-emptystate": "^14.1.1", "@pluralsight/ps-design-system-icon": "^25.4.0", @@ -32,6 +33,7 @@ "@pluralsight/ps-design-system-navitem": "^6.1.1", "@pluralsight/ps-design-system-navuser": "^5.0.16", "@pluralsight/ps-design-system-normalize": "^7.0.4", + "@pluralsight/ps-design-system-position": "^9.1.2", "@pluralsight/ps-design-system-table": "^17.1.1", "@pluralsight/ps-design-system-text": "^20.1.27", "@pluralsight/ps-design-system-textinput": "^12.1.1", diff --git a/src/NavBar/StoreConfig/StoreConfigNavItem.tsx b/src/NavBar/StoreConfig/StoreConfigNavItem.tsx new file mode 100644 index 0000000..fe52faa --- /dev/null +++ b/src/NavBar/StoreConfig/StoreConfigNavItem.tsx @@ -0,0 +1,21 @@ +import { Label } from "@pluralsight/ps-design-system-text"; +import { Below } from "@pluralsight/ps-design-system-position"; +import Dialog from "@pluralsight/ps-design-system-dialog"; + +import React, { useState } from "react"; +import Button from "@pluralsight/ps-design-system-button"; + +export const StoreConfigNavItem = () => { + const [isClicked, setClicked] = useState(false); + + return ( + Store Config} when={isClicked}> + + + ); +}; diff --git a/src/TopNav.tsx b/src/TopNav.tsx index 7de48c1..ab07548 100644 --- a/src/TopNav.tsx +++ b/src/TopNav.tsx @@ -6,6 +6,7 @@ import GitHubButton from "react-github-btn"; import NavItem from "@pluralsight/ps-design-system-navitem"; import { ProxyStatus } from "./NavBar/ProxyStatus/ProxyStatus.component"; import { LoginOrDisplayUser } from "./NavBar/User/LoginOrDisplayUser"; +import { StoreConfigNavItem } from "./NavBar/StoreConfig/StoreConfigNavItem"; function SkillsLogo() { return ( @@ -73,6 +74,7 @@ export default function TopNav() { , , + , ]} utility={ diff --git a/yarn.lock b/yarn.lock index 37c9543..1b6a7ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1618,6 +1618,15 @@ dependencies: "@pluralsight/ps-design-system-util" "^10.1.3" +"@pluralsight/ps-design-system-dialog@^15.0.12": + version "15.0.12" + resolved "https://registry.yarnpkg.com/@pluralsight/ps-design-system-dialog/-/ps-design-system-dialog-15.0.12.tgz#c4c99e584c253e1d727c279d53ff607891a74d06" + integrity sha512-siAtI4IagHYDii9bYCjVTre856pxHTP6dAQCR7CDTbph7kOUalYHK62ZZSOtl2xJzAqW59ZzeBsCthCp+XjRYQ== + dependencies: + "@pluralsight/ps-design-system-core" "^10.0.4" + "@pluralsight/ps-design-system-focusmanager" "^8.0.10" + "@pluralsight/ps-design-system-util" "^10.1.3" + "@pluralsight/ps-design-system-dropdown@^13.1.1": version "13.1.3" resolved "https://registry.yarnpkg.com/@pluralsight/ps-design-system-dropdown/-/ps-design-system-dropdown-13.1.3.tgz#1a6840f76c353f46039175d5c2baf948aeac357e" @@ -1638,6 +1647,11 @@ "@pluralsight/ps-design-system-core" "^10.0.4" "@pluralsight/ps-design-system-util" "^10.1.3" +"@pluralsight/ps-design-system-focusmanager@^8.0.10": + version "8.0.10" + resolved "https://registry.yarnpkg.com/@pluralsight/ps-design-system-focusmanager/-/ps-design-system-focusmanager-8.0.10.tgz#0cee32013f22857299fe09a0f129099949cc2d09" + integrity sha512-jYikS3wwytE1WK5Th7oLq7NyvE6/W1Kfsg1394lJk7O1VVQne22nXmAWFUukfyp+CxFfxF/V2knmFoIsDhoSHg== + "@pluralsight/ps-design-system-halo@^12.0.8": version "12.0.8" resolved "https://registry.yarnpkg.com/@pluralsight/ps-design-system-halo/-/ps-design-system-halo-12.0.8.tgz#1e6cd43f679e7dd1ede5799546f8ac776941858d" @@ -1732,6 +1746,14 @@ "@pluralsight/ps-design-system-core" "^10.0.4" normalize.css "^8.0.1" +"@pluralsight/ps-design-system-position@^9.1.2": + version "9.1.2" + resolved "https://registry.yarnpkg.com/@pluralsight/ps-design-system-position/-/ps-design-system-position-9.1.2.tgz#4a30e12336cd3adbeb819599f67031bae28c7a96" + integrity sha512-6GuvdDyhTWRvr2lSuztwSbtNuQIvMsHig3+LMXH8q491Rh9QJQub8r53IDQF1ljVJMyDxX+rfwX4CbJtUDom0g== + dependencies: + "@pluralsight/ps-design-system-core" "^10.0.4" + "@pluralsight/ps-design-system-util" "^10.1.3" + "@pluralsight/ps-design-system-screenreaderonly@^5.0.11": version "5.0.11" resolved "https://registry.yarnpkg.com/@pluralsight/ps-design-system-screenreaderonly/-/ps-design-system-screenreaderonly-5.0.11.tgz#b3c06a878b35350e75e8e455eaa072473fd67a48" From dc990080cd0eb2ca1dbdd995491fc2fc20f7d014 Mon Sep 17 00:00:00 2001 From: Sammy Teillet Date: Tue, 21 Mar 2023 17:39:24 +0100 Subject: [PATCH 3/8] feature: show store config in nav bar --- package.json | 1 + src/NavBar/StoreConfig/StoreConfigDialog.tsx | 61 +++++++++++++++++++ src/NavBar/StoreConfig/StoreConfigNavItem.tsx | 12 +++- yarn.lock | 9 +++ 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 src/NavBar/StoreConfig/StoreConfigDialog.tsx diff --git a/package.json b/package.json index 28b57f5..6a54f2d 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@pluralsight/ps-design-system-button": "^24.1.1", "@pluralsight/ps-design-system-carousel": "^14.1.1", "@pluralsight/ps-design-system-core": "^10.0.4", + "@pluralsight/ps-design-system-datawell": "^7.0.11", "@pluralsight/ps-design-system-dialog": "^15.0.12", "@pluralsight/ps-design-system-dropdown": "^13.1.1", "@pluralsight/ps-design-system-emptystate": "^14.1.1", diff --git a/src/NavBar/StoreConfig/StoreConfigDialog.tsx b/src/NavBar/StoreConfig/StoreConfigDialog.tsx new file mode 100644 index 0000000..dac5ab8 --- /dev/null +++ b/src/NavBar/StoreConfig/StoreConfigDialog.tsx @@ -0,0 +1,61 @@ +import DataWell from "@pluralsight/ps-design-system-datawell"; +import Link from "@pluralsight/ps-design-system-link/dist/esm/react"; +import { Heading, List, P } from "@pluralsight/ps-design-system-text"; +import React from "react"; + +export const StoreConfigInnerDialog = () => { + return ( + <> + +

Store Config

+
+
+ + Public ⚠️ + + 100 webhooks + + + https://preprod.yolo.croute + + +
+ + +

Your private webhooks stores

+
+ + + + + + samox.github.webhook.store + + + + + + + lendroit.github-org.webhook.store + + + + + + + openwebhook.github-org.webhook.store + + + + + +

+ + + WebhookStore access documentation + + +

+ + ); +}; diff --git a/src/NavBar/StoreConfig/StoreConfigNavItem.tsx b/src/NavBar/StoreConfig/StoreConfigNavItem.tsx index fe52faa..c1edc25 100644 --- a/src/NavBar/StoreConfig/StoreConfigNavItem.tsx +++ b/src/NavBar/StoreConfig/StoreConfigNavItem.tsx @@ -1,15 +1,23 @@ import { Label } from "@pluralsight/ps-design-system-text"; import { Below } from "@pluralsight/ps-design-system-position"; -import Dialog from "@pluralsight/ps-design-system-dialog"; import React, { useState } from "react"; import Button from "@pluralsight/ps-design-system-button"; +import { StoreConfigInnerDialog } from "./StoreConfigDialog"; +import Dialog from "@pluralsight/ps-design-system-dialog"; export const StoreConfigNavItem = () => { const [isClicked, setClicked] = useState(false); return ( - Store Config} when={isClicked}> + + + + } + when={isClicked} + > ); }; + +const describeAccessFromAuthConfig = ( + authConfig: AuthMetadata, + webhookStoreUrl: string +): { type: "public" | "private"; sublabel: string } => { + if (!authConfig.protected) { + return { type: "public", sublabel: "Anyone with the link" }; + } + + if (authConfig.protectionRule === "github-org") { + return { + type: "private", + sublabel: `Only members of ${authConfig.ghOrg} on GitHub`, + }; + } + + if (authConfig.protectionRule === "hostname webhook.store") { + const webhookStoreDomain = new URL(webhookStoreUrl).hostname; + if (webhookStoreDomain.endsWith(".github.webhook.store")) { + const githubUserName = + webhookStoreDomain.split(".")[webhookStoreDomain.split(".").length - 4]; + return { + type: "private", + sublabel: `Only Github user ${githubUserName}`, + }; + } + if (webhookStoreDomain.endsWith(".github-org.webhook.store")) { + const githubOrgaName = + webhookStoreDomain.split(".")[webhookStoreDomain.split(".").length - 4]; + return { + type: "private", + sublabel: `Only members of ${githubOrgaName} on GitHub`, + }; + } + return { type: "public", sublabel: "Anyone with the link" }; + } + + return { type: "public", sublabel: "Anyone with the link" }; +}; From 0f51bacee04589da3fd0a9c7ee2d9fa157eea8a2 Mon Sep 17 00:00:00 2001 From: Sammy Teillet Date: Tue, 21 Mar 2023 19:17:42 +0100 Subject: [PATCH 8/8] chore: add tsignore in package for build --- patches/use-http+1.0.27.patch | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 patches/use-http+1.0.27.patch diff --git a/patches/use-http+1.0.27.patch b/patches/use-http+1.0.27.patch new file mode 100644 index 0000000..96b8f71 --- /dev/null +++ b/patches/use-http+1.0.27.patch @@ -0,0 +1,10 @@ +diff --git a/node_modules/use-http/dist/cjs/types.d.ts b/node_modules/use-http/dist/cjs/types.d.ts +index e33cb72..37a643e 100644 +--- a/node_modules/use-http/dist/cjs/types.d.ts ++++ b/node_modules/use-http/dist/cjs/types.d.ts +@@ -215,4 +215,5 @@ export declare type NonObjectKeysOf = { + }[keyof T]; + export declare type ObjectValuesOf> = Exclude, object>, never>, Array>; + export declare type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never; ++//@ts-ignore + export declare type Flatten = Pick> & UnionToIntersection>;