mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 21:48:58 +08:00
fix: handle redirect in onboarding (#6324)
This commit is contained in:
parent
2fe75e74cd
commit
860145fb1d
@ -37,6 +37,7 @@ import {
|
|||||||
UPDATE_ORG_PREFERENCES,
|
UPDATE_ORG_PREFERENCES,
|
||||||
} from 'types/actions/app';
|
} from 'types/actions/app';
|
||||||
import AppReducer, { User } from 'types/reducer/app';
|
import AppReducer, { User } from 'types/reducer/app';
|
||||||
|
import { USER_ROLES } from 'types/roles';
|
||||||
import { extractDomain, isCloudUser, isEECloudUser } from 'utils/app';
|
import { extractDomain, isCloudUser, isEECloudUser } from 'utils/app';
|
||||||
|
|
||||||
import PrivateRoute from './Private';
|
import PrivateRoute from './Private';
|
||||||
@ -74,7 +75,7 @@ function App(): JSX.Element {
|
|||||||
const { data: orgPreferences, isLoading: isLoadingOrgPreferences } = useQuery({
|
const { data: orgPreferences, isLoading: isLoadingOrgPreferences } = useQuery({
|
||||||
queryFn: () => getAllOrgPreferences(),
|
queryFn: () => getAllOrgPreferences(),
|
||||||
queryKey: ['getOrgPreferences'],
|
queryKey: ['getOrgPreferences'],
|
||||||
enabled: isLoggedInState,
|
enabled: isLoggedInState && role === USER_ROLES.ADMIN,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -95,6 +96,17 @@ function App(): JSX.Element {
|
|||||||
}
|
}
|
||||||
}, [orgPreferences, dispatch, isLoadingOrgPreferences]);
|
}, [orgPreferences, dispatch, isLoadingOrgPreferences]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isLoggedInState && role !== USER_ROLES.ADMIN) {
|
||||||
|
dispatch({
|
||||||
|
type: UPDATE_IS_FETCHING_ORG_PREFERENCES,
|
||||||
|
payload: {
|
||||||
|
isFetchingOrgPreferences: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [isLoggedInState, role, dispatch]);
|
||||||
|
|
||||||
const featureResponse = useGetFeatureFlag((allFlags) => {
|
const featureResponse = useGetFeatureFlag((allFlags) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: UPDATE_FEATURE_FLAG_RESPONSE,
|
type: UPDATE_FEATURE_FLAG_RESPONSE,
|
||||||
|
@ -25,6 +25,7 @@ import {
|
|||||||
UPDATE_ORG_PREFERENCES,
|
UPDATE_ORG_PREFERENCES,
|
||||||
} from 'types/actions/app';
|
} from 'types/actions/app';
|
||||||
import AppReducer from 'types/reducer/app';
|
import AppReducer from 'types/reducer/app';
|
||||||
|
import { USER_ROLES } from 'types/roles';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AboutSigNozQuestions,
|
AboutSigNozQuestions,
|
||||||
@ -69,7 +70,10 @@ const INITIAL_OPTIMISE_SIGNOZ_DETAILS: OptimiseSignozDetails = {
|
|||||||
|
|
||||||
function OnboardingQuestionaire(): JSX.Element {
|
function OnboardingQuestionaire(): JSX.Element {
|
||||||
const { notifications } = useNotifications();
|
const { notifications } = useNotifications();
|
||||||
const { org } = useSelector<AppState, AppReducer>((state) => state.app);
|
const { org, role, isLoggedIn: isLoggedInState } = useSelector<
|
||||||
|
AppState,
|
||||||
|
AppReducer
|
||||||
|
>((state) => state.app);
|
||||||
const [currentStep, setCurrentStep] = useState<number>(1);
|
const [currentStep, setCurrentStep] = useState<number>(1);
|
||||||
const [orgDetails, setOrgDetails] = useState<OrgDetails>(INITIAL_ORG_DETAILS);
|
const [orgDetails, setOrgDetails] = useState<OrgDetails>(INITIAL_ORG_DETAILS);
|
||||||
const [signozDetails, setSignozDetails] = useState<SignozDetails>(
|
const [signozDetails, setSignozDetails] = useState<SignozDetails>(
|
||||||
@ -103,12 +107,13 @@ function OnboardingQuestionaire(): JSX.Element {
|
|||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryFn: () => getOrgPreference({ preferenceID: 'ORG_ONBOARDING' }),
|
queryFn: () => getOrgPreference({ preferenceID: 'ORG_ONBOARDING' }),
|
||||||
queryKey: ['getOrgPreferences', 'ORG_ONBOARDING'],
|
queryKey: ['getOrgPreferences', 'ORG_ONBOARDING'],
|
||||||
|
enabled: role === USER_ROLES.ADMIN,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: orgPreferences, isLoading: isLoadingOrgPreferences } = useQuery({
|
const { data: orgPreferences, isLoading: isLoadingOrgPreferences } = useQuery({
|
||||||
queryFn: () => getAllOrgPreferences(),
|
queryFn: () => getAllOrgPreferences(),
|
||||||
queryKey: ['getOrgPreferences'],
|
queryKey: ['getOrgPreferences'],
|
||||||
enabled: isOnboardingComplete,
|
enabled: isOnboardingComplete && role === USER_ROLES.ADMIN,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -129,6 +134,17 @@ function OnboardingQuestionaire(): JSX.Element {
|
|||||||
}
|
}
|
||||||
}, [orgPreferences, dispatch, isLoadingOrgPreferences]);
|
}, [orgPreferences, dispatch, isLoadingOrgPreferences]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isLoggedInState && role !== USER_ROLES.ADMIN) {
|
||||||
|
dispatch({
|
||||||
|
type: UPDATE_IS_FETCHING_ORG_PREFERENCES,
|
||||||
|
payload: {
|
||||||
|
isFetchingOrgPreferences: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [isLoggedInState, role, dispatch]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
!isLoadingOnboardingPreference &&
|
!isLoadingOnboardingPreference &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user