mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
## What kind of change does this PR introduce? Studio UI and interaction polish. This is the second PR in the Pipelines review stack and depends on #50251. ## What is the current behaviour? Pipeline rows require a separate view action, cannot be sorted, and present lifecycle, lag, and destination terminology inconsistently. ## What is the new behaviour? Makes rows navigable with link-like mouse and keyboard behaviour, adds Name and Status sorting, reuses cached status queries, and moves row actions into the overflow menu. It also clarifies pipeline terminology, adds Docs and feedback actions, and standardises state, error, lag, and loading presentation with accessible announcements. | Before | After | | --- | --- | | <img width="1280" height="1323" alt="Replication Database ETL BigTable ETL Team Supabase" src="https://github.com/user-attachments/assets/53a62283-0e58-4408-8409-2b87a38af159" /> | <img width="1280" height="1323" alt="Replication Database Agua Basket Supabase" src="https://github.com/user-attachments/assets/ba4de1e0-4a84-43b4-8975-ca05a3056bcf" /> | ## To test 1. Open `/project/<ref>/database/replication`. 2. Sort by Name and Status, then confirm failed and stopped pipelines surface first when Status is ascending. 3. Click a row, use Enter or Space, and modifier-click or middle-click to verify link behaviour. 4. Open the row overflow menu and confirm it does not navigate. 5. Check loading, initial sync, caught up, numeric lag, unavailable lag, and table-error states where available. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added sortable pipeline lists with clearer loading, empty, and error states. - Pipeline rows now support direct navigation, detail viewing, status indicators, lag progress, and table error summaries. - Added initial-sync progress indicators and accessible status announcements. - Added documentation and feedback links. - Improved pipeline version update and enable/disable dialogs. - **Bug Fixes** - Prevented right-clicks from triggering navigation. - Improved unavailable lag and initial-sync handling. - **Style** - Standardized replication terminology and confirmation messaging around pipelines. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
import { useRouter } from 'next/navigation'
|
|
import type { NextRouter } from 'next/router'
|
|
|
|
import { BASE_PATH } from './constants'
|
|
|
|
type Router = NextRouter | ReturnType<typeof useRouter>
|
|
|
|
const MIDDLE_MOUSE_BUTTON = 1
|
|
|
|
/**
|
|
* Creates a navigation handler that supports keyboard, modifier clicks, and middle mouse button.
|
|
*
|
|
* This is a curried function that takes a URL and router, and returns an event handler that:
|
|
* - Handles keyboard navigation (Enter/Space keys)
|
|
* - Opens in new tab on Cmd/Ctrl + click
|
|
* - Opens in new tab on middle mouse button click
|
|
* - Performs normal navigation on regular click
|
|
*
|
|
* @param url - The relative URL to navigate to (e.g., "/project/123/functions/my-function")
|
|
* @param router - Next.js router instance (supports both Pages Router and App Router)
|
|
* @returns Event handler function for onClick, onAuxClick, and onKeyDown
|
|
*
|
|
* @example
|
|
* ```tsx
|
|
* const router = useRouter()
|
|
* const handleNavigation = createNavigationHandler(`/project/${ref}/functions/${slug}`, router)
|
|
*
|
|
* <TableRow
|
|
* onClick={handleNavigation}
|
|
* onAuxClick={handleNavigation}
|
|
* onKeyDown={handleNavigation}
|
|
* tabIndex={0}
|
|
* />
|
|
* ```
|
|
*/
|
|
export const createNavigationHandler = (url: string, router: Router) => {
|
|
return (event: React.MouseEvent | React.KeyboardEvent) => {
|
|
// Handle keyboard events
|
|
if ('key' in event) {
|
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
event.preventDefault()
|
|
|
|
const isModifierKey = event.metaKey || event.ctrlKey
|
|
if (isModifierKey) {
|
|
window.open(`${BASE_PATH}${url}`, '_blank')
|
|
} else {
|
|
router.push(url)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// Handle Cmd/Ctrl + left click (modifier click)
|
|
const isModifierClick =
|
|
'button' in event && event.button === 0 && (event.metaKey || event.ctrlKey)
|
|
if (isModifierClick) {
|
|
event.preventDefault()
|
|
window.open(`${BASE_PATH}${url}`, '_blank')
|
|
return
|
|
}
|
|
|
|
// Handle middle mouse button click
|
|
const isMiddleClick = 'button' in event && event.button === MIDDLE_MOUSE_BUTTON
|
|
if (isMiddleClick) {
|
|
event.preventDefault()
|
|
window.open(`${BASE_PATH}${url}`, '_blank')
|
|
return
|
|
}
|
|
|
|
// Regular left click only. Other aux buttons (e.g. right-click) must not navigate.
|
|
if ('button' in event && event.button !== 0) return
|
|
|
|
router.push(url)
|
|
}
|
|
}
|