@@ -14,8 +14,16 @@ export function hasLaravelInsightsFeature(organization: Organization) {
14
14
15
15
export function useIsLaravelInsightsAvailable ( ) {
16
16
const organization = useOrganization ( ) ;
17
+ const { projects} = useProjects ( ) ;
18
+ const { selection} = usePageFilters ( ) ;
19
+
20
+ const selectedProjects = getSelectedProjectList ( selection . projects , projects ) ;
21
+
22
+ const isOnlyLaravelSelected = selectedProjects . every (
23
+ project => project . platform === 'php-laravel'
24
+ ) ;
17
25
18
- return hasLaravelInsightsFeature ( organization ) ;
26
+ return hasLaravelInsightsFeature ( organization ) && isOnlyLaravelSelected ;
19
27
}
20
28
21
29
// It started out as a dictionary of project IDs, but as we now want a global toggle we use a special key
@@ -24,20 +32,12 @@ const ALL_PROJECTS_KEY = 'all';
24
32
25
33
export function useIsLaravelInsightsEnabled ( ) {
26
34
const organization = useOrganization ( ) ;
27
- const { projects} = useProjects ( ) ;
28
- const { selection} = usePageFilters ( ) ;
29
35
const user = useUser ( ) ;
30
-
31
- const selectedProjects = getSelectedProjectList ( selection . projects , projects ) ;
32
-
33
- // The new experience is enabled by default for Laravel projects
34
- const defaultValue = Boolean (
35
- selectedProjects . every ( project => project . platform === 'php-laravel' )
36
- ) ;
36
+ const isAvailable = useIsLaravelInsightsAvailable ( ) ;
37
37
38
38
const isEnabled = Boolean (
39
- hasLaravelInsightsFeature ( organization ) &&
40
- ( user . options . prefersSpecializedProjectOverview [ ALL_PROJECTS_KEY ] ?? defaultValue )
39
+ isAvailable &&
40
+ ( user . options . prefersSpecializedProjectOverview [ ALL_PROJECTS_KEY ] ?? true )
41
41
) ;
42
42
43
43
const { mutate : mutateUserOptions } = useMutateUserOptions ( ) ;
0 commit comments