-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmbeddedPreviews.tsx
More file actions
153 lines (148 loc) · 5.08 KB
/
EmbeddedPreviews.tsx
File metadata and controls
153 lines (148 loc) · 5.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import styles from "./EmbeddedPreviews.module.css";
import type {
ExportTable,
ExportQueryInput,
ExportTableInput,
} from "../../types";
import { EmbedPreviewTableOrQuery } from "../EmbeddedQuery/EmbeddedQuery";
import { ComponentProps } from "react";
export const EmbeddedTablePreviewHeadingAndDescription = ({
exportComplete,
}: {
exportComplete: boolean;
}) => {
return (
<>
{!exportComplete ? (
<>
<h2 className={styles.embeddedPreviewHeading}>Tables to Export</h2>
<p className={styles.embeddedPreviewDescription}>
These are the tables that we'll export from Splitgraph to Seafowl.
You can query them in Splitgraph now, and then when the export is
complete, you'll be able to query them in Seafowl too.
</p>
</>
) : (
<>
<h2 className={styles.embeddedPreviewHeading}>Exported Tables</h2>
<p className={styles.embeddedPreviewDescription}>
We successfully exported the tables to Seafowl, so now you can query
them in Seafowl too.
</p>
</>
)}
</>
);
};
export const EmbeddedTablePreviews = ({
tablesToExport,
splitgraphRepository,
splitgraphNamespace,
useLoadingOrCompleted,
}: {
tablesToExport: ExportTableInput[];
splitgraphRepository: string;
splitgraphNamespace: string;
useLoadingOrCompleted: ComponentProps<
typeof EmbedPreviewTableOrQuery
>["useLoadingOrCompleted"];
}) => {
return (
<>
{tablesToExport.map((exportTable) => (
<EmbedPreviewTableOrQuery
key={`export-table-preview-${exportTable.table}`}
exportInput={exportTable}
importedRepository={{ splitgraphNamespace, splitgraphRepository }}
makeQuery={({ splitgraphNamespace, splitgraphRepository, table }) =>
`SELECT * FROM "${splitgraphNamespace}/${splitgraphRepository}"."${table}";`
}
useLoadingOrCompleted={useLoadingOrCompleted}
makeMatchInputToExported={(exportTableInput) => (exportTable) => {
return (
exportTable.destinationSchema === exportTableInput.repository &&
exportTable.destinationTable === exportTableInput.table
);
}}
/>
))}
</>
);
};
export const EmbeddedQueryPreviewHeadingAndDescription = ({
exportComplete,
}: {
exportComplete: boolean;
}) => {
return (
<>
{" "}
{!exportComplete ? (
<>
<h2 className={styles.embeddedPreviewHeading}>Queries to Export</h2>
<p className={styles.embeddedPreviewDescription}>
We've prepared a few queries to export from Splitgraph to Seafowl,
so that we can use them to render the charts that we want.
Splitgraph will execute the query and insert its result into
Seafowl. You can query them in Splitgraph now, and then when the
export is complete, you'll be able to query them in Seafowl too.
</p>
</>
) : (
<>
<h2 className={styles.embeddedPreviewHeading}>Exported Queries</h2>
<p className={styles.embeddedPreviewDescription}>
We successfully exported these queries from Splitgraph to Seafowl,
so now you can query them in Seafowl too.{" "}
<em className={styles.note}>
Note: If some queries failed to export, it's probably because they
had empty result sets (e.g. the table of issue reactions)
</em>
</p>
</>
)}
</>
);
};
export const EmbeddedQueryPreviews = ({
queriesToExport,
splitgraphRepository,
splitgraphNamespace,
useLoadingOrCompleted,
}: {
queriesToExport: ExportQueryInput[];
splitgraphRepository: string;
splitgraphNamespace: string;
useLoadingOrCompleted: ComponentProps<
typeof EmbedPreviewTableOrQuery
>["useLoadingOrCompleted"];
}) => {
return (
<>
{queriesToExport.map((exportQuery) => (
<EmbedPreviewTableOrQuery
key={`export-query-preview-${exportQuery.destinationTable}-${exportQuery.destinationSchema}`}
exportInput={exportQuery}
importedRepository={{ splitgraphNamespace, splitgraphRepository }}
// This is the query we run on Splitgraph that we exported to Seafowl
makeQuery={({ sourceQuery }) => sourceQuery}
// But once it's exported, we can just select from its table in Seafowl (and
// besides, the sourceQuery might not be compatible with Seafowl anyway)
makeSeafowlQuery={({ destinationSchema, destinationTable }) =>
`SELECT * FROM "${destinationSchema}"."${destinationTable}";`
}
useLoadingOrCompleted={useLoadingOrCompleted}
makeMatchInputToExported={(exportQueryInput) =>
(exportTable: ExportTable) => {
return (
exportTable.destinationSchema ===
exportQueryInput.destinationSchema &&
exportTable.destinationTable ===
exportQueryInput.destinationTable
);
}}
/>
))}
</>
);
};