From bf4e2f3051673b5a6b10b0a195dedac90e34325f Mon Sep 17 00:00:00 2001 From: Isaiah Hamilton Date: Wed, 5 Jan 2022 22:57:21 -0500 Subject: [PATCH 1/9] add doc link to database page --- www/pages/database/Database.tsx | 1 + 1 file changed, 1 insertion(+) 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'} /> From 3706800a4bf6529aa66cde51c054ee3525755163 Mon Sep 17 00:00:00 2001 From: Isaiah Hamilton Date: Wed, 5 Jan 2022 22:57:45 -0500 Subject: [PATCH 2/9] add doc link to storage page --- www/pages/storage/Storage.tsx | 1 + 1 file changed, 1 insertion(+) 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'} /> From aa892da4a4941804b5483399648341044c47a35f Mon Sep 17 00:00:00 2001 From: Mayank Virmani Date: Thu, 6 Jan 2022 13:03:30 +0530 Subject: [PATCH 3/9] www: added log in btn in nav --- www/components/Nav/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/www/components/Nav/index.tsx b/www/components/Nav/index.tsx index 661a6bc31e3..73beb0c93bd 100644 --- a/www/components/Nav/index.tsx +++ b/www/components/Nav/index.tsx @@ -243,10 +243,16 @@ const Nav = (props: Props) => {
- + + + From f42a1480138a71af2462a86d0abc5df3b7e7fd77 Mon Sep 17 00:00:00 2001 From: Mayank Virmani Date: Thu, 6 Jan 2022 13:48:38 +0530 Subject: [PATCH 4/9] www: updated log in to sign in --- www/components/Nav/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/components/Nav/index.tsx b/www/components/Nav/index.tsx index 73beb0c93bd..2b7984e661d 100644 --- a/www/components/Nav/index.tsx +++ b/www/components/Nav/index.tsx @@ -250,8 +250,8 @@ const Nav = (props: Props) => { Star us on GitHub - - + + From 68aca6cd61f1471947eb34de4fd3ac66ce37f394 Mon Sep 17 00:00:00 2001 From: Copple <10214025+kiwicopple@users.noreply.github.com> Date: Thu, 6 Jan 2022 11:59:48 +0100 Subject: [PATCH 5/9] Adds supabase as the issuer for the JWT token --- web/docs/learn/auth-deep-dive/jwts.md | 1 + web/src/components/JwtGenerator.js | 2 ++ 2 files changed, 3 insertions(+) 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)} } From 04c955334313594ae229b9632464ff5e0ec401a8 Mon Sep 17 00:00:00 2001 From: TzeYiing Date: Thu, 6 Jan 2022 19:44:32 +0800 Subject: [PATCH 6/9] bugfix for load older logs empty page bug. --- .../project/[ref]/settings/logs/[type].tsx | 37 ++++++++++++++----- studio/tests/pages/projects/logs.test.js | 34 ++++++++++++++++- 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/studio/pages/project/[ref]/settings/logs/[type].tsx b/studio/pages/project/[ref]/settings/logs/[type].tsx index d60a83f83b5..7bf04bd695c 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,7 +80,11 @@ export const LogPage: NextPage = () => { if (prevPageData === null) { // reduce interval window limit by using the timestamp of the last log queryParams = genQueryParams(params) - } else { + } 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] // create new key from params @@ -84,18 +96,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 +230,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() + }) +}) From be51a51396df26ce2727effef65f12dc4fa6a5c2 Mon Sep 17 00:00:00 2001 From: TzeYiing Date: Thu, 6 Jan 2022 23:07:19 +0800 Subject: [PATCH 7/9] ran prettier --- studio/pages/project/[ref]/settings/logs/[type].tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/studio/pages/project/[ref]/settings/logs/[type].tsx b/studio/pages/project/[ref]/settings/logs/[type].tsx index 7bf04bd695c..9837bd0917e 100644 --- a/studio/pages/project/[ref]/settings/logs/[type].tsx +++ b/studio/pages/project/[ref]/settings/logs/[type].tsx @@ -83,8 +83,7 @@ export const LogPage: NextPage = () => { } else if (prevPageData.data.length === 0) { // no rows returned, indicates that no more data to retrieve and append. return null - }else { - + } else { const len = prevPageData.data.length const { timestamp: tsLimit }: LogData = prevPageData.data[len - 1] // create new key from params From bb1beffe72e4c22ac90fed963f243f34bb1f69d9 Mon Sep 17 00:00:00 2001 From: Kang Ming Date: Fri, 7 Jan 2022 13:14:20 +0800 Subject: [PATCH 8/9] fix: sms autoconfirm toggle issue --- studio/pages/project/[ref]/auth/settings.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/studio/pages/project/[ref]/auth/settings.tsx b/studio/pages/project/[ref]/auth/settings.tsx index 980b24fa4a0..86e904ba4e8 100644 --- a/studio/pages/project/[ref]/auth/settings.tsx +++ b/studio/pages/project/[ref]/auth/settings.tsx @@ -335,10 +335,10 @@ const Settings = () => { { - handleToggle('SMS_AUTOCONFIRM') + onChange={(value) => { + handleToggle('SMS_AUTOCONFIRM', !value) }} - checked={model.SMS_AUTOCONFIRM} + checked={!model.SMS_AUTOCONFIRM} descriptionText={authConfig.properties.SMS_AUTOCONFIRM.help} /> From 9777ddea2e1d4ac9f35004a7ab83f4868cd92cd5 Mon Sep 17 00:00:00 2001 From: Kang Ming Date: Fri, 7 Jan 2022 15:28:17 +0800 Subject: [PATCH 9/9] chore: add comments to explain sms_autoconfirm & mailer_autoconfirm --- studio/pages/project/[ref]/auth/settings.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/studio/pages/project/[ref]/auth/settings.tsx b/studio/pages/project/[ref]/auth/settings.tsx index 86e904ba4e8..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} @@ -336,8 +338,11 @@ const Settings = () => { layout="horizontal" label={authConfig.properties.SMS_AUTOCONFIRM.title} 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} descriptionText={authConfig.properties.SMS_AUTOCONFIRM.help} />