Skip to content

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

Clean duplicate files.

Ivan Vasilovb501faed834d
diff --git a/studio/components/interfaces/Account/AuditLogs/index.tsx b/studio/components/interfaces/Account/AuditLogs.tsx
similarity index 99%
rename from studio/components/interfaces/Account/AuditLogs/index.tsx
rename to studio/components/interfaces/Account/AuditLogs.tsx
index 69461de5c21..578ce2f6e3e 100644
--- a/studio/components/interfaces/Account/AuditLogs/index.tsx
+++ b/studio/components/interfaces/Account/AuditLogs.tsx
@@ -12,8 +12,7 @@ import { useOrganizationsQuery } from 'data/organizations/organizations-query'
import { useProfileAuditLogsQuery } from 'data/profile/profile-audit-logs-query'
import { useProjectsQuery } from 'data/projects/projects-query'
import { Alert, Button, IconArrowDown, IconArrowUp, IconRefreshCw } from 'ui'
-import FilterPopover from './FilterPopover'
-import LogDetailsPanel from './LogDetailsPanel'
+import FilterPopover from '../Organization/AuditLogs/FilterPopover'
const AuditLogs = () => {
const currentTime = dayjs().utc().set('millisecond', 0)
diff --git a/studio/components/interfaces/Account/AuditLogs/FilterPopover.tsx b/studio/components/interfaces/Account/AuditLogs/FilterPopover.tsx
deleted file mode 100644
index c38c96736e3..00000000000
--- a/studio/components/interfaces/Account/AuditLogs/FilterPopover.tsx
+++ /dev/null
@@ -1,100 +0,0 @@
-import { useState } from 'react'
-import { Button, Checkbox, Popover } from 'ui'
-
-interface FilterPopoverProps {
- options: any[]
- activeOptions: any[]
- valueKey: string
- labelKey: string
- name: string
- onSaveFilters: (options: string[]) => void
-}
-
-// [Joshen] Form + Checkbox.Group doesn't seem to work properly RE form state
-// hence why the manual implementation here as a workaround
-
-const FilterPopover = ({
- options = [],
- activeOptions = [],
- valueKey,
- labelKey,
- name,
- onSaveFilters,
-}: FilterPopoverProps) => {
- const [open, setOpen] = useState(false)
- const [selectedOptions, setSelectedOptions] = useState<string[]>([])
-
- const formattedOptions = activeOptions.map((option) => {
- const base = options.find((x) => x[valueKey] === option)
- return base[labelKey]
- })
-
- return (
- <Popover
- side="bottom"
- align="start"
- open={open}
- onOpenChange={() => setOpen(!open)}
- header={<div className="prose text-xs">Select {name.toLowerCase()}</div>}
- overlay={
- <>
- <div className="space-y-4 px-3 py-3 min-w-[170px]">
- <Checkbox.Group
- id="projects"
- onChange={(event) => {
- const value = event.target.value
- if (selectedOptions.includes(value)) {
- setSelectedOptions(selectedOptions.filter((x) => x !== value))
- } else {
- setSelectedOptions(selectedOptions.concat(value))
- }
- }}
- options={options.map((option) => {
- return {
- value: option[valueKey],
- label: option[labelKey],
- defaultChecked: activeOptions.includes(option[valueKey]),
- }
- })}
- ></Checkbox.Group>
- </div>
- <div className="flex items-center justify-end gap-2 border-t border-scale-400 bg-scale-200 py-2 px-3 dark:border-scale-500 dark:bg-scale-400 ">
- <Button
- size="tiny"
- type="default"
- onClick={() => {
- onSaveFilters([])
- setOpen(false)
- }}
- >
- Clear
- </Button>
- <Button
- type="primary"
- onClick={() => {
- onSaveFilters(selectedOptions)
- setOpen(false)
- }}
- >
- Save
- </Button>
- </div>
- </>
- }
- >
- <Button type={activeOptions.length > 0 ? 'default' : 'dashed'} onClick={() => setOpen(false)}>
- <span>{name}</span>
- {activeOptions.length > 0 && <span className="mr-1">:</span>}
- {activeOptions.length >= 3 ? (
- <span>
- {formattedOptions[0]} and {activeOptions.length - 1} others
- </span>
- ) : activeOptions.length > 0 ? (
- <span>{formattedOptions.join(', ')}</span>
- ) : null}
- </Button>
- </Popover>
- )
-}
-
-export default FilterPopover
diff --git a/studio/components/interfaces/Account/AuditLogs/LogDetailsPanel.tsx b/studio/components/interfaces/Account/AuditLogs/LogDetailsPanel.tsx
deleted file mode 100644
index c39bf9cb446..00000000000
--- a/studio/components/interfaces/Account/AuditLogs/LogDetailsPanel.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms'
-import { AuditLog } from 'data/organizations/organization-audit-logs-query'
-import dayjs from 'dayjs'
-import { Input, SidePanel } from 'ui'
-
-export interface LogDetailsPanelProps {
- selectedLog?: AuditLog
- onClose: () => void
-}
-
-const LogDetailsPanel = ({ selectedLog, onClose }: LogDetailsPanelProps) => {
- return (
- <SidePanel
- size="large"
- header={`"${selectedLog?.action.name}" on ${dayjs(selectedLog?.occurred_at).format(
- 'DD MMM YYYY, HH:mm:ss'
- )}`}
- visible={selectedLog !== undefined}
- onCancel={onClose}
- cancelText="Close"
- >
- <FormSection header={<FormSectionLabel>General</FormSectionLabel>}>
- <FormSectionContent loading={false}>
- <Input
- readOnly
- size="small"
- label="Occurred at"
- value={selectedLog?.occurred_at}
- descriptionText={dayjs(selectedLog?.occurred_at).format('DD MMM YYYY, HH:mm:ss (ZZ)')}
- />
- </FormSectionContent>
- </FormSection>
-
- <SidePanel.Separator />
-
- <FormSection header={<FormSectionLabel>Actor</FormSectionLabel>}>
- <FormSectionContent loading={false}>
- <Input readOnly size="small" label="Actor ID" value={selectedLog?.actor.id} />
- <Input.TextArea
- readOnly
- size="small"
- label="Metadata"
- rows={5}
- className="input-mono input-xs"
- value={JSON.stringify(selectedLog?.actor.metadata, null, 2)}
- />
- </FormSectionContent>
- </FormSection>
-
- <SidePanel.Separator />
-
- <FormSection header={<FormSectionLabel>Action</FormSectionLabel>}>
- <FormSectionContent loading={false}>
- <Input readOnly size="small" label="Name" value={selectedLog?.action.name} />
- <Input.TextArea
- readOnly
- size="small"
- label="Metadata"
- rows={5}
- className="input-mono input-xs"
- value={JSON.stringify(selectedLog?.action.metadata, null, 2)}
- />
- </FormSectionContent>
- </FormSection>
-
- <SidePanel.Separator />
-
- <FormSection header={<FormSectionLabel>Target</FormSectionLabel>}>
- <FormSectionContent loading={false}>
- <Input readOnly size="small" label="Name" value={selectedLog?.target.description} />
- <Input.TextArea
- readOnly
- size="small"
- label="Metadata"
- rows={5}
- className="input-mono input-xs"
- value={JSON.stringify(selectedLog?.target.metadata, null, 2)}
- />
- </FormSectionContent>
- </FormSection>
- </SidePanel>
- )
-}
-
-export default LogDetailsPanel
diff --git a/studio/components/interfaces/Organization/AuditLogs/LogDetailsPanel.tsx b/studio/components/interfaces/Organization/AuditLogs/LogDetailsPanel.tsx
index 0f374319b15..99c53e2f906 100644
--- a/studio/components/interfaces/Organization/AuditLogs/LogDetailsPanel.tsx
+++ b/studio/components/interfaces/Organization/AuditLogs/LogDetailsPanel.tsx
@@ -1,12 +1,12 @@
import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms'
-import { OrganizationAuditLog } from 'data/organizations/organization-audit-logs-query'
+import { AuditLog } from 'data/organizations/organization-audit-logs-query'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
import { useProjectsQuery } from 'data/projects/projects-query'
import dayjs from 'dayjs'
import { Input, SidePanel } from 'ui'
export interface LogDetailsPanelProps {
- selectedLog?: OrganizationAuditLog
+ selectedLog?: AuditLog
onClose: () => void
}