Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Pull master and resolve conflicts

Joshen Lim9aeba26d54e3
diff --cc studio/components/grid/components/footer/pagination/Pagination.tsx
index 4e9a317db08,1c3ef9f5847..8bc26536eed
--- a/studio/components/grid/components/footer/pagination/Pagination.tsx
+++ b/studio/components/grid/components/footer/pagination/Pagination.tsx
@@@ -1,14 -1,8 +1,9 @@@
- import * as React from 'react';
- import AwesomeDebouncePromise from 'awesome-debounce-promise';
- import {
- Button,
- InputNumber,
- Typography,
- IconArrowRight,
- IconArrowLeft,
- } from '@supabase/ui';
- import { DropdownControl } from '../../common';
- import { useDispatch, useTrackedState } from '../../../store';
+ import { FC, useState, useEffect } from 'react'
+ import AwesomeDebouncePromise from 'awesome-debounce-promise'
+ import { Button, InputNumber, IconArrowRight, IconArrowLeft, IconLoader } from '@supabase/ui'
-import { DropdownControl, showConfirmAlert } from '../../common'
++import { DropdownControl } from '../../common'
+ import { useDispatch, useTrackedState } from '../../../store'
++import { confirmAlert } from 'components/to-be-cleaned/ModalsDeprecated/ConfirmModal'
const updatePage = (payload: number, dispatch: (value: unknown) => void) => {
dispatch({
@@@ -22,34 -16,65 +17,65 @@@ const rowsPerPageOptions =
{ value: 100, label: '100 rows' },
{ value: 500, label: '500 rows' },
{ value: 1000, label: '1000 rows' },
- ];
+ ]
- type PaginationProps = {};
+ type PaginationProps = {}
- const Pagination: React.FC<PaginationProps> = () => {
- const state = useTrackedState();
- const dispatch = useDispatch();
- const [page, setPage] = React.useState(state.page);
- const maxPages = Math.ceil(state.totalRows / state.rowsPerPage);
- const totalPages = state.totalRows > 0 ? maxPages : 1;
+ const Pagination: FC<PaginationProps> = () => {
+ const state = useTrackedState()
+ const dispatch = useDispatch()
+ const [page, setPage] = useState(state.page)
+ const maxPages = Math.ceil(state.totalRows / state.rowsPerPage)
+ const totalPages = state.totalRows > 0 ? maxPages : 1
- React.useEffect(() => {
- if (state.page != page) setPage(state.page);
- }, [state.page, page]);
+ useEffect(() => {
+ if (state.page != page) setPage(state.page)
+ }, [state.page, page])
- function onPreviousPage() {
+ // [Joshen] Oddly without this, state.selectedRows will be stale
+ useEffect(() => {}, [state.selectedRows])
+
+ // [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 want
+
+ const onPreviousPage = () => {
if (state.page > 1) {
- const previousPage = state.page - 1;
- setPage(previousPage);
- dispatch({ type: 'SET_PAGE', payload: previousPage });
+ if (state.selectedRows.size >= 1) {
- showConfirmAlert({
++ confirmAlert({
+ title: 'Confirm moving to previous page',
+ message: 'The currently selected lines will be deselected, do you want to proceed?',
+ onConfirm: () => {
+ goToPreviousPage()
+ dispatch({
+ type: 'SELECTED_ROWS_CHANGE',
+ payload: { selectedRows: new Set() },
+ })
+ },
+ })
+ } else {
+ goToPreviousPage()
+ }
}
}
- function onNextPage() {
+ const onNextPage = () => {
if (state.page < maxPages) {
- const nextPage = state.page + 1;
- setPage(nextPage);
- dispatch({ type: 'SET_PAGE', payload: nextPage });
+ if (state.selectedRows.size >= 1) {
- showConfirmAlert({
++ confirmAlert({
+ title: 'Confirm moving to next page',
+ message: 'The currently selected lines will be deselected, do you want to proceed?',
+ onConfirm: () => {
+ goToNextPage()
+ dispatch({
+ type: 'SELECTED_ROWS_CHANGE',
+ payload: { selectedRows: new Set() },
+ })
+ },
+ })
+ } else {
+ goToNextPage()
+ }
}
}
diff --cc studio/package-lock.json
index 082c18de554,5a72584b7e0..d912c0e883e
--- a/studio/package-lock.json
+++ b/studio/package-lock.json
@@@ -20,9 -20,9 +20,9 @@@
"@stripe/stripe-js": "^1.25.0",
"@supabase/postgres-meta": "^0.26.1",
"@supabase/react-data-grid": "^7.1.0-beta.7",
- "@supabase/shared-types": "^0.1.21",
+ "@supabase/shared-types": "^0.1.24",
"@supabase/supabase-js": "^1.35.3",
- "@supabase/ui": "0.37.0-alpha.58",
+ "@supabase/ui": "0.37.0-alpha.65",
"ajv": "^8.6.3",
"analytics-node": "^3.5.0",
"awesome-debounce-promise": "^2.1.0",
diff --cc studio/package.json
index ac526f87f83,53f50d4ebea..74955c82559
--- a/studio/package.json
+++ b/studio/package.json
@@@ -24,9 -24,9 +24,9 @@@
"@stripe/stripe-js": "^1.25.0",
"@supabase/postgres-meta": "^0.26.1",
"@supabase/react-data-grid": "^7.1.0-beta.7",
- "@supabase/shared-types": "^0.1.21",
+ "@supabase/shared-types": "^0.1.24",
"@supabase/supabase-js": "^1.35.3",
- "@supabase/ui": "0.37.0-alpha.58",
+ "@supabase/ui": "0.37.0-alpha.65",
"ajv": "^8.6.3",
"analytics-node": "^3.5.0",
"awesome-debounce-promise": "^2.1.0",