Skip to content

Commit

Permalink
Merge branch 'db-connection-pages' of github.com:centerofci/mathesar …
Browse files Browse the repository at this point in the history
…into db-connection-pages
  • Loading branch information
dmos62 committed Oct 9, 2023
2 parents f96a12a + 3edd094 commit 98e60ea
Show file tree
Hide file tree
Showing 60 changed files with 292 additions and 341 deletions.
10 changes: 10 additions & 0 deletions .github/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ centerofci/mathesar-design:
- .github/workflows/update-project-on-issue-label.yml
- .github/workflows/update-project-on-pr-edit.yml
- .github/workflows/update-project-on-pr-label.yml
centerofci/mathesar-internal-crm:
- .github/actions/project_update/
- .github/workflows/add-to-project.yml
- .github/workflows/toc.yml
- .github/workflows/stale.yml
- .github/workflows/update-project-on-issue-close.yml
- .github/workflows/update-project-on-issue-edit.yml
- .github/workflows/update-project-on-issue-label.yml
- .github/workflows/update-project-on-pr-edit.yml
- .github/workflows/update-project-on-pr-label.yml
centerofci/mathesar-private-notes:
- .github/actions/project_update/
- .github/workflows/add-to-project.yml
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/sync-github-labels-milestones.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- run: /home/runner/.composer/vendor/bin/github-sync labels -f centerofci/mathesar -t centerofci/mathesar-ansible -d
- run: /home/runner/.composer/vendor/bin/github-sync labels -f centerofci/mathesar -t centerofci/mathesar-data-playground -d
- run: /home/runner/.composer/vendor/bin/github-sync labels -f centerofci/mathesar -t centerofci/mathesar-design -d
- run: /home/runner/.composer/vendor/bin/github-sync labels -f centerofci/mathesar -t centerofci/mathesar-internal-crm -d
- run: /home/runner/.composer/vendor/bin/github-sync labels -f centerofci/mathesar -t centerofci/mathesar-private-notes -d
- run: /home/runner/.composer/vendor/bin/github-sync labels -f centerofci/mathesar -t centerofci/mathesar-scripts -d
- run: /home/runner/.composer/vendor/bin/github-sync labels -f centerofci/mathesar -t centerofci/mathesar-update-companion -d
Expand All @@ -24,6 +25,7 @@ jobs:
- run: /home/runner/.composer/vendor/bin/github-sync milestones -f centerofci/mathesar -t centerofci/mathesar-ansible -s open
- run: /home/runner/.composer/vendor/bin/github-sync milestones -f centerofci/mathesar -t centerofci/mathesar-data-playground -s open
- run: /home/runner/.composer/vendor/bin/github-sync milestones -f centerofci/mathesar -t centerofci/mathesar-design -s open
- run: /home/runner/.composer/vendor/bin/github-sync milestones -f centerofci/mathesar -t centerofci/mathesar-internal-crm -s open
- run: /home/runner/.composer/vendor/bin/github-sync milestones -f centerofci/mathesar -t centerofci/mathesar-private-notes -s open
- run: /home/runner/.composer/vendor/bin/github-sync milestones -f centerofci/mathesar -t centerofci/mathesar-scripts -s open
- run: /home/runner/.composer/vendor/bin/github-sync milestones -f centerofci/mathesar -t centerofci/mathesar-update-companion -s open
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sync-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Sync GitHub workflows to other repos
on:
push:
branches:
- master
- develop
workflow_dispatch:
jobs:
sync_workflows:
Expand All @@ -13,4 +13,4 @@ jobs:
- name: Run GitHub file sync
uses: BetaHuhn/repo-file-sync-action@v1
with:
GH_PAT: ${{secrets.MATHESAR_ORG_GITHUB_TOKEN}}
GH_PAT: ${{secrets.MATHESAR_ORG_GITHUB_TOKEN}}
12 changes: 3 additions & 9 deletions mathesar_ui/src/api/databaseConnection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SuccessfullyConnectedDatabase } from '@mathesar/AppTypes';
import type { Database } from '@mathesar/AppTypes';
import { deleteAPI, patchAPI, postAPI } from './utils/requestUtils';

