mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 12:55:06 +03:00
* start * added panels * remove stuff * fixes and refinements * clean up * remove old assistant panel * resizable assistant kinda * use icon * Add missing package * remove canvas * add suggestions * updated empty state if no tables exist * fix table condition * Implement diffing if using assistant in sql editor * Reinstate old assistant in SQL editor if feature preview is off * pane size adjustment * assistant button corners * Add SQL snippet content to assistant if opening assistant in sql editor * Add the necessary checks for opt in and hipaa * revert adding snippet to assistant when opening assistant in sql editor * Add cmd i shortcut * Add admonitions for when disablePrompt is toggled on, and if no api key is set. Add footer note RE rate limitation * Bump ai package in packages * some fixes for backwards compability depending on feature preview toggled * Rename feature preview property for new assistant * Smol fix * Prevent SQL snippet from running until message is finished * only loading last message * fix z-index * save chat state to global state * add debug to failed ai queries * Add basic contextual invalidation * Add explain code action to SQL editor * Add link to abort ongoing queries from SqlSnippet * Update feature preview content * Fix * Fix * Fix * Te4st * Fix tests * ONly show ai button within a project * Fix PH tracking * Beef up a bit more event tracking * Rough fix to padding when assistant is open * A bit more telemetry stuff * Update prompts * fix rls editing via assistant * Update generate-v3.ts prompt to get auth schema too * Add policy satement to assistant when editing * Address all comments * fixc * Fix SqlSnippet not taking full width on larger viewports * Adjust max width --------- Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com>
142 lines
3.7 KiB
TypeScript
142 lines
3.7 KiB
TypeScript
import SchemaSelector from 'components/ui/SchemaSelector'
|
|
|
|
import {
|
|
Button,
|
|
SelectContent_Shadcn_,
|
|
SelectGroup_Shadcn_,
|
|
SelectItem_Shadcn_,
|
|
SelectTrigger_Shadcn_,
|
|
SelectValue_Shadcn_,
|
|
Select_Shadcn_,
|
|
} from 'ui'
|
|
|
|
export interface PrivilegesHeadProps {
|
|
disabled: boolean
|
|
selectedSchema: string
|
|
selectedRole: string
|
|
selectedTable?: { name: string }
|
|
tables: string[]
|
|
roles: string[]
|
|
onChangeSchema: (schema: string) => void
|
|
onChangeRole: (role: string) => void
|
|
onChangeTable: (table: string) => void
|
|
hasChanges?: boolean
|
|
resetChanges: () => void
|
|
applyChanges: () => void
|
|
isApplyingChanges?: boolean
|
|
}
|
|
|
|
const PrivilegesHead = ({
|
|
disabled,
|
|
selectedSchema,
|
|
onChangeSchema,
|
|
selectedRole,
|
|
roles,
|
|
onChangeRole,
|
|
selectedTable,
|
|
tables,
|
|
onChangeTable,
|
|
hasChanges = false,
|
|
resetChanges,
|
|
applyChanges,
|
|
isApplyingChanges = false,
|
|
}: PrivilegesHeadProps) => {
|
|
return (
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center gap-x-2">
|
|
<SchemaSelector
|
|
className="bg-control rounded-md w-[180px] [&>button]:py-[5px]"
|
|
selectedSchemaName={selectedSchema}
|
|
onSelectSchema={onChangeSchema}
|
|
/>
|
|
<TablesSelect selectedTable={selectedTable} tables={tables} onChangeTable={onChangeTable} />
|
|
<div className="h-[20px] w-px border-r border-scale-600"></div>
|
|
<RolesSelect selectedRole={selectedRole} roles={roles} onChangeRole={onChangeRole} />
|
|
</div>
|
|
|
|
<div className="flex items-center gap-2">
|
|
<Button
|
|
type="default"
|
|
size="tiny"
|
|
onClick={resetChanges}
|
|
disabled={!hasChanges || isApplyingChanges}
|
|
>
|
|
Reset
|
|
</Button>
|
|
<Button
|
|
type="primary"
|
|
size="tiny"
|
|
onClick={applyChanges}
|
|
disabled={disabled || !hasChanges || isApplyingChanges}
|
|
loading={isApplyingChanges}
|
|
>
|
|
Apply Changes
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const RolesSelect = ({
|
|
selectedRole,
|
|
roles,
|
|
onChangeRole,
|
|
}: {
|
|
selectedRole: string
|
|
roles: string[]
|
|
onChangeRole: (role: string) => void
|
|
}) => {
|
|
return (
|
|
<Select_Shadcn_ value={selectedRole} onValueChange={onChangeRole}>
|
|
<SelectTrigger_Shadcn_ size="tiny" className="w-40">
|
|
<SelectValue_Shadcn_ placeholder="Select a role" />
|
|
</SelectTrigger_Shadcn_>
|
|
<SelectContent_Shadcn_>
|
|
<SelectGroup_Shadcn_>
|
|
{roles.map((role) => (
|
|
<SelectItem_Shadcn_ key={role} value={role} className="text-xs">
|
|
<span className="text-foreground-light mr-1">role</span> {role}
|
|
</SelectItem_Shadcn_>
|
|
))}
|
|
</SelectGroup_Shadcn_>
|
|
</SelectContent_Shadcn_>
|
|
</Select_Shadcn_>
|
|
)
|
|
}
|
|
|
|
const TablesSelect = ({
|
|
selectedTable,
|
|
tables,
|
|
onChangeTable,
|
|
}: {
|
|
selectedTable?: {
|
|
name: string
|
|
}
|
|
tables: string[]
|
|
onChangeTable: (table: string) => void
|
|
}) => {
|
|
return (
|
|
<Select_Shadcn_ value={selectedTable?.name} onValueChange={onChangeTable}>
|
|
<SelectTrigger_Shadcn_ size="tiny" className="w-44">
|
|
<SelectValue_Shadcn_ placeholder="Select a table" />
|
|
</SelectTrigger_Shadcn_>
|
|
<SelectContent_Shadcn_>
|
|
<SelectGroup_Shadcn_>
|
|
{tables.length === 0 ? (
|
|
<div className="text-xs text-foreground-light p-2">
|
|
No tables available in this schema
|
|
</div>
|
|
) : null}
|
|
{tables.map((table) => (
|
|
<SelectItem_Shadcn_ key={table} value={table} className="text-xs">
|
|
<span className="text-foreground-light mr-1">table</span> {table}
|
|
</SelectItem_Shadcn_>
|
|
))}
|
|
</SelectGroup_Shadcn_>
|
|
</SelectContent_Shadcn_>
|
|
</Select_Shadcn_>
|
|
)
|
|
}
|
|
|
|
export default PrivilegesHead
|