mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-26 16:02:36 +00:00
small refactor
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
// Assumes the db manager was already opened
|
||||
|
||||
import { expect, Page } from '@playwright/test'
|
||||
import type { DbFeatures } from '../src/lib/components/apps/components/display/dbtable/dbFeatures'
|
||||
|
||||
export class DbManagerPage {
|
||||
page: Page
|
||||
constructor(page: Page) {
|
||||
features: DbFeatures
|
||||
constructor(page: Page, features: DbFeatures) {
|
||||
this.page = page
|
||||
this.features = features
|
||||
}
|
||||
|
||||
async runTest() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { test, expect, Page } from '@playwright/test'
|
||||
import { DbManagerPage } from './DbManagerPage'
|
||||
import { getDbFeatures } from '../src/lib/components/apps/components/display/dbtable/dbFeatures'
|
||||
|
||||
async function setupNewDataTable(page: Page): Promise<{ datatableId: string }> {
|
||||
// Generate unique ID with timestamp
|
||||
@@ -78,6 +79,9 @@ test('create new data table, add a new table, CRUD rows and delete the table', a
|
||||
const lastRow = table.locator('tr').nth(-2)
|
||||
lastRow.locator('button:has-text("Manage")').click()
|
||||
|
||||
let dbManagerPage = new DbManagerPage(page)
|
||||
let dbManagerPage = new DbManagerPage(
|
||||
page,
|
||||
getDbFeatures({ type: 'database', resourceType: 'postgresql', resourcePath: '' })
|
||||
)
|
||||
await dbManagerPage.runTest()
|
||||
})
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { Pane, Splitpanes } from 'svelte-splitpanes'
|
||||
import { ClearableInput, Drawer, DrawerContent } from './common'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import { type ColumnDef, type DbFeatures } from './apps/components/display/dbtable/utils'
|
||||
import { type ColumnDef } from './apps/components/display/dbtable/utils'
|
||||
import DBTable from './DBTable.svelte'
|
||||
import type { IDbSchemaOps, IDbTableOps } from './dbOps'
|
||||
import DropdownV2 from './DropdownV2.svelte'
|
||||
@@ -22,6 +22,7 @@
|
||||
} from './apps/components/display/dbtable/queries/alterTable'
|
||||
import { resource } from 'runed'
|
||||
import { capitalize, onlyAlphaNumAndUnderscore, pluralize } from '$lib/utils'
|
||||
import type { DbFeatures } from './apps/components/display/dbtable/dbFeatures'
|
||||
|
||||
/** Represents a selected table with its schema */
|
||||
export interface SelectedTable {
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
import { dbSchemas, workspaceStore, type DBSchema } from '$lib/stores'
|
||||
import { sendUserToast, sortArray } from '$lib/utils'
|
||||
import { Loader2 } from 'lucide-svelte'
|
||||
import {
|
||||
dbSupportsSchemas,
|
||||
getDbFeatures,
|
||||
type TableMetadata
|
||||
} from './apps/components/display/dbtable/utils'
|
||||
import { dbSupportsSchemas, type TableMetadata } from './apps/components/display/dbtable/utils'
|
||||
import DbManager from './DBManager.svelte'
|
||||
import {
|
||||
dbSchemaOpsWithPreviewScripts,
|
||||
@@ -26,6 +22,7 @@
|
||||
} from './apps/components/display/dbtable/metadata'
|
||||
|
||||
import type { SelectedTable } from './DBManager.svelte'
|
||||
import { getDbFeatures } from './apps/components/display/dbtable/dbFeatures'
|
||||
|
||||
interface Props {
|
||||
input?: DbInput
|
||||
|
||||
@@ -45,11 +45,7 @@
|
||||
import { Cell } from './table'
|
||||
import DataTable from './table/DataTable.svelte'
|
||||
import Head from './table/Head.svelte'
|
||||
import {
|
||||
datatypeHasLength,
|
||||
dbSupportsSchemas,
|
||||
type DbFeatures
|
||||
} from './apps/components/display/dbtable/utils'
|
||||
import { datatypeHasLength, dbSupportsSchemas } from './apps/components/display/dbtable/utils'
|
||||
import { DB_TYPES } from '$lib/consts'
|
||||
import Popover from './meltComponents/Popover.svelte'
|
||||
import Tooltip from './meltComponents/Tooltip.svelte'
|
||||
@@ -70,6 +66,7 @@
|
||||
datatypeDefaultLength
|
||||
} from './apps/components/display/dbtable/tableEditor'
|
||||
import Alert from './common/alert/Alert.svelte'
|
||||
import type { DbFeatures } from './apps/components/display/dbtable/dbFeatures'
|
||||
|
||||
type Props = {
|
||||
dbType: DbType
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Separate file to import in both frontend and e2e
|
||||
|
||||
import type { DbInput } from '../../../../dbTypes'
|
||||
|
||||
export type DbFeatures = {
|
||||
foreignKeys?: boolean
|
||||
primaryKeys?: boolean
|
||||
defaultValues?: boolean
|
||||
defaultToNotNull?: boolean
|
||||
}
|
||||
|
||||
export function getDbFeatures(dbInput: DbInput): Required<DbFeatures> {
|
||||
const def: Required<DbFeatures> = {
|
||||
foreignKeys: true,
|
||||
primaryKeys: true,
|
||||
defaultValues: true,
|
||||
defaultToNotNull: true
|
||||
}
|
||||
|
||||
if (dbInput.type == 'ducklake') return { ...def, foreignKeys: false, primaryKeys: false }
|
||||
|
||||
if (dbInput.resourceType == 'bigquery')
|
||||
return {
|
||||
foreignKeys: false,
|
||||
primaryKeys: true,
|
||||
defaultValues: false,
|
||||
defaultToNotNull: false
|
||||
}
|
||||
|
||||
return { ...def }
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
type IntrospectionQuery
|
||||
} from 'graphql'
|
||||
|
||||
import type { DbInput, DbType } from '$lib/components/dbTypes'
|
||||
import type { DbType } from '$lib/components/dbTypes'
|
||||
|
||||
export enum ColumnIdentity {
|
||||
ByDefault = 'By Default',
|
||||
@@ -428,31 +428,3 @@ export function sqlDataTypeToJsTypeHeuristic(datatype: string): string {
|
||||
return 'any'
|
||||
}
|
||||
}
|
||||
|
||||
export type DbFeatures = {
|
||||
foreignKeys?: boolean
|
||||
primaryKeys?: boolean
|
||||
defaultValues?: boolean
|
||||
defaultToNotNull?: boolean
|
||||
}
|
||||
|
||||
export function getDbFeatures(dbInput: DbInput): Required<DbFeatures> {
|
||||
const def: Required<DbFeatures> = {
|
||||
foreignKeys: true,
|
||||
primaryKeys: true,
|
||||
defaultValues: true,
|
||||
defaultToNotNull: true
|
||||
}
|
||||
|
||||
if (dbInput.type == 'ducklake') return { ...def, foreignKeys: false, primaryKeys: false }
|
||||
|
||||
if (dbInput.resourceType == 'bigquery')
|
||||
return {
|
||||
foreignKeys: false,
|
||||
primaryKeys: true,
|
||||
defaultValues: false,
|
||||
defaultToNotNull: false
|
||||
}
|
||||
|
||||
return { ...def }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user