export interface NewConnection {
Expand All @@ -13,17 +13,11 @@ export interface NewConnection {
export type ConnectionUpdates = Partial<Omit<NewConnection, 'name'>>;

function add(connectionDetails: NewConnection) {
return postAPI<SuccessfullyConnectedDatabase>(
'/api/db/v0/databases/',
connectionDetails,
);
return postAPI<Database>('/api/db/v0/databases/', connectionDetails);
}

function update(databaseId: number, updates: ConnectionUpdates) {
return patchAPI<SuccessfullyConnectedDatabase>(
`/api/db/v0/databases/${databaseId}/`,
updates,
);
return patchAPI<Database>(`/api/db/v0/databases/${databaseId}/`, updates);
}

function deleteConnection(databaseId: number, removeMathesarSchemas = false) {
Expand Down
9 changes: 3 additions & 6 deletions mathesar_ui/src/api/users.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import type {
SuccessfullyConnectedDatabase,
SchemaEntry,
} from '@mathesar/AppTypes';
import type { Database, SchemaEntry } from '@mathesar/AppTypes';
import {
deleteAPI,
getAPI,
Expand All @@ -21,7 +18,7 @@ export type UserRole = 'viewer' | 'editor' | 'manager';

export interface DatabaseRole {
id: number;
database: SuccessfullyConnectedDatabase['id'];
database: Database['id'];
role: UserRole;
}

Expand Down Expand Up @@ -76,7 +73,7 @@ function resetPassword(userId: User['id'], password: string) {

function addDatabaseRole(
userId: User['id'],
databaseId: SuccessfullyConnectedDatabase['id'],
databaseId: Database['id'],
role: UserRole,
) {
return postAPI<DatabaseRole>('/api/ui/v0/database_roles/', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
background: var(--slate-100);
}

&:read-only {
&.read-only {
background: var(--slate-50);
}

Expand Down
6 changes: 3 additions & 3 deletions mathesar_ui/src/component-library/text-input/TextInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
export let value: $$Props['value'] = '';
// Additional classes
let classes = '';
let classes: $$Props['class'] = '';
export { classes as class };
// Underlying DOM element for direct access
export let element: $$Props['element'] = undefined;
export let hasError = false;
export let hasError: $$Props['hasError'] = false;
// Id for the input
export let id: $$Props['id'] = undefined;
Expand All @@ -35,14 +35,14 @@

<BaseInput {...$$restProps} bind:id />

<!-- TODO: Why do we have two base classes input-element & text-input -->
<input
bind:this={element}
{...$$restProps}
{style}
type="text"
class={['input-element', 'text-input', classes].join(' ')}
class:has-error={hasError}
class:read-only={$$restProps.readonly}
bind:value
{id}
on:input
Expand Down
6 changes: 3 additions & 3 deletions mathesar_ui/src/components/breadcrumb/DatabaseSelector.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { SuccessfullyConnectedDatabase } from '@mathesar/AppTypes';
import type { Database } from '@mathesar/AppTypes';
import { iconDatabase } from '@mathesar/icons';
import { getDatabasePageUrl } from '@mathesar/routes/urls';
import {
Expand All @@ -10,7 +10,7 @@
import type { BreadcrumbSelectorEntry } from './breadcrumbTypes';
function makeBreadcrumbSelectorItem(
dbEntry: SuccessfullyConnectedDatabase,
dbEntry: Database,
): BreadcrumbSelectorEntry {
return {
type: 'simple',
Expand All @@ -23,7 +23,7 @@
};
}
$: databases = [...$dbStore.successfulConnections.values()];
$: databases = [...$dbStore.data.values()];
</script>

<BreadcrumbSelector
Expand Down
7 changes: 2 additions & 5 deletions mathesar_ui/src/components/breadcrumb/EntitySelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
} from '@mathesar/stores/tables';
import type { TableEntry } from '@mathesar/api/types/tables';
import { getExplorationPageUrl } from '@mathesar/routes/urls';
import type {
SuccessfullyConnectedDatabase,
SchemaEntry,
} from '@mathesar/AppTypes';
import type { Database, SchemaEntry } from '@mathesar/AppTypes';
import { iconTable } from '@mathesar/icons';
import { queries as queriesStore } from '@mathesar/stores/queries';
import type { QueryInstance } from '@mathesar/api/types/queries';
Expand All @@ -21,7 +18,7 @@
BreadcrumbSelectorEntryForTable,
} from './breadcrumbTypes';
export let database: SuccessfullyConnectedDatabase;
export let database: Database;
export let schema: SchemaEntry;
function makeTableBreadcrumbSelectorItem(
Expand Down
7 changes: 2 additions & 5 deletions mathesar_ui/src/components/breadcrumb/SchemaSelector.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<script lang="ts">
import type {
SuccessfullyConnectedDatabase,
SchemaEntry,
} from '@mathesar/AppTypes';
import type { Database, SchemaEntry } from '@mathesar/AppTypes';
import { iconSchema } from '@mathesar/icons';
import { getSchemaPageUrl } from '@mathesar/routes/urls';
import {
Expand All @@ -12,7 +9,7 @@
import BreadcrumbSelector from './BreadcrumbSelector.svelte';
import type { BreadcrumbSelectorEntry } from './breadcrumbTypes';
export let database: SuccessfullyConnectedDatabase;
export let database: Database;
function makeBreadcrumbSelectorItem(
schemaEntry: SchemaEntry,
Expand Down
14 changes: 5 additions & 9 deletions mathesar_ui/src/components/breadcrumb/breadcrumbTypes.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { QueryInstance } from '@mathesar/api/types/queries';
import type { TableEntry } from '@mathesar/api/types/tables';
import type {
SuccessfullyConnectedDatabase,
Database,
SchemaEntry,
} from '@mathesar/AppTypes';
import type { Database, SchemaEntry } from '@mathesar/AppTypes';
import type {
ComponentAndProps,
IconProps,
Expand All @@ -17,13 +13,13 @@ export interface BreadcrumbItemDatabase {

export interface BreadcrumbItemSchema {
type: 'schema';
database: SuccessfullyConnectedDatabase;
database: Database;
schema: SchemaEntry;
}

export interface BreadcrumbItemTable {
type: 'table';
database: SuccessfullyConnectedDatabase;
database: Database;
schema: SchemaEntry;
table: TableEntry;
}
Expand All @@ -37,7 +33,7 @@ export interface BreadcrumbItemSimple {

export interface BreadcrumbItemRecord {
type: 'record';
database: SuccessfullyConnectedDatabase;
database: Database;
schema: SchemaEntry;
table: TableEntry;
record: {
Expand All @@ -48,7 +44,7 @@ export interface BreadcrumbItemRecord {

export interface BreadcrumbItemExploration {
type: 'exploration';
database: SuccessfullyConnectedDatabase;
database: Database;
schema: SchemaEntry;
query: Pick<QueryInstance, 'id' | 'name'>;
}
Expand Down
9 changes: 7 additions & 2 deletions mathesar_ui/src/components/form/GridFormInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@
<div class="input">
<Field {field} {input} />
</div>
{#if help}
{#if $$slots.help || help}
<div class="help">
{help}
{#if $$slots.help}
<slot name="help" />
{/if}
{#if help}
{help}
{/if}
</div>
{/if}
</div>
Expand Down
6 changes: 3 additions & 3 deletions mathesar_ui/src/pages/admin-users/AdminNavigation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
class="menu-item menu-item-link"
use:active
>
<MenuItemContents icon={iconDatabase}
>Database Connection</MenuItemContents
>
<MenuItemContents icon={iconDatabase}>
Database Connection
</MenuItemContents>
</a>
</Menu>
</div>
Expand Down
7 changes: 2 additions & 5 deletions mathesar_ui/src/pages/data-explorer/DataExplorerPage.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<script lang="ts">
import { router } from 'tinro';
import type {
SuccessfullyConnectedDatabase,
SchemaEntry,
} from '@mathesar/AppTypes';
import type { Database, SchemaEntry } from '@mathesar/AppTypes';
import LayoutWithHeader from '@mathesar/layouts/LayoutWithHeader.svelte';
import { DataExplorer } from '@mathesar/systems/data-explorer';
import type { QueryManager } from '@mathesar/systems/data-explorer/types';
Expand All @@ -16,7 +13,7 @@
const userProfile = getUserProfileStoreFromContext();
export let database: SuccessfullyConnectedDatabase;
export let database: Database;
export let schema: SchemaEntry;
export let queryManager: QueryManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@
getDatabasePageUrl,
} from '@mathesar/routes/urls';
import { toast } from '@mathesar/stores/toast';
import type { SuccessfullyConnectedDatabase } from '@mathesar/AppTypes';
import type { Database } from '@mathesar/AppTypes';
import { router } from 'tinro';
import { reloadDatabases } from '@mathesar/stores/databases';
import { reflectApi } from '@mathesar/api/reflect';
import FormBox from '../admin-users/FormBox.svelte';
import DatabaseConnectionForm from './DatabaseConnectionForm.svelte';
async function handleSuccess(
event: CustomEvent<SuccessfullyConnectedDatabase>,
) {
const database = event.detail;
async function handleSuccess(database: Database) {
toast.success(`${database.name} connected successfully!`);
await reflectApi.reflect();
await reloadDatabases();
router.goto(getDatabasePageUrl(database.name));
try {
await reflectApi.reflect();
await reloadDatabases();
} catch (e) {
toast.fromError(e);
} finally {
router.goto(getDatabasePageUrl(database.name));
}
}
</script>

Expand All @@ -36,5 +39,5 @@
<h1>Add Database Connection</h1>

<FormBox>
<DatabaseConnectionForm on:create={handleSuccess} />
<DatabaseConnectionForm onCreate={handleSuccess} />
</FormBox>

0 comments on commit 98e60ea

Please sign in to comment.