Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose a react sdk to integrate windmill into react apps (#1605)
* expose react sdk * expose react sdk * iterate * iterate * iterate * nit * update example * update example * small fixes * update all
- Loading branch information
1 parent
f27abec
commit 632be3b
Showing
114 changed files
with
11,500 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { BROWSER } from 'esm-env' | ||
import { page } from '$app/stores' | ||
import { get } from 'svelte/store' | ||
import { premiumStore, userStore, workspaceStore } from './stores' | ||
import { getUserExt } from './user' | ||
import { WorkspaceService } from './gen' | ||
|
||
export function isCloudHosted(): boolean { | ||
return get(page)?.url?.hostname == 'app.windmill.dev' | ||
} | ||
|
||
if (BROWSER) { | ||
workspaceStore.subscribe(async (workspace) => { | ||
if (workspace) { | ||
try { | ||
localStorage.setItem('workspace', String(workspace)) | ||
} catch (e) { | ||
console.error('Could not persist workspace to local storage', e) | ||
} | ||
const user = await getUserExt(workspace) | ||
userStore.set(user) | ||
if (isCloudHosted() && user?.is_admin) { | ||
premiumStore.set(await WorkspaceService.getPremiumInfo({ workspace })) | ||
} | ||
} else { | ||
userStore.set(undefined) | ||
} | ||
}) | ||
|
||
setInterval(async () => { | ||
try { | ||
const workspace = get(workspaceStore) | ||
const user = get(userStore) | ||
|
||
if (workspace && user && !user.is_super_admin && !user.is_admin) { | ||
userStore.set(await getUserExt(workspace)) | ||
console.log('refreshed user') | ||
} | ||
} catch (e) { | ||
console.error('Could not refresh user', e) | ||
} | ||
}, 30000) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.