Skip to content

Commit 8dcf78a

Browse files
fix(studio): tidy up index advisor panel (supabase#40241)
* fix: tidy up index advisor panel * style: some paddings and spacing * nit: margins for an alert
1 parent 6ca1f35 commit 8dcf78a

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

apps/studio/components/interfaces/QueryPerformance/IndexAdvisor/IndexImprovementText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const IndexImprovementText = ({
1919
const improvement = calculateImprovement(totalCostBefore, totalCostAfter)
2020

2121
return (
22-
<p className={cn('text-sm text-foreground-light', className)} {...props}>
22+
<p className={cn('text-sm text-foreground-light mb-3', className)} {...props}>
2323
Query's performance can be improved by{' '}
2424
<span className="text-brand">{improvement.toFixed(2)}%</span> by creating this{' '}
2525
{indexStatements.length > 1 ? 'indexes' : 'index'}:

apps/studio/components/interfaces/QueryPerformance/QueryIndexes.tsx

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ export const QueryIndexes = ({ selectedRow }: QueryIndexesProps) => {
124124

125125
return (
126126
<QueryPanelContainer className="h-full">
127-
<QueryPanelSection>
128-
<div>
129-
<p className="text-sm">Indexes in use</p>
127+
<QueryPanelSection className="pt-2 mb-6">
128+
<div className="mb-4 flex flex-col gap-y-1">
129+
<h4>Indexes in use</h4>
130130
<p className="text-sm text-foreground-light">
131131
This query is using the following index{(usedIndexes ?? []).length > 1 ? 's' : ''}:
132132
</p>
@@ -171,12 +171,9 @@ export const QueryIndexes = ({ selectedRow }: QueryIndexesProps) => {
171171
</div>
172172
)}
173173
</QueryPanelSection>
174-
175-
<div className="border-t" />
176-
177-
<QueryPanelSection className="flex flex-col gap-y-6">
178-
<div className="flex flex-col gap-y-2">
179-
<p className="text-sm">New index recommendations</p>
174+
<QueryPanelSection className="flex flex-col gap-y-6 py-6 border-t">
175+
<div className="flex flex-col gap-y-1">
176+
<h4>New index recommendations</h4>
180177
{isLoadingExtensions ? (
181178
<GenericSkeletonLoader />
182179
) : !isIndexAdvisorEnabled ? (
@@ -206,7 +203,7 @@ export const QueryIndexes = ({ selectedRow }: QueryIndexesProps) => {
206203
{isLinterWarning ? (
207204
<Alert_Shadcn_
208205
variant="default"
209-
className="border-brand-400 bg-alternative [&>svg]:p-0.5 [&>svg]:bg-transparent [&>svg]:text-brand"
206+
className="border-brand-400 bg-alternative [&>svg]:p-0.5 [&>svg]:bg-transparent [&>svg]:text-brand my-3"
210207
>
211208
<Lightbulb />
212209
<AlertTitle_Shadcn_>
@@ -238,10 +235,10 @@ export const QueryIndexes = ({ selectedRow }: QueryIndexesProps) => {
238235
'[&>code]:m-0 [&>code>span]:flex [&>code>span]:flex-wrap'
239236
)}
240237
/>
241-
<p className="text-sm text-foreground-light">
238+
<p className="text-sm text-foreground-light mt-3">
242239
This recommendation serves to prevent your queries from slowing down as your
243240
application grows, and hence the index may not be used immediately after
244-
it's created. (e.g If your table is still small at this time)
241+
it's created (e.g If your table is still small at this time).
245242
</p>
246243
</>
247244
)}
@@ -250,11 +247,13 @@ export const QueryIndexes = ({ selectedRow }: QueryIndexesProps) => {
250247
</>
251248
)}
252249
</div>
253-
{isIndexAdvisorEnabled && hasIndexRecommendation && (
254-
<>
255-
<div className="flex flex-col gap-y-2">
256-
<p className="text-sm">Query costs</p>
257-
<div className="border rounded-md flex flex-col bg-surface-100">
250+
</QueryPanelSection>
251+
{isIndexAdvisorEnabled && hasIndexRecommendation && (
252+
<>
253+
<QueryPanelSection className="py-6 border-t">
254+
<div className="flex flex-col gap-y-1">
255+
<h4>Query costs</h4>
256+
<div className="border rounded-md flex flex-col bg-surface-100 mt-3">
258257
<QueryPanelScoreSection
259258
name="Total cost of query"
260259
description="An estimate of how long it will take to return all the rows (Includes start up cost)"
@@ -278,8 +277,10 @@ export const QueryIndexes = ({ selectedRow }: QueryIndexesProps) => {
278277
</Collapsible_Shadcn_>
279278
</div>
280279
</div>
280+
</QueryPanelSection>
281+
<QueryPanelSection className="py-6 border-t">
281282
<div className="flex flex-col gap-y-2">
282-
<p className="text-sm">FAQ</p>
283+
<h4>FAQ</h4>
283284
<Accordion_Shadcn_ collapsible type="single" className="border rounded-md">
284285
<AccordionItem_Shadcn_ value="1">
285286
<AccordionTrigger className="px-4 py-3 text-sm font-normal text-foreground-light hover:text-foreground transition [&[data-state=open]]:text-foreground">
@@ -311,13 +312,13 @@ export const QueryIndexes = ({ selectedRow }: QueryIndexesProps) => {
311312
</AccordionItem_Shadcn_>
312313
</Accordion_Shadcn_>
313314
</div>
314-
</>
315-
)}
316-
</QueryPanelSection>
315+
</QueryPanelSection>
316+
</>
317+
)}
317318

318319
{isIndexAdvisorEnabled && hasIndexRecommendation && (
319320
<div className="bg-studio sticky bottom-0 border-t py-3 flex items-center justify-between px-5">
320-
<div className="flex flex-col gap-y-1 text-sm">
321+
<div className="flex flex-col gap-y-0.5 text-xs">
321322
<span>Apply index to database</span>
322323
<span className="text-xs text-foreground-light">
323324
This will run the SQL that is shown above

0 commit comments

Comments
 (0)