Skip to content

Commit

Permalink
Navigate to db page after adding connection
Browse files Browse the repository at this point in the history
  • Loading branch information
seancolsen committed Dec 19, 2023
1 parent d50edd1 commit d4c0fa0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
9 changes: 5 additions & 4 deletions mathesar_ui/src/systems/connections/AddConnection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
movie_collection: $_('sample_data_movies_help'),
};
export let onExit: () => void;
export let onCancel: () => void;
export let onSuccess: (c: Connection) => void;
$: availableConnectionsToReuse = $generalConnections;
$: defaultConnectionToReuse =
Expand Down Expand Up @@ -254,8 +255,8 @@
async function saveConnectionDetails() {
try {
await create();
onExit();
const connection = await create();
onSuccess(connection);
toast.success($_('connection_added_successfully'));
} catch (e) {
toast.fromError(e);
Expand Down Expand Up @@ -415,7 +416,7 @@
<FormSubmit
{form}
catchErrors
onCancel={() => onExit()}
{onCancel}
onProceed={saveConnectionDetails}
proceedButton={{ label: $_('add_connection') }}
cancelButton={{ label: $_('cancel') }}
Expand Down
15 changes: 14 additions & 1 deletion mathesar_ui/src/systems/connections/AddConnectionModal.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
<script lang="ts">
import { _ } from 'svelte-i18n';
import { router } from 'tinro';
import {
ControlledModal,
type ModalController,
} from '@mathesar-component-library';
import type { Connection } from '@mathesar/api/connections';
import { getDatabasePageUrl } from '@mathesar/routes/urls';
import AddConnection from './AddConnection.svelte';
export let controller: ModalController;
function handleCancel() {
controller.close();
}
function handleSuccess(connection: Connection) {
controller.close();
const url = getDatabasePageUrl(connection.id);
router.goto(url);
}
</script>

<ControlledModal
{controller}
size="large"
title={$_('new_postgresql_database_connection')}
>
<AddConnection onExit={() => controller.close()} />
<AddConnection onCancel={handleCancel} onSuccess={handleSuccess} />
</ControlledModal>

0 comments on commit d4c0fa0

Please sign in to comment.