diff --git a/studio/pages/project/[ref]/auth/settings.tsx b/studio/pages/project/[ref]/auth/settings.tsx index 980b24fa4a0..292e6583fa5 100644 --- a/studio/pages/project/[ref]/auth/settings.tsx +++ b/studio/pages/project/[ref]/auth/settings.tsx @@ -198,6 +198,8 @@ const Settings = () => { className="mb-4" label={authConfig.properties.MAILER_AUTOCONFIRM.title} onChange={(value) => { + // If MAILER_AUTOCONFIRM is set to true, it means we are disabling email confirmations. + // "Enable email confirmations" should be toggled off. handleToggle('MAILER_AUTOCONFIRM', !value) }} checked={!model.MAILER_AUTOCONFIRM} @@ -335,10 +337,13 @@ const Settings = () => { { - handleToggle('SMS_AUTOCONFIRM') + onChange={(value) => { + // If SMS_AUTOCONFIRM is set to true, it means we are disabling phone confirmations. + // "Enable phone confirmations" should be toggled off. + handleToggle('SMS_AUTOCONFIRM', !value) }} - checked={model.SMS_AUTOCONFIRM} + // + checked={!model.SMS_AUTOCONFIRM} descriptionText={authConfig.properties.SMS_AUTOCONFIRM.help} /> diff --git a/studio/pages/project/[ref]/settings/logs/[type].tsx b/studio/pages/project/[ref]/settings/logs/[type].tsx index d60a83f83b5..9837bd0917e 100644 --- a/studio/pages/project/[ref]/settings/logs/[type].tsx +++ b/studio/pages/project/[ref]/settings/logs/[type].tsx @@ -3,7 +3,15 @@ import React, { useEffect, useRef, useState } from 'react' import { NextPage } from 'next' import { useRouter } from 'next/router' import { observer } from 'mobx-react-lite' -import { Typography, IconLoader, IconAlertCircle, IconRewind, Button, IconInfo } from '@supabase/ui' +import { + Typography, + IconLoader, + IconAlertCircle, + IconRewind, + Button, + IconInfo, + Card, +} from '@supabase/ui' import { withAuth } from 'hooks' import { get } from 'lib/common/fetch' @@ -72,6 +80,9 @@ export const LogPage: NextPage = () => { if (prevPageData === null) { // reduce interval window limit by using the timestamp of the last log queryParams = genQueryParams(params) + } else if (prevPageData.data.length === 0) { + // no rows returned, indicates that no more data to retrieve and append. + return null } else { const len = prevPageData.data.length const { timestamp: tsLimit }: LogData = prevPageData.data[len - 1] @@ -84,18 +95,16 @@ export const LogPage: NextPage = () => { } const { data = [], + error: swrError, isValidating, mutate, size, setSize, } = useSWRInfinite(getKeyLogs, get, { revalidateOnFocus: false }) - - // const { data, isValidating, mutate } = useSWR(logUrl, get, { revalidateOnFocus: false }) let logData: LogData[] = [] - let error: null | string = null - + let error: null | string = swrError ? swrError.message : null data.forEach((response: Logs) => { - if (response && response.data) { + if (!error && response && response.data) { logData = [...logData, ...response.data] } if (!error && response && response.error) { @@ -220,9 +229,16 @@ export const LogPage: NextPage = () => { )} {error && ( -
- - Sorry! Could not fetch data +
+ +
+ + + Sorry! An error occured when fetching data. + +
+ {error} +
)} diff --git a/studio/tests/pages/projects/logs.test.js b/studio/tests/pages/projects/logs.test.js index c98b3fd856d..2352726b3dd 100644 --- a/studio/tests/pages/projects/logs.test.js +++ b/studio/tests/pages/projects/logs.test.js @@ -42,15 +42,21 @@ LogPage.mockImplementation((props) => { const Page = jest.requireActual('pages/project/[ref]/settings/logs/[type]').LogPage // wrap with SWR to reset the cache each time return ( - new Map() }}> + new Map(), + shouldRetryOnError: false, + }} + > ) }) -import { render, fireEvent, waitFor, screen } from '@testing-library/react' +import { render, fireEvent, waitFor, screen, act } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { getToggleByText } from '../../helpers' +import { wait } from '@testing-library/user-event/dist/utils' beforeEach(() => { // reset mocks between tests @@ -298,3 +304,27 @@ test('load older btn will fetch older logs', async () => { }) await waitFor(() => screen.getByText('second event')) }) + +test('bug: load older btn does not error out when previous page is empty', async () => { + // bugfix for https://sentry.io/organizations/supabase/issues/2903331460/?project=5459134&referrer=slack + get.mockImplementation((url) => { + if (url.includes('count')) { + return {} + } + return { data: [] } + }) + render() + + userEvent.click(screen.getByText('Load older')) + // NOTE: potential race condition, since we are asserting that something DOES NOT EXIST + // wait for 500s to make sure all ui logic is complete + // need to wrap in act because internal react state is changing during this time. + await act(async () => await wait(100)) + + // clicking load older multiple times should not give error + await waitFor(() => { + expect(screen.queryByText(/Sorry/)).toBeNull() + expect(screen.queryByText(/An error occured/)).toBeNull() + expect(screen.queryByText(/undefined/)).toBeNull() + }) +}) diff --git a/web/docs/learn/auth-deep-dive/jwts.md b/web/docs/learn/auth-deep-dive/jwts.md index 228c0418e9d..ae2453ff03b 100644 --- a/web/docs/learn/auth-deep-dive/jwts.md +++ b/web/docs/learn/auth-deep-dive/jwts.md @@ -122,6 +122,7 @@ If we put this token into https://jwt.io, we see it decodes to: ```js { "role": "anon", + "iss": "supabase", "iat": 1614205174, "exp": 1929781174 } diff --git a/web/src/components/JwtGenerator.js b/web/src/components/JwtGenerator.js index 88aafbc930d..aa768cb3374 100644 --- a/web/src/components/JwtGenerator.js +++ b/web/src/components/JwtGenerator.js @@ -9,6 +9,7 @@ const fiveYears = new Date(now.getFullYear() + 5, now.getMonth(), now.getDate()) const anonToken = ` { "role": "anon", + "iss": "supabase", "iat": ${Math.floor(today / 1000)}, "exp": ${Math.floor(fiveYears / 1000)} } @@ -17,6 +18,7 @@ const anonToken = ` const serviceToken = ` { "role": "service_role", + "iss": "supabase", "iat": ${Math.floor(today / 1000)}, "exp": ${Math.floor(fiveYears / 1000)} } diff --git a/www/components/Nav/index.tsx b/www/components/Nav/index.tsx index 661a6bc31e3..2b7984e661d 100644 --- a/www/components/Nav/index.tsx +++ b/www/components/Nav/index.tsx @@ -243,10 +243,16 @@ const Nav = (props: Props) => {
- + + + diff --git a/www/pages/database/Database.tsx b/www/pages/database/Database.tsx index 9a6c75a57df..56c79eb8b18 100644 --- a/www/pages/database/Database.tsx +++ b/www/pages/database/Database.tsx @@ -104,6 +104,7 @@ function Database() { />
, ]} + documentation_url={'/docs/guides/database'} /> diff --git a/www/pages/storage/Storage.tsx b/www/pages/storage/Storage.tsx index 5b78b2a4b8e..10be133d039 100644 --- a/www/pages/storage/Storage.tsx +++ b/www/pages/storage/Storage.tsx @@ -87,6 +87,7 @@ function StoragePage() { /> , ]} + documentation_url={'/docs/guides/storage'} />