Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Small UI fixes + fix switching projects while on a bucket, doesnt direct to the buckets page

Joshen Lima8893cb834c2
diff --git a/studio/components/layouts/ProjectLayout/LayoutHeader/ProjectDropdown.tsx b/studio/components/layouts/ProjectLayout/LayoutHeader/ProjectDropdown.tsx
index 1f685d4ca6f..6de692d35f7 100644
--- a/studio/components/layouts/ProjectLayout/LayoutHeader/ProjectDropdown.tsx
+++ b/studio/components/layouts/ProjectLayout/LayoutHeader/ProjectDropdown.tsx
@@ -14,16 +14,16 @@ import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'
// is a unique project id/marker so we'll redirect the user to the
// highest common route with just projectRef in the router queries.
-const sanitizeRoute = (route: string, routerQueries: ParsedUrlQuery) => {
+export const sanitizeRoute = (route: string, routerQueries: ParsedUrlQuery) => {
const queryArray = Object.entries(routerQueries)
if (queryArray.length > 1) {
- // account for query string, if exists (example: /logs/explorer?q=select...)
- const hasQueryString = queryArray.some(([key]) => key === 'q')
-
+ // [Joshen] Ideally we shouldn't use hard coded numbers, but temp workaround
+ // for storage bucket route since its longer
+ const isStorageBucketRoute = 'bucketId' in routerQueries
return route
.split('/')
- .slice(0, hasQueryString ? 5 : 4)
+ .slice(0, isStorageBucketRoute ? 5 : 4)
.join('/')
} else {
return route
diff --git a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconButton.tsx b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconButton.tsx
index fa2f9c3e883..9f7494094c3 100644
--- a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconButton.tsx
+++ b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconButton.tsx
@@ -16,7 +16,11 @@ const NavigationIconButton: FC<Props> = ({ route, isActive = false }) => {
<Tooltip.Trigger>
<ConditionalWrap
condition={route.link !== undefined}
- wrap={(children) => <Link href={route.link!}>{children}</Link>}
+ wrap={(children) => (
+ <Link href={route.link!}>
+ <a>{children}</a>
+ </Link>
+ )}
>
<span
className={[
diff --git a/studio/components/layouts/StorageLayout/StorageMenu.tsx b/studio/components/layouts/StorageLayout/StorageMenu.tsx
index afd1454f03a..1d85c34ee92 100644
--- a/studio/components/layouts/StorageLayout/StorageMenu.tsx
+++ b/studio/components/layouts/StorageLayout/StorageMenu.tsx
@@ -31,8 +31,8 @@ const StorageMenu = () => {
| 'logs'
const storageExplorerStore = useStorageStore()
- const { data } = useBucketsQuery({ projectRef: ref })
- const { loaded, openDeleteBucketModal } = storageExplorerStore || {}
+ const { data, isLoading } = useBucketsQuery({ projectRef: ref })
+ const { openDeleteBucketModal } = storageExplorerStore || {}
const buckets = data ?? []
@@ -80,11 +80,11 @@ const StorageMenu = () => {
<div className="">
<div>
<Menu.Group title="All buckets" />
- {!loaded ? (
- <div className="space-y-2">
+ {isLoading ? (
+ <div className="space-y-2 mx-2">
+ <ShimmeringLoader className="!py-2.5" />
+ <ShimmeringLoader className="!py-2.5" />
<ShimmeringLoader className="!py-2.5" />
- <ShimmeringLoader className="!py-2.5 w-3/4" />
- <ShimmeringLoader className="!py-2.5 w-1/2" />
</div>
) : (
<>
@@ -126,10 +126,7 @@ const StorageMenu = () => {
<CreateBucketModal
visible={showCreateBucketModal}
- onClose={() => {
- console.log('onClose')
- setShowCreateBucketModal(false)
- }}
+ onClose={() => setShowCreateBucketModal(false)}
/>
<EditBucketModal
diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js
index 0793f877423..3bf029e8f5f 100644
--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js
+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js
@@ -184,7 +184,7 @@ const FileExplorerColumn = ({
<div
className={`
${fullWidth ? 'w-full' : 'w-64 border-r border-gray-500'}
- px-2 py-1 my-1 flex flex-shrink-0 flex-col space-y-1 overflow-auto
+ px-2 py-1 my-1 flex flex-shrink-0 flex-col space-y-2 overflow-auto
`}
>
<ShimmeringLoader />
diff --git a/studio/tests/components/ProjectDropdown.test.ts b/studio/tests/components/ProjectDropdown.test.ts
new file mode 100644
index 00000000000..36142b2e1e7
--- /dev/null
+++ b/studio/tests/components/ProjectDropdown.test.ts
@@ -0,0 +1,22 @@
+import { sanitizeRoute } from 'components/layouts/ProjectLayout/LayoutHeader/ProjectDropdown'
+
+test('Should sanitize project routes correctly when switching projects by removing project specific parameters', () => {
+ expect(sanitizeRoute('/project/[ref]', { ref: 'abc' })).toBe('/project/[ref]')
+ expect(sanitizeRoute('/project/[ref]/editor', { ref: 'abc' })).toBe('/project/[ref]/editor')
+ expect(sanitizeRoute('/project/[ref]/storage/buckets', { ref: 'abc' })).toBe(
+ '/project/[ref]/storage/buckets'
+ )
+ expect(sanitizeRoute('/project/[ref]/settings/billing/subscription', { ref: 'abc' })).toBe(
+ '/project/[ref]/settings/billing/subscription'
+ )
+
+ expect(sanitizeRoute('/project/[ref]/editor/[tableId]', { ref: 'abc', tableId: '10' })).toBe(
+ '/project/[ref]/editor'
+ )
+ expect(
+ sanitizeRoute('/project/[ref]/storage/buckets/[bucketId]', { ref: 'abc', bucketId: 'bucket-1' })
+ ).toBe('/project/[ref]/storage/buckets')
+ expect(sanitizeRoute('/project/[ref]/logs/explorer?q=select', { ref: 'abc' })).toBe(
+ '/project/[ref]/logs/explorer?q=select'
+ )
+})