@@ -21,7 +21,6 @@ import { includesPredicate } from '$/utils/data/array'
2121import { useQuery , useQueryClient } from '@tanstack/react-query'
2222import * as React from 'react'
2323import {
24- ALL_SETTINGS_TABS ,
2524 SETTINGS_DATA ,
2625 SETTINGS_NO_RESULTS_SECTION_DATA ,
2726 SETTINGS_TAB_DATA ,
@@ -42,14 +41,18 @@ export function Settings() {
4241 SettingsTabType . account ,
4342 includesPredicate ( Object . values ( SettingsTabType ) ) ,
4443 )
45- const { user, accessToken } = useFullUserSession ( )
44+ const session = useFullUserSession ( )
45+ const { user, accessToken } = session
46+ const isCloudDataUnavailable = session . isCloudDataUnavailable ?? false
4647 const { changePassword } = useSession ( )
4748 const { getText } = useText ( )
4849 const toastAndLog = useToastAndLog ( )
4950 const [ query , setQuery ] = React . useState ( '' )
5051 const root = usePortalContext ( )
5152 const { data : organization = null } = useQuery (
52- backendQueryOptions ( backend , 'getOrganization' , [ ] ) ,
53+ backendQueryOptions ( backend , 'getOrganization' , [ ] , {
54+ enabled : ! isCloudDataUnavailable ,
55+ } ) ,
5356 )
5457 const isQueryBlank = ! / \S / . test ( query )
5558 const [ preferredTimeZone , setPreferredTimeZone ] = useLocalStorageState ( 'preferredTimeZone' )
@@ -85,6 +88,7 @@ export function Settings() {
8588 changePassword,
8689 preferredTimeZone,
8790 setPreferredTimeZone,
91+ isCloudDataUnavailable,
8892 } ) ,
8993 [
9094 accessToken ,
@@ -103,6 +107,7 @@ export function Settings() {
103107 changePassword ,
104108 preferredTimeZone ,
105109 setPreferredTimeZone ,
110+ isCloudDataUnavailable ,
106111 ] ,
107112 )
108113
@@ -129,11 +134,16 @@ export function Settings() {
129134 )
130135
131136 const tabsToShow = React . useMemo < readonly SettingsTabType [ ] > ( ( ) => {
137+ const matchesVisibility = ( tabData : SettingsTabData ) =>
138+ tabData . visible == null || tabData . visible ( context )
132139 if ( isQueryBlank ) {
133- return ALL_SETTINGS_TABS
140+ return SETTINGS_DATA . flatMap ( ( tabSection ) =>
141+ tabSection . tabs . filter ( matchesVisibility ) . map ( ( tabData ) => tabData . settingsTab ) ,
142+ )
134143 } else {
135144 return SETTINGS_DATA . flatMap ( ( tabSection ) =>
136145 tabSection . tabs
146+ . filter ( matchesVisibility )
137147 . filter ( ( tabData ) =>
138148 isMatch ( getText ( tabData . nameId ) ) || isMatch ( getText ( tabSection . nameId ) ) ?
139149 true
@@ -144,7 +154,7 @@ export function Settings() {
144154 . map ( ( tabData ) => tabData . settingsTab ) ,
145155 )
146156 }
147- } , [ isQueryBlank , doesEntryMatchQuery , getText , isMatch ] )
157+ } , [ isQueryBlank , doesEntryMatchQuery , getText , isMatch , context ] )
148158 const effectiveTab = tabsToShow . includes ( tab ) ? tab : ( tabsToShow [ 0 ] ?? SettingsTabType . account )
149159
150160 const data = React . useMemo < SettingsTabData > ( ( ) => {
0 commit comments