Skip to content

Commit adf8369

Browse files
Refactor
1 parent f70ea71 commit adf8369

2 files changed

Lines changed: 123 additions & 7 deletions

File tree

examples/nextjs-import-airbyte-github-export-seafowl/components/ImportExportStepper/ExportPanel.tsx

Lines changed: 122 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// components/ImportExportStepper/ExportPanel.tsx
22

3+
import { ComponentProps, Fragment } from "react";
4+
35
import { useStepper } from "./StepperContext";
46
import styles from "./ExportPanel.module.css";
57
import { ExportLoadingBars } from "./ExportLoadingBars";
@@ -181,14 +183,128 @@ export const ExportPanel = () => {
181183
</StepDescription>
182184
{exportError && <p className={styles.error}>{exportError}</p>}
183185
{stepperState === "import_complete" && (
184-
<button
185-
className={styles.startExportButton}
186-
onClick={handleStartExport}
187-
>
188-
Start Export of Tables and Queries from Splitgraph to Seafowl
189-
</button>
186+
<ExportPreview
187+
handleStartExport={handleStartExport}
188+
tablesToExport={tablesToExport}
189+
queriesToExport={queriesToExport}
190+
splitgraphRepository={splitgraphRepository}
191+
splitgraphNamespace={splitgraphNamespace}
192+
/>
190193
)}
191194
{stepperState === "awaiting_export" && <ExportLoadingBars />}
192195
</div>
193196
);
194197
};
198+
199+
const ExportPreview = ({
200+
handleStartExport,
201+
tablesToExport,
202+
queriesToExport,
203+
splitgraphRepository,
204+
splitgraphNamespace,
205+
}: {
206+
handleStartExport: () => Promise<() => void>;
207+
tablesToExport: ExportTableInput[];
208+
queriesToExport: ExportQueryInput[];
209+
splitgraphRepository: string;
210+
splitgraphNamespace: string;
211+
}) => {
212+
return (
213+
<>
214+
<button className={styles.startExportButton} onClick={handleStartExport}>
215+
Start Export of Tables and Queries from Splitgraph to Seafowl
216+
</button>
217+
{/*
218+
<h3>Debugging</h3>
219+
220+
<SplitgraphEmbeddedQuery
221+
importedRepository={{
222+
splitgraphNamespace,
223+
splitgraphRepository,
224+
}}
225+
tableName={"Debugging"}
226+
makeQuery={() => "select 1;"}
227+
/> */}
228+
229+
<h3>Tables to Export</h3>
230+
{tablesToExport
231+
.filter((_) => true)
232+
.map((exportTable) => (
233+
<ExportTablePreview
234+
key={`export-table-preview-${exportTable.table}`}
235+
splitgraphNamespace={splitgraphNamespace}
236+
splitgraphRepository={splitgraphRepository}
237+
{...exportTable}
238+
/>
239+
))}
240+
241+
<h3>Queries to Export</h3>
242+
{queriesToExport
243+
.filter((_) => true)
244+
.map((exportQuery) => (
245+
<ExportQueryPreview
246+
key={`export-query-preview-${exportQuery.destinationTable}-${exportQuery.destinationSchema}`}
247+
splitgraphNamespace={splitgraphNamespace}
248+
splitgraphRepository={splitgraphRepository}
249+
{...exportQuery}
250+
/>
251+
))}
252+
</>
253+
);
254+
};
255+
256+
const ExportQueryPreview = ({
257+
splitgraphNamespace,
258+
splitgraphRepository,
259+
destinationSchema,
260+
destinationTable,
261+
sourceQuery,
262+
}: ExportQueryInput & {
263+
splitgraphNamespace: string;
264+
splitgraphRepository: string;
265+
}) => {
266+
return (
267+
<>
268+
<h4>
269+
<code>
270+
{destinationSchema}.{destinationTable}
271+
</code>
272+
</h4>
273+
<SplitgraphEmbeddedQuery
274+
importedRepository={{
275+
splitgraphNamespace,
276+
splitgraphRepository,
277+
}}
278+
tableName={destinationTable}
279+
makeQuery={() => sourceQuery}
280+
/>
281+
</>
282+
);
283+
};
284+
285+
const ExportTablePreview = ({
286+
splitgraphNamespace,
287+
splitgraphRepository,
288+
table,
289+
}: {
290+
splitgraphNamespace: string;
291+
splitgraphRepository: string;
292+
} & ExportTableInput) => {
293+
return (
294+
<>
295+
<h4>
296+
<code>{table}</code>
297+
</h4>
298+
<SplitgraphEmbeddedQuery
299+
importedRepository={{
300+
splitgraphNamespace,
301+
splitgraphRepository,
302+
}}
303+
tableName={table}
304+
makeQuery={({ splitgraphNamespace, splitgraphRepository }) =>
305+
`SELECT * FROM "${splitgraphNamespace}/${splitgraphRepository}"."${table}";`
306+
}
307+
/>
308+
</>
309+
);
310+
};

examples/nextjs-import-airbyte-github-export-seafowl/components/RepositoryAnalytics/ImportedRepoMetadata.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ const makeSeafowlEmbeddableQueryHref = (sqlQuery: string) => {
216216

217217
const makeSplitgraphEmbeddableQueryHref = (sqlQuery: string) => {
218218
return `https://www.splitgraph.com/embed/workspace/ddn?${new URLSearchParams({
219-
layout: "hsplit",
219+
layout: "query",
220220
query: sqlQuery,
221221
})}`;
222222
};

0 commit comments

Comments
 (0)