Skip to content

Commit

Permalink
fix external link listener
Browse files Browse the repository at this point in the history
  • Loading branch information
EDsCODE committed Oct 30, 2023
1 parent 1efd068 commit 3c3844b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 18 deletions.
7 changes: 6 additions & 1 deletion frontend/src/scenes/data-warehouse/DataWarehouseTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { Form } from 'kea-forms'
import { LemonInput, LemonSelect } from '@posthog/lemon-ui'
import { Field } from 'lib/forms/Field'

export function DatawarehouseTableForm(): JSX.Element {
interface DataWarehouseTableFormProps {
footer?: JSX.Element
}

export function DatawarehouseTableForm({ footer }: DataWarehouseTableFormProps): JSX.Element {
return (
<Form formKey="table" logic={dataWarehouseTableLogic} className="space-y-4" enableFormOnSubmit>
<div className="flex flex-col gap-2 max-w-160">
Expand Down Expand Up @@ -71,6 +75,7 @@ export function DatawarehouseTableForm(): JSX.Element {
/>
</Field>
</div>
{footer}
</Form>
)
}
10 changes: 9 additions & 1 deletion frontend/src/scenes/data-warehouse/dataWarehouseTableLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AnyPropertyFilter, Breadcrumb, DataWarehouseTable } from '~/types'
import { DataTableNode } from '~/queries/schema'
import { databaseSceneLogic } from 'scenes/data-management/database/databaseSceneLogic'
import type { dataWarehouseTableLogicType } from './dataWarehouseTableLogicType'
import { dataWarehouseSceneLogic } from './external/dataWarehouseSceneLogic'

export interface TableLogicProps {
id: string | 'new'
Expand All @@ -30,7 +31,12 @@ export const dataWarehouseTableLogic = kea<dataWarehouseTableLogicType>([
path(['scenes', 'data-warehouse', 'tableLogic']),
props({} as TableLogicProps),
connect(() => ({
actions: [databaseSceneLogic, ['loadDatabase']],
actions: [
databaseSceneLogic,
['loadDatabase'],
dataWarehouseSceneLogic,
['loadDataWarehouse', 'toggleSourceModal'],
],
})),
actions({
editingTable: (editing: boolean) => ({ editing }),
Expand Down Expand Up @@ -64,6 +70,8 @@ export const dataWarehouseTableLogic = kea<dataWarehouseTableLogicType>([
createTableSuccess: async ({ table }) => {
lemonToast.success(<>Table {table.name} created</>)
actions.loadDatabase()
actions.loadDataWarehouse()
actions.toggleSourceModal()
router.actions.replace(urls.dataWarehouse())
},
updateTableSuccess: async ({ table }) => {
Expand Down
42 changes: 26 additions & 16 deletions frontend/src/scenes/data-warehouse/external/SourceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,32 @@ export default function SourceModal(props: SourceModalProps): JSX.Element {
if (isManualLinkFormVisible) {
return (
<div>
<DatawarehouseTableForm />
<LemonDivider className="mt-4" />
<div className="mt-2 flex flex-row justify-end gap-2">
<LemonButton type="secondary" center data-attr="source-modal-back-button" onClick={onClear}>
Back
</LemonButton>
<LemonButton
type="primary"
center
htmlType="submit"
data-attr="source-link"
loading={tableLoading}
>
Link
</LemonButton>
</div>
<DatawarehouseTableForm
footer={
<>
<LemonDivider className="mt-4" />
<div className="mt-2 flex flex-row justify-end gap-2">
<LemonButton
type="secondary"
center
data-attr="source-modal-back-button"
onClick={onClear}
>
Back
</LemonButton>
<LemonButton
type="primary"
center
htmlType="submit"
data-attr="source-link"
loading={tableLoading}
>
Link
</LemonButton>
</div>
</>
}
/>
</div>
)
}
Expand Down

0 comments on commit 3c3844b

Please sign in to comment.