diff --git a/apps/studio/components/grid/components/header/sort/SortPopover.tsx b/apps/studio/components/grid/components/header/sort/SortPopover.tsx
index 6d86f88d715..92394929e89 100644
--- a/apps/studio/components/grid/components/header/sort/SortPopover.tsx
+++ b/apps/studio/components/grid/components/header/sort/SortPopover.tsx
@@ -1,18 +1,18 @@
-import update from 'immutability-helper'
-import { isEqual } from 'lodash'
-import { ChevronDown, List } from 'lucide-react'
-import { useCallback, useMemo, useState } from 'react'
-
import { formatSortURLParams } from 'components/grid/SupabaseGrid.utils'
import { DropdownControl } from 'components/grid/components/common/DropdownControl'
import type { Sort, SupaTable } from 'components/grid/types'
import { useUrlState } from 'hooks/ui/useUrlState'
+import update from 'immutability-helper'
+import { isEqual } from 'lodash'
+import { ChevronDown, PlusCircle } from 'lucide-react'
+import { Fragment, useCallback, useMemo, useState } from 'react'
import {
Button,
PopoverContent_Shadcn_,
PopoverSeparator_Shadcn_,
PopoverTrigger_Shadcn_,
Popover_Shadcn_,
+ cn,
} from 'ui'
import SortRow from './SortRow'
@@ -25,10 +25,34 @@ export interface SortPopoverProps {
const SortPopover = ({ table, sorts, setParams }: SortPopoverProps) => {
const [open, setOpen] = useState(false)
- const btnText =
- (sorts || []).length > 0
- ? `Sorted by ${sorts.length} rule${sorts.length > 1 ? 's' : ''}`
- : 'Sort'
+ const hasSorts = (sorts || []).length > 0
+ const btnText = useMemo(() => {
+ if (!hasSorts) return 'Sort'
+
+ return (
+
+ Sorting by
+ {sorts.slice(0, 2).map((sort, i) => {
+ const [column, direction] = sort.split(':')
+ return (
+
+
+ {column}
+ :
+ {direction}
+
+ {i === 0 && sorts.length > 1 && and}
+
+ )
+ })}
+ {sorts.length > 2 && (
+
+ and {sorts.length - 2} more {sorts.length - 2 === 1 ? 'rule' : 'rules'}
+
+ )}
+
+ )
+ }, [sorts])
const onApplySorts = (appliedSorts: Sort[]) => {
setParams((prevParams) => {
@@ -42,7 +66,11 @@ const SortPopover = ({ table, sorts, setParams }: SortPopoverProps) => {
return (
-
diff --git a/apps/studio/pages/project/[ref]/sql/[id].tsx b/apps/studio/pages/project/[ref]/sql/[id].tsx
index 19999a4630b..7c113391f8d 100644
--- a/apps/studio/pages/project/[ref]/sql/[id].tsx
+++ b/apps/studio/pages/project/[ref]/sql/[id].tsx
@@ -189,11 +189,7 @@ const SqlEditor: NextPageWithLayout = () => {
}
}, [router.isReady, id])
- return (
-
-
-
- )
+ return
}
SqlEditor.getLayout = (page) => (