The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: resolves pagination issue with deleting all page items
gitstart6a7946976c5f
diff --git a/studio/components/grid/components/footer/pagination/Pagination.tsx b/studio/components/grid/components/footer/pagination/Pagination.tsxindex 85a5713369e..901478dec97 100644--- a/studio/components/grid/components/footer/pagination/Pagination.tsx+++ b/studio/components/grid/components/footer/pagination/Pagination.tsx@@ -4,6 +4,7 @@ import { Button, InputNumber, IconArrowRight, IconArrowLeft, IconLoader } from 'import { DropdownControl } from '../../common'import { useDispatch, useTrackedState } from '../../../store'import { confirmAlert } from 'components/to-be-cleaned/ModalsDeprecated/ConfirmModal'+import { REFRESH_PAGE_AFTER_DELETED_ROWS } from 'components/grid/constants'const updatePage = (payload: number, dispatch: (value: unknown) => void) => {dispatch({@@ -31,6 +32,12 @@ const Pagination: FC<PaginationProps> = () => {// [Joshen] Oddly without this, state.selectedRows will be staleuseEffect(() => {}, [state.selectedRows])+ useEffect(() => {+ if (state.refreshPageFlag === REFRESH_PAGE_AFTER_DELETED_ROWS) {+ setPage(state.page)+ }+ }, [state.page, state.refreshPageFlag])+// [Joshen] Note: I've made pagination buttons disabled while rows are being fetched for now// at least until we can send an abort signal to cancel requests if users are mashing the// pagination buttons to find the data they wantdiff --git a/studio/components/grid/constants.ts b/studio/components/grid/constants.tsindex 336b1c68e31..55e6ffcd32e 100644--- a/studio/components/grid/constants.ts+++ b/studio/components/grid/constants.ts@@ -7,7 +7,7 @@ export const COLUMN_MIN_WIDTH = 100export const STORAGE_KEY_PREFIX = 'supabase_grid'export const REFRESH_PAGE_IMMEDIATELY = -1-export const REFRESH_PAGE_DEBOUNCED = -3+export const REFRESH_PAGE_AFTER_DELETED_ROWS = -3export const TOTAL_ROWS_INITIAL = -1export const TOTAL_ROWS_RESET = -2diff --git a/studio/components/grid/store/reducers/row.ts b/studio/components/grid/store/reducers/row.tsindex 799bf114943..e5f06700bc4 100644--- a/studio/components/grid/store/reducers/row.ts+++ b/studio/components/grid/store/reducers/row.ts@@ -1,6 +1,6 @@import update from 'immutability-helper'import {- REFRESH_PAGE_DEBOUNCED,+ REFRESH_PAGE_AFTER_DELETED_ROWS,REFRESH_PAGE_IMMEDIATELY,TOTAL_ROWS_INITIAL,TOTAL_ROWS_RESET,@@ -143,11 +143,14 @@ const RowReducer = (state: RowInitialState, action: ROW_ACTIONTYPE) => {}case 'REMOVE_ROWS': {const totalRows = state.totalRows - action.payload.rowIdxs.length+ const maxPages = Math.ceil(totalRows / state.rowsPerPage)+return {...state,rows: state.rows.filter((x) => !action.payload.rowIdxs.includes(x.idx)),totalRows: totalRows,- refreshPageFlag: state.totalRows > state.rowsPerPage ? REFRESH_PAGE_DEBOUNCED : 0,+ refreshPageFlag: state.totalRows > state.rowsPerPage ? REFRESH_PAGE_AFTER_DELETED_ROWS : 0,+ page: Math.min(state.page, maxPages),}}case 'REMOVE_ALL_ROWS': {