File tree Expand file tree Collapse file tree 4 files changed +22
-6
lines changed
app/components/Onboarding Expand file tree Collapse file tree 4 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ import { useState } from 'react';
44import { useFetchInstances } from '../infrastructure/useFetchInstances' ;
55
66export function useOnboardingModal ( ) : DomainHookReturnValue {
7- const { instances } = useFetchInstances ( ) ;
8-
97 const [ settingsUrl , setSettingsUrl ] = useState ( 'https://grafana.com/auth/sign-in/' ) ;
10- const isCloud = / g r a f a n a ( - d e v | - o p s ) ? \. n e t / . test ( window . location . host ) ;
8+
9+ const isCloud = / \. g r a f a n a ( - d e v | - o p s ) ? \. n e t $ / . test ( window . location . host ) ;
10+ const { instances } = useFetchInstances ( isCloud ) ;
1111
1212 if ( instances && instances . orgSlug && instances . hpInstanceId ) {
1313 const newSettingsUrl = `https://grafana.com/orgs/${ instances . orgSlug } /hosted-profiles/${ instances . hpInstanceId } ` ;
Original file line number Diff line number Diff line change 11import { useQuery } from '@tanstack/react-query' ;
2+ import { PLUGIN_API_URL } from 'src/constants' ;
23
3- export function useFetchInstances ( ) {
4+ export function useFetchInstances ( enabled = true ) {
45 const { isFetching, error, data } = useQuery ( {
6+ enabled,
57 queryKey : [ 'instances' ] ,
68 queryFn : ( ) =>
7- fetch ( '/api/plugin-proxy/cloud-home-app/ grafanacom-api/instances' ) . then ( ( response ) => response . json ( ) ) ,
9+ fetch ( ` ${ PLUGIN_API_URL } / grafanacom-api/instances` ) . then ( ( response ) => response . json ( ) ) ,
810 } ) ;
911
1012 return {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import plugin from './plugin.json';
33export const PYROSCOPE_APP_ID = plugin . id ;
44
55export const PLUGIN_BASE_URL = `/a/${ PYROSCOPE_APP_ID } ` ;
6+ export const PLUGIN_API_URL = `/api/plugin-proxy/${ PYROSCOPE_APP_ID } ` ;
67
78export enum ROUTES {
89 EXPLORE = '/explore' ,
Original file line number Diff line number Diff line change 7979 ]
8080 }
8181 ]
82- }
82+ },
83+ "routes" : [
84+ {
85+ "path" : " /grafanacom-api/instances" ,
86+ "method" : " GET" ,
87+ "url" : " {{.SecureJsonData.gcomApiUrl}}/instances/{{.SecureJsonData.stackId}}" ,
88+ "headers" : [
89+ {
90+ "name" : " Authorization" ,
91+ "content" : " Bearer {{.SecureJsonData.gcomApiToken}}"
92+ }
93+ ]
94+ }
95+ ]
8396}
You can’t perform that action at this time.
0 commit comments