@@ -7,7 +7,7 @@ import { StoreConfigInnerDialog } from "./StoreConfigDialog";
77import Dialog from "@pluralsight/ps-design-system-dialog" ;
88import useFetch from "use-http" ;
99import { WebhookStoreUrlContext } from "../WebhookStoreUrl/WebhookStoreUrl.context" ;
10- import { IDENTITY_TOKEN_KEY } from "../../local-storage" ;
10+ import { ACCESS_TOKEN_KEY , IDENTITY_TOKEN_KEY } from "../../local-storage" ;
1111import { decodeJWT } from "../../utils/decode-jwt" ;
1212
1313export const StoreConfigNavItem = ( ) => {
@@ -16,23 +16,36 @@ export const StoreConfigNavItem = () => {
1616 const [ authConfig , setAuthConfig ] = useState < { protected : boolean } > ( {
1717 protected : false ,
1818 } ) ;
19+ const [ storeConfig , setStoreConfig ] = useState < {
20+ maxNumberOfWebhookPerHost ?: number ;
21+ defaultTarget ?: string [ ] ;
22+ } > ( { } ) ;
1923
2024 const { value : webhookStoreUrl } = useContext ( WebhookStoreUrlContext ) ;
21- const { get, response } = useFetch ( webhookStoreUrl ) ;
25+ const accessToken = localStorage . getItem ( ACCESS_TOKEN_KEY ) ;
26+ const { get, response } = useFetch ( webhookStoreUrl , {
27+ headers : accessToken ? { Authorization : `Bearer ${ accessToken } ` } : { } ,
28+ } ) ;
2229 const idToken = localStorage . getItem ( IDENTITY_TOKEN_KEY ) ;
2330 const identityToken =
2431 idToken &&
2532 decodeJWT < { name : string ; ghOrganisations : string [ ] } , any > ( idToken ) ;
2633
2734 useEffect ( ( ) => {
2835 getAuthConfig ( ) ;
36+ getStoreConfig ( ) ;
2937 } , [ ] ) ;
3038
3139 async function getAuthConfig ( ) {
3240 const initialiseAuthConfig = await get ( "auth-metadata" ) ;
3341 if ( response . ok ) setAuthConfig ( initialiseAuthConfig ) ;
3442 }
3543
44+ async function getStoreConfig ( ) {
45+ const initialiseStoreConfig = await get ( "store-metadata" ) ;
46+ if ( response . ok ) setStoreConfig ( initialiseStoreConfig ) ;
47+ }
48+
3649 const accessConfig = {
3750 type : authConfig . protected ? "private" : "public" ,
3851 sublabel : authConfig . protected ? "Only you" : "Anyone with the link" ,
@@ -54,8 +67,8 @@ export const StoreConfigNavItem = () => {
5467 display : "github.webhook.store" ,
5568 } ,
5669 ] ;
57- const defaultTargets = [ "https://google.com" , "https://google.com" ] ;
58- const storageLimit = 100 ;
70+ const defaultTargets = storeConfig . defaultTarget ;
71+ const storageLimit = storeConfig . maxNumberOfWebhookPerHost ;
5972
6073 return (
6174 < Below
0 commit comments