mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem Users should be able to purge the CDN cache for an individual object or entire bucket via the UI. This feature is only available for Pro+ customers. Free tier customers should be encouraged to upgrade to get access. ## Solution - Add a _Purge CDN cache_ action to the bucket menu. Prompt users on Free plan to upgrade if needed. <img width="182" height="149" alt="image" src="https://github.com/user-attachments/assets/b665c8d0-b540-400e-a328-85c48ddafee0" /> <img width="534" height="242" alt="image" src="https://github.com/user-attachments/assets/15dfd3d3-c8a9-4ad7-9046-0929fd715511" /> <img width="538" height="211" alt="image" src="https://github.com/user-attachments/assets/3e29644e-9335-4b1d-b321-49303c2e8476" /> - Add a _Purge CDN cache_ action to the bucket item menu. Prompt users on Free plan to upgrade if needed. <img width="283" height="313" alt="image" src="https://github.com/user-attachments/assets/a801297e-04b5-46c7-aaf7-4569e66e4714" /> <img width="541" height="249" alt="image" src="https://github.com/user-attachments/assets/b58d264b-76ba-43d4-9579-6c07be9cb684" /> <img width="537" height="207" alt="image" src="https://github.com/user-attachments/assets/132b37bd-3a29-48b5-aa7e-7df29abcbfe6" /> ## Notes - Refactored the _Edit bucket_ menu so that only one modal is allowed - Fixed focus management related to the modals displayed by the _Edit bucket_ menu items - Introduced a way to mock the authenticated users in tests ## Review instructions - On an org on at least _Pro_ plan - Open a bucket _Edit bucket_ menu and click _Purge CDN cache_ - Confirming should call the `/platform/storage/{ref}/cdn/purge-bucket` API endpoint - Open a bucket item menu and click _Purge CDN cache_ - Confirming should call the `/platform/storage/{ref}/cdn/purge-object` API endpoint - On an org on _Free_ plan - Open a bucket _Edit bucket_ menu and click _Purge CDN cache_ - You should be prompted to upgrade - Open a bucket item menu and click _Purge CDN cache_ - You should be prompted to upgrade --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { Session } from '@supabase/auth-js'
|
|
import { AuthContext as AuthContextType } from 'common'
|
|
|
|
export const createMockSession = (overrides: Partial<Session> = {}): Session => {
|
|
const baseSession: Session = {
|
|
access_token: '',
|
|
refresh_token: '',
|
|
expires_in: 1000,
|
|
token_type: 'bearer',
|
|
user: {
|
|
id: '00000000-0000-0000-0000-000000000000',
|
|
app_metadata: {},
|
|
user_metadata: {},
|
|
aud: 'authenticated',
|
|
created_at: '2020-09-21T15:47:47.900481Z',
|
|
},
|
|
}
|
|
|
|
return Object.assign(baseSession, overrides)
|
|
}
|
|
|
|
export const createMockAuthContext = (
|
|
overrides: Partial<AuthContextType> = {}
|
|
): AuthContextType => {
|
|
const session = overrides.session ?? createMockSession()
|
|
const refreshSession = async () => session
|
|
|
|
// @ts-expect-error Session is an union where when isLoading is true, session should be null
|
|
return {
|
|
session,
|
|
error: overrides.error ?? null,
|
|
isLoading: overrides.isLoading ?? false,
|
|
refreshSession: overrides.refreshSession ?? refreshSession,
|
|
}
|
|
}
|