The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Fix
Joshen Limc742ea8c7356
diff --git a/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx b/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsxindex 0657951a511..c463ce98397 100644--- a/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx+++ b/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx@@ -82,6 +82,84 @@ const AuditLogs = () => {<><ScaffoldContainerLegacy><div className="space-y-4 flex flex-col">+ <div className="flex items-center justify-between">+ <div className="flex items-center space-x-2">+ <p className="text-xs prose">Filter by</p>+ <FilterPopover+ name="Users"+ options={members ?? []}+ labelKey="username"+ valueKey="gotrue_id"+ activeOptions={filters.users}+ onSaveFilters={(values) => setFilters({ ...filters, users: values })}+ />+ <FilterPopover+ name="Projects"+ options={projects ?? []}+ labelKey="name"+ valueKey="ref"+ activeOptions={filters.projects}+ onSaveFilters={(values) => setFilters({ ...filters, projects: values })}+ />+ <DatePicker+ hideTime+ hideClear+ triggerButtonType="dashed"+ triggerButtonTitle=""+ from={dateRange.from}+ to={dateRange.to}+ minDate={dayjs().subtract(retentionPeriod, 'days').toDate()}+ maxDate={dayjs().toDate()}+ onChange={(value) => {+ if (value.from !== null && value.to !== null) {+ const current = dayjs().utc()+ const from = dayjs(value.from)+ .utc()+ .hour(current.hour())+ .minute(current.minute())+ .second(current.second())+ .toISOString()+ const to = dayjs(value.to)+ .utc()+ .hour(current.hour())+ .minute(current.minute())+ .second(current.second())+ .toISOString()+ setDateRange({ from, to })+ }+ }}+ renderFooter={() => {+ return (+ <Alert title="" variant="info" className="mx-3 pl-2 pr-2 pt-1 pb-2">+ Your organization has a log retention period of{' '}+ <span className="text-brand-900">+ {retentionPeriod} day+ {retentionPeriod > 1 ? 's' : ''}+ </span>+ . You may only view logs from{' '}+ {dayjs().subtract(retentionPeriod, 'days').format('DD MMM YYYY')} as the+ earliest date.+ </Alert>+ )+ }}+ />+ {isSuccess && (+ <>+ <div className="h-[20px] border-r border-scale-700 !ml-4 !mr-2" />+ <p className="prose text-xs">Viewing {sortedLogs.length} logs in total</p>+ </>+ )}+ </div>+ <Button+ type="default"+ disabled={isLoading || isRefetching}+ icon={<IconRefreshCw className={isRefetching ? 'animate-spin' : ''} />}+ onClick={() => refetch()}+ >+ {isRefetching ? 'Refreshing' : 'Refresh'}+ </Button>+ </div>+{isLoading && (<div className="space-y-2"><ShimmeringLoader />@@ -94,80 +172,6 @@ const AuditLogs = () => {{isSuccess && (<>- <div className="flex items-center justify-between">- <div className="flex items-center space-x-2">- <p className="text-xs prose">Filter by</p>- <FilterPopover- name="Users"- options={members ?? []}- labelKey="username"- valueKey="gotrue_id"- activeOptions={filters.users}- onSaveFilters={(values) => setFilters({ ...filters, users: values })}- />- <FilterPopover- name="Projects"- options={projects ?? []}- labelKey="name"- valueKey="ref"- activeOptions={filters.projects}- onSaveFilters={(values) => setFilters({ ...filters, projects: values })}- />- <DatePicker- hideTime- hideClear- triggerButtonType="dashed"- triggerButtonTitle=""- from={dateRange.from}- to={dateRange.to}- minDate={dayjs().subtract(retentionPeriod, 'days').toDate()}- maxDate={dayjs().toDate()}- onChange={(value) => {- if (value.from !== null && value.to !== null) {- const current = dayjs().utc()- const from = dayjs(value.from)- .utc()- .hour(current.hour())- .minute(current.minute())- .second(current.second())- .toISOString()- const to = dayjs(value.to)- .utc()- .hour(current.hour())- .minute(current.minute())- .second(current.second())- .toISOString()- setDateRange({ from, to })- }- }}- renderFooter={() => {- return (- <Alert title="" variant="info" className="mx-3 pl-2 pr-2 pt-1 pb-2">- Your organization has a log retention period of{' '}- <span className="text-brand-900">- {retentionPeriod} day- {retentionPeriod > 1 ? 's' : ''}- </span>- . You may only view logs from{' '}- {dayjs().subtract(retentionPeriod, 'days').format('DD MMM YYYY')} as the- earliest date.- </Alert>- )- }}- />- <div className="h-[20px] border-r border-scale-700 !ml-4 !mr-2" />- <p className="prose text-xs">Viewing {sortedLogs.length} logs in total</p>- </div>- <Button- type="default"- disabled={isRefetching}- icon={<IconRefreshCw className={isRefetching ? 'animate-spin' : ''} />}- onClick={() => refetch()}- >- {isRefetching ? 'Refreshing' : 'Refresh'}- </Button>- </div>-{logs.length === 0 ? (<div className="bg-scale-100 dark:bg-scale-300 border rounded p-4 flex items-center justify-between"><p className="prose text-sm">diff --git a/studio/data/organizations/keys.ts b/studio/data/organizations/keys.tsindex 82588884d4e..ea3596a0aaf 100644--- a/studio/data/organizations/keys.ts+++ b/studio/data/organizations/keys.ts@@ -7,7 +7,13 @@ export const organizationKeys = {['organizations', slug, 'free-project-limit-check'] as const,customerProfile: (slug: string | undefined) =>['organizations', slug, 'customer-profile'] as const,- auditLogs: (slug: string | undefined) => ['organizations', slug, 'audit-logs'] as const,+ auditLogs: (+ slug: string | undefined,+ {+ iso_timestamp_start,+ iso_timestamp_end,+ }: { iso_timestamp_start: string | undefined; iso_timestamp_end: string | undefined }+ ) => ['organizations', slug, 'audit-logs', { iso_timestamp_start, iso_timestamp_end }] as const,migrateBilling: (slug: string | undefined) => ['organizations', slug, 'migrate-billing'] as const,migrateBillingPreview: (slug: string | undefined) =>['organizations', slug, 'migrate-billing', 'preview'] as const,diff --git a/studio/data/organizations/organization-audit-logs-query.ts b/studio/data/organizations/organization-audit-logs-query.tsindex e70c3c73756..6884928ea9f 100644--- a/studio/data/organizations/organization-audit-logs-query.ts+++ b/studio/data/organizations/organization-audit-logs-query.ts@@ -48,12 +48,14 @@ export async function getOrganizationAuditLogs() {if (!slug) throw new Error('slug is required')- // return { result: MOCK_LOGS, retention_period: 1 }-const response = await get(`${API_URL}/organizations/${slug}/audit?iso_timestamp_start=${iso_timestamp_start}&iso_timestamp_end=${iso_timestamp_end}`,{ signal })+ // if (response.error) {+ // if (response.error.code === 400 && response.error.message.includes('Date range specified exceeds the retention period'))+ // throw response.error+ // }if (response.error) throw response.errorreturn response as OrganizationAuditLogsResponse}@@ -68,9 +70,9 @@ export const useOrganizationAuditLogsQuery = <TData = OrganizationAuditLogsData>...options}: UseQueryOptions<OrganizationAuditLogsData, OrganizationAuditLogsError, TData> = {}) => {- const { slug } = vars+ const { slug, iso_timestamp_start, iso_timestamp_end } = varsreturn useQuery<OrganizationAuditLogsData, OrganizationAuditLogsError, TData>(- organizationKeys.auditLogs(slug),+ organizationKeys.auditLogs(slug, { iso_timestamp_start, iso_timestamp_end }),({ signal }) => getOrganizationAuditLogs(vars, signal),{enabled: enabled && typeof slug !== 'undefined',@@ -82,13 +84,14 @@ export const useOrganizationAuditLogsQuery = <TData = OrganizationAuditLogsData>}export const useOrganizationAuditLogsPrefetch = (vars: OrganizationAuditLogsVariables) => {- const { slug } = vars+ const { slug, iso_timestamp_start, iso_timestamp_end } = varsconst client = useQueryClient()return useCallback(() => {if (slug) {- client.prefetchQuery(organizationKeys.auditLogs(slug), ({ signal }) =>- getOrganizationAuditLogs(vars, signal)+ client.prefetchQuery(+ organizationKeys.auditLogs(slug, { iso_timestamp_start, iso_timestamp_end }),+ ({ signal }) => getOrganizationAuditLogs(vars, signal))}// eslint-disable-next-line react-hooks/exhaustive-deps