import { BROWSER } from 'esm-env' export function isCloudHosted(): boolean { // `BROWSER` alone isn't enough: it resolves true wherever the browser export // condition is picked (SSR bundles, vitest's server project), where `window` // may be missing or a stub with no `location`. Same defensive shape as // `isChromiumBrowser`. if (!BROWSER) return false // Dev only: the cloud-specific UI (quotas, plan upgrade, the pre-approved trial offer) // is otherwise unreachable from localhost. `localStorage.cloudHostedOverride = '1'` opts // a browser in against a backend started with CLOUD_HOSTED. if ( import.meta.env.DEV && globalThis.window?.localStorage?.getItem('cloudHostedOverride') === '1' ) { return true } return globalThis.window?.location?.hostname == 'app.windmill.dev' } // On the managed cloud, the public demo workspace is kept clean and consistent by // disabling folder creation, item sharing, and group creation for non-admins. The // backend enforces the same rule; this only drives the UI hints. export const DEMO_RESTRICTION_HINT = 'Disabled in the demo workspace. Create your own workspace to keep the demo clean and consistent.' export function isDemoWorkspaceRestricted( workspace: string | undefined, isAdmin: boolean | undefined, isSuperAdmin: boolean | undefined ): boolean { return isCloudHosted() && workspace === 'demo' && !isAdmin && !isSuperAdmin }