Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions resources/js/pages/databases/components/create-database.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ export default function CreateDatabase({

// Auto-load collations when modal opens with a default charset
useEffect(() => {
if (open && defaultCharset && charsets.includes(defaultCharset) && collations.length === 0) {
axios.get(route('databases.collations', { server: server, charset: defaultCharset })).then((response) => {
if (open && form.data.charset && charsets.includes(form.data.charset) && collations.length === 0) {
axios.get(route('databases.collations', { server: server, charset: form.data.charset })).then((response) => {
setCollations(response.data);
});
}
}, [open, charsets, defaultCharset, server, collations]);
}, [open, charsets, form.data.charset, server, collations]);
Comment on lines 66 to +72
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The collations state is not reset when the modal closes or when the form is submitted successfully. This means that on subsequent opens of the modal, the useEffect will not run because the condition 'collations.length === 0' will be false, and the collations list will still contain values from the previous interaction. Consider resetting the collations state in the handleOpenChange function when open is false, or after form submission.

Copilot uses AI. Check for mistakes.

const submit = (e: FormEvent) => {
e.preventDefault();
Expand Down
6 changes: 5 additions & 1 deletion resources/js/pages/databases/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ type Page = {
export default function Databases() {
const page = usePage<Page>();

const dbType = page.props.server.services['database'];
const defaultCharset = dbType === 'postgresql' ? 'UTF8' : 'utf8mb4';
const defaultCollation = dbType === 'postgresql' ? 'C.utf8' : 'utf8mb4_0900_ai_ci';

return (
<ServerLayout>
<Head title={`Databases - ${page.props.server.name}`} />
Expand All @@ -36,7 +40,7 @@ export default function Databases() {
</Button>
</a>
<SyncDatabases server={page.props.server} />
<CreateDatabase server={page.props.server.id}>
<CreateDatabase server={page.props.server.id} defaultCharset={defaultCharset} defaultCollation={defaultCollation}>
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two consecutive spaces between the server prop and defaultCharset prop. Remove the extra space for consistent formatting.

Suggested change
<CreateDatabase server={page.props.server.id} defaultCharset={defaultCharset} defaultCollation={defaultCollation}>
<CreateDatabase server={page.props.server.id} defaultCharset={defaultCharset} defaultCollation={defaultCollation}>

Copilot uses AI. Check for mistakes.
<Button>
<PlusIcon />
<span className="hidden lg:block">Create</span>
Expand Down