Skip to content

Commit b423bd6

Browse files
committed
Improved layout when showing a Callout
1 parent 2d710ec commit b423bd6

File tree

1 file changed

+71
-35
lines changed
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query

1 file changed

+71
-35
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx

Lines changed: 71 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -810,31 +810,13 @@ export default function Page() {
810810
</div>
811811
</div>
812812
) : results?.rows && results?.columns ? (
813-
<div className="flex h-full flex-col overflow-hidden">
814-
{(results.hiddenColumns?.length || results.periodClipped) && (
815-
<div className="flex flex-col gap-2 p-2">
816-
{results.hiddenColumns && results.hiddenColumns.length > 0 && (
817-
<Callout variant="warning" className="shrink-0 text-sm">
818-
<code>SELECT *</code> doesn't return all columns because it's slow. The
819-
following columns are not shown:{" "}
820-
<span className="font-mono text-xs">
821-
{results.hiddenColumns.join(", ")}
822-
</span>
823-
. Specify them explicitly to include them.
824-
</Callout>
825-
)}
826-
{results.periodClipped && (
827-
<Callout
828-
variant="pricing"
829-
cta={<LinkButton variant="primary/small" to={organizationBillingPath({ slug: organization.slug })}>Upgrade</LinkButton>}
830-
className="items-center"
831-
>
832-
{simplur`Results are limited to the last ${results.periodClipped} day[|s] based on your plan.`}
833-
</Callout>
834-
)}
835-
</div>
836-
)}
837-
<div className="h-full bg-charcoal-900 p-2">
813+
<div className={`bg-charcoal-900 grid h-full max-h-full overflow-hidden ${hasQueryResultsCallouts(results.hiddenColumns, results.periodClipped) ? "grid-rows-[auto_1fr]" : "grid-rows-[1fr]"}`}>
814+
<QueryResultsCallouts
815+
hiddenColumns={results.hiddenColumns}
816+
periodClipped={results.periodClipped}
817+
organizationSlug={organization.slug}
818+
/>
819+
<div className="p-2 overflow-hidden">
838820
<Card className="h-full overflow-hidden px-0 pb-0">
839821
<Card.Header>
840822
<div className="flex items-center gap-1.5">
@@ -866,17 +848,24 @@ export default function Page() {
866848
</ClientTabsContent>
867849
<ClientTabsContent
868850
value="graph"
869-
className="m-0 grid min-h-0 grid-rows-[1fr] overflow-hidden"
851+
className={`bg-charcoal-900 m-0 grid min-h-0 f-full max-h-full overflow-hidden ${results?.rows && results.rows.length > 0 && hasQueryResultsCallouts(results.hiddenColumns, results.periodClipped) ? "grid-rows-[auto_1fr]" : "grid-rows-[1fr]"}`}
870852
>
871853
{results?.rows && results?.columns && results.rows.length > 0 ? (
872-
<ResultsChart
873-
rows={results.rows}
874-
columns={results.columns}
875-
chartConfig={chartConfig}
876-
onChartConfigChange={handleChartConfigChange}
877-
queryTitle={queryTitle}
878-
isTitleLoading={isTitleLoading}
879-
/>
854+
<>
855+
<QueryResultsCallouts
856+
hiddenColumns={results.hiddenColumns}
857+
periodClipped={results.periodClipped}
858+
organizationSlug={organization.slug}
859+
/>
860+
<ResultsChart
861+
rows={results.rows}
862+
columns={results.columns}
863+
chartConfig={chartConfig}
864+
onChartConfigChange={handleChartConfigChange}
865+
queryTitle={queryTitle}
866+
isTitleLoading={isTitleLoading}
867+
/>
868+
</>
880869
) : (
881870
<Paragraph variant="small" className="p-4 text-text-dimmed">
882871
Run a query to visualize results.
@@ -996,6 +985,53 @@ function ScopeItem({ scope }: { scope: QueryScope }) {
996985
}
997986
}
998987

988+
function QueryResultsCallouts({
989+
hiddenColumns,
990+
periodClipped,
991+
organizationSlug,
992+
}: {
993+
hiddenColumns: string[] | null | undefined;
994+
periodClipped: number | null | undefined;
995+
organizationSlug: string;
996+
}) {
997+
const hasCallouts = (hiddenColumns && hiddenColumns.length > 0) || periodClipped;
998+
999+
if (!hasCallouts) {
1000+
return null;
1001+
}
1002+
1003+
return (
1004+
<div className="flex flex-col gap-2 pt-2 px-2">
1005+
{hiddenColumns && hiddenColumns.length > 0 && (
1006+
<Callout variant="warning" className="shrink-0 text-sm">
1007+
<code>SELECT *</code> doesn't return all columns because it's slow. The
1008+
following columns are not shown:{" "}
1009+
<span className="font-mono text-xs">
1010+
{hiddenColumns.join(", ")}
1011+
</span>
1012+
. Specify them explicitly to include them.
1013+
</Callout>
1014+
)}
1015+
{periodClipped && (
1016+
<Callout
1017+
variant="pricing"
1018+
cta={<LinkButton variant="primary/small" to={organizationBillingPath({ slug: organizationSlug })}>Upgrade</LinkButton>}
1019+
className="items-center"
1020+
>
1021+
{simplur`Results are limited to the last ${periodClipped} day[|s] based on your plan.`}
1022+
</Callout>
1023+
)}
1024+
</div>
1025+
);
1026+
}
1027+
1028+
function hasQueryResultsCallouts(
1029+
hiddenColumns: string[] | null | undefined,
1030+
periodClipped: number | null | undefined
1031+
): boolean {
1032+
return (hiddenColumns && hiddenColumns.length > 0) || !!periodClipped;
1033+
}
1034+
9991035
function ResultsChart({
10001036
rows,
10011037
columns,
@@ -1022,7 +1058,7 @@ function ResultsChart({
10221058
);
10231059

10241060
return (
1025-
<><ResizablePanelGroup className="h-full overflow-hidden">
1061+
<><ResizablePanelGroup className="overflow-hidden">
10261062
<ResizablePanel id="chart-results">
10271063
<div className="h-full bg-charcoal-900 p-2 overflow-hidden">
10281064
<Card className="h-full">

0 commit comments

Comments
 (0)