Skip to content

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

Update based on endpoint changes

Joshen Lim11cdc82aaa50
diff --git a/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx b/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx
index 2dbdee07953..087d2620c68 100644
--- a/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx
+++ b/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx
@@ -59,8 +59,8 @@ const AuditLogs = () => {
const sortedLogs = logs
?.sort((a, b) =>
dateSortDesc
- ? Number(new Date(b.timestamp)) - Number(new Date(a.timestamp))
- : Number(new Date(a.timestamp)) - Number(new Date(b.timestamp))
+ ? Number(new Date(b.occurred_at)) - Number(new Date(a.occurred_at))
+ : Number(new Date(a.occurred_at)) - Number(new Date(b.occurred_at))
)
?.filter((log) => {
if (filters.users.length > 0) {
@@ -71,7 +71,7 @@ const AuditLogs = () => {
})
?.filter((log) => {
if (filters.projects.length > 0) {
- return filters.projects.includes(log.permission_group.project_ref || '')
+ return filters.projects.includes(log.target.metadata.project_ref || '')
} else {
return log
}
@@ -225,10 +225,10 @@ const AuditLogs = () => {
const user = members.find((member) => member.gotrue_id === log.actor.id)
const role = roles.find((role) => user?.role_ids?.[0] === role.id)
const project = projects?.find(
- (project) => project.ref === log.permission_group.project_ref
+ (project) => project.ref === log.target.metadata.project_ref
)
const organization = organizations?.find(
- (org) => org.slug === log.permission_group.org_slug
+ (org) => org.slug === log.target.metadata.org_slug
)
const hasStatusCode = log.action.metadata[0]?.status !== undefined
@@ -253,18 +253,23 @@ const AuditLogs = () => {
return (
<Table.tr
- key={log.timestamp}
+ key={log.occurred_at}
onClick={() => setSelectedLog(log)}
className="cursor-pointer hover:!bg-scale-100 transition duration-100"
>
<Table.td>
<div className="flex items-center space-x-4">
- {userIcon}
+ <div>{userIcon}</div>
<div>
- <p className="text-scale-1100">{user?.username ?? log.actor.id}</p>
+ <p className="text-scale-1100">{user?.username ?? 'Unknown'}</p>
{role && (
<p className="mt-0.5 text-xs text-scale-1000">{role?.name}</p>
)}
+ {user === undefined && role === undefined && (
+ <p className="mt-0.5 text-xs text-scale-1000">
+ ID: {log.actor.id}
+ </p>
+ )}
</div>
</div>
</Table.td>
@@ -288,16 +293,16 @@ const AuditLogs = () => {
{project?.name ?? organization?.name ?? 'Entity no longer exists'}
</p>
<p className="text-scale-1000 text-xs mt-0.5 truncate">
- {log.permission_group.project_ref
+ {log.target.metadata.project_ref
? 'Ref: '
- : log.permission_group.org_slug
+ : log.target.metadata.org_slug
? 'Slug: '
: null}
- {log.permission_group.project_ref ?? log.permission_group.org_slug}
+ {log.target.metadata.project_ref ?? log.target.metadata.org_slug}
</p>
</Table.td>
<Table.td>
- {dayjs(log.timestamp).format('DD MMM YYYY, HH:mm:ss')}
+ {dayjs(log.occurred_at).format('DD MMM YYYY, HH:mm:ss')}
</Table.td>
<Table.td align="right">
<Button type="default">View details</Button>
diff --git a/studio/components/interfaces/Organization/AuditLogs/LogDetailsPanel.tsx b/studio/components/interfaces/Organization/AuditLogs/LogDetailsPanel.tsx
index c1dce20cd16..0f374319b15 100644
--- a/studio/components/interfaces/Organization/AuditLogs/LogDetailsPanel.tsx
+++ b/studio/components/interfaces/Organization/AuditLogs/LogDetailsPanel.tsx
@@ -1,11 +1,9 @@
-import { useParams } from 'common'
import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms'
import { OrganizationAuditLog } from 'data/organizations/organization-audit-logs-query'
-import { useOrganizationDetailQuery } from 'data/organizations/organization-detail-query'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
import { useProjectsQuery } from 'data/projects/projects-query'
import dayjs from 'dayjs'
-import { Button, Input, SidePanel } from 'ui'
+import { Input, SidePanel } from 'ui'
export interface LogDetailsPanelProps {
selectedLog?: OrganizationAuditLog
@@ -17,16 +15,16 @@ const LogDetailsPanel = ({ selectedLog, onClose }: LogDetailsPanelProps) => {
const { data: organizations } = useOrganizationsQuery()
const project = projects?.find(
- (project) => project.ref === selectedLog?.permission_group.project_ref
+ (project) => project.ref === selectedLog?.target.metadata.project_ref
)
const organization = organizations?.find(
- (org) => org.slug === selectedLog?.permission_group.org_slug
+ (org) => org.slug === selectedLog?.target.metadata.org_slug
)
return (
<SidePanel
size="large"
- header={`"${selectedLog?.action.name}" on ${dayjs(selectedLog?.timestamp).format(
+ header={`"${selectedLog?.action.name}" on ${dayjs(selectedLog?.occurred_at).format(
'DD MMM YYYY, HH:mm:ss'
)}`}
visible={selectedLog !== undefined}
@@ -38,15 +36,9 @@ const LogDetailsPanel = ({ selectedLog, onClose }: LogDetailsPanelProps) => {
<Input
readOnly
size="small"
- label="Description"
- value={selectedLog?.target.description}
- />
- <Input
- readOnly
- size="small"
- label="Timestamp"
- value={selectedLog?.timestamp}
- descriptionText={dayjs(selectedLog?.timestamp).format('DD MMM YYYY, HH:mm:ss (ZZ)')}
+ label="Occurred at"
+ value={selectedLog?.occurred_at}
+ descriptionText={dayjs(selectedLog?.occurred_at).format('DD MMM YYYY, HH:mm:ss (ZZ)')}
/>
</FormSectionContent>
</FormSection>
@@ -60,7 +52,9 @@ const LogDetailsPanel = ({ selectedLog, onClose }: LogDetailsPanelProps) => {
readOnly
size="small"
label="Metadata"
- value={JSON.stringify(selectedLog?.actor.metadata)}
+ rows={5}
+ className="input-mono input-xs"
+ value={JSON.stringify(selectedLog?.actor.metadata, null, 2)}
/>
</FormSectionContent>
</FormSection>
@@ -74,30 +68,25 @@ const LogDetailsPanel = ({ selectedLog, onClose }: LogDetailsPanelProps) => {
readOnly
size="small"
label="Metadata"
- value={JSON.stringify(selectedLog?.action.metadata)}
+ rows={5}
+ className="input-mono input-xs"
+ value={JSON.stringify(selectedLog?.action.metadata, null, 2)}
/>
</FormSectionContent>
</FormSection>
<SidePanel.Separator />
- <FormSection header={<FormSectionLabel>Permission Group</FormSectionLabel>}>
+ <FormSection header={<FormSectionLabel>Target</FormSectionLabel>}>
<FormSectionContent loading={false}>
- <Input
- readOnly
- size="small"
- label="Organization slug"
- disabled={(selectedLog?.permission_group.org_slug ?? '').length === 0}
- value={selectedLog?.permission_group.org_slug ?? 'None'}
- descriptionText={organization?.name && `Organization: ${organization.name}`}
- />
- <Input
+ <Input readOnly size="small" label="Name" value={selectedLog?.target.description} />
+ <Input.TextArea
readOnly
size="small"
- label="Project reference"
- disabled={(selectedLog?.permission_group.project_ref ?? '').length === 0}
- value={selectedLog?.permission_group.project_ref ?? 'None'}
- descriptionText={project?.name && `Project: ${project.name}`}
+ label="Metadata"
+ rows={5}
+ className="input-mono input-xs"
+ value={JSON.stringify(selectedLog?.target.metadata, null, 2)}
/>
</FormSectionContent>
</FormSection>
diff --git a/studio/data/organizations/organization-audit-logs-query.ts b/studio/data/organizations/organization-audit-logs-query.ts
index 1bbe0b1d3f1..8179f9acf0f 100644
--- a/studio/data/organizations/organization-audit-logs-query.ts
+++ b/studio/data/organizations/organization-audit-logs-query.ts
@@ -7,8 +7,8 @@ import { organizationKeys } from './keys'
export type OrganizationAuditLog = {
action: {
metadata: {
- method: string
- status: number
+ method?: string
+ status?: number
}[]
name: string
}
@@ -16,17 +16,17 @@ export type OrganizationAuditLog = {
id: string
type: 'user' | string
metadata: {
- email: string
+ email?: string
}[]
}
- permission_group: {
- org_slug: string
- project_ref: string | null
- }
target: {
description: string
+ metadata: {
+ org_slug?: string
+ project_ref?: string
+ }
}
- timestamp: string
+ occurred_at: string
}
export type OrganizationAuditLogsResponse = {
@@ -34,53 +34,6 @@ export type OrganizationAuditLogsResponse = {
retention_period: number
}
-const MOCK_LOGS: OrganizationAuditLog[] = [
- {
- action: { name: 'Test', metadata: [{ method: 'Test', status: 200 }] },
- actor: {
- id: '88687b48-6496-478b-a9e5-f0d626605a3b',
- type: 'user',
- metadata: [{ email: '[email protected]' }],
- },
- permission_group: { org_slug: 'sfplxoawkrhwbgwzikum', project_ref: null },
- target: { description: 'Test description' },
- timestamp: new Date('2023-06-05 08:30:23').toISOString(),
- },
- {
- action: { name: 'Test', metadata: [{ method: 'Test', status: 200 }] },
- actor: {
- id: '88687b48-6496-478b-a9e5-f0d626605a3b',
- type: 'user',
- metadata: [{ email: '[email protected]' }],
- },
- permission_group: { org_slug: 'sfplxoawkrhwbgwzikum', project_ref: null },
- target: { description: 'Test description' },
- timestamp: new Date('2023-06-05 08:20:23').toISOString(),
- },
- {
- action: { name: 'Test', metadata: [{ method: 'Test', status: 200 }] },
- actor: {
- id: '88687b48-6496-478b-a9e5-f0d626605a3b',
- type: 'user',
- metadata: [{ email: '[email protected]' }],
- },
- permission_group: { org_slug: 'sfplxoawkrhwbgwzikum', project_ref: null },
- target: { description: 'Test description' },
- timestamp: new Date('2023-06-05 08:10:23').toISOString(),
- },
- {
- action: { name: 'Test', metadata: [{ method: 'Test', status: 200 }] },
- actor: {
- id: '88687b48-6496-478b-a9e5-f0d626605a3b',
- type: 'user',
- metadata: [{ email: '[email protected]' }],
- },
- permission_group: { org_slug: 'sfplxoawkrhwbgwzikum', project_ref: 'uipodoqangxyoawfsfer' },
- target: { description: 'Test description' },
- timestamp: new Date('2023-06-05 08:00:23').toISOString(),
- },
-]
-
export type OrganizationAuditLogsVariables = {
slug?: string
iso_timestamp_start?: string
diff --git a/studio/styles/main.scss b/studio/styles/main.scss
index 70970273ab4..344bc70f909 100644
--- a/studio/styles/main.scss
+++ b/studio/styles/main.scss
@@ -150,6 +150,13 @@ a {
}
}
+.input-xs {
+ input,
+ textarea {
+ @apply text-xs;
+ }
+}
+
input[type='radio'] {
@apply p-0;
}