Files
supabase/apps/studio/components/layouts/TableEditorLayout/TableEditorLayout.tsx
Ali Waseem 6be596ea34 feat: add user preference to enable queue operations (#44366)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

- Remove queue operations from feature preview into settings
- Refactor dashboard settings 
- Resolves DEPR-434

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Dashboard settings panel in Account preferences with toggles for
Inline Editor and Queue Operations; “Dashboard” added to project
Configuration.

* **Removed**
* Old Inline Editor settings UI and the Queue Operations feature-preview
UI removed.

* **Refactor**
* Consolidated dashboard preferences into a single settings surface;
banners and actions now navigate to preferences; account/preferences
layouts and back-navigation behavior adjusted for platform vs
self-hosted.

* **Tests**
* Added tests for settings UI, menu generation, redirects, and
local-storage.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
2026-04-06 13:52:53 +00:00

79 lines
2.5 KiB
TypeScript

import { PermissionAction } from '@supabase/shared-types/out/constants'
import { LOCAL_STORAGE_KEYS, useParams } from 'common'
import { PropsWithChildren, useEffect } from 'react'
import { ProjectLayoutWithAuth } from '../ProjectLayout'
import { SaveQueueActionBar } from '@/components/grid/components/footer/operations/SaveQueueActionBar'
import { useIsQueueOperationsEnabled } from '@/components/interfaces/Account/Preferences/useDashboardSettings'
import { BannerTableEditorQueueOperations } from '@/components/ui/BannerStack/Banners/BannerTableEditorQueueOperations'
import { useBannerStack } from '@/components/ui/BannerStack/BannerStackProvider'
import NoPermission from '@/components/ui/NoPermission'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
export const TableEditorLayout = ({ children }: PropsWithChildren<{}>) => {
const { ref } = useParams()
const { addBanner, dismissBanner } = useBannerStack()
const isTableQueueOperationsEnabled = useIsQueueOperationsEnabled()
const [isTableEditorQueueOperationsBannerDismissed] = useLocalStorageQuery(
LOCAL_STORAGE_KEYS.TABLE_EDITOR_QUEUE_OPERATIONS_BANNER_DISMISSED(ref ?? ''),
false
)
const { can: canReadTables, isSuccess: isPermissionsLoaded } = useAsyncCheckPermissions(
PermissionAction.TENANT_SQL_ADMIN_READ,
'tables'
)
const { can: canWriteTables } = useAsyncCheckPermissions(
PermissionAction.TENANT_SQL_ADMIN_WRITE,
'tables'
)
useEffect(() => {
if (!isPermissionsLoaded) return
if (
canWriteTables &&
!isTableEditorQueueOperationsBannerDismissed &&
!isTableQueueOperationsEnabled
) {
addBanner({
id: 'table-editor-queue-operations-banner',
priority: 2,
isDismissed: false,
content: <BannerTableEditorQueueOperations />,
})
} else {
dismissBanner('table-editor-queue-operations-banner')
}
return () => {
dismissBanner('table-editor-queue-operations-banner')
}
}, [
addBanner,
dismissBanner,
isPermissionsLoaded,
canWriteTables,
isTableEditorQueueOperationsBannerDismissed,
isTableQueueOperationsEnabled,
])
if (isPermissionsLoaded && !canReadTables) {
return (
<ProjectLayoutWithAuth isBlocking={false}>
<NoPermission isFullPage resourceText="view tables from this project" />
</ProjectLayoutWithAuth>
)
}
return (
<>
{children}
<SaveQueueActionBar />
</>
)
}